mirror of
https://github.com/sismics/docs.git
synced 2025-12-22 14:11:39 +00:00
#202 Actions on route transition
This commit is contained in:
@@ -45,9 +45,11 @@ angular.module('docs').controller('SettingsWorkflowEdit', function($scope, $dial
|
||||
* Add a workflow step.
|
||||
*/
|
||||
$scope.addStep = function () {
|
||||
$scope.workflow.steps.push({
|
||||
var step = {
|
||||
type: 'VALIDATE'
|
||||
});
|
||||
};
|
||||
$scope.updateTransitions(step);
|
||||
$scope.workflow.steps.push(step);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -64,6 +66,12 @@ angular.module('docs').controller('SettingsWorkflowEdit', function($scope, $dial
|
||||
Restangular.one('routemodel', $stateParams.id).get().then(function (data) {
|
||||
$scope.workflow = data;
|
||||
$scope.workflow.steps = JSON.parse(data.steps);
|
||||
_.each($scope.workflow.steps, function (step) {
|
||||
if (!step.transitions) {
|
||||
// Patch for old route models
|
||||
$scope.updateTransitions(step);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$scope.workflow = {
|
||||
@@ -124,4 +132,35 @@ angular.module('docs').controller('SettingsWorkflowEdit', function($scope, $dial
|
||||
$scope.removeStep = function (step) {
|
||||
$scope.workflow.steps.splice($scope.workflow.steps.indexOf(step), 1);
|
||||
};
|
||||
|
||||
$scope.updateTransitions = function (step) {
|
||||
if (step.type === 'VALIDATE') {
|
||||
step.transitions = [{
|
||||
name: 'VALIDATED',
|
||||
actions: []
|
||||
}];
|
||||
} else if (step.type === 'APPROVE') {
|
||||
step.transitions = [{
|
||||
name: 'APPROVED',
|
||||
actions: []
|
||||
}, {
|
||||
name: 'REJECTED',
|
||||
actions: []
|
||||
}];
|
||||
}
|
||||
};
|
||||
|
||||
$scope.addAction = function (transition) {
|
||||
transition.actions.push({
|
||||
type: 'ADD_TAG'
|
||||
});
|
||||
};
|
||||
|
||||
$scope.removeAction = function (actions, action) {
|
||||
actions.splice(actions.indexOf(action), 1);
|
||||
};
|
||||
|
||||
Restangular.one('tag/list').get().then(function(data) {
|
||||
$scope.tags = data.tags;
|
||||
});
|
||||
});
|
||||
@@ -301,7 +301,9 @@
|
||||
"type_validate": "Validate",
|
||||
"target": "Assigned to",
|
||||
"target_help": "<strong>Approve:</strong> Accept or reject the review<br/><strong>Validate:</strong> Review and continue the workflow",
|
||||
"add_step": "Add a workflow step"
|
||||
"add_step": "Add a workflow step",
|
||||
"actions": "What happens after?",
|
||||
"remove_action": "Remove action"
|
||||
}
|
||||
},
|
||||
"security": {
|
||||
@@ -507,6 +509,9 @@
|
||||
"number": "Number required",
|
||||
"no_space": "Spaces are not allowed"
|
||||
},
|
||||
"action_type": {
|
||||
"ADD_TAG": "Add this tag"
|
||||
},
|
||||
"pagination": {
|
||||
"previous": "Previous",
|
||||
"next": "Next",
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<span class="fas fa-exchange-alt" ng-if="step.type == 'APPROVE'"></span>
|
||||
<span class="fas fa-check-circle" ng-if="step.type == 'VALIDATE'"></span>
|
||||
</span>
|
||||
<select class="form-control" name="type-{{ $index }}" ng-model="step.type" required>
|
||||
<select class="form-control" name="type-{{ $index }}" ng-model="step.type" ng-change="updateTransitions(step)" required>
|
||||
<option value="APPROVE">{{ 'settings.workflow.edit.type_approve' | translate }}</option>
|
||||
<option value="VALIDATE">{{ 'settings.workflow.edit.type_validate' | translate }}</option>
|
||||
</select>
|
||||
@@ -82,17 +82,54 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-10">
|
||||
<div class="col-xs-2 text-center">
|
||||
<strong>{{ 'settings.workflow.edit.actions' | translate }}</strong>
|
||||
</div>
|
||||
<div class="col-xs-5" ng-repeat="transition in step.transitions">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading text-center">
|
||||
<strong>{{ 'workflow_transition.' + transition.name | translate }}</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div ng-repeat="action in transition.actions" class="mb-10 workflow-action">
|
||||
<p><strong>{{ 'action_type.' + action.type | translate }}</strong></p>
|
||||
<div ng-switch="action.type" class="mb-10">
|
||||
<div ng-switch-when="ADD_TAG">
|
||||
<select title="{{ 'action_type.ADD_TAG' | translate }}" ng-model="action.tag" required class="form-control">
|
||||
<option ng-repeat="tag in tags" value="{{ tag.id }}">{{ tag.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-center">
|
||||
<a href ng-click="removeAction(transition.actions, action)">
|
||||
<span class="fas fa-minus-circle"></span> {{ 'settings.workflow.edit.remove_action' | translate }}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<select title="Action type" class="form-control">
|
||||
<option name="ADD_TAG">{{ 'action_type.ADD_TAG' | translate }}</option>
|
||||
</select>
|
||||
<span class="input-group-addon btn" ng-click="addAction(transition)">
|
||||
<span class="fas fa-plus-circle"></span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="clearfix form-group mt-10">
|
||||
<div class="col-sm-offset-2 col-sm-10 btn-link pointer" ng-click="addStep()">
|
||||
<span class="fas fa-plus-circle"></span> {{ 'settings.workflow.edit.add_step' | translate }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="clearfix form-group mt-10">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-primary" ng-click="edit()" ng-disabled="!editWorkflowForm.$valid">
|
||||
<span class="fas fa-pencil-alt"></span> {{ isEdit() ? 'save' : 'add' | translate }}
|
||||
|
||||
@@ -366,6 +366,11 @@ input[readonly].share-link {
|
||||
}
|
||||
}
|
||||
|
||||
.workflow-action {
|
||||
border: 2px dashed #ccc;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
// Settings
|
||||
.settings-menu {
|
||||
.panel-default {
|
||||
|
||||
Reference in New Issue
Block a user