Merge pull request #1204 from BogdanAlexandru/mct1198

[Edit] Switch other edit actions to mct-control
This commit is contained in:
Victor Woeltjen 2016-10-04 18:09:16 -07:00 committed by GitHub
commit 8a0018177a
3 changed files with 17 additions and 8 deletions

View File

@ -245,7 +245,9 @@ define([
"key": "cancel", "key": "cancel",
"category": "conclude-editing", "category": "conclude-editing",
"implementation": CancelAction, "implementation": CancelAction,
"name": "Cancel", // Because we use the name as label for edit buttons and mct-control buttons need
// the label to be set to undefined in order to not apply the labeled CSS rule.
"name": undefined,
"cssclass": "icon-x no-label", "cssclass": "icon-x no-label",
"description": "Discard changes made to these objects.", "description": "Discard changes made to these objects.",
"depends": [] "depends": []

View File

@ -25,7 +25,7 @@
<mct-control key="'button'" <mct-control key="'button'"
structure="{ structure="{
text: saveActions[0].getMetadata().name, text: saveActions[0].getMetadata().name,
click: saveActions[0].perform, click: actionPerformer(saveActions[0]),
cssclass: 'major ' + saveActions[0].getMetadata().cssclass cssclass: 'major ' + saveActions[0].getMetadata().cssclass
}"> }">
</mct-control> </mct-control>
@ -42,11 +42,12 @@
</span> </span>
<span ng-repeat="currentAction in otherEditActions"> <span ng-repeat="currentAction in otherEditActions">
<a class='s-button {{currentAction.getMetadata().cssclass}}' <mct-control key="'button'"
title='{{currentAction.getMetadata().name}}' structure="{
ng-click="currentAction.perform()" text: currentAction.getMetadata().name,
ng-class="{ major: $index === 0 && saveActions.length === 0 }"> click: actionPerformer(currentAction),
<span class="title-label">{{currentAction.getMetadata().name}}</span> cssclass: currentAction.getMetadata().cssclass
</a> }">
</mct-control>
</span> </span>
</span> </span>

View File

@ -61,6 +61,12 @@ define(
$scope.otherEditActions = $scope.action ? $scope.otherEditActions = $scope.action ?
$scope.action.getActions(OTHERS_ACTION_CONTEXT) : $scope.action.getActions(OTHERS_ACTION_CONTEXT) :
[]; [];
// Required because Angular does not allow 'bind'
// in expressions.
$scope.actionPerformer = function (action) {
return action.perform.bind(action);
};
} }
// Update set of actions whenever the action capability // Update set of actions whenever the action capability