Skip to content

Commit

Permalink
Merge pull request #993 from marmelab/submit_button_directive
Browse files Browse the repository at this point in the history
[RFR] Add submit button directive
  • Loading branch information
fzaninotto committed Mar 22, 2016
2 parents 1b1b917 + e2623d5 commit ba78799
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/javascripts/ng-admin/Crud/CrudModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ CrudModule.directive('maListButton', require('./button/maListButton'));
CrudModule.directive('maDeleteButton', require('./button/maDeleteButton'));
CrudModule.directive('maBatchDeleteButton', require('./button/maBatchDeleteButton'));
CrudModule.directive('maExportToCsvButton', require('./button/maExportToCsvButton'));
CrudModule.directive('maSubmitButton', require('./button/maSubmitButton'));
CrudModule.directive('maViewBatchActions', require('./button/maViewBatchActions'));

CrudModule.directive('maShowItem', require('./show/maShowItem'));
Expand Down
20 changes: 20 additions & 0 deletions src/javascripts/ng-admin/Crud/button/maSubmitButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Save button
*
* Usage:
* <ma-submit-button label="Save changes"></ma-submit-button>
*/
export default function maSubmitButtonDirective() {
return {
restrict: 'E',
scope: {
label: '@',
},
link: function (scope) {
scope.label = scope.label || 'Save';
},
template: '<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span> {{ label }}</button>'
};
}

maSubmitButtonDirective.$inject = [];
2 changes: 1 addition & 1 deletion src/javascripts/ng-admin/Crud/form/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1 compile="::formController.title">

<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span> Submit</button>
<ma-submit-button label="Submit"></ma-submit-button>
</div>
</div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/ng-admin/Crud/form/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1 compile="::formController.title">

<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span> Save Changes</button>
<ma-submit-button label="Save Changes"></ma-submit-button>
</div>
</div>
</form>
Expand Down

0 comments on commit ba78799

Please sign in to comment.