0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-14 05:52:52 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-custom-step.js.es6
Angus McLeod 87a53a8c85 wip
2020-04-02 16:21:57 +11:00

55 Zeilen
1,3 KiB
JavaScript

import { observes, on, default as discourseComputed } from 'discourse-common/utils/decorators';
import { not } from "@ember/object/computed";
import EmberObject from "@ember/object";
export default Ember.Component.extend({
classNames: 'wizard-custom-step',
currentField: null,
currentAction: null,
disableId: not('step.isNew'),
@on('didInsertElement')
@observes('step')
resetCurrentObjects() {
const fields = this.step.fields;
const actions = this.step.actions;
this.setProperties({
currentField: fields.length ? fields[0] : null,
currentAction: actions.length ? actions[0] : null
});
},
@discourseComputed('wizardFields', 'wizard.steps')
requiredContent(wizardFields, steps) {
let content = wizardFields;
let actions = [];
steps.forEach(s => {
actions.push(...s.actions);
});
actions.forEach(a => {
if (a.type === 'route_to' && a.code) {
content.push(
EmberObject.create({
id: a.code,
label: "code (Route To)"
})
);
}
});
return content;
},
actions: {
bannerUploadDone(upload) {
this.set("step.banner", upload.url);
},
bannerUploadDeleted() {
this.set("step.banner", null);
}
}
});