0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00
Dieser Commit ist enthalten in:
Angus McLeod 2022-03-25 12:22:27 +01:00
Ursprung f607863510
Commit 92219ace2f
15 geänderte Dateien mit 62 neuen und 46 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,4 @@
import { default as discourseComputed } from "discourse-common/utils/decorators"; import { default as discourseComputed } from "discourse-common/utils/decorators";
import wizardSchema from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
import { subscriptionSelectKitContent } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-subscription"; import { subscriptionSelectKitContent } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-subscription";
import { empty, equal, or } from "@ember/object/computed"; import { empty, equal, or } from "@ember/object/computed";
import { notificationLevels, selectKitContent } from "../lib/wizard"; import { notificationLevels, selectKitContent } from "../lib/wizard";

Datei anzeigen

@ -5,7 +5,7 @@ import DiscourseURL from "discourse/lib/url";
import I18n from "I18n"; import I18n from "I18n";
export default Component.extend(Subscription, { export default Component.extend(Subscription, {
tagName: 'a', tagName: "a",
classNameBindings: [":wizard-subscription-badge", "subscriptionType"], classNameBindings: [":wizard-subscription-badge", "subscriptionType"],
attributeBindings: ["title"], attributeBindings: ["title"],
@ -26,5 +26,5 @@ export default Component.extend(Subscription, {
click() { click() {
DiscourseURL.routeTo(this.subscriptionLink); DiscourseURL.routeTo(this.subscriptionLink);
} },
}); });

Datei anzeigen

@ -22,5 +22,5 @@ export default Component.extend(Subscription, {
return `admin.wizard.subscription_container.${ return `admin.wizard.subscription_container.${
subscribed ? "subscribed" : "not_subscribed" subscribed ? "subscribed" : "not_subscribed"
}.title`; }.title`;
} },
}); });

Datei anzeigen

@ -3,17 +3,18 @@ import Subscription from "../mixins/subscription";
import wizardSchema from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema"; import wizardSchema from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
import { import {
subscriptionTypeSufficient, subscriptionTypeSufficient,
subscriptionTypes subscriptionTypes,
} from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-subscription"; } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-subscription";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import I18n from "I18n";
const nameKey = function (feature, attribute, value) { const nameKey = function (feature, attribute, value) {
if (feature === 'action') { if (feature === "action") {
return `admin.wizard.action.${value}.label`; return `admin.wizard.action.${value}.label`;
} else { } else {
return `admin.wizard.${feature}.${attribute}.${value}`; return `admin.wizard.${feature}.${attribute}.${value}`;
} }
} };
export default SingleSelectComponent.extend(Subscription, { export default SingleSelectComponent.extend(Subscription, {
classNames: ["combo-box", "wizard-subscription-selector"], classNames: ["combo-box", "wizard-subscription-selector"],
@ -30,10 +31,12 @@ export default SingleSelectComponent.extend(Subscription, {
requiredSubscriptionType(feature, attribute, value) { requiredSubscriptionType(feature, attribute, value) {
let attributes = this.subscriptionAttributes[feature]; let attributes = this.subscriptionAttributes[feature];
if (!attributes || !attributes[attribute]) return null; if (!attributes || !attributes[attribute]) {
return null;
}
let requiredType = null; let requiredType = null;
Object.keys(attributes[attribute]).some(subscriptionType => { Object.keys(attributes[attribute]).some((subscriptionType) => {
let values = attributes[attribute][subscriptionType]; let values = attributes[attribute][subscriptionType];
if (values[0] === "*" || values.includes(value)) { if (values[0] === "*" || values.includes(value)) {
if (subscriptionTypes.includes(subscriptionType)) { if (subscriptionTypes.includes(subscriptionType)) {
@ -47,15 +50,22 @@ export default SingleSelectComponent.extend(Subscription, {
return requiredType; return requiredType;
}, },
@discourseComputed('feature', 'attribute') @discourseComputed("feature", "attribute")
content(feature, attribute) { content(feature, attribute) {
return wizardSchema[feature][attribute].map((value) => { return wizardSchema[feature][attribute].map((value) => {
let requiredSubscriptionType = this.requiredSubscriptionType(feature, attribute, value); let requiredSubscriptionType = this.requiredSubscriptionType(
feature,
attribute,
value
);
return { return {
id: value, id: value,
name: I18n.t(nameKey(feature, attribute, value)), name: I18n.t(nameKey(feature, attribute, value)),
subscriptionType: requiredSubscriptionType, subscriptionType: requiredSubscriptionType,
disabled: !subscriptionTypeSufficient(this.subscriptionType, requiredSubscriptionType) disabled: !subscriptionTypeSufficient(
this.subscriptionType,
requiredSubscriptionType
),
}; };
}); });
}, },

Datei anzeigen

@ -14,7 +14,6 @@ import I18n from "I18n";
export default Controller.extend({ export default Controller.extend({
hasName: notEmpty("wizard.name"), hasName: notEmpty("wizard.name"),
@observes("currentStep") @observes("currentStep")
resetCurrentObjects() { resetCurrentObjects() {
const currentStep = this.currentStep; const currentStep = this.currentStep;

Datei anzeigen

@ -2,6 +2,6 @@ import Controller from "@ember/controller";
import { equal } from "@ember/object/computed"; import { equal } from "@ember/object/computed";
export default Controller.extend({ export default Controller.extend({
businessSubscription: equal('subscriptionType', 'business'), businessSubscription: equal("subscriptionType", "business"),
standardSubscription: equal('subscriptionType', 'standard') standardSubscription: equal("subscriptionType", "standard"),
}); });

Datei anzeigen

@ -1,7 +1,5 @@
import DiscourseURL from "discourse/lib/url"; import DiscourseURL from "discourse/lib/url";
import { withPluginApi } from "discourse/lib/plugin-api"; import { withPluginApi } from "discourse/lib/plugin-api";
import { isPresent } from "@ember/utils";
import { A } from "@ember/array";
import getUrl from "discourse-common/lib/get-url"; import getUrl from "discourse-common/lib/get-url";
export default { export default {

Datei anzeigen

@ -211,7 +211,7 @@ const wizardSchema = {
step, step,
field, field,
custom_field, custom_field,
action action,
}; };
export function buildFieldTypes(types) { export function buildFieldTypes(types) {

Datei anzeigen

@ -1,17 +1,22 @@
const subscriptionTypes = [ const subscriptionTypes = ["standard", "business"];
'standard',
'business'
]
function subscriptionTypeSufficient(subscriptionType, requiredType) { function subscriptionTypeSufficient(subscriptionType, requiredType) {
if (requiredType && !subscriptionType) return false; if (requiredType && !subscriptionType) {
if (requiredType === 'none' || requiredType === null) return true; return false;
if (requiredType === 'standard' && subscriptionTypes.includes(subscriptionType)) return true; }
if (requiredType === 'business' && subscriptionType === 'business') return true; if (requiredType === "none" || requiredType === null) {
return true;
}
if (
requiredType === "standard" &&
subscriptionTypes.includes(subscriptionType)
) {
return true;
}
if (requiredType === "business" && subscriptionType === "business") {
return true;
}
return false; return false;
} }
export { export { subscriptionTypeSufficient, subscriptionTypes };
subscriptionTypeSufficient,
subscriptionTypes
}

Datei anzeigen

@ -9,18 +9,22 @@ export default Mixin.create({
@discourseComputed @discourseComputed
adminWizards() { adminWizards() {
return getOwner(this).lookup('controller:admin-wizards'); return getOwner(this).lookup("controller:admin-wizards");
}, },
subscribed: readOnly('adminWizards.subscribed'), subscribed: readOnly("adminWizards.subscribed"),
subscriptionType: readOnly('adminWizards.subscriptionType'), subscriptionType: readOnly("adminWizards.subscriptionType"),
businessSubscription: readOnly('adminWizards.businessSubscription'), businessSubscription: readOnly("adminWizards.businessSubscription"),
standardSubscription: readOnly('adminWizards.standardSubscription'), standardSubscription: readOnly("adminWizards.standardSubscription"),
subscriptionAttributes: readOnly('adminWizards.subscriptionAttributes'), subscriptionAttributes: readOnly("adminWizards.subscriptionAttributes"),
subscriptionClientInstalled: readOnly('adminWizards.subscriptionClientInstalled'), subscriptionClientInstalled: readOnly(
"adminWizards.subscriptionClientInstalled"
),
@discourseComputed("subscriptionClientInstalled") @discourseComputed("subscriptionClientInstalled")
subscriptionLink(subscriptionClientInstalled) { subscriptionLink(subscriptionClientInstalled) {
return subscriptionClientInstalled ? this.subscriptionClientUrl : this.subscriptionLandingUrl; return subscriptionClientInstalled
} ? this.subscriptionClientUrl
: this.subscriptionLandingUrl;
},
}); });

Datei anzeigen

@ -11,7 +11,7 @@ export default DiscourseRoute.extend({
const customFields = A(model.custom_fields || []); const customFields = A(model.custom_fields || []);
controller.setProperties({ controller.setProperties({
customFields customFields,
}); });
}, },
}); });

Datei anzeigen

@ -38,7 +38,7 @@ export default DiscourseRoute.extend({
wizard, wizard,
currentStep: wizard.steps[0], currentStep: wizard.steps[0],
currentAction: wizard.actions[0], currentAction: wizard.actions[0],
creating: model.create creating: model.create,
}; };
controller.setProperties(props); controller.setProperties(props);

Datei anzeigen

@ -11,7 +11,7 @@ export default DiscourseRoute.extend({
subscribed: model.subscribed, subscribed: model.subscribed,
subscriptionType: model.subscription_type, subscriptionType: model.subscription_type,
subscriptionAttributes: model.subscription_attributes, subscriptionAttributes: model.subscription_attributes,
subscriptionClientInstalled: model.subscription_client_installed subscriptionClientInstalled: model.subscription_client_installed,
}); });
}, },
@ -19,5 +19,5 @@ export default DiscourseRoute.extend({
if (transition.targetName === "adminWizards.index") { if (transition.targetName === "adminWizards.index") {
this.transitionTo("adminWizardsWizard"); this.transitionTo("adminWizardsWizard");
} }
} },
}); });

Datei anzeigen

@ -847,7 +847,7 @@ $error: #ef1700;
.subscription-header { .subscription-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
margin-bottom: .25em; margin-bottom: 0.25em;
h3 { h3 {
margin: 0; margin: 0;
@ -871,7 +871,7 @@ $error: #ef1700;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
cursor: pointer; cursor: pointer;
padding: .5em .65em; padding: 0.5em 0.65em;
background-color: rgba($primary-medium, 0.05); background-color: rgba($primary-medium, 0.05);
border: 1.5px solid rgba($primary-medium, 0.5); border: 1.5px solid rgba($primary-medium, 0.5);
color: $primary-medium; color: $primary-medium;

Datei anzeigen

@ -1,3 +1,4 @@
# frozen_string_literal: true
class CustomWizard::Subscription class CustomWizard::Subscription
STANDARD_PRODUCT_ID = 'prod_LNAGVAaIqDsHmB' STANDARD_PRODUCT_ID = 'prod_LNAGVAaIqDsHmB'
BUSINESS_PRODUCT_ID = 'prod_LNABQ50maBQ1pY' BUSINESS_PRODUCT_ID = 'prod_LNABQ50maBQ1pY'