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

Datei anzeigen

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

Datei anzeigen

@ -9,18 +9,6 @@
</div> </div>
</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 full">
<div class="setting-label"> <div class="setting-label">
<label>{{i18n 'admin.wizard.step.banner'}}</label> <label>{{i18n 'admin.wizard.step.banner'}}</label>
@ -89,6 +77,18 @@
</div> </div>
</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> </div>
{{/if}} {{/if}}