Skip to content

Commit 821c2f0

Browse files
authored
Merge pull request #5552 from ozer550/fix-trash-page-pagination
Fix trash page pagination
2 parents c0cf16b + 52a27d5 commit 821c2f0

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

contentcuration/contentcuration/frontend/channelEdit/views/trash/TrashModal.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,19 +281,24 @@
281281
'moveContentNodes',
282282
'loadContentNodes',
283283
'loadAncestors',
284+
'removeContentNodes',
284285
]),
285286
loadNodes() {
286287
this.loading = true;
288+
this.more = null;
289+
this.moreLoading = false;
287290
if (!this.trashId) {
288291
this.loading = false;
289292
return;
290293
}
291-
this.loadChildren({ parent: this.trashId, ordering: '-modified' }).then(
292-
childrenResponse => {
293-
this.loading = false;
294-
this.more = childrenResponse.more || null;
295-
},
296-
);
294+
this.removeContentNodes({ parentId: this.trashId }).then(() => {
295+
this.loadChildren({ parent: this.trashId, ordering: '-modified' }).then(
296+
childrenResponse => {
297+
this.loading = false;
298+
this.more = childrenResponse.more || null;
299+
},
300+
);
301+
});
297302
},
298303
moveNodes(target) {
299304
return this.moveContentNodes({

contentcuration/contentcuration/frontend/shared/data/__tests__/ContentNodeResource.spec.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,12 @@ describe('ContentNode methods', () => {
574574

575575
it('should update the node with the payload', async () => {
576576
node.parent = parent.id;
577-
await expect(ContentNode.tableMove({ node, parent, payload, change })).resolves.toBe(payload);
578-
expect(table.update).toHaveBeenCalledWith(node.id, payload);
577+
const result = await ContentNode.tableMove({ node, parent, payload, change });
578+
expect(result).toMatchObject({ ...payload, modified: expect.any(String) });
579+
expect(table.update).toHaveBeenCalledTimes(1);
580+
const [updateId, updatePayload] = table.update.mock.calls[0];
581+
expect(updateId).toBe(node.id);
582+
expect(updatePayload).toBe(result);
579583
expect(table.put).not.toBeCalled();
580584
expect(table.update).not.toHaveBeenCalledWith(node.parent, { changed: true });
581585
});
@@ -584,19 +588,23 @@ describe('ContentNode methods', () => {
584588
node.parent = parent.id;
585589
updated = false;
586590
const newPayload = { ...payload, root_id: parent.root_id };
587-
await expect(ContentNode.tableMove({ node, parent, payload, change })).resolves.toMatchObject(
588-
newPayload,
591+
const result = await ContentNode.tableMove({ node, parent, payload, change });
592+
expect(result).toMatchObject({ ...newPayload, modified: expect.any(String) });
593+
expect(table.update).toHaveBeenCalledWith(
594+
node.id,
595+
expect.objectContaining({ ...payload, modified: expect.any(String) }),
589596
);
590-
expect(table.update).toHaveBeenCalledWith(node.id, payload);
591-
expect(table.put).toHaveBeenCalledWith(newPayload);
597+
expect(table.put).toHaveBeenCalledWith(result);
592598
expect(table.update).not.toHaveBeenCalledWith(node.parent, { changed: true });
593599
});
594600

595601
it('should mark the old parent as changed', async () => {
596-
await expect(ContentNode.tableMove({ node, parent, payload, change })).resolves.toMatchObject(
597-
payload,
602+
const result = await ContentNode.tableMove({ node, parent, payload, change });
603+
expect(result).toMatchObject({ ...payload, modified: expect.any(String) });
604+
expect(table.update).toHaveBeenCalledWith(
605+
node.id,
606+
expect.objectContaining({ ...payload, modified: expect.any(String) }),
598607
);
599-
expect(table.update).toHaveBeenCalledWith(node.id, payload);
600608
expect(table.put).not.toBeCalled();
601609
expect(table.update).toHaveBeenCalledWith(node.parent, { changed: true });
602610
});

contentcuration/contentcuration/frontend/shared/data/resources.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,10 @@ export const ContentNode = new TreeResource({
16871687
async tableMove({ node, parent, payload }) {
16881688
// Do direct table writes here rather than using add/update methods to avoid
16891689
// creating unnecessary additional change events.
1690+
payload = {
1691+
...payload,
1692+
modified: new Date().toISOString(),
1693+
};
16901694
const updated = await this.table.update(node.id, payload);
16911695
// Update didn't succeed, this node probably doesn't exist, do a put instead,
16921696
// but need to add in other parent info.

0 commit comments

Comments
 (0)