mirror of
https://github.com/sismics/docs.git
synced 2025-12-22 14:11:39 +00:00
Closes #205: action: remote tag
This commit is contained in:
@@ -84,9 +84,17 @@ angular.module('docs').controller('SettingsWorkflowEdit', function($scope, $dial
|
||||
*/
|
||||
$scope.edit = function () {
|
||||
var promise = null;
|
||||
|
||||
// Cleanup the workflow data
|
||||
var workflow = angular.copy($scope.workflow);
|
||||
_.each(workflow.steps, function (step) {
|
||||
_.each(step.transitions, function (transition) {
|
||||
delete transition.actionType;
|
||||
});
|
||||
});
|
||||
workflow.steps = JSON.stringify(workflow.steps);
|
||||
|
||||
|
||||
if ($scope.isEdit()) {
|
||||
promise = Restangular
|
||||
.one('routemodel', $stateParams.id)
|
||||
@@ -133,33 +141,50 @@ angular.module('docs').controller('SettingsWorkflowEdit', function($scope, $dial
|
||||
$scope.workflow.steps.splice($scope.workflow.steps.indexOf(step), 1);
|
||||
};
|
||||
|
||||
/**
|
||||
* Update transitions on a step.
|
||||
*/
|
||||
$scope.updateTransitions = function (step) {
|
||||
if (step.type === 'VALIDATE') {
|
||||
step.transitions = [{
|
||||
name: 'VALIDATED',
|
||||
actions: []
|
||||
actions: [],
|
||||
actionType: 'ADD_TAG'
|
||||
}];
|
||||
} else if (step.type === 'APPROVE') {
|
||||
step.transitions = [{
|
||||
name: 'APPROVED',
|
||||
actions: []
|
||||
actions: [],
|
||||
actionType: 'ADD_TAG'
|
||||
}, {
|
||||
name: 'REJECTED',
|
||||
actions: []
|
||||
actions: [],
|
||||
actionType: 'ADD_TAG'
|
||||
}];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add an action.
|
||||
*/
|
||||
$scope.addAction = function (transition) {
|
||||
if (_.isUndefined(transition.actionType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
transition.actions.push({
|
||||
type: 'ADD_TAG'
|
||||
type: transition.actionType
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove an action.
|
||||
*/
|
||||
$scope.removeAction = function (actions, action) {
|
||||
actions.splice(actions.indexOf(action), 1);
|
||||
};
|
||||
|
||||
// Fetch tags
|
||||
Restangular.one('tag/list').get().then(function(data) {
|
||||
$scope.tags = data.tags;
|
||||
});
|
||||
|
||||
@@ -510,7 +510,8 @@
|
||||
"no_space": "Spaces are not allowed"
|
||||
},
|
||||
"action_type": {
|
||||
"ADD_TAG": "Add this tag"
|
||||
"ADD_TAG": "Add a tag",
|
||||
"REMOVE_TAG": "Remove a tag"
|
||||
},
|
||||
"pagination": {
|
||||
"previous": "Previous",
|
||||
|
||||
@@ -100,6 +100,11 @@
|
||||
<option ng-repeat="tag in tags" value="{{ tag.id }}">{{ tag.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div ng-switch-when="REMOVE_TAG">
|
||||
<select title="{{ 'action_type.REMOVE_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)">
|
||||
@@ -108,8 +113,9 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<select title="Action type" class="form-control">
|
||||
<option name="ADD_TAG">{{ 'action_type.ADD_TAG' | translate }}</option>
|
||||
<select title="Action type" class="form-control" ng-model="transition.actionType">
|
||||
<option value="ADD_TAG">{{ 'action_type.ADD_TAG' | translate }}</option>
|
||||
<option value="REMOVE_TAG">{{ 'action_type.REMOVE_TAG' | translate }}</option>
|
||||
</select>
|
||||
<span class="input-group-addon btn" ng-click="addAction(transition)">
|
||||
<span class="fas fa-plus-circle"></span>
|
||||
|
||||
Reference in New Issue
Block a user