@bigbinary/neeto-rules-frontend 2.7.23 → 2.7.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/javascript/src/translations/en.json +1 -0
- package/dist/.ready +1 -1
- package/dist/cjs/v2/NeetoRulesBuilder.js +466 -227
- package/dist/cjs/v2/NeetoRulesBuilder.js.map +1 -1
- package/dist/cjs/v2/NeetoRulesForm.js +1 -1
- package/dist/cjs/v2/index.js +1 -1
- package/dist/{index-CvpoP63h.js → index-Br0dDuGK.js} +2 -2
- package/dist/index-Br0dDuGK.js.map +1 -0
- package/dist/{index-puRtNWZV.js → index-D1PW24Zw.js} +2 -2
- package/dist/index-D1PW24Zw.js.map +1 -0
- package/dist/v2/NeetoRulesBuilder.js +466 -227
- package/dist/v2/NeetoRulesBuilder.js.map +1 -1
- package/dist/v2/NeetoRulesForm.js +1 -1
- package/dist/v2/index.js +1 -1
- package/package.json +1 -1
- package/dist/index-CvpoP63h.js.map +0 -1
- package/dist/index-puRtNWZV.js.map +0 -1
|
@@ -11,7 +11,7 @@ import { isNotEmpty, toLabelAndValue, removeBy, isNot, noop } from '@bigbinary/n
|
|
|
11
11
|
import Container from '@bigbinary/neeto-molecules/v2/Container';
|
|
12
12
|
import Header from '@bigbinary/neeto-molecules/v2/Header';
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
|
-
import { r as ApiFields, E as EditorAction, L as ListField, o as Panel, s as ErrorCallout, t as SmsFields, M as MIN_DELAY_VALUE, v as MAX_DELAY_VALUE, w as PhoneNumberField, l as formatData, u as usePollRuleName, T as TouchErrors, n as ScrollToErrorField, p as getValidationSchema, q as DEFAULT_INITIAL_VALUE, m as buildPayload } from '../index-
|
|
14
|
+
import { r as ApiFields, E as EditorAction, L as ListField, o as Panel, s as ErrorCallout, t as SmsFields, M as MIN_DELAY_VALUE, v as MAX_DELAY_VALUE, w as PhoneNumberField, l as formatData, u as usePollRuleName, T as TouchErrors, n as ScrollToErrorField, p as getValidationSchema, q as DEFAULT_INITIAL_VALUE, m as buildPayload } from '../index-Br0dDuGK.js';
|
|
15
15
|
import { u as useCustomDataStore } from '../useCustomDataStore-CEbhXugO.js';
|
|
16
16
|
import { u as useUtilityStore } from '../useUtilityStore-BVCulMEC.js';
|
|
17
17
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
@@ -159,6 +159,7 @@ var BUILDER_PANEL_TYPES = {
|
|
|
159
159
|
CONDITION_VALUE: "builder-condition-value",
|
|
160
160
|
ACTION_CHANNEL: "builder-action-channel",
|
|
161
161
|
ACTION_CONFIG: "builder-action-config",
|
|
162
|
+
ACTION_STEP: "builder-action-step",
|
|
162
163
|
RECIPIENT: "builder-recipient",
|
|
163
164
|
DELAY: "builder-delay",
|
|
164
165
|
LEAD_TIME: "builder-lead-time",
|
|
@@ -179,15 +180,16 @@ var BUILDER_ANCHORS = {
|
|
|
179
180
|
ACTION_CHANNEL: "action-channel",
|
|
180
181
|
ACTION_CONFIG: "action-config",
|
|
181
182
|
ACTION_RECIPIENT: "action-recipient",
|
|
183
|
+
ACTION_STEP: "action-step",
|
|
182
184
|
RULE_DELAY: "rule-delay",
|
|
183
185
|
META_NAME: "meta-name",
|
|
184
186
|
SCOPE: "scope",
|
|
185
187
|
SCOPE_PHONE_FIELD: "scope-phone-field"
|
|
186
188
|
};
|
|
187
|
-
var TOKEN_TO_PANEL_TYPE = (_TOKEN_TO_PANEL_TYPE = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.TRIGGER_ADD, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_REPLACE, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_ACTOR, BUILDER_PANEL_TYPES.ACTOR), BUILDER_ANCHORS.COND_FIELD, BUILDER_PANEL_TYPES.CONDITION_FIELD), BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_PANEL_TYPES.OPERATOR), BUILDER_ANCHORS.COND_CONNECTOR, BUILDER_PANEL_TYPES.CONNECTOR), BUILDER_ANCHORS.COND_VALUES, BUILDER_PANEL_TYPES.CONDITION_VALUE), BUILDER_ANCHORS.ACTION_ADD, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_PANEL_TYPES.ACTION_CONFIG), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.ACTION_RECIPIENT, BUILDER_PANEL_TYPES.RECIPIENT), BUILDER_ANCHORS.RULE_DELAY, BUILDER_PANEL_TYPES.DELAY), BUILDER_ANCHORS.TRIGGER_LEAD_TIME, BUILDER_PANEL_TYPES.LEAD_TIME), BUILDER_ANCHORS.META_NAME, BUILDER_PANEL_TYPES.NAME), BUILDER_ANCHORS.SCOPE, BUILDER_PANEL_TYPES.SCOPE), BUILDER_ANCHORS.SCOPE_PHONE_FIELD, BUILDER_PANEL_TYPES.SCOPE_PHONE_FIELD));
|
|
189
|
+
var TOKEN_TO_PANEL_TYPE = (_TOKEN_TO_PANEL_TYPE = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.TRIGGER_ADD, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_REPLACE, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_ACTOR, BUILDER_PANEL_TYPES.ACTOR), BUILDER_ANCHORS.COND_FIELD, BUILDER_PANEL_TYPES.CONDITION_FIELD), BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_PANEL_TYPES.OPERATOR), BUILDER_ANCHORS.COND_CONNECTOR, BUILDER_PANEL_TYPES.CONNECTOR), BUILDER_ANCHORS.COND_VALUES, BUILDER_PANEL_TYPES.CONDITION_VALUE), BUILDER_ANCHORS.ACTION_ADD, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_PANEL_TYPES.ACTION_CONFIG), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.ACTION_RECIPIENT, BUILDER_PANEL_TYPES.RECIPIENT), BUILDER_ANCHORS.ACTION_STEP, BUILDER_PANEL_TYPES.ACTION_STEP), BUILDER_ANCHORS.RULE_DELAY, BUILDER_PANEL_TYPES.DELAY), BUILDER_ANCHORS.TRIGGER_LEAD_TIME, BUILDER_PANEL_TYPES.LEAD_TIME), BUILDER_ANCHORS.META_NAME, BUILDER_PANEL_TYPES.NAME), BUILDER_ANCHORS.SCOPE, BUILDER_PANEL_TYPES.SCOPE), BUILDER_ANCHORS.SCOPE_PHONE_FIELD, BUILDER_PANEL_TYPES.SCOPE_PHONE_FIELD));
|
|
188
190
|
var LARGE_PANEL_TYPES = [BUILDER_PANEL_TYPES.ACTION_CONFIG, BUILDER_PANEL_TYPES.SCOPE, BUILDER_PANEL_TYPES.NAME];
|
|
189
191
|
var CONDITION_ANCHORS = [BUILDER_ANCHORS.COND_FIELD, BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_ANCHORS.COND_VALUES, BUILDER_ANCHORS.COND_CONNECTOR];
|
|
190
|
-
var ACTION_ANCHORS = [BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_ANCHORS.ACTION_RECIPIENT];
|
|
192
|
+
var ACTION_ANCHORS = [BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_ANCHORS.ACTION_RECIPIENT, BUILDER_ANCHORS.ACTION_STEP];
|
|
191
193
|
var PANE_SEARCH_THRESHOLD = 8;
|
|
192
194
|
var CONFIG_FOCUSABLE_SELECTOR = 'input:not([type="radio"]):not([type="checkbox"]), textarea, [contenteditable="true"]';
|
|
193
195
|
var SMS_TYPES = ["sms", "smsToNumbers"];
|
|
@@ -248,7 +250,7 @@ var useReplayFlash = function useReplayFlash(flashSeq) {
|
|
|
248
250
|
return ref;
|
|
249
251
|
};
|
|
250
252
|
|
|
251
|
-
var _excluded = ["children", "state", "active", "invalid", "onClick", "className", "dataTestid"];
|
|
253
|
+
var _excluded$1 = ["children", "state", "active", "invalid", "onClick", "className", "dataTestid"];
|
|
252
254
|
function ownKeys$c(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
253
255
|
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
254
256
|
var Token = function Token(_ref) {
|
|
@@ -262,7 +264,7 @@ var Token = function Token(_ref) {
|
|
|
262
264
|
onClick = _ref.onClick,
|
|
263
265
|
className = _ref.className,
|
|
264
266
|
dataTestid = _ref.dataTestid,
|
|
265
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
267
|
+
rest = _objectWithoutProperties(_ref, _excluded$1);
|
|
266
268
|
var isInteractive = typeof onClick === "function" && state !== TOKEN_STATE.DISABLED;
|
|
267
269
|
var tokenRef = useReplayFlash(invalid);
|
|
268
270
|
return /*#__PURE__*/jsx("span", _objectSpread$c(_objectSpread$c({
|
|
@@ -306,8 +308,13 @@ var isExcludeVerb = function isExcludeVerb(verb) {
|
|
|
306
308
|
var isMultiValueVerb = function isMultiValueVerb(verb) {
|
|
307
309
|
return String(verb).includes(VERB_TOKENS.MULTI_VALUE);
|
|
308
310
|
};
|
|
311
|
+
|
|
312
|
+
// Lowers a label so it reads mid-sentence, but never an acronym: "API" and
|
|
313
|
+
// "SMS" are already how they should appear.
|
|
309
314
|
var sentencify = function sentencify(label) {
|
|
310
|
-
|
|
315
|
+
if (!label) return label;
|
|
316
|
+
if (label.charAt(1) === label.charAt(1).toUpperCase()) return label;
|
|
317
|
+
return label.charAt(0).toLowerCase() + label.slice(1);
|
|
311
318
|
};
|
|
312
319
|
var copyFor = function copyFor(value, args) {
|
|
313
320
|
return typeof value === "function" ? value(args) : value;
|
|
@@ -416,10 +423,43 @@ var channelOption = function channelOption(_ref10) {
|
|
|
416
423
|
return ((_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.id) === channel;
|
|
417
424
|
});
|
|
418
425
|
};
|
|
419
|
-
|
|
420
|
-
|
|
426
|
+
|
|
427
|
+
// A step is an extra sentence token a host hangs off an action — its own
|
|
428
|
+
// separator, its own pane — for settings that do not belong in the config pane.
|
|
429
|
+
// Its key shares the action's metadata namespace, so declaring one is how a
|
|
430
|
+
// host hands a field to the step: whoever declares it owns it, and the config
|
|
431
|
+
// pane stops validating it.
|
|
432
|
+
var actionStepsOf = function actionStepsOf(_ref11) {
|
|
421
433
|
var schema = _ref11.schema,
|
|
422
434
|
action = _ref11.action;
|
|
435
|
+
return actionParts({
|
|
436
|
+
schema: schema,
|
|
437
|
+
action: action
|
|
438
|
+
}).steps || [];
|
|
439
|
+
};
|
|
440
|
+
var stepValueOf = function stepValueOf(_ref12) {
|
|
441
|
+
var _action$metadata;
|
|
442
|
+
var action = _ref12.action,
|
|
443
|
+
step = _ref12.step;
|
|
444
|
+
return action === null || action === void 0 || (_action$metadata = action.metadata) === null || _action$metadata === void 0 ? void 0 : _action$metadata[step.key];
|
|
445
|
+
};
|
|
446
|
+
var stepLabelOf = function stepLabelOf(_ref13) {
|
|
447
|
+
var _find;
|
|
448
|
+
var action = _ref13.action,
|
|
449
|
+
step = _ref13.step;
|
|
450
|
+
var value = stepValueOf({
|
|
451
|
+
action: action,
|
|
452
|
+
step: step
|
|
453
|
+
});
|
|
454
|
+
return ((_find = (step.options || []).find(function (option) {
|
|
455
|
+
var _option$value2;
|
|
456
|
+
return ((_option$value2 = option.value) !== null && _option$value2 !== void 0 ? _option$value2 : option.id) === value;
|
|
457
|
+
})) === null || _find === void 0 ? void 0 : _find.label) || "";
|
|
458
|
+
};
|
|
459
|
+
var actionParts = function actionParts(_ref14) {
|
|
460
|
+
var _actions$actionForNam, _action$recipient, _actions$channelMeta, _find2, _find3, _channelMeta$needsRec, _actions$configValueL;
|
|
461
|
+
var schema = _ref14.schema,
|
|
462
|
+
action = _ref14.action;
|
|
423
463
|
var actions = (schema === null || schema === void 0 ? void 0 : schema.actions) || {};
|
|
424
464
|
var resolved = action !== null && action !== void 0 && action.channel ? {
|
|
425
465
|
channel: action.channel,
|
|
@@ -441,7 +481,7 @@ var actionParts = function actionParts(_ref11) {
|
|
|
441
481
|
var _recipient$value;
|
|
442
482
|
return ((_recipient$value = recipient.value) !== null && _recipient$value !== void 0 ? _recipient$value : recipient.id) === recipientValue;
|
|
443
483
|
};
|
|
444
|
-
var recipientLabel = ((
|
|
484
|
+
var recipientLabel = ((_find2 = (actions.recipients || []).find(matchesRecipient)) === null || _find2 === void 0 ? void 0 : _find2.label) || ((_find3 = ((option === null || option === void 0 ? void 0 : option.recipients) || []).find(matchesRecipient)) === null || _find3 === void 0 ? void 0 : _find3.label) || recipientValue;
|
|
445
485
|
return {
|
|
446
486
|
option: option,
|
|
447
487
|
channel: channel,
|
|
@@ -460,6 +500,7 @@ var actionParts = function actionParts(_ref11) {
|
|
|
460
500
|
recipientLabel: recipientLabel,
|
|
461
501
|
configTitle: channelMeta.configTitle || (option === null || option === void 0 ? void 0 : option.configTitle),
|
|
462
502
|
configSubtitle: channelMeta.configSubtitle || (option === null || option === void 0 ? void 0 : option.configSubtitle),
|
|
503
|
+
steps: channelMeta.steps || (option === null || option === void 0 ? void 0 : option.steps) || [],
|
|
463
504
|
recipientTitle: channelMeta.recipientTitle || (option === null || option === void 0 ? void 0 : option.recipientTitle),
|
|
464
505
|
recipientSubtitle: channelMeta.recipientSubtitle || (option === null || option === void 0 ? void 0 : option.recipientSubtitle)
|
|
465
506
|
};
|
|
@@ -468,13 +509,13 @@ var actionParts = function actionParts(_ref11) {
|
|
|
468
509
|
// Which condition fields a host offers can depend on the rule — a trigger may
|
|
469
510
|
// only support a subset. Lookups deliberately keep using the full list so a
|
|
470
511
|
// field already on the rule still resolves after the offer narrows.
|
|
471
|
-
var offeredConditionFields = function offeredConditionFields(
|
|
472
|
-
var
|
|
473
|
-
var schema =
|
|
474
|
-
rule =
|
|
475
|
-
return (
|
|
512
|
+
var offeredConditionFields = function offeredConditionFields(_ref15) {
|
|
513
|
+
var _ref16, _schema$conditions$fi, _schema$conditions3, _schema$conditions3$f, _schema$conditions4;
|
|
514
|
+
var schema = _ref15.schema,
|
|
515
|
+
rule = _ref15.rule;
|
|
516
|
+
return (_ref16 = (_schema$conditions$fi = schema === null || schema === void 0 || (_schema$conditions3 = schema.conditions) === null || _schema$conditions3 === void 0 || (_schema$conditions3$f = _schema$conditions3.fieldsFor) === null || _schema$conditions3$f === void 0 ? void 0 : _schema$conditions3$f.call(_schema$conditions3, {
|
|
476
517
|
rule: rule
|
|
477
|
-
})) !== null && _schema$conditions$fi !== void 0 ? _schema$conditions$fi : schema === null || schema === void 0 || (_schema$conditions4 = schema.conditions) === null || _schema$conditions4 === void 0 ? void 0 : _schema$conditions4.fields) !== null &&
|
|
518
|
+
})) !== null && _schema$conditions$fi !== void 0 ? _schema$conditions$fi : schema === null || schema === void 0 || (_schema$conditions4 = schema.conditions) === null || _schema$conditions4 === void 0 ? void 0 : _schema$conditions4.fields) !== null && _ref16 !== void 0 ? _ref16 : [];
|
|
478
519
|
};
|
|
479
520
|
var hasTrigger = function hasTrigger(rule) {
|
|
480
521
|
return !isEmpty((rule === null || rule === void 0 ? void 0 : rule.triggers) || []);
|
|
@@ -488,50 +529,68 @@ var isTriggerEnabled = function isTriggerEnabled(schema) {
|
|
|
488
529
|
var _schema$triggers2;
|
|
489
530
|
return (schema === null || schema === void 0 || (_schema$triggers2 = schema.triggers) === null || _schema$triggers2 === void 0 ? void 0 : _schema$triggers2.enabled) !== false;
|
|
490
531
|
};
|
|
491
|
-
var isTriggerSatisfied = function isTriggerSatisfied(
|
|
492
|
-
var rule =
|
|
493
|
-
schema =
|
|
532
|
+
var isTriggerSatisfied = function isTriggerSatisfied(_ref17) {
|
|
533
|
+
var rule = _ref17.rule,
|
|
534
|
+
schema = _ref17.schema;
|
|
494
535
|
return !isTriggerEnabled(schema) || hasTrigger(rule);
|
|
495
536
|
};
|
|
496
|
-
var hasRequiredConditions = function hasRequiredConditions(
|
|
537
|
+
var hasRequiredConditions = function hasRequiredConditions(_ref18) {
|
|
497
538
|
var _schema$conditions5;
|
|
498
|
-
var rule =
|
|
499
|
-
schema =
|
|
539
|
+
var rule = _ref18.rule,
|
|
540
|
+
schema = _ref18.schema;
|
|
500
541
|
return (schema === null || schema === void 0 || (_schema$conditions5 = schema.conditions) === null || _schema$conditions5 === void 0 ? void 0 : _schema$conditions5.allowEmpty) === false ? isNotEmpty((rule === null || rule === void 0 ? void 0 : rule.conditions) || []) : true;
|
|
501
542
|
};
|
|
502
|
-
var
|
|
503
|
-
var rule =
|
|
504
|
-
schema =
|
|
543
|
+
var hasUnansweredStep = function hasUnansweredStep(_ref19) {
|
|
544
|
+
var rule = _ref19.rule,
|
|
545
|
+
schema = _ref19.schema;
|
|
546
|
+
return ((rule === null || rule === void 0 ? void 0 : rule.actions) || []).some(function (action) {
|
|
547
|
+
return actionStepsOf({
|
|
548
|
+
schema: schema,
|
|
549
|
+
action: action
|
|
550
|
+
}).some(function (step) {
|
|
551
|
+
return step.required && !stepValueOf({
|
|
552
|
+
action: action,
|
|
553
|
+
step: step
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
};
|
|
558
|
+
var isRuleComplete = function isRuleComplete(_ref20) {
|
|
559
|
+
var rule = _ref20.rule,
|
|
560
|
+
schema = _ref20.schema;
|
|
505
561
|
return isTriggerSatisfied({
|
|
506
562
|
rule: rule,
|
|
507
563
|
schema: schema
|
|
508
564
|
}) && hasRequiredConditions({
|
|
509
565
|
rule: rule,
|
|
510
566
|
schema: schema
|
|
511
|
-
}) && hasAction(rule)
|
|
567
|
+
}) && hasAction(rule) && !hasUnansweredStep({
|
|
568
|
+
rule: rule,
|
|
569
|
+
schema: schema
|
|
570
|
+
});
|
|
512
571
|
};
|
|
513
|
-
var scopeOptionFor = function scopeOptionFor(
|
|
572
|
+
var scopeOptionFor = function scopeOptionFor(_ref21) {
|
|
514
573
|
var _item$value, _schema$scope;
|
|
515
|
-
var schema =
|
|
516
|
-
item =
|
|
574
|
+
var schema = _ref21.schema,
|
|
575
|
+
item = _ref21.item;
|
|
517
576
|
var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
|
|
518
577
|
return ((schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.options) || []).find(function (candidate) {
|
|
519
578
|
var _candidate$value2;
|
|
520
579
|
return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
|
|
521
580
|
});
|
|
522
581
|
};
|
|
523
|
-
var scopePhoneFields = function scopePhoneFields(
|
|
524
|
-
var
|
|
525
|
-
var schema =
|
|
526
|
-
item =
|
|
527
|
-
return (
|
|
582
|
+
var scopePhoneFields = function scopePhoneFields(_ref22) {
|
|
583
|
+
var _ref23, _item$phoneFields, _scopeOptionFor;
|
|
584
|
+
var schema = _ref22.schema,
|
|
585
|
+
item = _ref22.item;
|
|
586
|
+
return (_ref23 = (_item$phoneFields = item === null || item === void 0 ? void 0 : item.phoneFields) !== null && _item$phoneFields !== void 0 ? _item$phoneFields : (_scopeOptionFor = scopeOptionFor({
|
|
528
587
|
schema: schema,
|
|
529
588
|
item: item
|
|
530
|
-
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null &&
|
|
589
|
+
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null && _ref23 !== void 0 ? _ref23 : null;
|
|
531
590
|
};
|
|
532
|
-
var effectiveScopePhoneField = function effectiveScopePhoneField(
|
|
533
|
-
var schema =
|
|
534
|
-
item =
|
|
591
|
+
var effectiveScopePhoneField = function effectiveScopePhoneField(_ref24) {
|
|
592
|
+
var schema = _ref24.schema,
|
|
593
|
+
item = _ref24.item;
|
|
535
594
|
if (item !== null && item !== void 0 && item.phoneField) return item.phoneField;
|
|
536
595
|
var phoneFields = scopePhoneFields({
|
|
537
596
|
schema: schema,
|
|
@@ -539,14 +598,14 @@ var effectiveScopePhoneField = function effectiveScopePhoneField(_ref20) {
|
|
|
539
598
|
});
|
|
540
599
|
return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].value : undefined;
|
|
541
600
|
};
|
|
542
|
-
var invalidScopeIndexes = function invalidScopeIndexes(
|
|
601
|
+
var invalidScopeIndexes = function invalidScopeIndexes(_ref25) {
|
|
543
602
|
var _scope$requiresPhone;
|
|
544
|
-
var rule =
|
|
545
|
-
schema =
|
|
603
|
+
var rule = _ref25.rule,
|
|
604
|
+
schema = _ref25.schema;
|
|
546
605
|
var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
|
|
547
606
|
if (!(scope !== null && scope !== void 0 && scope.enabled) || !((_scope$requiresPhone = scope.requiresPhone) !== null && _scope$requiresPhone !== void 0 && _scope$requiresPhone.call(scope, (rule === null || rule === void 0 ? void 0 : rule.actions) || []))) return [];
|
|
548
607
|
return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
|
|
549
|
-
var
|
|
608
|
+
var _ref26, _item$hasPhoneField;
|
|
550
609
|
var option = scopeOptionFor({
|
|
551
610
|
schema: schema,
|
|
552
611
|
item: item
|
|
@@ -555,15 +614,15 @@ var invalidScopeIndexes = function invalidScopeIndexes(_ref21) {
|
|
|
555
614
|
schema: schema,
|
|
556
615
|
item: item
|
|
557
616
|
});
|
|
558
|
-
var hasPhoneField = (
|
|
617
|
+
var hasPhoneField = (_ref26 = (_item$hasPhoneField = item === null || item === void 0 ? void 0 : item.hasPhoneField) !== null && _item$hasPhoneField !== void 0 ? _item$hasPhoneField : option === null || option === void 0 ? void 0 : option.hasPhoneField) !== null && _ref26 !== void 0 ? _ref26 : phoneFields ? phoneFields.length > 0 : undefined;
|
|
559
618
|
if (hasPhoneField === false) indexes.push(index);
|
|
560
619
|
return indexes;
|
|
561
620
|
}, []);
|
|
562
621
|
};
|
|
563
|
-
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(
|
|
622
|
+
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(_ref27) {
|
|
564
623
|
var _scope$requiresPhone2;
|
|
565
|
-
var rule =
|
|
566
|
-
schema =
|
|
624
|
+
var rule = _ref27.rule,
|
|
625
|
+
schema = _ref27.schema;
|
|
567
626
|
var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
|
|
568
627
|
if (!(scope !== null && scope !== void 0 && scope.enabled) || !((_scope$requiresPhone2 = scope.requiresPhone) !== null && _scope$requiresPhone2 !== void 0 && _scope$requiresPhone2.call(scope, (rule === null || rule === void 0 ? void 0 : rule.actions) || []))) return [];
|
|
569
628
|
return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
|
|
@@ -600,9 +659,9 @@ var minutesToParts = function minutesToParts(minutes) {
|
|
|
600
659
|
unit: "minutes"
|
|
601
660
|
};
|
|
602
661
|
};
|
|
603
|
-
var partsToMinutes = function partsToMinutes(
|
|
604
|
-
var value =
|
|
605
|
-
unit =
|
|
662
|
+
var partsToMinutes = function partsToMinutes(_ref28) {
|
|
663
|
+
var value = _ref28.value,
|
|
664
|
+
unit = _ref28.unit;
|
|
606
665
|
return (
|
|
607
666
|
// eslint-disable-next-line security/detect-object-injection
|
|
608
667
|
(Number(value) || 0) * (UNIT_MINUTES[unit] || 1)
|
|
@@ -652,15 +711,49 @@ var joinTypeFor = function joinTypeFor(mode) {
|
|
|
652
711
|
var recipientStorageField = function recipientStorageField(field) {
|
|
653
712
|
return field === RECIPIENT_STORAGE_FIELDS.emails ? RECIPIENT_STORAGE_FIELDS.emails : RECIPIENT_STORAGE_FIELDS.value;
|
|
654
713
|
};
|
|
714
|
+
|
|
715
|
+
// Which metadata fields the recipient pane renders, and therefore owns: no
|
|
716
|
+
// other pane may block Continue on them. Canvas and ConfigPane both ask here
|
|
717
|
+
// so the two lists cannot drift apart.
|
|
718
|
+
var recipientOwnedFields = function recipientOwnedFields(_ref29) {
|
|
719
|
+
var _actions$actionForNam2, _action$recipient2, _actions$renderRecipi, _actions$renderRecipi2, _actions$optionForNam, _actions$optionForCha;
|
|
720
|
+
var schema = _ref29.schema,
|
|
721
|
+
action = _ref29.action,
|
|
722
|
+
name = _ref29.name;
|
|
723
|
+
var actions = (schema === null || schema === void 0 ? void 0 : schema.actions) || {};
|
|
724
|
+
var resolved = ((_actions$actionForNam2 = actions.actionForName) === null || _actions$actionForNam2 === void 0 ? void 0 : _actions$actionForNam2.call(actions, action === null || action === void 0 ? void 0 : action.name)) || {};
|
|
725
|
+
var channel = (action === null || action === void 0 ? void 0 : action.channel) || resolved.channel;
|
|
726
|
+
// A recipient the host implies from the action name counts just as much as
|
|
727
|
+
// one the user picked, or the pane it owns cannot be excluded.
|
|
728
|
+
var recipient = (_action$recipient2 = action === null || action === void 0 ? void 0 : action.recipient) !== null && _action$recipient2 !== void 0 ? _action$recipient2 : resolved.recipient;
|
|
729
|
+
var rendersEmails = !!((_actions$renderRecipi = actions.renderRecipientEditor) !== null && _actions$renderRecipi !== void 0 && _actions$renderRecipi.call(actions, {
|
|
730
|
+
channel: channel,
|
|
731
|
+
name: name,
|
|
732
|
+
action: action
|
|
733
|
+
})) || !!((_actions$renderRecipi2 = actions.renderRecipientField) !== null && _actions$renderRecipi2 !== void 0 && _actions$renderRecipi2.call(actions, {
|
|
734
|
+
channel: channel,
|
|
735
|
+
name: name,
|
|
736
|
+
action: action,
|
|
737
|
+
recipient: recipient
|
|
738
|
+
}));
|
|
739
|
+
var recipientConfig = (actions.options || []).flatMap(function (option) {
|
|
740
|
+
return option.recipients || [];
|
|
741
|
+
}).concat(actions.recipients || []).find(function (item) {
|
|
742
|
+
var _item$value2;
|
|
743
|
+
return ((_item$value2 = item.value) !== null && _item$value2 !== void 0 ? _item$value2 : item.id) === recipient;
|
|
744
|
+
});
|
|
745
|
+
var flatOption = ((_actions$optionForNam = actions.optionForName) === null || _actions$optionForNam === void 0 ? void 0 : _actions$optionForNam.call(actions, action === null || action === void 0 ? void 0 : action.name)) || ((_actions$optionForCha = actions.optionForChannel) === null || _actions$optionForCha === void 0 ? void 0 : _actions$optionForCha.call(actions, channel));
|
|
746
|
+
return [].concat(_toConsumableArray(rendersEmails ? [RECIPIENT_STORAGE_FIELDS.emails] : []), _toConsumableArray(recipientConfig !== null && recipientConfig !== void 0 && recipientConfig.field ? [recipientStorageField(recipientConfig.field)] : []), _toConsumableArray((flatOption === null || flatOption === void 0 ? void 0 : flatOption.type) === SMS_TO_NUMBERS ? [RECIPIENT_STORAGE_FIELDS.phoneNumbers] : []));
|
|
747
|
+
};
|
|
655
748
|
var modeFromJoinType = function modeFromJoinType(joinType) {
|
|
656
749
|
return joinType === JOIN_TYPE.or ? CONDITION_MODE.OR : CONDITION_MODE.AND;
|
|
657
750
|
};
|
|
658
751
|
|
|
659
752
|
// eslint-disable-next-line security/detect-object-injection
|
|
660
|
-
var valueAt = function valueAt(
|
|
753
|
+
var valueAt = function valueAt(_ref30) {
|
|
661
754
|
var _values$key;
|
|
662
|
-
var values =
|
|
663
|
-
key =
|
|
755
|
+
var values = _ref30.values,
|
|
756
|
+
key = _ref30.key;
|
|
664
757
|
return values === null || values === void 0 || (_values$key = values[key]) === null || _values$key === void 0 ? void 0 : _values$key.value;
|
|
665
758
|
};
|
|
666
759
|
var asArray = function asArray(maybeArray) {
|
|
@@ -683,11 +776,11 @@ var fieldKeysFromSchema = function fieldKeysFromSchema() {
|
|
|
683
776
|
};
|
|
684
777
|
var valuesToRuleModel = function valuesToRuleModel() {
|
|
685
778
|
var _valueAt, _conditions$;
|
|
686
|
-
var
|
|
687
|
-
|
|
688
|
-
values =
|
|
689
|
-
|
|
690
|
-
schema =
|
|
779
|
+
var _ref31 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
780
|
+
_ref31$values = _ref31.values,
|
|
781
|
+
values = _ref31$values === void 0 ? {} : _ref31$values,
|
|
782
|
+
_ref31$schema = _ref31.schema,
|
|
783
|
+
schema = _ref31$schema === void 0 ? {} : _ref31$schema;
|
|
691
784
|
var keys = fieldKeysFromSchema(schema);
|
|
692
785
|
var conditions = asArray(valueAt({
|
|
693
786
|
values: values,
|
|
@@ -731,42 +824,42 @@ var valuesToRuleModel = function valuesToRuleModel() {
|
|
|
731
824
|
}))
|
|
732
825
|
};
|
|
733
826
|
};
|
|
734
|
-
var setTriggers = function setTriggers(
|
|
735
|
-
var schema =
|
|
736
|
-
triggers =
|
|
827
|
+
var setTriggers = function setTriggers(_ref32) {
|
|
828
|
+
var schema = _ref32.schema,
|
|
829
|
+
triggers = _ref32.triggers;
|
|
737
830
|
return {
|
|
738
831
|
path: "".concat(fieldKeysFromSchema(schema).triggers, ".value"),
|
|
739
832
|
value: triggers
|
|
740
833
|
};
|
|
741
834
|
};
|
|
742
|
-
var setPerformer = function setPerformer(
|
|
743
|
-
var schema =
|
|
744
|
-
performer =
|
|
835
|
+
var setPerformer = function setPerformer(_ref33) {
|
|
836
|
+
var schema = _ref33.schema,
|
|
837
|
+
performer = _ref33.performer;
|
|
745
838
|
return {
|
|
746
839
|
path: "".concat(fieldKeysFromSchema(schema).performer, ".value"),
|
|
747
840
|
value: performer
|
|
748
841
|
};
|
|
749
842
|
};
|
|
750
|
-
var setActions = function setActions(
|
|
751
|
-
var schema =
|
|
752
|
-
actions =
|
|
843
|
+
var setActions = function setActions(_ref34) {
|
|
844
|
+
var schema = _ref34.schema,
|
|
845
|
+
actions = _ref34.actions;
|
|
753
846
|
return {
|
|
754
847
|
path: "".concat(fieldKeysFromSchema(schema).actions, ".value"),
|
|
755
848
|
value: actions
|
|
756
849
|
};
|
|
757
850
|
};
|
|
758
|
-
var setConditions = function setConditions(
|
|
759
|
-
var schema =
|
|
760
|
-
conditions =
|
|
851
|
+
var setConditions = function setConditions(_ref35) {
|
|
852
|
+
var schema = _ref35.schema,
|
|
853
|
+
conditions = _ref35.conditions;
|
|
761
854
|
return {
|
|
762
855
|
path: "".concat(fieldKeysFromSchema(schema).conditions, ".value"),
|
|
763
856
|
value: conditions
|
|
764
857
|
};
|
|
765
858
|
};
|
|
766
|
-
var setConditionMode = function setConditionMode(
|
|
767
|
-
var schema =
|
|
768
|
-
conditions =
|
|
769
|
-
joinType =
|
|
859
|
+
var setConditionMode = function setConditionMode(_ref36) {
|
|
860
|
+
var schema = _ref36.schema,
|
|
861
|
+
conditions = _ref36.conditions,
|
|
862
|
+
joinType = _ref36.joinType;
|
|
770
863
|
return setConditions({
|
|
771
864
|
schema: schema,
|
|
772
865
|
conditions: conditions.map(function (condition) {
|
|
@@ -774,34 +867,34 @@ var setConditionMode = function setConditionMode(_ref31) {
|
|
|
774
867
|
})
|
|
775
868
|
});
|
|
776
869
|
};
|
|
777
|
-
var setDelay = function setDelay(
|
|
778
|
-
var schema =
|
|
779
|
-
delay =
|
|
870
|
+
var setDelay = function setDelay(_ref37) {
|
|
871
|
+
var schema = _ref37.schema,
|
|
872
|
+
delay = _ref37.delay;
|
|
780
873
|
return {
|
|
781
874
|
path: "".concat(fieldKeysFromSchema(schema).delay, ".value"),
|
|
782
875
|
value: delay !== null && delay !== void 0 ? delay : {}
|
|
783
876
|
};
|
|
784
877
|
};
|
|
785
|
-
var setActive = function setActive(
|
|
786
|
-
var schema =
|
|
787
|
-
active =
|
|
878
|
+
var setActive = function setActive(_ref38) {
|
|
879
|
+
var schema = _ref38.schema,
|
|
880
|
+
active = _ref38.active;
|
|
788
881
|
return {
|
|
789
882
|
path: "".concat(fieldKeysFromSchema(schema).status, ".value"),
|
|
790
883
|
value: active ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED
|
|
791
884
|
};
|
|
792
885
|
};
|
|
793
|
-
var setScope = function setScope(
|
|
794
|
-
var schema =
|
|
795
|
-
scope =
|
|
886
|
+
var setScope = function setScope(_ref39) {
|
|
887
|
+
var schema = _ref39.schema,
|
|
888
|
+
scope = _ref39.scope;
|
|
796
889
|
return {
|
|
797
890
|
path: "".concat(fieldKeysFromSchema(schema).scope, ".value"),
|
|
798
891
|
value: scope
|
|
799
892
|
};
|
|
800
893
|
};
|
|
801
|
-
var removeArrayItem = function removeArrayItem(
|
|
802
|
-
var values =
|
|
803
|
-
fieldKey =
|
|
804
|
-
index =
|
|
894
|
+
var removeArrayItem = function removeArrayItem(_ref40) {
|
|
895
|
+
var values = _ref40.values,
|
|
896
|
+
fieldKey = _ref40.fieldKey,
|
|
897
|
+
index = _ref40.index;
|
|
805
898
|
var list = asArray(valueAt({
|
|
806
899
|
values: values,
|
|
807
900
|
key: fieldKey
|
|
@@ -828,9 +921,9 @@ var removeArrayItem = function removeArrayItem(_ref35) {
|
|
|
828
921
|
}
|
|
829
922
|
return result;
|
|
830
923
|
};
|
|
831
|
-
var clearArrayItems = function clearArrayItems(
|
|
832
|
-
var values =
|
|
833
|
-
fieldKey =
|
|
924
|
+
var clearArrayItems = function clearArrayItems(_ref41) {
|
|
925
|
+
var values = _ref41.values,
|
|
926
|
+
fieldKey = _ref41.fieldKey;
|
|
834
927
|
var list = asArray(valueAt({
|
|
835
928
|
values: values,
|
|
836
929
|
key: fieldKey
|
|
@@ -1408,7 +1501,8 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1408
1501
|
configValuePlaceholder = _actionParts.configValuePlaceholder,
|
|
1409
1502
|
paramKind = _actionParts.paramKind,
|
|
1410
1503
|
valueNoun = _actionParts.valueNoun,
|
|
1411
|
-
valueNounPlural = _actionParts.valueNounPlural
|
|
1504
|
+
valueNounPlural = _actionParts.valueNounPlural,
|
|
1505
|
+
steps = _actionParts.steps;
|
|
1412
1506
|
|
|
1413
1507
|
// A separator-less action still needs a value slot when the host declares a
|
|
1414
1508
|
// placeholder for it, otherwise its chosen value never reaches the canvas.
|
|
@@ -1490,6 +1584,32 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1490
1584
|
children: recipient ? String(recipientLabel).toLowerCase() : t("neetoRules.builder.selectRecipient")
|
|
1491
1585
|
})]
|
|
1492
1586
|
}, "recipient") : null;
|
|
1587
|
+
var stepTokens = steps.map(function (step) {
|
|
1588
|
+
var stepLabel = stepLabelOf({
|
|
1589
|
+
action: action,
|
|
1590
|
+
step: step
|
|
1591
|
+
});
|
|
1592
|
+
var token = {
|
|
1593
|
+
type: BUILDER_ANCHORS.ACTION_STEP,
|
|
1594
|
+
index: index,
|
|
1595
|
+
stepKey: step.key
|
|
1596
|
+
};
|
|
1597
|
+
return /*#__PURE__*/jsxs(Fragment$1, {
|
|
1598
|
+
children: [step.separator && /*#__PURE__*/jsx("span", {
|
|
1599
|
+
className: "mb-fixed",
|
|
1600
|
+
children: step.separator
|
|
1601
|
+
}), /*#__PURE__*/jsx(Token, {
|
|
1602
|
+
active: isActive(token),
|
|
1603
|
+
dataTestid: "action-step-".concat(step.key, "-").concat(index),
|
|
1604
|
+
invalid: isInvalid(token),
|
|
1605
|
+
state: stepLabel ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
|
|
1606
|
+
onClick: handleToken && function () {
|
|
1607
|
+
return handleToken(token);
|
|
1608
|
+
},
|
|
1609
|
+
children: (step.preserveCase ? stepLabel : sentencify(stepLabel)) || sentencify(step.placeholder)
|
|
1610
|
+
})]
|
|
1611
|
+
}, "step-".concat(step.key));
|
|
1612
|
+
});
|
|
1493
1613
|
return /*#__PURE__*/jsxs("div", {
|
|
1494
1614
|
className: classNames("mb-row mb-row-draggable", {
|
|
1495
1615
|
clearing: clearing
|
|
@@ -1563,7 +1683,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1563
1683
|
size: 14
|
|
1564
1684
|
}), configLabel]
|
|
1565
1685
|
})]
|
|
1566
|
-
}), recipientSeparator ? [recipientToken, configToken] : [configToken, recipientToken]]
|
|
1686
|
+
}), recipientSeparator ? [recipientToken, configToken] : [configToken, recipientToken], stepTokens]
|
|
1567
1687
|
}), /*#__PURE__*/jsxs("div", {
|
|
1568
1688
|
className: "mb-row-actions",
|
|
1569
1689
|
children: [handleAddAction && /*#__PURE__*/jsx(Button, {
|
|
@@ -1857,6 +1977,7 @@ var WhenBlock = function WhenBlock(_ref) {
|
|
|
1857
1977
|
});
|
|
1858
1978
|
};
|
|
1859
1979
|
|
|
1980
|
+
var _excluded = ["type"];
|
|
1860
1981
|
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1861
1982
|
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1862
1983
|
var usePaneCascade = function usePaneCascade(schema) {
|
|
@@ -1884,12 +2005,13 @@ var usePaneCascade = function usePaneCascade(schema) {
|
|
|
1884
2005
|
var openPane = useCallback(function (token) {
|
|
1885
2006
|
var type = TOKEN_TO_PANEL_TYPE[token === null || token === void 0 ? void 0 : token.type];
|
|
1886
2007
|
if (!type) return;
|
|
2008
|
+
var anchor = token.type,
|
|
2009
|
+
rest = _objectWithoutProperties(token, _excluded);
|
|
1887
2010
|
openType({
|
|
1888
2011
|
type: type,
|
|
1889
|
-
data: {
|
|
1890
|
-
anchor:
|
|
1891
|
-
|
|
1892
|
-
}
|
|
2012
|
+
data: _objectSpread$5({
|
|
2013
|
+
anchor: anchor
|
|
2014
|
+
}, rest)
|
|
1893
2015
|
});
|
|
1894
2016
|
}, [openType]);
|
|
1895
2017
|
return {
|
|
@@ -2010,6 +2132,52 @@ var triggerValue = function triggerValue(option) {
|
|
|
2010
2132
|
var _ref, _option$eventValue;
|
|
2011
2133
|
return (_ref = (_option$eventValue = option.eventValue) !== null && _option$eventValue !== void 0 ? _option$eventValue : option.value) !== null && _ref !== void 0 ? _ref : option.id;
|
|
2012
2134
|
};
|
|
2135
|
+
var stepAt = function stepAt(_ref2) {
|
|
2136
|
+
var schema = _ref2.schema,
|
|
2137
|
+
rule = _ref2.rule,
|
|
2138
|
+
index = _ref2.index,
|
|
2139
|
+
stepKey = _ref2.stepKey;
|
|
2140
|
+
return actionStepsOf({
|
|
2141
|
+
schema: schema,
|
|
2142
|
+
action: actionAt({
|
|
2143
|
+
rule: rule,
|
|
2144
|
+
index: index
|
|
2145
|
+
})
|
|
2146
|
+
}).find(function (step) {
|
|
2147
|
+
return step.key === stepKey;
|
|
2148
|
+
});
|
|
2149
|
+
};
|
|
2150
|
+
|
|
2151
|
+
// Panes hand off in sentence order — config, recipient, then each host step —
|
|
2152
|
+
// so every "what comes next" question resolves through this one list.
|
|
2153
|
+
var stepTargetAfter = function stepTargetAfter(_ref3) {
|
|
2154
|
+
var schema = _ref3.schema,
|
|
2155
|
+
rule = _ref3.rule,
|
|
2156
|
+
index = _ref3.index,
|
|
2157
|
+
stepKey = _ref3.stepKey;
|
|
2158
|
+
var steps = actionStepsOf({
|
|
2159
|
+
schema: schema,
|
|
2160
|
+
action: actionAt({
|
|
2161
|
+
rule: rule,
|
|
2162
|
+
index: index
|
|
2163
|
+
})
|
|
2164
|
+
});
|
|
2165
|
+
var at = stepKey ? steps.findIndex(function (step) {
|
|
2166
|
+
return step.key === stepKey;
|
|
2167
|
+
}) : -1;
|
|
2168
|
+
// An unknown key means the step is gone from under the pane; restarting the
|
|
2169
|
+
// cascade at the first step would be worse than ending it.
|
|
2170
|
+
if (stepKey && at === -1) return null;
|
|
2171
|
+
var next = steps[at + 1];
|
|
2172
|
+
return next ? {
|
|
2173
|
+
type: BUILDER_PANEL_TYPES.ACTION_STEP,
|
|
2174
|
+
data: {
|
|
2175
|
+
index: index,
|
|
2176
|
+
stepKey: next.key,
|
|
2177
|
+
anchor: BUILDER_ANCHORS.ACTION_STEP
|
|
2178
|
+
}
|
|
2179
|
+
} : null;
|
|
2180
|
+
};
|
|
2013
2181
|
var optionValue = function optionValue(option) {
|
|
2014
2182
|
var _option$value;
|
|
2015
2183
|
return (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.id;
|
|
@@ -2035,9 +2203,9 @@ var groupByCategory = function groupByCategory(options) {
|
|
|
2035
2203
|
});
|
|
2036
2204
|
return groups;
|
|
2037
2205
|
};
|
|
2038
|
-
var conditionAt = function conditionAt(
|
|
2039
|
-
var rule =
|
|
2040
|
-
index =
|
|
2206
|
+
var conditionAt = function conditionAt(_ref4) {
|
|
2207
|
+
var rule = _ref4.rule,
|
|
2208
|
+
index = _ref4.index;
|
|
2041
2209
|
return (
|
|
2042
2210
|
// eslint-disable-next-line security/detect-object-injection
|
|
2043
2211
|
rule.conditions[index] || {}
|
|
@@ -2045,63 +2213,63 @@ var conditionAt = function conditionAt(_ref2) {
|
|
|
2045
2213
|
};
|
|
2046
2214
|
|
|
2047
2215
|
// eslint-disable-next-line security/detect-object-injection
|
|
2048
|
-
var actionAt = function actionAt(
|
|
2049
|
-
var rule =
|
|
2050
|
-
index =
|
|
2216
|
+
var actionAt = function actionAt(_ref5) {
|
|
2217
|
+
var rule = _ref5.rule,
|
|
2218
|
+
index = _ref5.index;
|
|
2051
2219
|
return rule.actions[index] || {};
|
|
2052
2220
|
};
|
|
2053
2221
|
|
|
2054
2222
|
// eslint-disable-next-line security/detect-object-injection
|
|
2055
|
-
var scopeItemAt = function scopeItemAt(
|
|
2223
|
+
var scopeItemAt = function scopeItemAt(_ref6) {
|
|
2056
2224
|
var _rule$scope;
|
|
2057
|
-
var rule =
|
|
2058
|
-
index =
|
|
2225
|
+
var rule = _ref6.rule,
|
|
2226
|
+
index = _ref6.index;
|
|
2059
2227
|
return ((_rule$scope = rule.scope) === null || _rule$scope === void 0 ? void 0 : _rule$scope[index]) || {};
|
|
2060
2228
|
};
|
|
2061
2229
|
var scopeItemLabel = function scopeItemLabel(item) {
|
|
2062
2230
|
return (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.value) || String(item !== null && item !== void 0 ? item : "");
|
|
2063
2231
|
};
|
|
2064
|
-
var findField = function findField(
|
|
2232
|
+
var findField = function findField(_ref7) {
|
|
2065
2233
|
var _schema$conditions;
|
|
2066
|
-
var schema =
|
|
2067
|
-
value =
|
|
2234
|
+
var schema = _ref7.schema,
|
|
2235
|
+
value = _ref7.value;
|
|
2068
2236
|
return (((_schema$conditions = schema.conditions) === null || _schema$conditions === void 0 ? void 0 : _schema$conditions.fields) || []).find(function (field) {
|
|
2069
2237
|
return optionValue(field) === value;
|
|
2070
2238
|
});
|
|
2071
2239
|
};
|
|
2072
|
-
var findActionOption = function findActionOption(
|
|
2240
|
+
var findActionOption = function findActionOption(_ref8) {
|
|
2073
2241
|
var _schema$actions;
|
|
2074
|
-
var schema =
|
|
2075
|
-
name =
|
|
2242
|
+
var schema = _ref8.schema,
|
|
2243
|
+
name = _ref8.name;
|
|
2076
2244
|
return (((_schema$actions = schema.actions) === null || _schema$actions === void 0 ? void 0 : _schema$actions.options) || []).find(function (option) {
|
|
2077
2245
|
return optionValue(option) === name;
|
|
2078
2246
|
});
|
|
2079
2247
|
};
|
|
2080
|
-
var channelOf = function channelOf(
|
|
2248
|
+
var channelOf = function channelOf(_ref9) {
|
|
2081
2249
|
var _schema$actions2, _schema$actions2$acti;
|
|
2082
|
-
var schema =
|
|
2083
|
-
action =
|
|
2250
|
+
var schema = _ref9.schema,
|
|
2251
|
+
action = _ref9.action;
|
|
2084
2252
|
return (action === null || action === void 0 ? void 0 : action.channel) || ((_schema$actions2 = schema.actions) === null || _schema$actions2 === void 0 || (_schema$actions2$acti = _schema$actions2.actionForName) === null || _schema$actions2$acti === void 0 || (_schema$actions2$acti = _schema$actions2$acti.call(_schema$actions2, action === null || action === void 0 ? void 0 : action.name)) === null || _schema$actions2$acti === void 0 ? void 0 : _schema$actions2$acti.channel);
|
|
2085
2253
|
};
|
|
2086
|
-
var recipientOf = function recipientOf(
|
|
2254
|
+
var recipientOf = function recipientOf(_ref0) {
|
|
2087
2255
|
var _action$recipient, _schema$actions3, _schema$actions3$acti;
|
|
2088
|
-
var schema =
|
|
2089
|
-
action =
|
|
2256
|
+
var schema = _ref0.schema,
|
|
2257
|
+
action = _ref0.action;
|
|
2090
2258
|
return (_action$recipient = action === null || action === void 0 ? void 0 : action.recipient) !== null && _action$recipient !== void 0 ? _action$recipient : (_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 || (_schema$actions3$acti = _schema$actions3.actionForName) === null || _schema$actions3$acti === void 0 || (_schema$actions3$acti = _schema$actions3$acti.call(_schema$actions3, action === null || action === void 0 ? void 0 : action.name)) === null || _schema$actions3$acti === void 0 ? void 0 : _schema$actions3$acti.recipient;
|
|
2091
2259
|
};
|
|
2092
|
-
var channelMetaOf = function channelMetaOf(
|
|
2260
|
+
var channelMetaOf = function channelMetaOf(_ref1) {
|
|
2093
2261
|
var _schema$actions4;
|
|
2094
|
-
var schema =
|
|
2095
|
-
action =
|
|
2262
|
+
var schema = _ref1.schema,
|
|
2263
|
+
action = _ref1.action;
|
|
2096
2264
|
return ((_schema$actions4 = schema.actions) === null || _schema$actions4 === void 0 || (_schema$actions4 = _schema$actions4.channelMeta) === null || _schema$actions4 === void 0 ? void 0 : _schema$actions4[channelOf({
|
|
2097
2265
|
schema: schema,
|
|
2098
2266
|
action: action
|
|
2099
2267
|
})]) || {};
|
|
2100
2268
|
};
|
|
2101
|
-
var actionHasConfig = function actionHasConfig(
|
|
2269
|
+
var actionHasConfig = function actionHasConfig(_ref10) {
|
|
2102
2270
|
var _schema$actions5, _schema$actions6;
|
|
2103
|
-
var schema =
|
|
2104
|
-
action =
|
|
2271
|
+
var schema = _ref10.schema,
|
|
2272
|
+
action = _ref10.action;
|
|
2105
2273
|
var meta = channelMetaOf({
|
|
2106
2274
|
schema: schema,
|
|
2107
2275
|
action: action
|
|
@@ -2115,10 +2283,10 @@ var actionHasConfig = function actionHasConfig(_ref0) {
|
|
|
2115
2283
|
if ((_schema$actions5 = schema.actions) !== null && _schema$actions5 !== void 0 && _schema$actions5.hasConfig) return schema.actions.hasConfig(action);
|
|
2116
2284
|
return !!((_schema$actions6 = schema.actions) !== null && _schema$actions6 !== void 0 && _schema$actions6.renderConfig);
|
|
2117
2285
|
};
|
|
2118
|
-
var recipientsFor = function recipientsFor(
|
|
2286
|
+
var recipientsFor = function recipientsFor(_ref11) {
|
|
2119
2287
|
var _schema$actions7, _schema$actions8;
|
|
2120
|
-
var schema =
|
|
2121
|
-
action =
|
|
2288
|
+
var schema = _ref11.schema,
|
|
2289
|
+
action = _ref11.action;
|
|
2122
2290
|
var channel = channelOf({
|
|
2123
2291
|
schema: schema,
|
|
2124
2292
|
action: action
|
|
@@ -2133,11 +2301,11 @@ var recipientsFor = function recipientsFor(_ref1) {
|
|
|
2133
2301
|
if (option !== null && option !== void 0 && option.recipients) return option.recipients;
|
|
2134
2302
|
return ((_schema$actions8 = schema.actions) === null || _schema$actions8 === void 0 ? void 0 : _schema$actions8.recipients) || [];
|
|
2135
2303
|
};
|
|
2136
|
-
var nextTriggers = function nextTriggers(
|
|
2304
|
+
var nextTriggers = function nextTriggers(_ref12) {
|
|
2137
2305
|
var _schema$triggers;
|
|
2138
|
-
var schema =
|
|
2139
|
-
rule =
|
|
2140
|
-
value =
|
|
2306
|
+
var schema = _ref12.schema,
|
|
2307
|
+
rule = _ref12.rule,
|
|
2308
|
+
value = _ref12.value;
|
|
2141
2309
|
if ((_schema$triggers = schema.triggers) !== null && _schema$triggers !== void 0 && _schema$triggers.multi) {
|
|
2142
2310
|
var names = pluck("name", rule.triggers);
|
|
2143
2311
|
return names.includes(value) ? removeBy({
|
|
@@ -2150,12 +2318,12 @@ var nextTriggers = function nextTriggers(_ref10) {
|
|
|
2150
2318
|
name: value
|
|
2151
2319
|
})];
|
|
2152
2320
|
};
|
|
2153
|
-
var nextConditionAt = function nextConditionAt(
|
|
2321
|
+
var nextConditionAt = function nextConditionAt(_ref13) {
|
|
2154
2322
|
var _field$allowMatching;
|
|
2155
|
-
var schema =
|
|
2156
|
-
rule =
|
|
2157
|
-
index =
|
|
2158
|
-
value =
|
|
2323
|
+
var schema = _ref13.schema,
|
|
2324
|
+
rule = _ref13.rule,
|
|
2325
|
+
index = _ref13.index,
|
|
2326
|
+
value = _ref13.value;
|
|
2159
2327
|
var field = findField({
|
|
2160
2328
|
schema: schema,
|
|
2161
2329
|
value: value
|
|
@@ -2174,12 +2342,12 @@ var nextConditionAt = function nextConditionAt(_ref11) {
|
|
|
2174
2342
|
metadata: {}
|
|
2175
2343
|
});
|
|
2176
2344
|
};
|
|
2177
|
-
var nextActionAt = function nextActionAt(
|
|
2345
|
+
var nextActionAt = function nextActionAt(_ref14) {
|
|
2178
2346
|
var _schema$actions9;
|
|
2179
|
-
var schema =
|
|
2180
|
-
rule =
|
|
2181
|
-
index =
|
|
2182
|
-
value =
|
|
2347
|
+
var schema = _ref14.schema,
|
|
2348
|
+
rule = _ref14.rule,
|
|
2349
|
+
index = _ref14.index,
|
|
2350
|
+
value = _ref14.value;
|
|
2183
2351
|
if (!((_schema$actions9 = schema.actions) !== null && _schema$actions9 !== void 0 && _schema$actions9.resolveName)) {
|
|
2184
2352
|
var option = findActionOption({
|
|
2185
2353
|
schema: schema,
|
|
@@ -2237,11 +2405,11 @@ var nextActionAt = function nextActionAt(_ref12) {
|
|
|
2237
2405
|
metadata: channelChanged ? {} : prev.metadata
|
|
2238
2406
|
});
|
|
2239
2407
|
};
|
|
2240
|
-
var appendScopeItem = function appendScopeItem(
|
|
2408
|
+
var appendScopeItem = function appendScopeItem(_ref15) {
|
|
2241
2409
|
var _sc$requiresPhone;
|
|
2242
|
-
var schema =
|
|
2243
|
-
rule =
|
|
2244
|
-
value =
|
|
2410
|
+
var schema = _ref15.schema,
|
|
2411
|
+
rule = _ref15.rule,
|
|
2412
|
+
value = _ref15.value;
|
|
2245
2413
|
var sc = schema.scope || {};
|
|
2246
2414
|
var option = (sc.options || []).find(function (candidate) {
|
|
2247
2415
|
return optionValue(candidate) === value;
|
|
@@ -2258,12 +2426,12 @@ var appendScopeItem = function appendScopeItem(_ref13) {
|
|
|
2258
2426
|
phoneField: phoneFields[0].value
|
|
2259
2427
|
}) : option;
|
|
2260
2428
|
};
|
|
2261
|
-
var nextActionRecipientAt = function nextActionRecipientAt(
|
|
2429
|
+
var nextActionRecipientAt = function nextActionRecipientAt(_ref16) {
|
|
2262
2430
|
var _schema$actions1;
|
|
2263
|
-
var schema =
|
|
2264
|
-
rule =
|
|
2265
|
-
index =
|
|
2266
|
-
value =
|
|
2431
|
+
var schema = _ref16.schema,
|
|
2432
|
+
rule = _ref16.rule,
|
|
2433
|
+
index = _ref16.index,
|
|
2434
|
+
value = _ref16.value;
|
|
2267
2435
|
var prev = actionAt({
|
|
2268
2436
|
rule: rule,
|
|
2269
2437
|
index: index
|
|
@@ -2280,12 +2448,13 @@ var nextActionRecipientAt = function nextActionRecipientAt(_ref14) {
|
|
|
2280
2448
|
}) : value
|
|
2281
2449
|
});
|
|
2282
2450
|
};
|
|
2283
|
-
var descriptorFor = function descriptorFor(
|
|
2451
|
+
var descriptorFor = function descriptorFor(_ref17) {
|
|
2284
2452
|
var _schema$actor2;
|
|
2285
|
-
var anchor =
|
|
2286
|
-
schema =
|
|
2287
|
-
rule =
|
|
2288
|
-
index =
|
|
2453
|
+
var anchor = _ref17.anchor,
|
|
2454
|
+
schema = _ref17.schema,
|
|
2455
|
+
rule = _ref17.rule,
|
|
2456
|
+
index = _ref17.index,
|
|
2457
|
+
stepKey = _ref17.stepKey;
|
|
2289
2458
|
switch (anchor) {
|
|
2290
2459
|
case BUILDER_ANCHORS.TRIGGER_ADD:
|
|
2291
2460
|
case BUILDER_ANCHORS.TRIGGER_REPLACE:
|
|
@@ -2481,6 +2650,29 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2481
2650
|
cascade: true
|
|
2482
2651
|
};
|
|
2483
2652
|
}
|
|
2653
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
2654
|
+
{
|
|
2655
|
+
var _action = actionAt({
|
|
2656
|
+
rule: rule,
|
|
2657
|
+
index: index
|
|
2658
|
+
});
|
|
2659
|
+
var step = stepAt({
|
|
2660
|
+
schema: schema,
|
|
2661
|
+
rule: rule,
|
|
2662
|
+
index: index,
|
|
2663
|
+
stepKey: stepKey
|
|
2664
|
+
}) || {};
|
|
2665
|
+
return {
|
|
2666
|
+
title: step.title || t("neetoRules.builder.panes.stepTitle"),
|
|
2667
|
+
subtitle: step.subtitle,
|
|
2668
|
+
options: normalizeOptions(step.options),
|
|
2669
|
+
selectedValues: [stepValueOf({
|
|
2670
|
+
action: _action,
|
|
2671
|
+
step: step
|
|
2672
|
+
})],
|
|
2673
|
+
cascade: true
|
|
2674
|
+
};
|
|
2675
|
+
}
|
|
2484
2676
|
case BUILDER_ANCHORS.SCOPE:
|
|
2485
2677
|
{
|
|
2486
2678
|
var _sc$requiresPhone2;
|
|
@@ -2550,13 +2742,14 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2550
2742
|
};
|
|
2551
2743
|
}
|
|
2552
2744
|
};
|
|
2553
|
-
var commitFor = function commitFor(
|
|
2554
|
-
var anchor =
|
|
2555
|
-
schema =
|
|
2556
|
-
rule =
|
|
2557
|
-
index =
|
|
2558
|
-
|
|
2559
|
-
|
|
2745
|
+
var commitFor = function commitFor(_ref18) {
|
|
2746
|
+
var anchor = _ref18.anchor,
|
|
2747
|
+
schema = _ref18.schema,
|
|
2748
|
+
rule = _ref18.rule,
|
|
2749
|
+
index = _ref18.index,
|
|
2750
|
+
stepKey = _ref18.stepKey,
|
|
2751
|
+
value = _ref18.value,
|
|
2752
|
+
helpers = _ref18.helpers;
|
|
2560
2753
|
var setTriggers = helpers.setTriggers,
|
|
2561
2754
|
setPerformer = helpers.setPerformer,
|
|
2562
2755
|
setConditionMode = helpers.setConditionMode,
|
|
@@ -2627,6 +2820,11 @@ var commitFor = function commitFor(_ref16) {
|
|
|
2627
2820
|
}));
|
|
2628
2821
|
return "stay";
|
|
2629
2822
|
}
|
|
2823
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
2824
|
+
{
|
|
2825
|
+
setFieldValue("".concat(fieldKeys.actions, ".value.").concat(index, ".metadata.").concat(stepKey), value);
|
|
2826
|
+
return "stay";
|
|
2827
|
+
}
|
|
2630
2828
|
case BUILDER_ANCHORS.SCOPE:
|
|
2631
2829
|
{
|
|
2632
2830
|
var key = fieldKeys.scope;
|
|
@@ -2656,13 +2854,14 @@ var commitFor = function commitFor(_ref16) {
|
|
|
2656
2854
|
return "close";
|
|
2657
2855
|
}
|
|
2658
2856
|
};
|
|
2659
|
-
var continueTargetFor = function continueTargetFor(
|
|
2857
|
+
var continueTargetFor = function continueTargetFor(_ref19) {
|
|
2660
2858
|
var _schema$actor3;
|
|
2661
|
-
var anchor =
|
|
2662
|
-
schema =
|
|
2663
|
-
rule =
|
|
2664
|
-
index =
|
|
2665
|
-
|
|
2859
|
+
var anchor = _ref19.anchor,
|
|
2860
|
+
schema = _ref19.schema,
|
|
2861
|
+
rule = _ref19.rule,
|
|
2862
|
+
index = _ref19.index,
|
|
2863
|
+
stepKey = _ref19.stepKey,
|
|
2864
|
+
configPending = _ref19.configPending;
|
|
2666
2865
|
switch (anchor) {
|
|
2667
2866
|
case BUILDER_ANCHORS.TRIGGER_ADD:
|
|
2668
2867
|
case BUILDER_ANCHORS.TRIGGER_REPLACE:
|
|
@@ -2721,56 +2920,74 @@ var continueTargetFor = function continueTargetFor(_ref17) {
|
|
|
2721
2920
|
|
|
2722
2921
|
// Reached here only because the action has no config yet — its name is
|
|
2723
2922
|
// still unresolved — so the recipient pane owes us that step afterwards.
|
|
2724
|
-
|
|
2923
|
+
if (channelMetaOf({
|
|
2725
2924
|
schema: schema,
|
|
2726
2925
|
action: action
|
|
2727
|
-
}).needsRecipient
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2926
|
+
}).needsRecipient) {
|
|
2927
|
+
return {
|
|
2928
|
+
type: BUILDER_PANEL_TYPES.RECIPIENT,
|
|
2929
|
+
data: {
|
|
2930
|
+
index: index,
|
|
2931
|
+
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
2932
|
+
configPending: true
|
|
2933
|
+
}
|
|
2934
|
+
};
|
|
2935
|
+
}
|
|
2936
|
+
return stepTargetAfter({
|
|
2937
|
+
schema: schema,
|
|
2938
|
+
rule: rule,
|
|
2939
|
+
index: index
|
|
2940
|
+
});
|
|
2735
2941
|
}
|
|
2736
2942
|
case BUILDER_ANCHORS.ACTION_RECIPIENT:
|
|
2737
2943
|
{
|
|
2738
|
-
// Only chain
|
|
2739
|
-
// the config pane or from the token means
|
|
2740
|
-
var
|
|
2944
|
+
// Only chain back to config when it was skipped on the way in; arriving
|
|
2945
|
+
// from the config pane or from the token means config is already done.
|
|
2946
|
+
var _action2 = actionAt({
|
|
2741
2947
|
rule: rule,
|
|
2742
2948
|
index: index
|
|
2743
2949
|
});
|
|
2744
2950
|
return configPending && actionHasConfig({
|
|
2745
2951
|
schema: schema,
|
|
2746
|
-
action:
|
|
2952
|
+
action: _action2
|
|
2747
2953
|
}) ? {
|
|
2748
2954
|
type: BUILDER_PANEL_TYPES.ACTION_CONFIG,
|
|
2749
2955
|
data: {
|
|
2750
2956
|
index: index,
|
|
2751
2957
|
anchor: BUILDER_ANCHORS.ACTION_CONFIG
|
|
2752
2958
|
}
|
|
2753
|
-
} :
|
|
2959
|
+
} : stepTargetAfter({
|
|
2960
|
+
schema: schema,
|
|
2961
|
+
rule: rule,
|
|
2962
|
+
index: index
|
|
2963
|
+
});
|
|
2754
2964
|
}
|
|
2965
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
2966
|
+
return stepTargetAfter({
|
|
2967
|
+
schema: schema,
|
|
2968
|
+
rule: rule,
|
|
2969
|
+
index: index,
|
|
2970
|
+
stepKey: stepKey
|
|
2971
|
+
});
|
|
2755
2972
|
default:
|
|
2756
2973
|
return null;
|
|
2757
2974
|
}
|
|
2758
2975
|
};
|
|
2759
|
-
var replaceAt = function replaceAt(
|
|
2760
|
-
var list =
|
|
2761
|
-
index =
|
|
2762
|
-
item =
|
|
2976
|
+
var replaceAt = function replaceAt(_ref20) {
|
|
2977
|
+
var list = _ref20.list,
|
|
2978
|
+
index = _ref20.index,
|
|
2979
|
+
item = _ref20.item;
|
|
2763
2980
|
var next = _toConsumableArray(list);
|
|
2764
2981
|
// eslint-disable-next-line security/detect-object-injection
|
|
2765
2982
|
next[index] = item;
|
|
2766
2983
|
return next;
|
|
2767
2984
|
};
|
|
2768
|
-
var applyPreview = function applyPreview(
|
|
2769
|
-
var rule =
|
|
2770
|
-
schema =
|
|
2771
|
-
anchor =
|
|
2772
|
-
index =
|
|
2773
|
-
value =
|
|
2985
|
+
var applyPreview = function applyPreview(_ref21) {
|
|
2986
|
+
var rule = _ref21.rule,
|
|
2987
|
+
schema = _ref21.schema,
|
|
2988
|
+
anchor = _ref21.anchor,
|
|
2989
|
+
index = _ref21.index,
|
|
2990
|
+
value = _ref21.value;
|
|
2774
2991
|
switch (anchor) {
|
|
2775
2992
|
case BUILDER_ANCHORS.TRIGGER_ADD:
|
|
2776
2993
|
case BUILDER_ANCHORS.TRIGGER_REPLACE:
|
|
@@ -2954,33 +3171,25 @@ var Canvas = function Canvas(_ref) {
|
|
|
2954
3171
|
});
|
|
2955
3172
|
};
|
|
2956
3173
|
var matchesInvalid = function matchesInvalid(_ref4) {
|
|
2957
|
-
var _schema$actions, _schema$actions$actio, _schema$actions2, _schema$actions2$rend, _schema$actions3, _schema$actions3$rend, _schema$actions4, _schema$actions4$opti, _schema$actions5, _schema$actions5$opti, _schema$actions6, _schema$actions7;
|
|
2958
3174
|
var type = _ref4.type,
|
|
2959
|
-
index = _ref4.index
|
|
3175
|
+
index = _ref4.index,
|
|
3176
|
+
stepKey = _ref4.stepKey;
|
|
2960
3177
|
var conditionMeta = "".concat(fieldKeys.conditions, ".value.").concat(index, ".metadata");
|
|
2961
3178
|
var actionMeta = "".concat(fieldKeys.actions, ".value.").concat(index, ".metadata");
|
|
2962
3179
|
// eslint-disable-next-line security/detect-object-injection
|
|
2963
3180
|
var actionItem = rule.actions[index] || {};
|
|
2964
|
-
var
|
|
2965
|
-
|
|
2966
|
-
channel: channel,
|
|
2967
|
-
name: actionMeta,
|
|
2968
|
-
action: actionItem
|
|
2969
|
-
}));
|
|
2970
|
-
var hasRecipientField = !!((_schema$actions3 = schema.actions) !== null && _schema$actions3 !== void 0 && (_schema$actions3$rend = _schema$actions3.renderRecipientField) !== null && _schema$actions3$rend !== void 0 && _schema$actions3$rend.call(_schema$actions3, {
|
|
2971
|
-
channel: channel,
|
|
2972
|
-
recipient: actionItem.recipient,
|
|
2973
|
-
name: actionMeta,
|
|
3181
|
+
var steps = actionStepsOf({
|
|
3182
|
+
schema: schema,
|
|
2974
3183
|
action: actionItem
|
|
2975
|
-
}));
|
|
2976
|
-
var flatOption = ((_schema$actions4 = schema.actions) === null || _schema$actions4 === void 0 || (_schema$actions4$opti = _schema$actions4.optionForName) === null || _schema$actions4$opti === void 0 ? void 0 : _schema$actions4$opti.call(_schema$actions4, actionItem.name)) || ((_schema$actions5 = schema.actions) === null || _schema$actions5 === void 0 || (_schema$actions5$opti = _schema$actions5.optionForChannel) === null || _schema$actions5$opti === void 0 ? void 0 : _schema$actions5$opti.call(_schema$actions5, channel));
|
|
2977
|
-
var recipientConfig = [].concat(_toConsumableArray((((_schema$actions6 = schema.actions) === null || _schema$actions6 === void 0 ? void 0 : _schema$actions6.options) || []).flatMap(function (option) {
|
|
2978
|
-
return option.recipients || [];
|
|
2979
|
-
})), _toConsumableArray(((_schema$actions7 = schema.actions) === null || _schema$actions7 === void 0 ? void 0 : _schema$actions7.recipients) || [])).find(function (item) {
|
|
2980
|
-
var _item$value;
|
|
2981
|
-
return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === actionItem.recipient;
|
|
2982
3184
|
});
|
|
2983
|
-
var
|
|
3185
|
+
var stepKeys = steps.map(function (step) {
|
|
3186
|
+
return step.key;
|
|
3187
|
+
});
|
|
3188
|
+
var recipientFields = recipientOwnedFields({
|
|
3189
|
+
schema: schema,
|
|
3190
|
+
action: actionItem,
|
|
3191
|
+
name: actionMeta
|
|
3192
|
+
});
|
|
2984
3193
|
switch (type) {
|
|
2985
3194
|
case BUILDER_ANCHORS.TRIGGER_ACTOR:
|
|
2986
3195
|
{
|
|
@@ -3011,8 +3220,20 @@ var Canvas = function Canvas(_ref) {
|
|
|
3011
3220
|
case BUILDER_ANCHORS.ACTION_CONFIG:
|
|
3012
3221
|
return hasErrorAt({
|
|
3013
3222
|
prefix: actionMeta,
|
|
3014
|
-
exclude: recipientFields
|
|
3223
|
+
exclude: [].concat(_toConsumableArray(recipientFields), _toConsumableArray(stepKeys))
|
|
3015
3224
|
});
|
|
3225
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
3226
|
+
{
|
|
3227
|
+
var step = steps.find(function (item) {
|
|
3228
|
+
return item.key === stepKey;
|
|
3229
|
+
});
|
|
3230
|
+
return hasErrorAt({
|
|
3231
|
+
prefix: "".concat(actionMeta, ".").concat(stepKey)
|
|
3232
|
+
}) || !!(step !== null && step !== void 0 && step.required) && !stepValueOf({
|
|
3233
|
+
action: actionItem,
|
|
3234
|
+
step: step
|
|
3235
|
+
});
|
|
3236
|
+
}
|
|
3016
3237
|
case BUILDER_ANCHORS.ACTION_RECIPIENT:
|
|
3017
3238
|
return hasErrorAt({
|
|
3018
3239
|
prefix: "".concat(fieldKeys.actions, ".value.").concat(index, ".name")
|
|
@@ -3644,7 +3865,8 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3644
3865
|
mediumLabel = _actionParts.mediumLabel,
|
|
3645
3866
|
needsRecipient = _actionParts.needsRecipient,
|
|
3646
3867
|
configTitle = _actionParts.configTitle,
|
|
3647
|
-
configSubtitle = _actionParts.configSubtitle
|
|
3868
|
+
configSubtitle = _actionParts.configSubtitle,
|
|
3869
|
+
steps = _actionParts.steps;
|
|
3648
3870
|
var name = "".concat(base, ".metadata");
|
|
3649
3871
|
var flatOption = ((_schema$actions = schema.actions) === null || _schema$actions === void 0 || (_schema$actions$optio = _schema$actions.optionForName) === null || _schema$actions$optio === void 0 ? void 0 : _schema$actions$optio.call(_schema$actions, action.name)) || ((_schema$actions2 = schema.actions) === null || _schema$actions2 === void 0 || (_schema$actions2$opti = _schema$actions2.optionForChannel) === null || _schema$actions2$opti === void 0 ? void 0 : _schema$actions2$opti.call(_schema$actions2, channel)) || option;
|
|
3650
3872
|
|
|
@@ -3698,11 +3920,21 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3698
3920
|
}) || (option === null || option === void 0 ? void 0 : option.label) || t("neetoRules.builder.setUpAction");
|
|
3699
3921
|
var handleContinue = /*#__PURE__*/function () {
|
|
3700
3922
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
3923
|
+
var owned, next;
|
|
3701
3924
|
return _regenerator().w(function (_context) {
|
|
3702
3925
|
while (1) switch (_context.n) {
|
|
3703
3926
|
case 0:
|
|
3927
|
+
// A pane only answers for what it renders: the recipient pane owns its
|
|
3928
|
+
// storage fields and each step owns its key, so neither blocks Continue.
|
|
3929
|
+
owned = [].concat(_toConsumableArray(recipientOwnedFields({
|
|
3930
|
+
schema: schema,
|
|
3931
|
+
action: action,
|
|
3932
|
+
name: name
|
|
3933
|
+
})), _toConsumableArray(steps.map(function (step) {
|
|
3934
|
+
return step.key;
|
|
3935
|
+
})));
|
|
3704
3936
|
_context.n = 1;
|
|
3705
|
-
return validate(
|
|
3937
|
+
return validate(owned);
|
|
3706
3938
|
case 1:
|
|
3707
3939
|
if (_context.v) {
|
|
3708
3940
|
_context.n = 2;
|
|
@@ -3710,17 +3942,18 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3710
3942
|
}
|
|
3711
3943
|
return _context.a(2);
|
|
3712
3944
|
case 2:
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
}
|
|
3945
|
+
next = shouldAdvanceToRecipient ? {
|
|
3946
|
+
type: BUILDER_PANEL_TYPES.RECIPIENT,
|
|
3947
|
+
data: {
|
|
3948
|
+
index: index,
|
|
3949
|
+
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT
|
|
3950
|
+
}
|
|
3951
|
+
} : stepTargetAfter({
|
|
3952
|
+
schema: schema,
|
|
3953
|
+
rule: rule,
|
|
3954
|
+
index: index
|
|
3955
|
+
});
|
|
3956
|
+
if (next) openType(next);else closePane();
|
|
3724
3957
|
case 3:
|
|
3725
3958
|
return _context.a(2);
|
|
3726
3959
|
}
|
|
@@ -4121,6 +4354,7 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4121
4354
|
var schema = _ref.schema,
|
|
4122
4355
|
anchor = _ref.anchor,
|
|
4123
4356
|
index = _ref.index,
|
|
4357
|
+
stepKey = _ref.stepKey,
|
|
4124
4358
|
_ref$belowContent = _ref.belowContent,
|
|
4125
4359
|
belowContent = _ref$belowContent === void 0 ? null : _ref$belowContent,
|
|
4126
4360
|
_ref$configPending = _ref.configPending,
|
|
@@ -4165,9 +4399,10 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4165
4399
|
anchor: anchor,
|
|
4166
4400
|
schema: schema,
|
|
4167
4401
|
rule: rule,
|
|
4168
|
-
index: index
|
|
4402
|
+
index: index,
|
|
4403
|
+
stepKey: stepKey
|
|
4169
4404
|
});
|
|
4170
|
-
}, [anchor, schema, rule, index]),
|
|
4405
|
+
}, [anchor, schema, rule, index, stepKey]),
|
|
4171
4406
|
title = _useMemo.title,
|
|
4172
4407
|
subtitle = _useMemo.subtitle,
|
|
4173
4408
|
multi = _useMemo.multi,
|
|
@@ -4202,6 +4437,7 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4202
4437
|
schema: schema,
|
|
4203
4438
|
rule: rule,
|
|
4204
4439
|
index: index,
|
|
4440
|
+
stepKey: stepKey,
|
|
4205
4441
|
value: value,
|
|
4206
4442
|
helpers: helpers
|
|
4207
4443
|
});
|
|
@@ -4231,6 +4467,7 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4231
4467
|
schema: schema,
|
|
4232
4468
|
rule: rule,
|
|
4233
4469
|
index: index,
|
|
4470
|
+
stepKey: stepKey,
|
|
4234
4471
|
configPending: configPending
|
|
4235
4472
|
});
|
|
4236
4473
|
if (target) openType({
|
|
@@ -4804,9 +5041,11 @@ var BUILDER_PANEL_TYPE_CONFIG_MAP = (_BUILDER_PANEL_TYPE_C = {}, _defineProperty
|
|
|
4804
5041
|
component: ValuePane
|
|
4805
5042
|
}), BUILDER_PANEL_TYPES.ACTION_CONFIG, {
|
|
4806
5043
|
component: ConfigPane
|
|
4807
|
-
}), BUILDER_PANEL_TYPES.
|
|
5044
|
+
}), BUILDER_PANEL_TYPES.ACTION_STEP, {
|
|
5045
|
+
component: OptionsPane
|
|
5046
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_BUILDER_PANEL_TYPE_C, BUILDER_PANEL_TYPES.DELAY, {
|
|
4808
5047
|
component: DelayPane
|
|
4809
|
-
}),
|
|
5048
|
+
}), BUILDER_PANEL_TYPES.LEAD_TIME, {
|
|
4810
5049
|
component: LeadTimePane
|
|
4811
5050
|
}), BUILDER_PANEL_TYPES.NAME, {
|
|
4812
5051
|
component: NamePane
|