Skip to content

Commit

Permalink
Changes for conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Jun 8, 2020
1 parent d9d233a commit d776eb4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lhc_web/design/defaulttheme/js/react/build/all.js

Large diffs are not rendered by default.

Expand Up @@ -81,7 +81,7 @@ class NodeTriggerActionConditions extends Component {
<div className="row">
<div className="col-6">
<div className="form-group">
<label>If conditions are met execute this trigger</label>
<label>If conditions <b>are</b> met execute this trigger</label>
<NodeTriggerList onSetPayload={(e) => this.onchangeAttr({'path' : ['attr_options','callback_match'], 'value' : e})} payload={this.props.action.getIn(['content','attr_options','callback_match'])} />
</div>
</div>
Expand All @@ -92,6 +92,22 @@ class NodeTriggerActionConditions extends Component {
</div>
</div>
</div>

<div className="row">
<div className="col-6">
<div className="form-group">
<label>If conditions <b>are NOT</b> met execute this trigger</label>
<NodeTriggerList onSetPayload={(e) => this.onchangeAttr({'path' : ['attr_options','callback_unmatch'], 'value' : e})} payload={this.props.action.getIn(['content','attr_options','callback_unmatch'])} />
</div>
</div>
<div className="col-6">
<div className="form-group">
<label>Schedule this trigger execution</label>
<NodeTriggerList onSetPayload={(e) => this.onchangeAttr({'path' : ['attr_options','callback_unreschedule'], 'value' : e})} payload={this.props.action.getIn(['content','attr_options','callback_unreschedule'])} />
</div>
</div>
</div>

<hr className="hr-big" />
</div>
);
Expand Down
Expand Up @@ -25,10 +25,10 @@ public static function process($chat, $action, $trigger, $params)

foreach ($action['content']['conditions'] as $condition) {
if (isset($condition['content']['attr']) && $condition['content']['attr'] != '' &&
isset($condition['content']['val']) && $condition['content']['val'] != '' &&
isset($condition['content']['comp']) && $condition['content']['comp'] != '')
{
$attr = null;
$valAttr = isset($condition['content']['val']) ? $condition['content']['val'] : null;

$paramsConditions = explode('.',$condition['content']['attr']);

Expand All @@ -45,28 +45,28 @@ public static function process($chat, $action, $trigger, $params)
break;
}

if ($condition['content']['comp'] == 'eq' && !($attr == $condition['content']['val'])) {
if ($condition['content']['comp'] == 'eq' && !($attr == $valAttr)) {
$conditionsMet = false;
break;
} else if ($condition['content']['comp'] == 'lt' && !($attr < $condition['content']['val'])) {
} else if ($condition['content']['comp'] == 'lt' && !($attr < $valAttr)) {
$conditionsMet = false;
break;
} else if ($condition['content']['comp'] == 'lte' && !($attr <= $condition['content']['val'])) {
} else if ($condition['content']['comp'] == 'lte' && !($attr <= $valAttr)) {
$conditionsMet = false;
break;
} else if ($condition['content']['comp'] == 'neq' && !($attr != $condition['content']['val'])) {
} else if ($condition['content']['comp'] == 'neq' && !($attr != $valAttr)) {
$conditionsMet = false;
break;
} else if ($condition['content']['comp'] == 'gte' && !($attr >= $condition['content']['val'])) {
} else if ($condition['content']['comp'] == 'gte' && !($attr >= $valAttr)) {
$conditionsMet = false;
break;
} else if ($condition['content']['comp'] == 'gt' && !($attr > $condition['content']['val'])) {
} else if ($condition['content']['comp'] == 'gt' && !($attr > $valAttr)) {
$conditionsMet = false;
break;
} else if ($condition['content']['comp'] == 'like' && erLhcoreClassGenericBotWorkflow::checkPresence(explode(',',$condition['content']['val']),$attr,0) == false) {
} else if ($condition['content']['comp'] == 'like' && erLhcoreClassGenericBotWorkflow::checkPresence(explode(',',$valAttr),$attr,0) == false) {
$conditionsMet = false;
break;
} else if ($condition['content']['comp'] == 'notlike' && erLhcoreClassGenericBotWorkflow::checkPresence(explode(',',$condition['content']['val']),$attr,0) == true) {
} else if ($condition['content']['comp'] == 'notlike' && erLhcoreClassGenericBotWorkflow::checkPresence(explode(',',$valAttr),$attr,0) == true) {
$conditionsMet = false;
break;
}
Expand All @@ -82,10 +82,26 @@ public static function process($chat, $action, $trigger, $params)
$pendingAction->saveThis();
}

return array(
return array (
'status' => 'stop',
'trigger_id' => ((isset($action['content']['attr_options']['callback_match']) && is_numeric($action['content']['attr_options']['callback_match'])) ? $action['content']['attr_options']['callback_match'] : null)
);

} else {

if (isset($action['content']['attr_options']['callback_unreschedule']) && is_numeric($action['content']['attr_options']['callback_unreschedule']) && $action['content']['attr_options']['callback_unreschedule'] > 0) {
$pendingAction = new erLhcoreClassModelGenericBotPendingEvent();
$pendingAction->chat_id = $chat->id;
$pendingAction->trigger_id = $action['content']['attr_options']['callback_unreschedule'];
$pendingAction->saveThis();
}

if (isset($action['content']['attr_options']['callback_unmatch']) && is_numeric($action['content']['attr_options']['callback_unmatch'])){
return array(
'status' => 'stop',
'trigger_id' => ((isset($action['content']['attr_options']['callback_unmatch']) && is_numeric($action['content']['attr_options']['callback_unmatch'])) ? $action['content']['attr_options']['callback_unmatch'] : null)
);
}
}
}
}
Expand Down

0 comments on commit d776eb4

Please sign in to comment.