mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
list: move the spinner into its own blaze component
This way, when a list is at the maximum number of cards shown and adding a new card would make the spinner appear, the list would load the next N items. This can happen if user A and B are both looking at the same board, B adds a new cards, and A will see the spinner and will not be able to remove it.
This commit is contained in:
parent
00376b43f8
commit
cbb6c82113
2 changed files with 47 additions and 37 deletions
|
|
@ -13,14 +13,7 @@ template(name="listBody")
|
|||
class="{{#if MultiSelection.isSelected _id}}is-checked{{/if}}")
|
||||
+minicard(this)
|
||||
if (showSpinner (idOrNull ../../_id))
|
||||
.sk-spinner.sk-spinner-wave.sk-spinner-list(
|
||||
class=currentBoard.colorClass
|
||||
id="showMoreResults")
|
||||
.sk-rect1
|
||||
.sk-rect2
|
||||
.sk-rect3
|
||||
.sk-rect4
|
||||
.sk-rect5
|
||||
+spinnerList
|
||||
|
||||
if canSeeAddCard
|
||||
+inlinedForm(autoclose=false position="bottom")
|
||||
|
|
@ -30,6 +23,16 @@ template(name="listBody")
|
|||
i.fa.fa-plus
|
||||
| {{_ 'add-card'}}
|
||||
|
||||
template(name="spinnerList")
|
||||
.sk-spinner.sk-spinner-wave.sk-spinner-list(
|
||||
class=currentBoard.colorClass
|
||||
id="showMoreResults")
|
||||
.sk-rect1
|
||||
.sk-rect2
|
||||
.sk-rect3
|
||||
.sk-rect4
|
||||
.sk-rect5
|
||||
|
||||
template(name="addCardForm")
|
||||
.minicard.minicard-composer.js-composer
|
||||
if getLabels
|
||||
|
|
|
|||
|
|
@ -5,35 +5,6 @@ BlazeComponent.extendComponent({
|
|||
onCreated() {
|
||||
// for infinite scrolling
|
||||
this.cardlimit = new ReactiveVar(InfiniteScrollIter);
|
||||
this.spinnerShown = false;
|
||||
},
|
||||
|
||||
onRendered() {
|
||||
const spinner = this.find('.sk-spinner-list');
|
||||
|
||||
if (spinner) {
|
||||
const options = {
|
||||
root: null, // we check if the spinner is on the current viewport
|
||||
rootMargin: '0px',
|
||||
threshold: 0.25,
|
||||
};
|
||||
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach((entry) => {
|
||||
this.spinnerShown = entry.isIntersecting;
|
||||
this.updateList();
|
||||
});
|
||||
}, options);
|
||||
|
||||
observer.observe(spinner);
|
||||
}
|
||||
},
|
||||
|
||||
updateList() {
|
||||
if (this.spinnerShown) {
|
||||
this.cardlimit.set(this.cardlimit.get() + InfiniteScrollIter);
|
||||
window.requestIdleCallback(() => this.updateList());
|
||||
}
|
||||
},
|
||||
|
||||
mixins() {
|
||||
|
|
@ -641,3 +612,39 @@ BlazeComponent.extendComponent({
|
|||
}];
|
||||
},
|
||||
}).register('searchElementPopup');
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
onCreated() {
|
||||
this.spinnerShown = false;
|
||||
this.cardlimit = this.parentComponent().cardlimit;
|
||||
},
|
||||
|
||||
onRendered() {
|
||||
const spinner = this.find('.sk-spinner-list');
|
||||
|
||||
if (spinner) {
|
||||
const options = {
|
||||
root: null, // we check if the spinner is on the current viewport
|
||||
rootMargin: '0px',
|
||||
threshold: 0.25,
|
||||
};
|
||||
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach((entry) => {
|
||||
this.spinnerShown = entry.isIntersecting;
|
||||
this.updateList();
|
||||
});
|
||||
}, options);
|
||||
|
||||
observer.observe(spinner);
|
||||
}
|
||||
},
|
||||
|
||||
updateList() {
|
||||
if (this.spinnerShown) {
|
||||
this.cardlimit.set(this.cardlimit.get() + InfiniteScrollIter);
|
||||
window.requestIdleCallback(() => this.updateList());
|
||||
}
|
||||
},
|
||||
|
||||
}).register('spinnerList');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue