[Tree] Add wait spinner

This commit is contained in:
Victor Woeltjen
2016-03-11 18:00:58 -08:00
parent f7ba24c0b6
commit d789e91c18
2 changed files with 39 additions and 3 deletions

View File

@@ -23,8 +23,9 @@
define([
'zepto',
'./TreeNodeView'
], function ($, TreeNodeView) {
'./TreeNodeView',
'text!../../res/templates/tree/wait-node.html'
], function ($, TreeNodeView, spinnerTemplate) {
'use strict';
function TreeView(gestureService, selectFn) {
@@ -33,6 +34,7 @@ define([
this.callbacks = [];
this.selectFn = selectFn || this.value.bind(this);
this.gestureService = gestureService;
this.pending = false;
}
TreeView.prototype.newTreeView = function () {
@@ -66,6 +68,12 @@ define([
}
function addNodes(domainObjects) {
if (self.pending) {
self.pending = false;
self.nodeViews = [];
self.ul.empty();
}
if (domainObject === self.activeObject) {
self.setSize(domainObjects.length);
domainObjects.forEach(addNode);
@@ -73,7 +81,6 @@ define([
}
}
// TODO: Add pending indicator
domainObject.useCapability('composition')
.then(addNodes);
};
@@ -87,6 +94,8 @@ define([
this.ul.empty();
if (domainObject && domainObject.hasCapability('composition')) {
this.pending = true;
this.ul.append($(spinnerTemplate));
this.unlisten = domainObject.getCapability('mutation')
.listen(this.loadComposition.bind(this));
this.loadComposition(domainObject);