Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
Handle corrupted wizard data
Dieser Commit ist enthalten in:
Ursprung
03ae1dc7c9
Commit
e285674c8f
7 geänderte Dateien mit 57 neuen und 23 gelöschten Zeilen
|
@ -1,6 +1,8 @@
|
|||
import Component from "@ember/component";
|
||||
import { gt } from '@ember/object/computed';
|
||||
import { computed } from "@ember/object";
|
||||
import { defaultConnector } from '../lib/wizard-mapper';
|
||||
import { later } from "@ember/runloop";
|
||||
|
||||
export default Component.extend({
|
||||
classNameBindings: [':mapper-connector', ':mapper-block', 'hasMultiple::single'],
|
||||
|
@ -9,5 +11,16 @@ export default Component.extend({
|
|||
let key = this.connector;
|
||||
let path = this.inputTypes ? `input.${key}.name` : `connector.${key}`;
|
||||
return I18n.t(`admin.wizard.${path}`);
|
||||
})
|
||||
}),
|
||||
|
||||
didReceiveAttrs() {
|
||||
if (!this.connector) {
|
||||
later(() => {
|
||||
this.set(
|
||||
'connector',
|
||||
defaultConnector(this.connectorType, this.inputType, this.options)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
|
@ -5,7 +5,7 @@ import { getOwner } from 'discourse-common/lib/get-owner';
|
|||
import { defaultSelectionType, selectionTypes } from '../lib/wizard-mapper';
|
||||
import { snakeCase } from '../lib/wizard';
|
||||
import Component from "@ember/component";
|
||||
import { bind } from "@ember/runloop";
|
||||
import { bind, later } from "@ember/runloop";
|
||||
|
||||
export default Component.extend({
|
||||
classNameBindings: [':mapper-selector', 'activeType'],
|
||||
|
@ -33,6 +33,10 @@ export default Component.extend({
|
|||
showTypes: false,
|
||||
|
||||
didInsertElement() {
|
||||
if (this.activeType && !this[`${this.activeType}Enabled`]) {
|
||||
later(() => this.resetActiveType());
|
||||
}
|
||||
|
||||
$(document).on("click", bind(this, this.documentClick));
|
||||
},
|
||||
|
||||
|
|
|
@ -22,13 +22,9 @@ function inputTypesContent(options = {}) {
|
|||
mapInputTypes(selectableInputTypes);
|
||||
}
|
||||
|
||||
// Connectors
|
||||
// connectorTypes
|
||||
|
||||
const connectors = {
|
||||
output: [
|
||||
'then',
|
||||
'set',
|
||||
],
|
||||
pair: [
|
||||
'equal',
|
||||
'greater',
|
||||
|
@ -36,16 +32,26 @@ const connectors = {
|
|||
'greater_or_equal',
|
||||
'less_or_equal',
|
||||
'regex'
|
||||
]
|
||||
],
|
||||
output: [
|
||||
'then',
|
||||
'set',
|
||||
],
|
||||
}
|
||||
|
||||
function defaultConnector(connectorType, inputType, opts = {}) {
|
||||
if (opts[`${connectorType}Connector`]) return opts[`${connectorType}Connector`];
|
||||
if (inputType === 'conditional' && connectorType === 'output') return 'then';
|
||||
if (inputType === 'conditional' && connectorType === 'pair') return 'equal';
|
||||
if (inputType === 'assignment' && connectorType === 'output') return 'set';
|
||||
if (inputType === 'association' && connectorType === 'pair') return 'association';
|
||||
if (inputType === 'validation' && connectorType === 'pair') return 'equal';
|
||||
function defaultConnector(connectorType, inputType, options={}) {
|
||||
if (connectorType === 'input') {
|
||||
return defaultInputType(options);
|
||||
}
|
||||
if (connectorType === 'pair') {
|
||||
if (inputType === 'conditional') return 'equal';
|
||||
if (inputType === 'association') return 'association';
|
||||
if (inputType === 'validation') return 'equal';
|
||||
}
|
||||
if (connectorType === 'output') {
|
||||
if (inputType === 'conditional') return 'then';
|
||||
if (inputType === 'assignment') return 'set';
|
||||
}
|
||||
return 'equal';
|
||||
}
|
||||
|
||||
|
@ -53,7 +59,7 @@ function connectorContent(connectorType, inputType, opts) {
|
|||
let connector = opts[`${connectorType}Connector`];
|
||||
|
||||
if ((!connector && connectorType === 'output') || inputType === 'association') {
|
||||
connector = defaultConnector(connectorType, inputType, opts);
|
||||
connector = defaultConnector(connectorType, inputType);
|
||||
}
|
||||
|
||||
let content = connector ? [connector] : connectors[connectorType];
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
content=connectors
|
||||
onChange=(action (mut connector))}}
|
||||
{{else}}
|
||||
{{#if connector}}
|
||||
<span class="connector-single">
|
||||
{{connectorLabel}}
|
||||
</span>
|
||||
{{/if}}
|
||||
{{/if}}
|
|
@ -1,7 +1,10 @@
|
|||
{{wizard-mapper-connector
|
||||
connector=input.type
|
||||
connectors=inputTypes
|
||||
inputTypes=true}}
|
||||
inputTypes=true
|
||||
inputType=inputType
|
||||
connectorType="type"
|
||||
options=options}}
|
||||
|
||||
{{#if hasPairs}}
|
||||
<div class="mapper-pairs mapper-block">
|
||||
|
@ -26,7 +29,10 @@
|
|||
{{#if hasPairs}}
|
||||
{{wizard-mapper-connector
|
||||
connector=input.output_connector
|
||||
connectors=connectors}}
|
||||
connectors=connectors
|
||||
connectorType="output"
|
||||
inputType=inputType
|
||||
options=options}}
|
||||
{{/if}}
|
||||
|
||||
<div class="output mapper-block">
|
||||
|
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
{{wizard-mapper-connector
|
||||
connector=pair.connector
|
||||
connectors=connectors}}
|
||||
connectors=connectors
|
||||
connectorType="pair"
|
||||
inputType=inputType
|
||||
options=options}}
|
||||
|
||||
<div class="value mapper-block">
|
||||
{{wizard-mapper-selector
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{#each inputs as |input|}}
|
||||
{{#if input.connector}}
|
||||
{{wizard-mapper-connector connector=input.connector}}
|
||||
{{wizard-mapper-connector connector=input.connector connectorType="input"}}
|
||||
{{/if}}
|
||||
|
||||
{{wizard-mapper-input
|
||||
|
|
Laden …
In neuem Issue referenzieren