From 0ab6c8e4b09a50120974db0f1d322c237f1c4aa5 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Sun, 28 Jan 2018 12:24:40 +0100 Subject: [PATCH] #159: workflow steps ui --- .../settings/SettingsWorkflowEdit.js | 50 +++++++++- docs-web/src/main/webapp/src/locale/en.json | 13 ++- .../src/partial/docs/directive.auditlog.html | 3 + .../partial/docs/settings.workflow.edit.html | 97 +++++++++++-------- docs-web/src/main/webapp/src/style/main.less | 19 ++++ 5 files changed, 137 insertions(+), 45 deletions(-) diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsWorkflowEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsWorkflowEdit.js index ee708b54..5d0a3d7a 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsWorkflowEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsWorkflowEdit.js @@ -3,7 +3,53 @@ /** * Settings workflow edition page controller. */ -angular.module('docs').controller('SettingsWorkflowEdit', function($scope, $dialog, $state, $stateParams, Restangular, $translate) { +angular.module('docs').controller('SettingsWorkflowEdit', function($scope, $dialog, $state, $stateParams, Restangular, $translate, $q) { + /** + * UI sortable options. + */ + $scope.sortableOptions = { + forceHelperSize: true, + forcePlaceholderSize: true, + tolerance: 'pointer', + handle: '.handle' + }; + + /** + * Auto-complete on ACL target. + */ + $scope.getTargetAclTypeahead = function($viewValue) { + var deferred = $q.defer(); + Restangular.one('acl/target/search') + .get({ + search: $viewValue + }).then(function(data) { + var output = []; + + // Add the type to use later + output.push.apply(output, _.map(data.users, function(user) { + user.type = 'USER'; + return user; + })); + output.push.apply(output, _.map(data.groups, function(group) { + group.type = 'GROUP'; + return group; + })); + + // Send the data to the typeahead directive + deferred.resolve(output, true); + }); + return deferred.promise; + }; + + /** + * Add a workflow step. + */ + $scope.addStep = function () { + $scope.workflow.steps.push({ + type: 'VALIDATE' + }); + }; + /** * Returns true if in edit mode (false in add mode). */ @@ -17,6 +63,7 @@ angular.module('docs').controller('SettingsWorkflowEdit', function($scope, $dial if ($scope.isEdit()) { Restangular.one('routemodel', $stateParams.id).get().then(function (data) { $scope.workflow = data; + $scope.workflow.steps = JSON.parse(data.steps); }); } else { $scope.workflow = { @@ -30,6 +77,7 @@ angular.module('docs').controller('SettingsWorkflowEdit', function($scope, $dial $scope.edit = function () { var promise = null; var workflow = angular.copy($scope.workflow); + workflow.steps = JSON.stringify(workflow.steps); if ($scope.isEdit()) { promise = Restangular diff --git a/docs-web/src/main/webapp/src/locale/en.json b/docs-web/src/main/webapp/src/locale/en.json index c4db55cb..4dc084df 100644 --- a/docs-web/src/main/webapp/src/locale/en.json +++ b/docs-web/src/main/webapp/src/locale/en.json @@ -266,7 +266,15 @@ "delete_workflow_message": "Do you really want to delete this workflow? Currently running workflows will not be deleted", "edit_workflow_title": "Edit \"{{ name }}\"", "add_workflow_title": "Add a workflow", - "name": "Name" + "name": "Name", + "name_placeholder": "Step name or description", + "drag_help": "Drag and drop to rorder the step", + "type": "Step type", + "type_approve": "Approve", + "type_validate": "Validate", + "target": "Assigned to", + "target_help": "Approve: Review and continue the workflow
Validate: Accept or reject the review", + "add_step": "Add a workflow step" } }, "security": { @@ -391,7 +399,8 @@ "File": "File", "Group": "Group", "Tag": "Tag", - "User": "User" + "User": "User", + "RouteModel": "Workflow" }, "selectrelation": { "typeahead": "Type a document title" diff --git a/docs-web/src/main/webapp/src/partial/docs/directive.auditlog.html b/docs-web/src/main/webapp/src/partial/docs/directive.auditlog.html index 072552ae..c87ad733 100644 --- a/docs-web/src/main/webapp/src/partial/docs/directive.auditlog.html +++ b/docs-web/src/main/webapp/src/partial/docs/directive.auditlog.html @@ -42,6 +42,9 @@ {{ log.message }} + + {{ log.message }} + diff --git a/docs-web/src/main/webapp/src/partial/docs/settings.workflow.edit.html b/docs-web/src/main/webapp/src/partial/docs/settings.workflow.edit.html index 2f2461dc..68c80f95 100644 --- a/docs-web/src/main/webapp/src/partial/docs/settings.workflow.edit.html +++ b/docs-web/src/main/webapp/src/partial/docs/settings.workflow.edit.html @@ -19,48 +19,61 @@ -
-
-
-
-
-
-
-
{{ $index + 1 }}
- - -
-
-
-
- - Step type - - -
-
- Assigned to -
+
+
+
+
+
+
-
-
- -
-
- -
+
+
{{ $index + 1 }}
-
-
- +
@@ -69,8 +82,8 @@
- diff --git a/docs-web/src/main/webapp/src/style/main.less b/docs-web/src/main/webapp/src/style/main.less index f155e407..7fe6872f 100644 --- a/docs-web/src/main/webapp/src/style/main.less +++ b/docs-web/src/main/webapp/src/style/main.less @@ -310,6 +310,16 @@ input[readonly].share-link { padding-bottom: 0; } +// Workflow model edition +.route-step-row { + display: flex; + align-items: center; + + .text-center { + font-size: 200%; + } +} + // Feedback .feedback { display: block; @@ -430,4 +440,13 @@ input[readonly].share-link { 100%{ transform:scale(1.1); } +} + +// Margins +.mt-10 { + margin-top: 10px; +} + +.mb-10 { + margin-bottom: 10px; } \ No newline at end of file