diff --git a/examples/blog/config.js b/examples/blog/config.js index 6ba8d80a..f3599973 100644 --- a/examples/blog/config.js +++ b/examples/blog/config.js @@ -256,7 +256,7 @@ template: '

View post

', link: function (scope) { scope.displayPost = function () { - $location.path('/show/posts/' + scope.entry().values.post_id); + $location.path('/posts/show/' + scope.entry().values.post_id); }; } }; diff --git a/src/javascripts/ng-admin/Crud/column/maColumn.js b/src/javascripts/ng-admin/Crud/column/maColumn.js index 17f09a6d..234541c2 100644 --- a/src/javascripts/ng-admin/Crud/column/maColumn.js +++ b/src/javascripts/ng-admin/Crud/column/maColumn.js @@ -37,8 +37,10 @@ define(function (require) { $compile(element.contents())(scope); scope.gotoDetail = function () { this.clearRouteParams(); - var route = scope.entity().isReadOnly ? 'show' : scope.field.detailLinkRoute(); - + var route = scope.field.detailLinkRoute(); + if (route == 'edit' && !scope.entity().editionView().enabled) { + route = 'show'; + } $location.path('/' + scope.entry.entityName + '/' + route + '/' + scope.entry.identifierValue); $anchorScroll(0); }; diff --git a/src/javascripts/ng-admin/Crud/delete/batchDelete.html b/src/javascripts/ng-admin/Crud/delete/batchDelete.html index 5b2b2859..3758ef85 100644 --- a/src/javascripts/ng-admin/Crud/delete/batchDelete.html +++ b/src/javascripts/ng-admin/Crud/delete/batchDelete.html @@ -1,12 +1,12 @@
- - + +
@@ -20,9 +20,9 @@

-
+
- diff --git a/src/javascripts/ng-admin/Crud/delete/delete.html b/src/javascripts/ng-admin/Crud/delete/delete.html index 65cf0e58..958ce5c9 100644 --- a/src/javascripts/ng-admin/Crud/delete/delete.html +++ b/src/javascripts/ng-admin/Crud/delete/delete.html @@ -1,14 +1,14 @@
- - + +
diff --git a/src/javascripts/ng-admin/Crud/form/FormController.js b/src/javascripts/ng-admin/Crud/form/FormController.js index 2955f96b..bcfd8cbc 100644 --- a/src/javascripts/ng-admin/Crud/form/FormController.js +++ b/src/javascripts/ng-admin/Crud/form/FormController.js @@ -3,11 +3,11 @@ define(function () { 'use strict'; - var FormController = function ($scope, $location, CreateQueries, UpdateQueries, Validator, Configuration, + var FormController = function ($scope, $state, CreateQueries, UpdateQueries, Validator, Configuration, progression, notification, view, entry) { this.$scope = $scope; - this.$location = $location; + this.$state = $state; this.CreateQueries = CreateQueries; this.UpdateQueries = UpdateQueries; this.Validator = Validator; @@ -20,7 +20,6 @@ define(function () { this.config = Configuration(); this.view = view; this.entity = this.view.getEntity(); - this.$scope.edit = this.edit.bind(this); this.$scope.entry = entry; this.$scope.view = view; this.$scope.entity = this.entity; @@ -71,20 +70,22 @@ define(function () { FormController.prototype.submitCreation = function ($event) { $event.preventDefault(); var entry = this.validateEntry(); + var entity = this.$scope.entity; + var route = !entity.editionView().enabled ? 'show' : 'edit'; if (!entry) { return; } var progression = this.progression, notification = this.notification, entity = this.entity, - $location = this.$location; + $state = this.$state; progression.start(); this.CreateQueries .createOne(this.view, entry) .then(function (response) { progression.done(); notification.log('Element successfully created.', {addnCls: 'humane-flatty-success'}); - $location.path(entity.name() + '/edit/' + response.identifierValue); + $state.go($state.get(route), { entity: entity.name(), id: response.identifierValue }); }, this.handleError.bind(this)); }; @@ -105,15 +106,6 @@ define(function () { }, this.handleError.bind(this)); }; - /** - * Link to edit entity page - * - * @param {View} entry - */ - FormController.prototype.edit = function (entry) { - this.$location.path(entry.entityName + '/edit/' + entry.identifierValue); - }; - /** * Handle create or update errors * @@ -128,14 +120,14 @@ define(function () { FormController.prototype.destroy = function () { this.$scope = undefined; - this.$location = undefined; + this.$state = undefined; this.CreateQueries = undefined; this.UpdateQueries = undefined; this.view = undefined; this.entity = undefined; }; - FormController.$inject = ['$scope', '$location', 'CreateQueries', 'UpdateQueries', 'Validator', 'NgAdminConfiguration', 'progression', 'notification', 'view', 'entry']; + FormController.$inject = ['$scope', '$state', 'CreateQueries', 'UpdateQueries', 'Validator', 'NgAdminConfiguration', 'progression', 'notification', 'view', 'entry']; return FormController; }); diff --git a/src/javascripts/ng-admin/Crud/form/create.html b/src/javascripts/ng-admin/Crud/form/create.html index 228559fa..6f5b74dc 100644 --- a/src/javascripts/ng-admin/Crud/form/create.html +++ b/src/javascripts/ng-admin/Crud/form/create.html @@ -1,21 +1,21 @@
- - + +
-
+
-
+
diff --git a/src/javascripts/ng-admin/Crud/form/edit.html b/src/javascripts/ng-admin/Crud/form/edit.html index 9dd2484a..dc9c14c6 100644 --- a/src/javascripts/ng-admin/Crud/form/edit.html +++ b/src/javascripts/ng-admin/Crud/form/edit.html @@ -1,22 +1,22 @@
- - - + + +
-
+
-
+
diff --git a/src/javascripts/ng-admin/Crud/list/DatagridController.js b/src/javascripts/ng-admin/Crud/list/DatagridController.js index f1eb27f1..bc7fb8f2 100644 --- a/src/javascripts/ng-admin/Crud/list/DatagridController.js +++ b/src/javascripts/ng-admin/Crud/list/DatagridController.js @@ -36,8 +36,8 @@ define(function () { */ DatagridController.prototype.gotoDetail = function (entry) { this.clearRouteParams(); - var route = this.$scope.entity.isReadOnly ? 'show' : 'edit'; - + var entity = this.$scope.entity; + var route = entity.editionView().enabled ? 'edit' : 'show'; this.$location.path('/' + entry.entityName + '/' + route + '/' + entry.identifierValue); this.$anchorScroll(0); }; diff --git a/src/javascripts/ng-admin/Crud/list/ListActions.html b/src/javascripts/ng-admin/Crud/list/ListActions.html index 160c1b05..1feca920 100644 --- a/src/javascripts/ng-admin/Crud/list/ListActions.html +++ b/src/javascripts/ng-admin/Crud/list/ListActions.html @@ -1,8 +1,8 @@ - - - - + + + + diff --git a/src/javascripts/ng-admin/Crud/list/list.html b/src/javascripts/ng-admin/Crud/list/list.html index 47c71ed1..d56a4037 100644 --- a/src/javascripts/ng-admin/Crud/list/list.html +++ b/src/javascripts/ng-admin/Crud/list/list.html @@ -1,25 +1,25 @@
- - - - + + + +
-
+
-
-
+
+ set-page="::listController.setPageCallback">
- + diff --git a/src/javascripts/ng-admin/Crud/show/show.html b/src/javascripts/ng-admin/Crud/show/show.html index f9fdce68..4ecabe75 100644 --- a/src/javascripts/ng-admin/Crud/show/show.html +++ b/src/javascripts/ng-admin/Crud/show/show.html @@ -1,16 +1,16 @@
- - - - + + + +
@@ -18,11 +18,11 @@

-
+
-
+
diff --git a/src/javascripts/ng-admin/Main/run/ErrorHandler.js b/src/javascripts/ng-admin/Main/run/ErrorHandler.js index cfad2d56..e726037d 100644 --- a/src/javascripts/ng-admin/Main/run/ErrorHandler.js +++ b/src/javascripts/ng-admin/Main/run/ErrorHandler.js @@ -3,18 +3,19 @@ define(function () { 'use strict'; - function errorHandler($rootScope, $state, $location) { + function errorHandler($rootScope, $state, notification) { $rootScope.$on("$stateChangeError", function handleError(event, toState, toParams, fromState, fromParams, error) { if (error.status == 404) { $state.go('ma-404'); event.preventDefault(); } else { + notification.log('State change error: ' + error.message, { addnCls: 'humane-flatty-error' }); throw error; } }); } - errorHandler.$inject = ['$rootScope', '$state', '$location']; + errorHandler.$inject = ['$rootScope', '$state', 'notification']; return errorHandler; }); diff --git a/src/javascripts/ng-admin/Main/run/Loader.js b/src/javascripts/ng-admin/Main/run/Loader.js index 0f1272e3..f062b6c0 100644 --- a/src/javascripts/ng-admin/Main/run/Loader.js +++ b/src/javascripts/ng-admin/Main/run/Loader.js @@ -13,10 +13,16 @@ define(function () { function loader($rootScope, $window, progression) { $rootScope.$on('$stateChangeStart', function () { progression.start(); + }); + + $rootScope.$on('$stateChangeSuccess', function() { + progression.done(); $window.scrollTo(0, 0); }); - $rootScope.$on('$stateChangeSuccess', progression.done.bind(progression)); + $rootScope.$on("$stateChangeError", function() { + progression.done(); + }); } loader.$inject = ['$rootScope', '$window', 'progression'];