Skip to content

Commit

Permalink
Merge pull request #74 from greenpeace-cee/gp-46306-add-warning-popup…
Browse files Browse the repository at this point in the history
…-window

GP-46306: Show warning when unchecking 'Execute disabled tasks'.
  • Loading branch information
pfigel authored Oct 23, 2024
2 parents ab28ad5 + f2099eb commit 1607896
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 13 deletions.
9 changes: 6 additions & 3 deletions ang/actions/CallTask.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,21 @@
<action-additional-info model='model' fieldPrefix="'call_task'" index='index'></action-additional-info>

<check-box
checkbox-change="executeDisabledTasksOnChange(value)"
checkbox-on-click="executeDisabledTasksOnClick($event)"
fieldid="'is_execute_disabled_tasks' + index"
fieldlabel="ts('Execute disabled tasks')"
model="model['is_execute_disabled_tasks']">
model="model['is_execute_disabled_tasks']"
showHelpIcon="true"
helpaction='onInfoPress("Execute Disabled Tasks", "id-is-execute-disabled-tasks", "CRM\/Sqltasks\/Action\/CallTask")'>
</check-box>

<check-box
checkbox-change=""
fieldid="'execute_in_parallel' + index"
fieldlabel="ts('Parallel execution')"
model="model['execute_in_parallel']"
showHelpIcon="true">
showHelpIcon="true"
helpaction='onInfoPress("Parallel Execution", "id-execute-in-parallel", "CRM\/Sqltasks\/Action\/CallTask")'>
</check-box>

<multiple-select2
Expand Down
1 change: 1 addition & 0 deletions ang/inputs/checkBox.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<div class="content">
<input ng-change="checkboxChange({value: componentModel})" ng-true-value="'1'" ng-false-value="'0'"
id="{{fieldId}}" name="{{fieldId}}" type="checkbox" class="crm-form-checkbox"
ng-click="onClickEvent({$event: $event})"
ng-model="componentModel" ng-required="isRequired">
</div>
<div class="clear"></div>
Expand Down
43 changes: 33 additions & 10 deletions ang/sqlTaskConfigurator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1360,23 +1360,38 @@
$scope.isDataExists = function(array) {
return Boolean(array && array.length);
};

$scope.refreshSelectSqlTasks = function() {};
$scope.refreshSelectSqlTaskCategories = function() {};
$scope.executeDisabledTasksOnChange = function(value) {
$scope.model['is_execute_disabled_tasks'] = value;
$scope.refreshSqlTaskSelects = function() {
$scope.loadTasks(function () {
$scope.refreshSelectSqlTaskCategories();
$scope.refreshSelectSqlTasks();
});
};

$scope.refreshSelectSqlTaskCategories = function() {};
$scope.onApplyTemplateCallback = function(value) {
$scope.loadTasks(function () {
$scope.refreshSelectSqlTaskCategories();
$scope.refreshSelectSqlTasks();
});
$scope.refreshSqlTaskSelects();
};
$scope.executeDisabledTasksOnClick = function($event) {

// // when user try to turn off executing disabled tasks:
if ($scope.model['is_execute_disabled_tasks'] === '1') {
CRM.confirm({
title: ts("Confirm change"),
message: ts('<p>Are you sure you want to disable the execution of disabled tasks?</p><p><strong>This will remove any tasks that are disabled from your task selection!</strong></p>'),
options: { yes: "Continue", no: "Cancel" },
}).on("crmConfirm:yes", () => {
$scope.model['is_execute_disabled_tasks'] = '0';
$scope.refreshSqlTaskSelects();
}).on("crmConfirm:no", () => {
$scope.model['is_execute_disabled_tasks'] = '1';
$scope.refreshSqlTaskSelects();
$event.preventDefault();
});
} else {
$scope.model['is_execute_disabled_tasks'] = '1';
$scope.refreshSqlTaskSelects();
}
}

var tasksData = [];

Expand Down Expand Up @@ -1856,7 +1871,15 @@
fieldId: "<fieldid",
helpAction: "&helpaction",
showHelpIcon: "<showhelpicon",
checkboxChange: "&"
checkboxChange: "&",
checkboxOnClick: "&"
},
controller: function($scope) {
$scope.onClickEvent = function ($event) {
if (angular.isFunction($scope.checkboxOnClick)) {
$scope.checkboxOnClick($event);
}
};
}
};
});
Expand Down
13 changes: 13 additions & 0 deletions templates/CRM/Sqltasks/Action/CallTask.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
| written permission from the original author(s). |
+-------------------------------------------------------*}

{htxt id='id-is-execute-disabled-tasks'}
<p>{ts domain="de.systopia.sqltasks"}You can decide whether tasks that are disabled should be executed by this action.{/ts}</p>
<p>{ts domain="de.systopia.sqltasks"}This setting applies to tasks and categories.{/ts}</p>
<p>{ts domain="de.systopia.sqltasks"}The check will be performed during execution, so disabling a task being called by this action could change the behaviour of this task if the setting is off.{/ts}</p>
{/htxt}

{htxt id='id-execute-in-parallel'}
<p>{ts domain="de.systopia.sqltasks"}You can run tasks in parallel via a background queue, e.g. with coworker. {/ts}</p>
<p>{ts domain="de.systopia.sqltasks"}This will only apply if your CiviCRM installation is configured for background queues via the <code>enableBackgroundQueue</code> setting and if a background queue runner is set up.{/ts}</p>
<p>{ts domain="de.systopia.sqltasks"}If <code>enableBackgroundQueue</code> is disabled and you use this option, tasks will simply be executed sequentially.{/ts}</p>
<p>{ts domain="de.systopia.sqltasks"}<strong>Be <id>very</id> careful with this! Order of execution is not guaranteed during parallel execution, so this feature must not be used when tasks must be executed in a specific order.</strong>{/ts}</p>
{/htxt}

{htxt id='id-task-tasks'}
<p>{ts domain="de.systopia.sqltasks"}You can select any tasks (except this one) to be run as an action of this task.{/ts}</p>
<p>{ts domain="de.systopia.sqltasks"}Only enabled tasks will be run, in the order defined by the task manager, <i>not</i> this list.{/ts}</p>
Expand Down

0 comments on commit 1607896

Please sign in to comment.