Commit efb66820 authored by Clement Ho's avatar Clement Ho

Add loading message for droplab_ajax

parent cf3504ed
...@@ -23,6 +23,7 @@ require('../window')(function(w){ ...@@ -23,6 +23,7 @@ require('../window')(function(w){
}, },
init: function init(hook) { init: function init(hook) {
var self = this;
var config = hook.config.droplabAjax; var config = hook.config.droplabAjax;
if (!config || !config.endpoint || !config.method) { if (!config || !config.endpoint || !config.method) {
...@@ -33,7 +34,21 @@ require('../window')(function(w){ ...@@ -33,7 +34,21 @@ require('../window')(function(w){
return; return;
} }
if (config.loadingTemplate) {
var dynamicList = hook.list.list.querySelector('[data-dynamic]');
var loadingTemplate = document.createElement('div');
loadingTemplate.innerHTML = config.loadingTemplate;
loadingTemplate.setAttribute('data-loading-template', true);
this.listTemplate = dynamicList.outerHTML;
dynamicList.outerHTML = loadingTemplate.outerHTML;
}
this._loadUrlData(config.endpoint).then(function(d) { this._loadUrlData(config.endpoint).then(function(d) {
if (config.loadingTemplate) {
hook.list.list.querySelector('[data-loading-template]').outerHTML = self.listTemplate;
}
hook.list[config.method].call(hook.list, d); hook.list[config.method].call(hook.list, d);
}).catch(function(e) { }).catch(function(e) {
if(e.message) { if(e.message) {
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
droplabAjax: { droplabAjax: {
endpoint: 'labels.json', endpoint: 'labels.json',
method: 'setData', method: 'setData',
loadingTemplate: `
<div class="filter-dropdown-loading">
<i class="fa fa-spinner fa-spin"></i>
</div>`,
}, },
droplabFilter: { droplabFilter: {
filterFunction: this.filterWithSymbol.bind(this, '~'), filterFunction: this.filterWithSymbol.bind(this, '~'),
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
droplabAjax: { droplabAjax: {
endpoint: 'milestones.json', endpoint: 'milestones.json',
method: 'setData', method: 'setData',
loadingTemplate: `
<div class="filter-dropdown-loading">
<i class="fa fa-spinner fa-spin"></i>
</div>`,
}, },
droplabFilter: { droplabFilter: {
filterFunction: this.filterWithSymbol.bind(this, '%'), filterFunction: this.filterWithSymbol.bind(this, '%'),
......
...@@ -121,3 +121,7 @@ ...@@ -121,3 +121,7 @@
.hint-dropdown { .hint-dropdown {
width: 250px; width: 250px;
} }
.filter-dropdown-loading {
padding: 8px 16px;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment