open mini list view before children are loaded

This commit is contained in:
Mads Rasmussen
2017-02-08 15:02:03 +01:00
parent 843796c9a4
commit 548f9fd01f

View File

@@ -1,7 +1,7 @@
(function () { (function () {
'use strict'; 'use strict';
function MiniListViewDirective($q, contentResource, memberResource, mediaResource, entityResource) { function MiniListViewDirective(contentResource, memberResource, mediaResource, entityResource) {
function link(scope, el, attr, ctrl) { function link(scope, el, attr, ctrl) {
@@ -33,23 +33,15 @@
} }
}; };
// start loading animation on node // clear and push mini list view in dom so we only render 1 view
node.loading = true; scope.miniListViews = [];
scope.miniListViews.push(miniListView);
getChildrenForMiniListView(miniListView) // store in history so we quickly can navigate back
.then(function (data) { miniListViewsHistory.push(miniListView);
// stop loading animation on node // get children
node.loading = false; getChildrenForMiniListView(miniListView);
// clear and push mini list view in dom so we only render 1 view
scope.miniListViews = [];
scope.miniListViews.push(miniListView);
// store in history so we quickly can navigate back
miniListViewsHistory.push(miniListView);
});
// get ancestors // get ancestors
getAncestors(node); getAncestors(node);
@@ -58,9 +50,6 @@
function getChildrenForMiniListView(miniListView) { function getChildrenForMiniListView(miniListView) {
// setup promise
var deferred = $q.defer();
// start loading animation list view // start loading animation list view
miniListView.loading = true; miniListView.loading = true;
@@ -77,22 +66,14 @@
resource(miniListView.node.id, miniListView.pagination) resource(miniListView.node.id, miniListView.pagination)
.then(function (data) { .then(function (data) {
// update children // update children
miniListView.children = data.items; miniListView.children = data.items;
// update pagination // update pagination
miniListView.pagination.totalItems = data.totalItems; miniListView.pagination.totalItems = data.totalItems;
miniListView.pagination.totalPages = data.totalPages; miniListView.pagination.totalPages = data.totalPages;
// stop load indicator // stop load indicator
miniListView.loading = false; miniListView.loading = false;
deferred.resolve(data);
}); });
return deferred.promise;
} }
scope.openNode = function(event, node) { scope.openNode = function(event, node) {