1
0
Fork 0
Dieser Commit ist enthalten in:
Angus McLeod 2020-04-07 14:56:16 +10:00
Ursprung 6570e4b74b
Commit e3fa75597b
6 geänderte Dateien mit 65 neuen und 30 gelöschten Zeilen

Datei anzeigen

@ -80,6 +80,13 @@ export default Component.extend({
this.set('field.prefill', null);
},
@observes('isCategory')
setupCategoryType() {
if (this.isCategory && !this.field.property) {
this.set('field.property', 'id');
}
},
actions: {
imageUploadDone(upload) {
this.set("field.image", upload.url);

Datei anzeigen

@ -53,7 +53,12 @@ export default Component.extend({
},
remove(input) {
this.get('inputs').removeObject(input);
const inputs = this.inputs;
inputs.removeObject(input);
if (inputs.length) {
inputs[0].set('connector', null);
}
}
}
});

Datei anzeigen

@ -214,9 +214,11 @@ function stepHasAdvanced(property, value) {
return advancedProperties.step[property] && present(value);
}
function hasAdvanced(params, type) {
function objectHasAdvanced(params, type) {
return Object.keys(params).some(p => {
return advancedProperties[type].indexOf(p) > -1 && present(params[p]);
let value = params[p];
let advanced = advancedProperties[type][params.type];
return advanced && advanced.indexOf(p) > -1 && present(value);
});
}
@ -245,7 +247,7 @@ function buildProperties(json) {
};
properties.step.forEach((p) => {
stepParams[p] = buildProperty(stepJson, p, 'wizard');;
stepParams[p] = buildProperty(stepJson, p, 'wizard');
if (stepHasAdvanced(p, stepJson[p])) {
stepParams.showAdvanced = true;
@ -258,7 +260,7 @@ function buildProperties(json) {
stepJson.fields.forEach((f) => {
let params = buildObject(f, 'field');
if (hasAdvanced(params, 'field')) {
if (objectHasAdvanced(params, 'field')) {
params.showAdvanced = true;
}
@ -272,7 +274,7 @@ function buildProperties(json) {
stepJson.actions.forEach((a) => {
let params = buildObject(a, 'action');
if (hasAdvanced(params, 'action')) {
if (objectHasAdvanced(params, 'action')) {
params.showAdvanced = true;
}

Datei anzeigen

@ -83,7 +83,7 @@ const fieldProperties = [
'property',
'limit',
'prefill',
'content',
'content'
]
const actionProperties = [
@ -139,27 +139,12 @@ const mappedProperties = {
]
}
const advancedProperties = {
step: [
'required_data',
'permitted_params'
],
field: [
'property',
'prefill',
'content'
],
action: [
'code',
'custom_fields',
'skip_redirect',
'required'
]
}
const advancedFieldProperties = [
'prefill',
'content'
]
const actionTypes = [
'create_topic',
'update_profile',
'create_topic',
'update_profile',
'send_message',
@ -171,6 +156,37 @@ const actionTypes = [
return Discourse.SiteSettings.wizard_api_features || type !== 'send_to_api';
});
const advancedProperties = {
step: [
'required_data',
'permitted_params'
],
field: advancedFieldProperties.reduce(
function(map, type) {
console.log(map, type);
map[type] = advancedFieldProperties;
if (type === 'category') {
map.push('property');
}
return map;
}, {}
),
action: actionTypes.reduce(
function(map, type) {
if (type === 'route_to') {
map[type] = ['code'];
} else if (['create_topic', 'send_message', 'open_composer'].indexOf(type) > -1) {
map[type] = ['custom_fields'];
} else if (['create_topic', 'send_message'].indexOf(type) > -1) {
map[type].push('skip_redirect');
} else if (type === 'send_message') {
map[type].push('required');
}
return map;
}, {}
)
}
export {
selectKitContent,
generateName,

Datei anzeigen

@ -110,7 +110,7 @@
content=categoryPropertyTypes
onChange=(action (mut field.property))
options=(hash
none='admin.wizard.select_property'
none='admin.wizard.selector.placeholder.property'
)}}
</div>
</div>

Datei anzeigen

@ -54,9 +54,14 @@
a.remove-input {
position: absolute;
right: -25px;
top: 50%;
right: -14px;
top: 0px;
padding: 2px 5px;
transform: translateY(-50%);
background: $secondary;
border-radius: 50%;
font-size: 0.8em;
border: 2px solid $primary-low;
}
}