From 209087dafec1ae460a26c5bd288f5278e6554e80 Mon Sep 17 00:00:00 2001 From: Jonathan Petitcolas Date: Wed, 11 Mar 2015 09:12:19 +0100 Subject: [PATCH 1/5] Fix build process --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index f323be5c..9338fe51 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -250,7 +250,7 @@ module.exports = function (grunt) { grunt.registerTask('test:local', ['mochaTest', 'karma', 'build:dev', 'copy_build:dev', 'test:local:e2e']); grunt.registerTask('test:local:e2e', ['json_server', 'connect', 'protractor']); - grunt.registerTask('build:dev', ['requirejs:dev', 'compass:dev', 'concat:css']); + grunt.registerTask('build:dev', ['ngconfig', 'requirejs:dev', 'compass:dev', 'concat:css']); grunt.registerTask('copy_build:dev', ['copy:es6_dev', 'copy:es6_devmap', 'copy:js_dev', 'copy:angular', 'copy:css_dev', 'copy:fonts_dev', 'clean']); // register default task From 8733d41f1936cad5001d460e546b4151b29c3483 Mon Sep 17 00:00:00 2001 From: Jonathan Petitcolas Date: Wed, 11 Mar 2015 09:46:28 +0100 Subject: [PATCH 2/5] Add proxy method to ConfigurationProvider for BC --- examples/blog/config.js | 6 +-- src/javascripts/ng-admin.js | 5 +- .../ng-admin/Crud/column/maColumn.js | 2 +- .../Crud/column/maReferenceManyLinkColumn.js | 2 +- .../ng-admin/Crud/form/FormController.js | 2 +- .../ng-admin/Crud/repository/CreateQueries.js | 2 +- .../ng-admin/Crud/repository/DeleteQueries.js | 2 +- .../ng-admin/Crud/repository/Queries.js | 2 +- .../Crud/repository/RetrieveQueries.js | 2 +- .../ng-admin/Crud/repository/UpdateQueries.js | 2 +- src/javascripts/ng-admin/Crud/routing.js | 4 +- src/javascripts/ng-admin/Main/MainModule.js | 2 +- .../component/controller/AppController.js | 2 +- .../component/controller/SidebarController.js | 2 +- .../Main/component/provider/NgAdmin.js | 24 --------- .../provider/NgAdminConfiguration.js | 50 +++++++++++++++++++ .../Main/component/service/PanelBuilder.js | 2 +- .../ng-admin/Main/config/routing.js | 2 +- 18 files changed, 72 insertions(+), 43 deletions(-) delete mode 100644 src/javascripts/ng-admin/Main/component/provider/NgAdmin.js create mode 100644 src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js diff --git a/examples/blog/config.js b/examples/blog/config.js index be199cbb..3c57e2dc 100644 --- a/examples/blog/config.js +++ b/examples/blog/config.js @@ -4,8 +4,8 @@ var app = angular.module('myApp', ['ng-admin']); - app.config(function (AdminDescription, NgAdminProvider, RestangularProvider) { - var nga = AdminDescription; + app.config(function (NgAdminConfigurationProvider, RestangularProvider) { + var nga = NgAdminConfigurationProvider; function truncate(value) { if (!value) { @@ -248,7 +248,7 @@ nga.field('published', 'boolean') ]); - NgAdminProvider.configure(admin); + nga.configure(admin); }); app.directive('postLink', ['$location', function ($location) { diff --git a/src/javascripts/ng-admin.js b/src/javascripts/ng-admin.js index 552d7a8e..30fb69c5 100644 --- a/src/javascripts/ng-admin.js +++ b/src/javascripts/ng-admin.js @@ -55,5 +55,8 @@ define(function (require) { var factory = angular.module('AdminDescriptionModule', []); factory.constant('AdminDescription', new AdminDescription()); - angular.module('ng-admin', ['main', 'crud', 'AdminDescriptionModule']); + var ngadmin = angular.module('ng-admin', ['main', 'crud', 'AdminDescriptionModule']); + ngadmin.config(function(NgAdminConfigurationProvider, AdminDescription) { + NgAdminConfigurationProvider.setAdminDescription(AdminDescription); + }); }); diff --git a/src/javascripts/ng-admin/Crud/column/maColumn.js b/src/javascripts/ng-admin/Crud/column/maColumn.js index 22434d97..d52b39a5 100644 --- a/src/javascripts/ng-admin/Crud/column/maColumn.js +++ b/src/javascripts/ng-admin/Crud/column/maColumn.js @@ -60,7 +60,7 @@ define(function (require) { }; } - maColumn.$inject = ['$location', '$anchorScroll', '$compile', 'NgAdmin', 'FieldViewConfiguration']; + maColumn.$inject = ['$location', '$anchorScroll', '$compile', 'NgAdminConfiguration', 'FieldViewConfiguration']; return maColumn; }); diff --git a/src/javascripts/ng-admin/Crud/column/maReferenceManyLinkColumn.js b/src/javascripts/ng-admin/Crud/column/maReferenceManyLinkColumn.js index a2951bba..ef6f1569 100644 --- a/src/javascripts/ng-admin/Crud/column/maReferenceManyLinkColumn.js +++ b/src/javascripts/ng-admin/Crud/column/maReferenceManyLinkColumn.js @@ -29,7 +29,7 @@ define(function (require) { }; } - maReferenceManyLinkColumn.$inject = ['$location', 'NgAdmin']; + maReferenceManyLinkColumn.$inject = ['$location', 'NgAdminConfiguration']; return maReferenceManyLinkColumn; }); diff --git a/src/javascripts/ng-admin/Crud/form/FormController.js b/src/javascripts/ng-admin/Crud/form/FormController.js index 90ac937b..ca7bcbb2 100644 --- a/src/javascripts/ng-admin/Crud/form/FormController.js +++ b/src/javascripts/ng-admin/Crud/form/FormController.js @@ -134,7 +134,7 @@ define(function () { this.entity = undefined; }; - FormController.$inject = ['$scope', '$location', '$filter', 'CreateQueries', 'UpdateQueries', 'Validator', 'NgAdmin', 'progression', 'notification', 'view', 'entry']; + FormController.$inject = ['$scope', '$location', '$filter', 'CreateQueries', 'UpdateQueries', 'Validator', 'NgAdminConfiguration', 'progression', 'notification', 'view', 'entry']; return FormController; }); diff --git a/src/javascripts/ng-admin/Crud/repository/CreateQueries.js b/src/javascripts/ng-admin/Crud/repository/CreateQueries.js index 7065ffbd..13ff43cc 100644 --- a/src/javascripts/ng-admin/Crud/repository/CreateQueries.js +++ b/src/javascripts/ng-admin/Crud/repository/CreateQueries.js @@ -32,7 +32,7 @@ define(function (require) { }); }; - CreateQueries.$inject = ['$q', 'Restangular', 'NgAdmin']; + CreateQueries.$inject = ['$q', 'Restangular', 'NgAdminConfiguration']; return CreateQueries; }); diff --git a/src/javascripts/ng-admin/Crud/repository/DeleteQueries.js b/src/javascripts/ng-admin/Crud/repository/DeleteQueries.js index bafc06e0..1e1eddb1 100644 --- a/src/javascripts/ng-admin/Crud/repository/DeleteQueries.js +++ b/src/javascripts/ng-admin/Crud/repository/DeleteQueries.js @@ -29,7 +29,7 @@ define(function (require) { .customDELETE(); }; - DeleteQueries.$inject = ['$q', 'Restangular', 'NgAdmin']; + DeleteQueries.$inject = ['$q', 'Restangular', 'NgAdminConfiguration']; return DeleteQueries; }); diff --git a/src/javascripts/ng-admin/Crud/repository/Queries.js b/src/javascripts/ng-admin/Crud/repository/Queries.js index 4880cfc2..359a209c 100644 --- a/src/javascripts/ng-admin/Crud/repository/Queries.js +++ b/src/javascripts/ng-admin/Crud/repository/Queries.js @@ -18,7 +18,7 @@ define(function () { this.Restangular.setFullResponse(true); // To get also the headers } - Queries.$inject = ['$q', 'Restangular', 'NgAdmin']; + Queries.$inject = ['$q', 'Restangular', 'NgAdminConfiguration']; return Queries; }); diff --git a/src/javascripts/ng-admin/Crud/repository/RetrieveQueries.js b/src/javascripts/ng-admin/Crud/repository/RetrieveQueries.js index ef4b707d..f832cecd 100644 --- a/src/javascripts/ng-admin/Crud/repository/RetrieveQueries.js +++ b/src/javascripts/ng-admin/Crud/repository/RetrieveQueries.js @@ -287,7 +287,7 @@ define(function (require) { return entry; }; - RetrieveQueries.$inject = ['$q', 'Restangular', 'NgAdmin']; + RetrieveQueries.$inject = ['$q', 'Restangular', 'NgAdminConfiguration']; return RetrieveQueries; }); diff --git a/src/javascripts/ng-admin/Crud/repository/UpdateQueries.js b/src/javascripts/ng-admin/Crud/repository/UpdateQueries.js index a5dc98bd..0fe29dd3 100644 --- a/src/javascripts/ng-admin/Crud/repository/UpdateQueries.js +++ b/src/javascripts/ng-admin/Crud/repository/UpdateQueries.js @@ -35,7 +35,7 @@ define(function (require) { }); }; - UpdateQueries.$inject = ['$q', 'Restangular', 'NgAdmin']; + UpdateQueries.$inject = ['$q', 'Restangular', 'NgAdminConfiguration']; return UpdateQueries; }); diff --git a/src/javascripts/ng-admin/Crud/routing.js b/src/javascripts/ng-admin/Crud/routing.js index 2e5d95c2..284c13c9 100644 --- a/src/javascripts/ng-admin/Crud/routing.js +++ b/src/javascripts/ng-admin/Crud/routing.js @@ -10,7 +10,7 @@ define(function (require) { deleteTemplate = require('text!./delete/delete.html'); function templateProvider(viewName, defaultView) { - return ['$stateParams', 'NgAdmin', function ($stateParams, Configuration) { + return ['$stateParams', 'NgAdminConfiguration', function ($stateParams, Configuration) { var customTemplate; var view = Configuration().getViewByEntityAndType($stateParams.entity, viewName); customTemplate = view.template(); @@ -22,7 +22,7 @@ define(function (require) { } function viewProvider(viewName) { - return ['$stateParams', 'NgAdmin', function ($stateParams, Configuration) { + return ['$stateParams', 'NgAdminConfiguration', function ($stateParams, Configuration) { var view = Configuration().getViewByEntityAndType($stateParams.entity, viewName); if (!view.isEnabled()) { throw new Error('The ' + viewName + ' is disabled for this entity'); diff --git a/src/javascripts/ng-admin/Main/MainModule.js b/src/javascripts/ng-admin/Main/MainModule.js index dde99ad8..33932b35 100644 --- a/src/javascripts/ng-admin/Main/MainModule.js +++ b/src/javascripts/ng-admin/Main/MainModule.js @@ -17,7 +17,7 @@ define(function (require) { MainModule.service('PanelBuilder', require('ng-admin/Main/component/service/PanelBuilder')); MainModule.service('Validator', require('ng-admin/Main/component/service/Validator')); - MainModule.provider('NgAdmin', require('ng-admin/Main/component/provider/NgAdmin')); + MainModule.provider('NgAdminConfiguration', require('ng-admin/Main/component/provider/NgAdminConfiguration')); MainModule.filter('enabled', require('ng-admin/Main/component/filter/Enabled')); MainModule.filter('orderElement', require('ng-admin/Main/component/filter/OrderElement')); diff --git a/src/javascripts/ng-admin/Main/component/controller/AppController.js b/src/javascripts/ng-admin/Main/component/controller/AppController.js index d2cf9232..38ec7b15 100644 --- a/src/javascripts/ng-admin/Main/component/controller/AppController.js +++ b/src/javascripts/ng-admin/Main/component/controller/AppController.js @@ -26,7 +26,7 @@ define(function () { this.$scope = undefined; }; - AppController.$inject = ['$scope', '$location', 'NgAdmin']; + AppController.$inject = ['$scope', '$location', 'NgAdminConfiguration']; return AppController; }); diff --git a/src/javascripts/ng-admin/Main/component/controller/SidebarController.js b/src/javascripts/ng-admin/Main/component/controller/SidebarController.js index b70e768d..1df2f336 100644 --- a/src/javascripts/ng-admin/Main/component/controller/SidebarController.js +++ b/src/javascripts/ng-admin/Main/component/controller/SidebarController.js @@ -53,7 +53,7 @@ define(function () { this.$filter = undefined; }; - SidebarController.$inject = ['$scope', '$location', '$sce', '$filter', 'NgAdmin']; + SidebarController.$inject = ['$scope', '$location', '$sce', '$filter', 'NgAdminConfiguration']; return SidebarController; }); diff --git a/src/javascripts/ng-admin/Main/component/provider/NgAdmin.js b/src/javascripts/ng-admin/Main/component/provider/NgAdmin.js deleted file mode 100644 index 0627cd65..00000000 --- a/src/javascripts/ng-admin/Main/component/provider/NgAdmin.js +++ /dev/null @@ -1,24 +0,0 @@ -/*global define*/ - -define(function () { - 'use strict'; - - function NgAdmin() { - this.config = null; - } - - NgAdmin.prototype.configure = function (config) { - this.config = config; - }; - - NgAdmin.prototype.$get = function () { - var config = this.config; - return function () { - return config; - }; - }; - - NgAdmin.$inject = []; - - return NgAdmin; -}); diff --git a/src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js b/src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js new file mode 100644 index 00000000..7dbe3bff --- /dev/null +++ b/src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js @@ -0,0 +1,50 @@ +/*global define*/ + +define(function () { + 'use strict'; + + function NgAdminConfiguration() { + this.config = null; + this.adminDescription = null; + } + + NgAdminConfiguration.prototype.setAdminDescription = function(adminDescription) { + this.adminDescription = adminDescription; + } + + NgAdminConfiguration.prototype.configure = function (config) { + this.config = config; + }; + + NgAdminConfiguration.prototype.$get = function () { + var config = this.config; + return function () { + return config; + }; + }; + + /** + * @deprecated Use AdminDescription.application instead + */ + NgAdminConfiguration.prototype.application = function(name) { + return this.adminDescription.application(name); + }; + + /** + * @deprecated Use AdminDescription.entity instead + */ + NgAdminConfiguration.prototype.entity = function(name) { + return this.adminDescription.entity(name); + }; + + /** + * @deprecated Use AdminDescription.field instead + */ + NgAdminConfiguration.prototype.field = function(name, type) { + return this.adminDescription.field(name, type); + }; + + NgAdminConfiguration.$inject = []; + + return NgAdminConfiguration; +}); diff --git a/src/javascripts/ng-admin/Main/component/service/PanelBuilder.js b/src/javascripts/ng-admin/Main/component/service/PanelBuilder.js index 1d7e5f5b..fb6fa5a7 100644 --- a/src/javascripts/ng-admin/Main/component/service/PanelBuilder.js +++ b/src/javascripts/ng-admin/Main/component/service/PanelBuilder.js @@ -66,7 +66,7 @@ define(function () { }); }; - PanelBuilder.$inject = ['$q', '$filter', '$location', 'RetrieveQueries', 'NgAdmin']; + PanelBuilder.$inject = ['$q', '$filter', '$location', 'RetrieveQueries', 'NgAdminConfiguration']; return PanelBuilder; }); diff --git a/src/javascripts/ng-admin/Main/config/routing.js b/src/javascripts/ng-admin/Main/config/routing.js index eca31a49..31d4ef9f 100644 --- a/src/javascripts/ng-admin/Main/config/routing.js +++ b/src/javascripts/ng-admin/Main/config/routing.js @@ -12,7 +12,7 @@ define(function (require) { abstract: true, controller: 'AppController', controllerAs: 'appController', - templateProvider: ['NgAdmin', function(Configuration) { + templateProvider: ['NgAdminConfiguration', function(Configuration) { return Configuration().layout() || layoutTemplate; }] }); From e9a2e2a7e0c4aa1a24c174cb91f7ab5897640022 Mon Sep 17 00:00:00 2001 From: Jonathan Petitcolas Date: Wed, 11 Mar 2015 14:15:59 +0100 Subject: [PATCH 3/5] Fix issue with perPage() --- .../ng-admin/es6/lib/Field/ReferenceField.js | 8 ++++--- .../ng-admin/es6/lib/View/ListView.js | 24 +++++++------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/javascripts/ng-admin/es6/lib/Field/ReferenceField.js b/src/javascripts/ng-admin/es6/lib/Field/ReferenceField.js index fe42b189..685ccfb2 100644 --- a/src/javascripts/ng-admin/es6/lib/Field/ReferenceField.js +++ b/src/javascripts/ng-admin/es6/lib/Field/ReferenceField.js @@ -17,8 +17,10 @@ class ReferenceField extends ChoiceField { this._detailLink = true; } - get perPage() { - return this._perPage; + perPage(perPage) { + if (!arguments.length) return this._perPage; + this._perPage = perPage; + return this; } targetEntity(entity) { @@ -48,7 +50,7 @@ class ReferenceField extends ChoiceField { } getReferencedView() { - return this._referencedView.perPage(this.perPage); + return this._referencedView.perPage(this._perPage); } filters(filters) { diff --git a/src/javascripts/ng-admin/es6/lib/View/ListView.js b/src/javascripts/ng-admin/es6/lib/View/ListView.js index 06f994e3..0a88e8f0 100644 --- a/src/javascripts/ng-admin/es6/lib/View/ListView.js +++ b/src/javascripts/ng-admin/es6/lib/View/ListView.js @@ -14,13 +14,16 @@ class ListView extends View { this._sortDir = 'DESC'; } - perPage() { - if (arguments.length) { - this._perPage = arguments[0]; - return this; - } + perPage(perPage) { + if (!arguments.length) return this._perPage; + this._perPage = arguments[0]; + return this; + } - return this._perPage; + /** @deprecated Use perPage instead */ + limit() { + if (!arguments.length) return this.perPage(); + return this.perPage(arguments[0]); } sortField() { @@ -70,15 +73,6 @@ class ListView extends View { return this; } - limit() { - if (arguments.length) { - this._perPage = parseInt(arguments[0]); - return this; - } - - return this._perPage; - } - getFilterReferences() { return this._filters.filter(f => f.type() === 'reference'); } From 96c9e4bde66a2d3b198178967914ea82f6748fde Mon Sep 17 00:00:00 2001 From: Jonathan Petitcolas Date: Wed, 11 Mar 2015 17:50:46 +0100 Subject: [PATCH 4/5] Update README and UPGRADE files --- README.md | 8 +++---- UPGRADE-0.7.md | 23 ++++++++++++++++--- examples/blog/config.js | 6 ++--- .../provider/NgAdminConfiguration.js | 7 ++++++ src/javascripts/ng-admin/es6/lib/Factory.js | 4 ++++ 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 724877e2..45eec2f6 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ Here is a full example for a backend that will let you create, update, and delet var app = angular.module('myApp', ['ng-admin']); -app.config(function (AdminDescription, NgAdminProvider) { +app.config(function (AdminDescription, NgAdminConfigurationProvider) { var nga = AdminDescription; var app = nga.application('ng-admin backend demo') // application main title .baseApiUrl('http://localhost:3000/'); // main API endpoint @@ -100,7 +100,7 @@ app.config(function (AdminDescription, NgAdminProvider) { post.dashboardView() // customize the dashboard panel for this entity .title('Recent posts') .order(1) // display the post panel first in the dashboard - .limit(5) // limit the panel to the 5 latest posts + .perPage(5) // limit the panel to the 5 latest posts .fields([nga.field('title').isDetailLink(true).map(truncate)]); // fields() called with arguments add fields to the view post.listView() @@ -156,7 +156,7 @@ app.config(function (AdminDescription, NgAdminProvider) { .template('') ]); - NgAdminProvider.configure(app); + NgAdminConfigurationProvider.configure(app); }); ``` @@ -261,7 +261,7 @@ Defines the API endpoint for a view. It can be a string or a function. The `dashboardView` also defines `sortField` and `sortDir` fields like the `listView`. -* `limit(Number)` +* `.perPage(Number)` Set the number of items. * `order(Number)` diff --git a/UPGRADE-0.7.md b/UPGRADE-0.7.md index 688d26ff..3ec7f582 100644 --- a/UPGRADE-0.7.md +++ b/UPGRADE-0.7.md @@ -6,17 +6,34 @@ ng-admin 0.7 breaks compatibility with 0.5 and makes the "factories" configurati ## Configuration factory -The configuration is now done through the `AdminDescription` object. You can retrieve it directly from Angular DI. You just have to retrieve your application from this factory instead of the `NgAdminConfigurationProvider` as previously. In addition, `NgAdminConfigurationProvider` was renamed to `NgAdminProvider`: +The configuration is now done through the `AdminDescription` object. You can retrieve it directly from Angular DI. ``` diff - app.config(function (NgAdminConfigurationProvider, RestangularProvider) { -+ app.config(function (AdminDescription, NgAdminProvider, RestangularProvider) { ++ app.config(function (AdminDescription, NgAdminConfigurationProvider, RestangularProvider) { - var nga = NgAdminConfigurationProvider; + var nga = AdminDescription; // ... - nga.configure(admin); -+ NgAdminProvider.configure(admin); ++ NgAdminConfigurationProvider.configure(admin); }); ``` + +Note you still need the `NgAdminConfigurationProvider` to apply your application configuration. + +During the 0.8 version, some proxy methods transmits actions from `NgAdminConfigurationProvider` to `AdminDescription`, allowing you to transition smoothly. + +## Field type + +Method `Field.type()` is no longer supported as a setter. Instead, you should specify the second argument from the field factory. + +``` diff +- nga.field('created_at').type('date') ++ nga.field('created_at', 'date') +``` + +## perPage instead of limit + +Dashboard view `limit()` method has been deprecated. Please use the `perPage` method instead. diff --git a/examples/blog/config.js b/examples/blog/config.js index 3c57e2dc..9a07c426 100644 --- a/examples/blog/config.js +++ b/examples/blog/config.js @@ -66,7 +66,7 @@ post.dashboardView() // customize the dashboard panel for this entity .title('Recent posts') .order(1) // display the post panel first in the dashboard - .limit(5) // limit the panel to the 5 latest posts + .perPage(5) // limit the panel to the 5 latest posts .fields([nga.field('title').isDetailLink(true).map(truncate)]); // fields() called with arguments add fields to the view post.listView() @@ -133,7 +133,7 @@ comment.dashboardView() .title('Last comments') .order(2) // display the comment panel second in the dashboard - .limit(5) + .perPage(5) .fields([ nga.field('id'), nga.field('body', 'wysiwyg') @@ -218,7 +218,7 @@ tag.dashboardView() .title('Recent tags') .order(3) - .limit(10) + .perPage(10) .fields([ nga.field('id'), nga.field('name'), diff --git a/src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js b/src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js index 7dbe3bff..ddba77d2 100644 --- a/src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js +++ b/src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js @@ -44,6 +44,13 @@ define(function () { return this.adminDescription.field(name, type); }; + /** + * @deprecated Use AdminDescription.registerFieldType instead + */ + NgAdminConfiguration.prototype.registerFieldType = function(name, type) { + return this.adminDescription.registerFieldType(name, type); + }; + NgAdminConfiguration.$inject = []; return NgAdminConfiguration; diff --git a/src/javascripts/ng-admin/es6/lib/Factory.js b/src/javascripts/ng-admin/es6/lib/Factory.js index c2b71674..721837f6 100644 --- a/src/javascripts/ng-admin/es6/lib/Factory.js +++ b/src/javascripts/ng-admin/es6/lib/Factory.js @@ -46,6 +46,10 @@ class Factory { this._fieldTypes[name] = constructor; } + getFieldConstructor(name) { + return this._fieldTypes[name]; + } + _init() { this.registerFieldType('boolean', BooleanField); this.registerFieldType('choice', ChoiceField); From 2be055ab5122a40f0517f28311263250ed2b8f95 Mon Sep 17 00:00:00 2001 From: Jonathan Petitcolas Date: Thu, 12 Mar 2015 09:43:56 +0100 Subject: [PATCH 5/5] Don't depreciate NgAdminConfigurationProvider proxy methods --- README.md | 8 +++---- UPGRADE-0.7.md | 21 ------------------- .../provider/NgAdminConfiguration.js | 12 ----------- 3 files changed, 4 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 45eec2f6..aae1cca7 100644 --- a/README.md +++ b/README.md @@ -80,8 +80,8 @@ Here is a full example for a backend that will let you create, update, and delet var app = angular.module('myApp', ['ng-admin']); -app.config(function (AdminDescription, NgAdminConfigurationProvider) { - var nga = AdminDescription; +app.config(function (NgAdminConfigurationProvider) { + var nga = NgAdminConfigurationProvider; var app = nga.application('ng-admin backend demo') // application main title .baseApiUrl('http://localhost:3000/'); // main API endpoint @@ -156,7 +156,7 @@ app.config(function (AdminDescription, NgAdminConfigurationProvider) { .template('') ]); - NgAdminConfigurationProvider.configure(app); + nga.configure(app); }); ``` @@ -261,7 +261,7 @@ Defines the API endpoint for a view. It can be a string or a function. The `dashboardView` also defines `sortField` and `sortDir` fields like the `listView`. -* `.perPage(Number)` +* `perPage(Number)` Set the number of items. * `order(Number)` diff --git a/UPGRADE-0.7.md b/UPGRADE-0.7.md index 3ec7f582..29e93435 100644 --- a/UPGRADE-0.7.md +++ b/UPGRADE-0.7.md @@ -4,27 +4,6 @@ ng-admin 0.7 breaks compatibility with 0.5 and makes the "factories" configuration API compulsory. If your configuration uses `nga.field()`, it will still work woth 0.7. If it uses `new Field()`, you'll need to follow [the 0.6 upgrade guide](https://github.com/marmelab/ng-admin/blob/b3c7b1afc6a52651df6ba4454d8461620339b4da/UPGRADE-0.6.md). -## Configuration factory - -The configuration is now done through the `AdminDescription` object. You can retrieve it directly from Angular DI. - -``` diff -- app.config(function (NgAdminConfigurationProvider, RestangularProvider) { -+ app.config(function (AdminDescription, NgAdminConfigurationProvider, RestangularProvider) { -- var nga = NgAdminConfigurationProvider; -+ var nga = AdminDescription; - - // ... - -- nga.configure(admin); -+ NgAdminConfigurationProvider.configure(admin); - }); -``` - -Note you still need the `NgAdminConfigurationProvider` to apply your application configuration. - -During the 0.8 version, some proxy methods transmits actions from `NgAdminConfigurationProvider` to `AdminDescription`, allowing you to transition smoothly. - ## Field type Method `Field.type()` is no longer supported as a setter. Instead, you should specify the second argument from the field factory. diff --git a/src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js b/src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js index ddba77d2..e8746dac 100644 --- a/src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js +++ b/src/javascripts/ng-admin/Main/component/provider/NgAdminConfiguration.js @@ -23,30 +23,18 @@ define(function () { }; }; - /** - * @deprecated Use AdminDescription.application instead - */ NgAdminConfiguration.prototype.application = function(name) { return this.adminDescription.application(name); }; - /** - * @deprecated Use AdminDescription.entity instead - */ NgAdminConfiguration.prototype.entity = function(name) { return this.adminDescription.entity(name); }; - /** - * @deprecated Use AdminDescription.field instead - */ NgAdminConfiguration.prototype.field = function(name, type) { return this.adminDescription.field(name, type); }; - /** - * @deprecated Use AdminDescription.registerFieldType instead - */ NgAdminConfiguration.prototype.registerFieldType = function(name, type) { return this.adminDescription.registerFieldType(name, type); };