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){
},
init: function init(hook) {
var self = this;
var config = hook.config.droplabAjax;
if (!config || !config.endpoint || !config.method) {
......@@ -33,7 +34,21 @@ require('../window')(function(w){
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) {
if (config.loadingTemplate) {
hook.list.list.querySelector('[data-loading-template]').outerHTML = self.listTemplate;
}
hook.list[config.method].call(hook.list, d);
}).catch(function(e) {
if(e.message) {
......
......@@ -10,6 +10,10 @@
droplabAjax: {
endpoint: 'labels.json',
method: 'setData',
loadingTemplate: `
<div class="filter-dropdown-loading">
<i class="fa fa-spinner fa-spin"></i>
</div>`,
},
droplabFilter: {
filterFunction: this.filterWithSymbol.bind(this, '~'),
......
......@@ -10,6 +10,10 @@
droplabAjax: {
endpoint: 'milestones.json',
method: 'setData',
loadingTemplate: `
<div class="filter-dropdown-loading">
<i class="fa fa-spinner fa-spin"></i>
</div>`,
},
droplabFilter: {
filterFunction: this.filterWithSymbol.bind(this, '%'),
......
......@@ -121,3 +121,7 @@
.hint-dropdown {
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