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:
angusmcleod 2021-09-07 20:13:01 +08:00
Ursprung 7c9a0ef862
Commit 0313c773e8
15 geänderte Dateien mit 111 neuen und 99 gelöschten Zeilen

Datei anzeigen

@ -8,8 +8,8 @@ const klasses = ["topic", "post", "group", "category"];
const types = ["string", "boolean", "integer", "json"];
const proTypes = {
klass: ["group", "category"],
type: ["json"]
}
type: ["json"],
};
const generateContent = function (array, type, proSubscribed = false) {
return array.reduce((result, key) => {
@ -19,7 +19,7 @@ const generateContent = function (array, type, proSubscribed = false) {
result.push({
id: key,
name: I18n.t(`admin.wizard.custom_field.${type}.${key}`),
pro
pro,
});
}
return result;
@ -32,10 +32,10 @@ export default Component.extend({
postSerializers: ["post"],
groupSerializers: ["basic_group"],
categorySerializers: ["basic_category"],
klassContent: computed("proSubscribed", function() {
klassContent: computed("proSubscribed", function () {
return generateContent(klasses, "klass", this.proSubscribed);
}),
typeContent: computed("proSubscribed", function() {
typeContent: computed("proSubscribed", function () {
return generateContent(types, "type", this.proSubscribed);
}),
showInputs: or("field.new", "field.edit"),

Datei anzeigen

@ -102,10 +102,10 @@ export default Component.extend(UndoChanges, {
result.push({
id: type,
name: I18n.t(`admin.wizard.action.${type}.label`),
pro
pro,
});
}
return result;
}, []);
}
},
});

Datei anzeigen

@ -2,7 +2,7 @@ import SingleSelectComponent from "select-kit/components/single-select";
import { computed } from "@ember/object";
export default SingleSelectComponent.extend({
classNames: ["combo-box", 'wizard-pro-selector'],
classNames: ["combo-box", "wizard-pro-selector"],
selectKitOptions: {
autoFilterable: false,
@ -10,10 +10,10 @@ export default SingleSelectComponent.extend({
showFullTitle: true,
headerComponent: "wizard-pro-selector/wizard-pro-selector-header",
caretUpIcon: "caret-up",
caretDownIcon: "caret-down"
caretDownIcon: "caret-down",
},
modifyComponentForRow() {
return "wizard-pro-selector/wizard-pro-selector-row";
}
},
});

Datei anzeigen

@ -4,44 +4,49 @@ import { notEmpty } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators";
export default Component.extend({
classNameBindings: [':custom-wizard-pro-subscription', 'subscription.active:active:inactive'],
subscribed: notEmpty('subscription'),
classNameBindings: [
":custom-wizard-pro-subscription",
"subscription.active:active:inactive",
],
subscribed: notEmpty("subscription"),
@discourseComputed('subscription.type')
@discourseComputed("subscription.type")
title(type) {
return type ?
I18n.t(`admin.wizard.pro.subscription.title.${type}`) :
I18n.t("admin.wizard.pro.not_subscribed");
return type
? I18n.t(`admin.wizard.pro.subscription.title.${type}`)
: I18n.t("admin.wizard.pro.not_subscribed");
},
@discourseComputed('subscription.active')
@discourseComputed("subscription.active")
stateClass(active) {
return active ? 'active' : 'inactive';
return active ? "active" : "inactive";
},
@discourseComputed('stateClass')
@discourseComputed("stateClass")
stateLabel(stateClass) {
return I18n.t(`admin.wizard.pro.subscription.status.${stateClass}`);
},
actions: {
update() {
this.set('updating', true);
CustomWizardPro.update_subscription().then(result => {
if (result.success) {
this.setProperties({
updateIcon: 'check',
subscription: result.subscription
});
} else {
this.set('updateIcon', 'times');
}
}).finally(() => {
this.set('updating', false);
setTimeout(() => {
this.set('updateIcon', null);
}, 7000);
})
}
}
this.set("updating", true);
CustomWizardPro.update_subscription()
.then((result) => {
if (result.success) {
this.setProperties({
updateIcon: "check",
subscription: result.subscription,
});
} else {
this.set("updateIcon", "times");
}
})
.finally(() => {
this.set("updating", false);
setTimeout(() => {
this.set("updateIcon", null);
}, 7000);
});
},
},
});

Datei anzeigen

@ -5,52 +5,58 @@ import { alias } from "@ember/object/computed";
export default Controller.extend({
messageUrl: "https://thepavilion.io/t/3652",
messageType: 'info',
messageType: "info",
messageKey: null,
showSubscription: alias('model.authentication.active'),
showSubscription: alias("model.authentication.active"),
setup() {
const authentication = this.get('model.authentication');
const subscription = this.get('model.subscription');
const authentication = this.get("model.authentication");
const subscription = this.get("model.subscription");
const subscribed = subscription && subscription.active;
const authenticated = authentication && authentication.active;
if (!subscribed) {
this.set('messageKey', authenticated ? 'not_subscribed' : 'authorize');
this.set("messageKey", authenticated ? "not_subscribed" : "authorize");
} else {
this.set('messageKey', !authenticated ?
'subscription_expiring' :
subscribed ? 'subscription_active' : 'subscription_inactive'
this.set(
"messageKey",
!authenticated
? "subscription_expiring"
: subscribed
? "subscription_active"
: "subscription_inactive"
);
}
},
@discourseComputed('model.server')
@discourseComputed("model.server")
messageOpts(server) {
return { server };
},
actions: {
unauthorize() {
this.set('unauthorizing', true);
this.set("unauthorizing", true);
CustomWizardPro.unauthorize().then(result => {
if (result.success) {
this.setProperties({
messageKey: 'unauthorized',
messageType: 'warn',
"model.authentication": null,
"model.subscription": null
});
} else {
this.setProperties({
messageKey: 'unauthorize_failed',
messageType: 'error'
});
}
}).finally(() => {
this.set('unauthorizing', false);
})
}
}
CustomWizardPro.unauthorize()
.then((result) => {
if (result.success) {
this.setProperties({
messageKey: "unauthorized",
messageType: "warn",
"model.authentication": null,
"model.subscription": null,
});
} else {
this.setProperties({
messageKey: "unauthorize_failed",
messageType: "error",
});
}
})
.finally(() => {
this.set("unauthorizing", false);
});
},
},
});

Datei anzeigen

@ -80,7 +80,7 @@ export default Controller.extend({
if (result.wizard_id) {
this.send("afterSave", result.wizard_id);
} else if (result.errors) {
this.set('error', result.errors.join(', '));
this.set("error", result.errors.join(", "));
}
})
.catch((result) => {

Datei anzeigen

@ -45,7 +45,7 @@ export default {
this.route("adminWizardsLogs", {
path: "/logs",
resetNamespace: true
resetNamespace: true,
});
this.route("adminWizardsManager", {

Datei anzeigen

@ -196,11 +196,11 @@ const action = {
],
required: ["id", "type"],
proTypes: [
'send_message',
'add_to_group',
'create_category',
'create_group',
'send_to_api'
"send_message",
"add_to_group",
"create_category",
"create_group",
"send_to_api",
],
dependent: {},
objectArrays: {},

Datei anzeigen

@ -28,7 +28,7 @@ CustomWizardPro.reopenClass({
return ajax(`${basePath}/subscription`, {
type: "POST",
}).catch(popupAjaxError);
}
},
});
export default CustomWizardPro;

Datei anzeigen

@ -221,7 +221,7 @@ CustomWizard.reopenClass({
const wizard = this._super.apply(this);
wizard.setProperties(buildProperties(wizardJson));
return wizard;
}
},
});
export default CustomWizard;

Datei anzeigen

@ -13,7 +13,7 @@ export default DiscourseRoute.extend({
controller.setProperties({
customFields,
proSubscribed
proSubscribed,
});
},
});

Datei anzeigen

@ -7,13 +7,13 @@ export default DiscourseRoute.extend({
},
setupController(controller, model) {
controller.set('model', model);
controller.set("model", model);
controller.setup();
},
actions: {
authorize() {
CustomWizardPro.authorize();
}
}
},
},
});

Datei anzeigen

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

Datei anzeigen

@ -741,7 +741,7 @@
.validation-section {
min-width: 250px;
margin: .5em 0;
margin: 0.5em 0;
}
}
@ -761,18 +761,19 @@
.pro-label {
color: var(--tertiary);
font-size: .75em;
font-size: 0.75em;
}
.admin-wizards-pro {
.admin-wizard-controls {
h3, label {
h3,
label {
margin: 0;
}
label {
padding: .4em .5em;
margin-left: .75em;
padding: 0.4em 0.5em;
margin-left: 0.75em;
background-color: var(--success);
color: var(--secondary);
}
@ -792,14 +793,14 @@
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: .5em;
margin-bottom: 0.5em;
h3 {
margin: 0;
}
.buttons > span {
margin-right: .5em;
margin-right: 0.5em;
}
}
@ -810,8 +811,8 @@
background-color: var(--primary-very-low);
.subscription-state {
padding: .25em .5em;
margin-right: .75em;
padding: 0.25em 0.5em;
margin-right: 0.75em;
&.active {
background-color: var(--success);
@ -829,7 +830,7 @@
}
.pro-label {
margin-left: .75em;
padding-top: .25em;
margin-left: 0.75em;
padding-top: 0.25em;
}
}