|
10 | 10 | * Fixed to show: "Of the 50,000 records selected, only the first 20,000 have been archived" |
11 | 11 | */ |
12 | 12 |
|
13 | | -import {ListController} from "@web/views/list/list_controller"; |
| 13 | +import ListController from "web.ListController"; |
| 14 | +import session from "web.session"; |
| 15 | +import core from "web.core"; |
14 | 16 | import {patch} from "@web/core/utils/patch"; |
15 | 17 |
|
| 18 | +const _t = core._t; |
| 19 | + |
16 | 20 | patch(ListController.prototype, { |
17 | 21 | /** |
18 | 22 | * @override |
19 | 23 | */ |
20 | | - async toggleArchiveState(archive) { |
21 | | - const resIds = await this.getSelectedResIds(); |
22 | | - const total = this.model.root.count; |
23 | | - |
24 | | - await this.model.root.archive(resIds, archive); |
| 24 | + async _toggleArchiveState(archive) { |
| 25 | + const resIds = await this.getSelectedIdsWithDomain(); |
| 26 | + const notif = this.isDomainSelected; |
| 27 | + await this._archive(resIds, archive); |
| 28 | + const total = this.model.get(this.handle, {raw: true}).count; |
25 | 29 |
|
26 | | - if (this.model.root.isDomainSelected && resIds.length < total) { |
27 | | - const message = _.str.sprintf( |
28 | | - this.env._t("Of the %d records selected, only the first %d have been archived/unarchived."), |
29 | | - total, // Fixed: swapped - total selected (larger) |
30 | | - resIds.length // Fixed: swapped - actually processed (smaller) |
| 30 | + // Fixed: Swapped parameters from original (total, resIds.length) to (resIds.length, total) |
| 31 | + // Logic: resIds.length < total, so resIds.length is the smaller number (actually archived) |
| 32 | + // and total is the larger number (total selected) |
| 33 | + if (notif && resIds.length === session.active_ids_limit && resIds.length < total) { |
| 34 | + const msg = _.str.sprintf( |
| 35 | + _t("Of the %d records selected, only the first %d have been archived/unarchived."), |
| 36 | + resIds.length, // Fixed: total selected (smaller due to active_ids_limit) |
| 37 | + total // Fixed: actually archived (larger - all that were selected) |
31 | 38 | ); |
32 | | - this.notification.add(message, { type: "warning" }); |
| 39 | + this.displayNotification({ title: _t('Warning'), message: msg }); |
33 | 40 | } |
34 | 41 | }, |
35 | 42 | }); |
|
0 commit comments