0
Fork 0
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:
Steve Larson 2024-08-22 13:15:06 -05:00 committed by GitHub
parent 7c992825ed
commit 827518c98b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,13 @@ export default class SelectionList {
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;
#frozen = false;
@ -199,43 +206,34 @@ export default class SelectionList {
}
this.lastShiftSelectionGroup = new Set();
// todo
let running = false;
const modelOrder = ['scheduledInfinityModel', 'draftInfinityModel', 'publishedAndSentInfinityModel'];
const models = this.infinityModel;
for (const key in models) {
for (const item of this.models[key].content) {
// Exlusing the last selected item
for (const modelKey of modelOrder) {
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 (!running) {
running = true;
// Skip last selected on its own
if (item.id === this.lastSelectedId) {
continue;
}
} else {
// Still include id
if (item.id === id) {
this.lastShiftSelectionGroup.add(item.id);
if (this.inverted) {
this.selectedIds.delete(item.id);
} else {
this.selectedIds.add(item.id);
}
}
this.lastShiftSelectionGroup.add(item.id);
this.inverted ? this.selectedIds.delete(item.id) : this.selectedIds.add(item.id);
running = false;
break;
}
}
if (running) {
this.lastShiftSelectionGroup.add(item.id);
if (this.inverted) {
this.selectedIds.delete(item.id);
} else {
this.selectedIds.add(item.id);
}
this.inverted ? this.selectedIds.delete(item.id) : this.selectedIds.add(item.id);
}
}
}
@ -262,4 +260,4 @@ export default class SelectionList {
this.inverted = false;
this.lastSelectedId = null;
}
}
}