Merge pull request #1461 from ostcar/js-data

Updated angular-data to js-data (angular-data 2.1).
This commit is contained in:
Norman Jäckel 2015-02-14 00:32:17 +01:00
commit 99c6a4dbd8
4 changed files with 20 additions and 4 deletions

View File

@ -9,7 +9,7 @@
"datatables-bootstrap3-plugin": "~0.2.0",
"angular": "~1.3.11",
"angular-ui-router": "~0.2.13",
"angular-data": "~1.5.3",
"js-data-angular": "~2.1.0",
"sockjs": "~0.3.4",
"jed": "~1.1.0"
},

View File

@ -1,6 +1,6 @@
angular.module('OpenSlidesApp', [
'ui.router',
'angular-data.DS',
'js-data',
'OpenSlidesApp.core',
'OpenSlidesApp.agenda',
'OpenSlidesApp.assignments',

View File

@ -82,6 +82,22 @@ angular.module('OpenSlidesApp.core', [])
$locationProvider.html5Mode(true);
})
.config(function(DSProvider) {
// Reloads everything after 5 minutes.
// TODO: * find a way only to reload things that are still needed
DSProvider.defaults.maxAge = 5 * 60 * 1000; // 5 minutes
DSProvider.defaults.reapAction = 'none';
DSProvider.defaults.afterReap = function(model, items) {
if (items.length > 5) {
model.findAll({}, {bypassCache: true});
} else {
_.forEach(items, function (item) {
model.refresh(item[model.idAttribute]);
});
}
};
})
.run(function(DS, autoupdate) {
autoupdate.on_message(function(data) {
// TODO: when MODEL.find() is called after this

View File

@ -64,11 +64,11 @@ angular.module('OpenSlidesApp.users', [])
})
.controller('UserListCtrl', function($scope, User, i18n) {
User.bindAll($scope, 'users');
User.bindAll({}, $scope, 'users');
})
.controller('UserDetailCtrl', function($scope, User, user) {
User.bindOne($scope, 'user', user.id);
User.bindOne(user.id, $scope, 'user');
})
.controller('UserCreateCtrl', function($scope, User) {