mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
🐛 Fixed shift selection in the posts list (#20818)
ref https://linear.app/tryghost/issue/ENG-1489/ The changes to improve posts loading in admin broke the shift selection functionality. This restores that, as we need to be able to crawl across the (now) three models when present.
This commit is contained in:
parent
7c992825ed
commit
827518c98b
1 changed files with 21 additions and 23 deletions
|
@ -8,6 +8,13 @@ export default class SelectionList {
|
||||||
|
|
||||||
enabled = true;
|
enabled = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The infinity model containing the list of posts.
|
||||||
|
* @type {Object}
|
||||||
|
* @property {InfinityModel} scheduledInfinityModel - The infinity model for scheduled posts.
|
||||||
|
* @property {InfinityModel} draftInfinityModel - The infinity model for draft posts.
|
||||||
|
* @property {InfinityModel} publishedAndSentInfinityModel - The infinity model for published and sent posts.
|
||||||
|
*/
|
||||||
infinityModel;
|
infinityModel;
|
||||||
|
|
||||||
#frozen = false;
|
#frozen = false;
|
||||||
|
@ -199,43 +206,34 @@ export default class SelectionList {
|
||||||
}
|
}
|
||||||
this.lastShiftSelectionGroup = new Set();
|
this.lastShiftSelectionGroup = new Set();
|
||||||
|
|
||||||
// todo
|
|
||||||
let running = false;
|
let running = false;
|
||||||
|
const modelOrder = ['scheduledInfinityModel', 'draftInfinityModel', 'publishedAndSentInfinityModel'];
|
||||||
const models = this.infinityModel;
|
const models = this.infinityModel;
|
||||||
for (const key in models) {
|
|
||||||
for (const item of this.models[key].content) {
|
for (const modelKey of modelOrder) {
|
||||||
// Exlusing the last selected item
|
const model = models[modelKey];
|
||||||
|
if (!model?.content || model.content.length === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const item of model.content) {
|
||||||
if (item.id === this.lastSelectedId || item.id === id) {
|
if (item.id === this.lastSelectedId || item.id === id) {
|
||||||
if (!running) {
|
if (!running) {
|
||||||
running = true;
|
running = true;
|
||||||
|
|
||||||
// Skip last selected on its own
|
|
||||||
if (item.id === this.lastSelectedId) {
|
if (item.id === this.lastSelectedId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Still include id
|
|
||||||
if (item.id === id) {
|
|
||||||
this.lastShiftSelectionGroup.add(item.id);
|
this.lastShiftSelectionGroup.add(item.id);
|
||||||
|
this.inverted ? this.selectedIds.delete(item.id) : this.selectedIds.add(item.id);
|
||||||
if (this.inverted) {
|
running = false;
|
||||||
this.selectedIds.delete(item.id);
|
|
||||||
} else {
|
|
||||||
this.selectedIds.add(item.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (running) {
|
if (running) {
|
||||||
this.lastShiftSelectionGroup.add(item.id);
|
this.lastShiftSelectionGroup.add(item.id);
|
||||||
if (this.inverted) {
|
this.inverted ? this.selectedIds.delete(item.id) : this.selectedIds.add(item.id);
|
||||||
this.selectedIds.delete(item.id);
|
|
||||||
} else {
|
|
||||||
this.selectedIds.add(item.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue