0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +01:00
Dieser Commit ist enthalten in:
Angus McLeod 2020-04-02 20:29:22 +11:00
Ursprung 9e71195236
Commit 10fb3c4c44
4 geänderte Dateien mit 68 neuen und 54 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,7 @@
import {
properties,
mappedProperties,
advancedProperties,
camelCase,
snakeCase
} from '../lib/wizard';
@ -205,28 +206,20 @@ function buildObject(json, type) {
return EmberObject.create(params);
}
function isAdvancedWizard(property, value) {
function wizardHasAdvanced(property, value) {
if (property === 'save_submissions' && value == false) return true;
if (property === 'restart_on_revisit' && value == true) return true;
return false;
}
function isAdvancedStep(property, value) {
return mapped(property, 'step') && present(value);
function stepHasAdvanced(property, value) {
return advancedProperties.step[property] && present(value);
}
function isAdvancedField(params) {
if (present(params.property)) return true;
if (present(params.prefill)) return true;
if (present(params.content)) return true;
return false;
}
function isAdvancedAction(params) {
if (present(params.code)) return true;
if (present(params.custom_fields)) return true;
if (present(params.skip_redirect)) return true;
return false;
function hasAdvanced(params, type) {
return Object.keys(params).some(p => {
return advancedProperties[type].indexOf(p) > -1 && present(params[p]);
});
}
function buildProperties(json) {
@ -242,7 +235,7 @@ function buildProperties(json) {
properties.wizard.forEach((p) => {
props[p] = json[p];
if (isAdvancedWizard(p, json[p])) {
if (wizardHasAdvanced(p, json[p])) {
props.showAdvanced = true;
}
});
@ -256,7 +249,7 @@ function buildProperties(json) {
properties.step.forEach((p) => {
stepParams[p] = stepJson[p];
if (isAdvancedStep(p, stepJson[p])) {
if (stepHasAdvanced(p, stepJson[p])) {
stepParams.showAdvanced = true;
}
});
@ -266,8 +259,8 @@ function buildProperties(json) {
if (present(stepJson.fields)) {
stepJson.fields.forEach((f) => {
let params = buildObject(f, 'field');
if (isAdvancedField(params)) {
if (hasAdvanced(params, 'field')) {
params.showAdvanced = true;
}
@ -281,7 +274,7 @@ function buildProperties(json) {
stepJson.actions.forEach((a) => {
let params = buildObject(a, 'action');
if (isAdvancedAction(params)) {
if (hasAdvanced(params, 'action')) {
params.showAdvanced = true;
}

Datei anzeigen

@ -140,6 +140,24 @@ const mappedProperties = {
]
}
const advancedProperties = {
step: [
'required_data',
'permitted_params'
],
field: [
'property',
'prefill',
'content'
],
action: [
'code',
'custom_fields',
'skip_redirect',
'required'
]
}
const actionTypes = [
'create_topic',
'update_profile',
@ -162,5 +180,6 @@ export {
wizardProperties,
mappedProperties,
profileFields,
advancedProperties,
actionTypes
};

Datei anzeigen

@ -9,10 +9,21 @@
<div class="setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.translation'}}</label>
<label>{{i18n 'admin.wizard.field.required'}}</label>
</div>
<div class="setting-value">
<span>{{i18n 'admin.wizard.field.required_label'}}</span>
{{input type='checkbox' checked=field.required}}
</div>
</div>
<div class="setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.field.description'}}</label>
</div>
<div class="setting-value">
{{input name="key" value=field.key placeholderKey="admin.wizard.translation_placeholder"}}
{{textarea name="description" value=field.description}}
</div>
</div>
@ -30,15 +41,6 @@
</div>
</div>
<div class="setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.field.description'}}</label>
</div>
<div class="setting-value">
{{textarea name="description" value=field.description}}
</div>
</div>
<div class="setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.type'}}</label>
@ -55,17 +57,6 @@
</div>
</div>
<div class="setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.field.required'}}</label>
</div>
<div class="setting-value">
<span>{{i18n 'admin.wizard.field.required_label'}}</span>
{{input type='checkbox' checked=field.required}}
</div>
</div>
{{#if isInput}}
<div class="setting">
<div class="setting-label">
@ -142,6 +133,7 @@
{{#if field.showAdvanced}}
<div class="advanced-settings">
{{#if isCategory}}
<div class="setting">
<div class="setting-label">
@ -183,6 +175,16 @@
</div>
</div>
{{/if}}
<div class="setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.translation'}}</label>
</div>
<div class="setting-value">
{{input name="key" value=field.key placeholderKey="admin.wizard.translation_placeholder"}}
</div>
</div>
</div>
{{/if}}
{{/if}}

Datei anzeigen

@ -9,18 +9,6 @@
</div>
</div>
<div class="setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.translation'}}</label>
</div>
<div class="setting-value">
{{input
name="key"
value=step.key
placeholderKey="admin.wizard.translation_placeholder"}}
</div>
</div>
<div class="setting full">
<div class="setting-label">
<label>{{i18n 'admin.wizard.step.banner'}}</label>
@ -89,6 +77,18 @@
</div>
</div>
<div class="setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.translation'}}</label>
</div>
<div class="setting-value">
{{input
name="key"
value=step.key
placeholderKey="admin.wizard.translation_placeholder"}}
</div>
</div>
</div>
{{/if}}