Bugfix - merge tag was incorrectly validate when only name was entered and Save was clicked immediately after

This commit is contained in:
Tomas Bures 2018-12-31 10:11:44 +00:00
parent b26f5008da
commit 01720ae128
6 changed files with 17 additions and 17 deletions

View file

@ -137,9 +137,9 @@ export default class CUD extends Component {
return id; return id;
} }
onCustomTemplateTypeChanged(mutState, key, oldType, type) { onCustomTemplateTypeChanged(mutStateData, key, oldType, type) {
if (type) { if (type) {
this.templateTypes[type].afterTypeChange(mutState); this.templateTypes[type].afterTypeChange(mutStateData);
} }
} }

View file

@ -64,7 +64,7 @@ export default class CUD extends Component {
changed: ['key'], changed: ['key'],
extra: ['id'] extra: ['id']
}, },
onChange: { onChangeBeforeValidation: {
name: ::this.onChangeName name: ::this.onChangeName
} }
}); });
@ -77,13 +77,13 @@ export default class CUD extends Component {
entity: PropTypes.object entity: PropTypes.object
} }
onChangeName(state, attr, oldValue, newValue) { onChangeName(mutStateData, attr, oldValue, newValue) {
const oldComputedKey = ('MERGE_' + slugify(oldValue, '_')).toUpperCase().replace(/[^A-Z0-9_]/g, ''); const oldComputedKey = ('MERGE_' + slugify(oldValue, '_')).toUpperCase().replace(/[^A-Z0-9_]/g, '');
const oldKey = state.formState.getIn(['data', 'key', 'value']); const oldKey = mutStateData.getIn(['key', 'value']);
if (oldKey === '' || oldKey === oldComputedKey) { if (oldKey === '' || oldKey === oldComputedKey) {
const newKey = ('MERGE_' + slugify(newValue, '_')).toUpperCase().replace(/[^A-Z0-9_]/g, ''); const newKey = ('MERGE_' + slugify(newValue, '_')).toUpperCase().replace(/[^A-Z0-9_]/g, '');
state.formState = state.formState.setIn(['data', 'key', 'value'], newKey); mutStateData.setIn(['key', 'value'], newKey);
} }
} }

View file

@ -123,12 +123,12 @@ export default class RuleSettingsPane extends PureComponent {
} }
} }
populateRuleDefaults(mutState) { populateRuleDefaults(mutStateData) {
const ruleHelpers = this.ruleHelpers; const ruleHelpers = this.ruleHelpers;
const type = mutState.getIn(['type','value']); const type = mutStateData.getIn(['type','value']);
if (!ruleHelpers.isCompositeRuleType(type)) { if (!ruleHelpers.isCompositeRuleType(type)) {
const column = mutState.getIn(['column', 'value']); const column = mutStateData.getIn(['column', 'value']);
if (column) { if (column) {
const colType = ruleHelpers.getColumnType(column); const colType = ruleHelpers.getColumnType(column);
@ -137,7 +137,7 @@ export default class RuleSettingsPane extends PureComponent {
const settings = ruleHelpers.primitiveRuleTypes[colType][type]; const settings = ruleHelpers.primitiveRuleTypes[colType][type];
if (!settings) { if (!settings) {
// The existing rule type does not fit the newly changed column. This resets the rule type chooser to "--- Select ---" // The existing rule type does not fit the newly changed column. This resets the rule type chooser to "--- Select ---"
mutState.setIn(['type', 'value'], ''); mutStateData.setIn(['type', 'value'], '');
} }
} }
} }

View file

@ -73,9 +73,9 @@ export default class CUD extends Component {
entity: PropTypes.object entity: PropTypes.object
} }
onMailerTypeChanged(mutState, key, oldType, type) { onMailerTypeChanged(mutStateDate, key, oldType, type) {
if (type) { if (type) {
this.mailerTypes[type].afterTypeChange(mutState); this.mailerTypes[type].afterTypeChange(mutStateDate);
} }
} }

View file

@ -23,12 +23,12 @@ export const mailerTypesOrder = [
export function getMailerTypes(t) { export function getMailerTypes(t) {
const mailerTypes = {}; const mailerTypes = {};
function initFieldsIfMissing(mutState, mailerType) { function initFieldsIfMissing(mutStateData, mailerType) {
const initVals = mailerTypes[mailerType].initData(); const initVals = mailerTypes[mailerType].initData();
for (const key in initVals) { for (const key in initVals) {
if (!mutState.hasIn([key])) { if (!mutStateData.hasIn([key])) {
mutState.setIn([key, 'value'], initVals[key]); mutStateData.setIn([key, 'value'], initVals[key]);
} }
} }
} }

View file

@ -77,9 +77,9 @@ export default class CUD extends Component {
entity: PropTypes.object entity: PropTypes.object
} }
onTypeChanged(mutState, key, oldType, type) { onTypeChanged(mutStateData, key, oldType, type) {
if (type) { if (type) {
this.templateTypes[type].afterTypeChange(mutState); this.templateTypes[type].afterTypeChange(mutStateData);
} }
} }