Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
Handle incorrect data in mapped inputs
Dieser Commit ist enthalten in:
Ursprung
e285674c8f
Commit
92bd7953f1
3 geänderte Dateien mit 26 neuen und 8 gelöschten Zeilen
|
@ -1,17 +1,26 @@
|
||||||
import { getOwner } from 'discourse-common/lib/get-owner';
|
import { getOwner } from 'discourse-common/lib/get-owner';
|
||||||
import { newInput, selectionTypes } from '../lib/wizard-mapper';
|
import { newInput, selectionTypes } from '../lib/wizard-mapper';
|
||||||
import { default as discourseComputed, observes, on } from 'discourse-common/utils/decorators';
|
import { default as discourseComputed, observes, on } from 'discourse-common/utils/decorators';
|
||||||
|
import { later } from "@ember/runloop";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { A } from "@ember/array";
|
import { A } from "@ember/array";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNames: 'wizard-mapper',
|
classNames: 'wizard-mapper',
|
||||||
|
|
||||||
|
didReceiveAttrs() {
|
||||||
|
if (this.inputs && this.inputs.constructor !== Array) {
|
||||||
|
later(() => this.set('inputs', null));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
@discourseComputed('inputs.@each.type')
|
@discourseComputed('inputs.@each.type')
|
||||||
canAdd(inputs) {
|
canAdd(inputs) {
|
||||||
return !inputs || inputs.every(i => {
|
return !inputs ||
|
||||||
return ['assignment','association'].indexOf(i.type) === -1;
|
inputs.constructor !== Array ||
|
||||||
});
|
inputs.every(i => {
|
||||||
|
return ['assignment','association'].indexOf(i.type) === -1;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed('options.@each.inputType')
|
@discourseComputed('options.@each.inputType')
|
||||||
|
|
|
@ -23,10 +23,15 @@ function castCase(property, value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildProperty(json, property, type) {
|
function buildProperty(json, property, type) {
|
||||||
if (mapped(property, type) && present(json[property])) {
|
let value = json[property];
|
||||||
|
|
||||||
|
if (mapped(property, type) &&
|
||||||
|
present(value) &&
|
||||||
|
value.constructor === Array) {
|
||||||
|
|
||||||
let inputs = [];
|
let inputs = [];
|
||||||
|
|
||||||
json[property].forEach(inputJson => {
|
value.forEach(inputJson => {
|
||||||
let input = {}
|
let input = {}
|
||||||
|
|
||||||
Object.keys(inputJson).forEach(inputKey => {
|
Object.keys(inputJson).forEach(inputKey => {
|
||||||
|
@ -61,7 +66,7 @@ function buildProperty(json, property, type) {
|
||||||
|
|
||||||
return A(inputs);
|
return A(inputs);
|
||||||
} else {
|
} else {
|
||||||
return json[property];
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,10 @@
|
||||||
|
|
||||||
.wizard-submissions {
|
.wizard-submissions {
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
|
|
||||||
|
table td {
|
||||||
|
min-width: 150px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-wizards-logs {
|
.admin-wizards-logs {
|
||||||
|
|
Laden …
In neuem Issue referenzieren