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 default value parameter for create view and create-button directive #696

Merged
merged 3 commits into from
Sep 21, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix scope bug
  • Loading branch information
fzaninotto committed Sep 18, 2015
commit cbc624b03b3372d3718e68f6e4cb65428f4d784c
12 changes: 7 additions & 5 deletions src/javascripts/ng-admin/Crud/button/maCreateButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ function maCreateButtonDirective($state) {
label: '@',
},
link: function (scope, element, attrs) {
var entityName = scope.entity() ? scope.entity().name() : attrs.entityName;
var params = entityName == $state.params.entity ? $state.params : {};
params.entity = entityName;
params.defaultValues = scope.defaultValues();
scope.gotoCreate = () => $state.go($state.get('create'), params);
scope.gotoCreate = () => {
var entityName = scope.entity() ? scope.entity().name() : attrs.entityName;
var params = entityName == $state.params.entity ? $state.params : {};
params.entity = entityName;
params.defaultValues = scope.defaultValues();
$state.go($state.get('create'), params);
};
scope.label = scope.label || 'Create';
},
template:
Expand Down
12 changes: 7 additions & 5 deletions src/javascripts/ng-admin/Crud/button/maDeleteButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ function maDeleteButtonDirective($state) {
label: '@',
},
link: function (scope, element, attrs) {
var entityName = scope.entity() ? scope.entity().name() : attrs.entityName;
var params = entityName == $state.params.entity ? $state.params : {};
params.entity = entityName;
params.id = scope.entry().identifierValue;
scope.gotoDelete = () => $state.go($state.get('delete'), params);
scope.gotoDelete = () => {
var entityName = scope.entity() ? scope.entity().name() : attrs.entityName;
var params = entityName == $state.params.entity ? $state.params : {};
params.entity = entityName;
params.id = scope.entry().identifierValue;
$state.go($state.get('delete'), params);
}
scope.label = scope.label || 'Delete';
},
template:
Expand Down
12 changes: 7 additions & 5 deletions src/javascripts/ng-admin/Crud/button/maEditButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ function maEditButtonDirective($state) {
label: '@',
},
link: function (scope, element, attrs) {
var entityName = scope.entity() ? scope.entity().name() : attrs.entityName;
var params = entityName == $state.params.entity ? $state.params : {};
params.entity = entityName;
params.id = scope.entry().identifierValue;
scope.gotoEdit = () => $state.go($state.get('edit'), params);
scope.gotoEdit = () => {
var entityName = scope.entity() ? scope.entity().name() : attrs.entityName;
var params = entityName == $state.params.entity ? $state.params : {};
params.entity = entityName;
params.id = scope.entry().identifierValue;
$state.go($state.get('edit'), params);
}
scope.label = scope.label || 'Edit';
},
template:
Expand Down
10 changes: 6 additions & 4 deletions src/javascripts/ng-admin/Crud/button/maListButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ function maListButtonDirective($state) {
label: '@',
},
link: function (scope, element, attrs) {
var entityName = scope.entity() ? scope.entity().name() : attrs.entityName;
var params = entityName == $state.params.entity ? $state.params : {};
params.entity = entityName;
scope.gotoList = () => $state.go($state.get('list'), params);
scope.gotoList = () => {
var entityName = scope.entity() ? scope.entity().name() : attrs.entityName;
var params = entityName == $state.params.entity ? $state.params : {};
params.entity = entityName;
$state.go($state.get('list'), params);
}
scope.label = scope.label || 'List';
},
template:
Expand Down
12 changes: 7 additions & 5 deletions src/javascripts/ng-admin/Crud/button/maShowButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ function maShowButtonDirective($state) {
label: '@',
},
link: function (scope, element, attrs) {
var entityName = scope.entity() ? scope.entity().name() : attrs.entityName;
var params = entityName == $state.params.entity ? $state.params : {};
params.entity = entityName;
params.id = scope.entry().identifierValue;
scope.gotoShow = () => $state.go($state.get('show'), params);
scope.gotoShow = () => {
var entityName = scope.entity() ? scope.entity().name() : attrs.entityName;
var params = entityName == $state.params.entity ? $state.params : {};
params.entity = entityName;
params.id = scope.entry().identifierValue;
$state.go($state.get('show'), params);
}
scope.label = scope.label || 'Show';
},
template:
Expand Down