Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Add label attribute on button directives #407

Merged
merged 3 commits into from
Apr 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,17 @@ listView.fields([
]);
```

You can also provide custom label using the `label` attribute:

```js
listView.listActions([
'<ma-edit-button entry="entry" entity="entity" label="Edit me" size="xs">' +
'</ma-edit-button>',
'<ma-delete-button entry="entry" entity="entity" label="Delete me" size="xs">' +
'</ma-delete-button>'
]);
```

## Relationships

### `reference` Field
Expand Down
7 changes: 5 additions & 2 deletions src/javascripts/ng-admin/Crud/button/maBackButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
'<a class="btn btn-default" ng-class="size ? \'btn-\' + size : \'\'" ng-click="back()">' +
'<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>&nbsp;Back' +
'<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>&nbsp;{{ ::label }}' +
'</a>'
};
}
Expand Down
9 changes: 6 additions & 3 deletions src/javascripts/ng-admin/Crud/button/maBatchDeleteButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -21,7 +24,7 @@ define(function () {
},
template:
'<span ng-click="gotoBatchDelete()">' +
'<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>&nbsp;Delete' +
'<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>&nbsp;{{ ::label }}' +
'</span>'

};
Expand Down
9 changes: 6 additions & 3 deletions src/javascripts/ng-admin/Crud/button/maCreateButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
'<a class="btn btn-default" ng-class="size ? \'btn-\' + size : \'\'" ng-click="gotoCreate()">' +
'<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;Create' +
'<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;{{ ::label }}' +
'</a>'
};
}
Expand Down
11 changes: 7 additions & 4 deletions src/javascripts/ng-admin/Crud/button/maDeleteButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
'<a class="btn btn-default" ng-class="size ? \'btn-\' + size : \'\'" ng-click="gotoDelete()">' +
'<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>&nbsp;Delete' +
'<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>&nbsp;{{ ::label }}' +
'</a>'

};
Expand Down
11 changes: 7 additions & 4 deletions src/javascripts/ng-admin/Crud/button/maEditButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
'<a class="btn btn-default" ng-class="size ? \'btn-\' + size : \'\'" ng-click="gotoEdit()">' +
'<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>&nbsp;Edit' +
'<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>&nbsp;{{ ::label }}' +
'</a>'
};
}
Expand Down
7 changes: 5 additions & 2 deletions src/javascripts/ng-admin/Crud/button/maExportToCsvButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ define(function () {
return {
restrict: 'E',
scope: {
entity: '&'
entity: '&',
label: '@',
},
template: '<button ng-if="has_export" class="btn btn-default" ng-click="exportToCsv()"><span class="glyphicon glyphicon-download" aria-hidden="true"></span>&nbsp;Export</button>',
template: '<button ng-if="has_export" class="btn btn-default" ng-click="exportToCsv()"><span class="glyphicon glyphicon-download" aria-hidden="true"></span>&nbsp;{{ ::label }}</button>',
link: function(scope) {
scope.label = scope.label || 'Export';

scope.entity = scope.entity();
var exportView = scope.entity.exportView();
var listView = scope.entity.listView();
Expand Down
6 changes: 3 additions & 3 deletions src/javascripts/ng-admin/Crud/button/maFilteredListButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
'<a class="btn btn-default" ng-class="size ? \'btn-\' + size : \'\'" ng-click="gotoList()">' +
'<span class="glyphicon glyphicon-list" aria-hidden="true"></span>&nbsp;{{ buttonText }}' +
'<span class="glyphicon glyphicon-list" aria-hidden="true"></span>&nbsp;{{ ::label }}' +
'</a>'
};
}
Expand Down
9 changes: 6 additions & 3 deletions src/javascripts/ng-admin/Crud/button/maListButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
'<a class="btn btn-default" ng-class="size ? \'btn-\' + size : \'\'" ng-click="gotoList()">' +
'<span class="glyphicon glyphicon-list" aria-hidden="true"></span>&nbsp;List' +
'<span class="glyphicon glyphicon-list" aria-hidden="true"></span>&nbsp;{{ ::label }}' +
'</a>'
};
}
Expand Down
11 changes: 7 additions & 4 deletions src/javascripts/ng-admin/Crud/button/maShowButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
'<a class="btn btn-default" ng-class="size ? \'btn-\' + size : \'\'" ng-click="gotoShow()">' +
'<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>&nbsp;Show' +
'<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>&nbsp;{{ ::label }}' +
'</a>'
};
}
Expand Down