diff --git a/README.md b/README.md index cd55baee..9a747497 100644 --- a/README.md +++ b/README.md @@ -592,6 +592,17 @@ listView.fields([ ]); ``` +You can also provide custom label using the `label` attribute: + +```js +listView.listActions([ + '' + + '', + '' + + '' +]); +``` + ## Relationships ### `reference` Field diff --git a/src/javascripts/ng-admin/Crud/button/maBackButton.js b/src/javascripts/ng-admin/Crud/button/maBackButton.js index 83bd1e54..36e09cd2 100644 --- a/src/javascripts/ng-admin/Crud/button/maBackButton.js +++ b/src/javascripts/ng-admin/Crud/button/maBackButton.js @@ -7,16 +7,19 @@ define(function () { return { restrict: 'E', scope: { - 'size': '@' + size: '@', + label: '@', }, link: function ($scope) { + $scope.label = $scope.label || 'Back'; + $scope.back = function () { $window.history.back(); }; }, template: '' + - ' Back' + + ' {{ ::label }}' + '' }; } diff --git a/src/javascripts/ng-admin/Crud/button/maBatchDeleteButton.js b/src/javascripts/ng-admin/Crud/button/maBatchDeleteButton.js index 4ae5fc39..ea6a0e54 100644 --- a/src/javascripts/ng-admin/Crud/button/maBatchDeleteButton.js +++ b/src/javascripts/ng-admin/Crud/button/maBatchDeleteButton.js @@ -7,10 +7,13 @@ define(function () { return { restrict: 'E', scope: { - 'entity': '&', - 'selection': '&', + entity: '&', + selection: '&', + label: '@', }, link: function ($scope) { + $scope.label = $scope.label || 'Delete'; + $scope.gotoBatchDelete = function () { var entity = $scope.entity(); var ids = $scope.selection().map(function(entry) { @@ -21,7 +24,7 @@ define(function () { }, template: '' + - ' Delete' + + ' {{ ::label }}' + '' }; diff --git a/src/javascripts/ng-admin/Crud/button/maCreateButton.js b/src/javascripts/ng-admin/Crud/button/maCreateButton.js index 915aa207..7f81c5e3 100644 --- a/src/javascripts/ng-admin/Crud/button/maCreateButton.js +++ b/src/javascripts/ng-admin/Crud/button/maCreateButton.js @@ -7,17 +7,20 @@ define(function () { return { restrict: 'E', scope: { - 'entity': '&', - 'size': '@' + entity: '&', + size: '@', + label: '@', }, link: function (scope) { + scope.label = scope.label || 'Create'; + scope.gotoCreate = function () { $state.go($state.get('create'), { 'entity': scope.entity().name() }); }; }, template: '' + - ' Create' + + ' {{ ::label }}' + '' }; } diff --git a/src/javascripts/ng-admin/Crud/button/maDeleteButton.js b/src/javascripts/ng-admin/Crud/button/maDeleteButton.js index bd64590d..0bd79fb2 100644 --- a/src/javascripts/ng-admin/Crud/button/maDeleteButton.js +++ b/src/javascripts/ng-admin/Crud/button/maDeleteButton.js @@ -7,18 +7,21 @@ define(function () { return { restrict: 'E', scope: { - 'entity': '&', - 'entry': '&', - 'size': '@' + entity: '&', + entry: '&', + size: '@', + label: '@', }, link: function (scope) { + scope.label = scope.label || 'Delete'; + scope.gotoDelete = function () { $state.go($state.get('delete'), { entity: scope.entity().name(), id: scope.entry().identifierValue }); }; }, template: '' + - ' Delete' + + ' {{ ::label }}' + '' }; diff --git a/src/javascripts/ng-admin/Crud/button/maEditButton.js b/src/javascripts/ng-admin/Crud/button/maEditButton.js index a297d9cb..42460655 100644 --- a/src/javascripts/ng-admin/Crud/button/maEditButton.js +++ b/src/javascripts/ng-admin/Crud/button/maEditButton.js @@ -7,18 +7,21 @@ define(function () { return { restrict: 'E', scope: { - 'entity': '&', - 'entry': '&', - 'size': '@' + entity: '&', + entry: '&', + size: '@', + label: '@', }, link: function (scope) { + scope.label = scope.label || 'Edit'; + scope.gotoEdit = function () { $state.go($state.get('edit'), { entity: scope.entity().name(), id: scope.entry().identifierValue }); }; }, template: '' + - ' Edit' + + ' {{ ::label }}' + '' }; } diff --git a/src/javascripts/ng-admin/Crud/button/maExportToCsvButton.js b/src/javascripts/ng-admin/Crud/button/maExportToCsvButton.js index 4fb54636..b6931d5d 100644 --- a/src/javascripts/ng-admin/Crud/button/maExportToCsvButton.js +++ b/src/javascripts/ng-admin/Crud/button/maExportToCsvButton.js @@ -7,10 +7,13 @@ define(function () { return { restrict: 'E', scope: { - entity: '&' + entity: '&', + label: '@', }, - template: '', + template: '', link: function(scope) { + scope.label = scope.label || 'Export'; + scope.entity = scope.entity(); var exportView = scope.entity.exportView(); var listView = scope.entity.listView(); diff --git a/src/javascripts/ng-admin/Crud/button/maFilteredListButton.js b/src/javascripts/ng-admin/Crud/button/maFilteredListButton.js index 54084bfd..74267e8a 100644 --- a/src/javascripts/ng-admin/Crud/button/maFilteredListButton.js +++ b/src/javascripts/ng-admin/Crud/button/maFilteredListButton.js @@ -28,18 +28,18 @@ define(function () { scope: { entityName: '@', filter: '&', - text: '@', + label: '@', size: '@' }, link: function (scope) { - scope.buttonText = scope.text || ('See all related ' + scope.entityName); + scope.label = scope.label || ('See all related ' + scope.entityName); scope.gotoList = function () { $state.go($state.get('list'), { 'entity': scope.entityName, 'search': scope.filter()}); }; }, template: '' + - ' {{ buttonText }}' + + ' {{ ::label }}' + '' }; } diff --git a/src/javascripts/ng-admin/Crud/button/maListButton.js b/src/javascripts/ng-admin/Crud/button/maListButton.js index 15e0320f..ff00000f 100644 --- a/src/javascripts/ng-admin/Crud/button/maListButton.js +++ b/src/javascripts/ng-admin/Crud/button/maListButton.js @@ -13,17 +13,20 @@ define(function () { return { restrict: 'E', scope: { - 'entity': '&', - 'size': '@' + entity: '&', + size: '@', + label: '@', }, link: function (scope) { + scope.label = scope.label || 'List'; + scope.gotoList = function () { $state.go($state.get('list'), { 'entity': scope.entity().name() }); }; }, template: '' + - ' List' + + ' {{ ::label }}' + '' }; } diff --git a/src/javascripts/ng-admin/Crud/button/maShowButton.js b/src/javascripts/ng-admin/Crud/button/maShowButton.js index 43184710..d2a82727 100644 --- a/src/javascripts/ng-admin/Crud/button/maShowButton.js +++ b/src/javascripts/ng-admin/Crud/button/maShowButton.js @@ -7,18 +7,21 @@ define(function () { return { restrict: 'E', scope: { - 'entity': '&', - 'entry': '&', - 'size': '@' + entity: '&', + entry: '&', + size: '@', + label: '@', }, link: function (scope) { + scope.label = scope.label || 'Show'; + scope.gotoShow = function () { $state.go($state.get('show'), { entity: scope.entity().name(), id: scope.entry().identifierValue }); }; }, template: '' + - ' Show' + + ' {{ ::label }}' + '' }; }