2020-03-22 07:47:56 +01:00
|
|
|
import {
|
|
|
|
observes,
|
|
|
|
on,
|
|
|
|
default as computed
|
|
|
|
} from 'discourse-common/utils/decorators';
|
2017-10-19 04:17:36 +02:00
|
|
|
|
2017-09-23 04:34:07 +02:00
|
|
|
export default Ember.Component.extend({
|
|
|
|
classNames: 'wizard-custom-step',
|
2017-10-06 04:59:02 +02:00
|
|
|
currentField: null,
|
|
|
|
currentAction: null,
|
2017-10-19 04:17:36 +02:00
|
|
|
disableId: Ember.computed.not('step.isNew'),
|
2020-03-22 07:47:56 +01:00
|
|
|
|
|
|
|
@on('didInsertElement')
|
2017-10-19 04:17:36 +02:00
|
|
|
@observes('step')
|
|
|
|
resetCurrentObjects() {
|
|
|
|
const fields = this.get('step.fields');
|
|
|
|
const actions = this.get('step.actions');
|
|
|
|
this.setProperties({
|
|
|
|
currentField: fields.length ? fields[0] : null,
|
|
|
|
currentAction: actions.length ? actions[0] : null
|
|
|
|
});
|
2019-07-02 06:49:14 +02:00
|
|
|
},
|
|
|
|
|
2020-03-21 18:30:11 +01:00
|
|
|
@computed('wizardFields', 'wizard.steps')
|
|
|
|
requiredContent(wizardFields, steps) {
|
|
|
|
let content = wizardFields;
|
2019-07-02 06:49:14 +02:00
|
|
|
let actions = [];
|
|
|
|
|
|
|
|
steps.forEach(s => {
|
|
|
|
actions.push(...s.actions);
|
|
|
|
});
|
|
|
|
|
|
|
|
actions.forEach(a => {
|
|
|
|
if (a.type === 'route_to' && a.code) {
|
|
|
|
content.push(Ember.Object.create({
|
|
|
|
id: a.code,
|
2019-07-02 08:52:47 +02:00
|
|
|
label: "code (Route To)"
|
2019-07-02 06:49:14 +02:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return content;
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed('step.id', 'wizard.save_submissions')
|
2020-03-21 18:30:11 +01:00
|
|
|
wizardFields(currentStepId, saveSubmissions) {
|
2019-07-02 06:49:14 +02:00
|
|
|
const allSteps = this.get('wizard.steps');
|
|
|
|
let steps = allSteps;
|
|
|
|
let fields = [];
|
|
|
|
|
|
|
|
if (!saveSubmissions) {
|
|
|
|
steps = [allSteps.findBy('id', currentStepId)];
|
|
|
|
}
|
|
|
|
|
|
|
|
steps.forEach((s) => {
|
|
|
|
if (s.fields && s.fields.length > 0) {
|
|
|
|
let stepFields = s.fields.map((f) => {
|
|
|
|
return Ember.Object.create({
|
|
|
|
id: f.id,
|
2019-10-15 07:08:49 +02:00
|
|
|
label: `${f.id} (${s.id})`,
|
|
|
|
type: f.type
|
2019-07-02 06:49:14 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
fields.push(...stepFields);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return fields;
|
|
|
|
},
|
2020-03-30 01:53:28 +02:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
bannerUploadDone(upload) {
|
|
|
|
this.set("step.banner", upload.url);
|
|
|
|
},
|
|
|
|
|
|
|
|
bannerUploadDeleted() {
|
|
|
|
this.set("step.banner", null);
|
|
|
|
}
|
|
|
|
}
|
2017-09-23 04:34:07 +02:00
|
|
|
});
|