Bug 35477: Show a warning when non-existent items are added to the waiting list

Only messages "X new items added" or "No items added" were displayed.
With this patch we will display:
A warning with "No items added"
A warning with "X new items added. Y items not found." when some items
have not been added
A messages "X new items added" when everything went well

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2023-12-05 14:19:37 +01:00 committed by Katrin Fischer
parent c3d78bc35a
commit ed37c7e68d
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -135,13 +135,19 @@ export default {
const PreservationStore = inject("PreservationStore") const PreservationStore = inject("PreservationStore")
const { config } = PreservationStore const { config } = PreservationStore
const { setMessage, setConfirmationDialog, loading, loaded } = const {
inject("mainStore") setMessage,
setWarning,
setConfirmationDialog,
loading,
loaded,
} = inject("mainStore")
return { return {
table, table,
config, config,
setMessage, setMessage,
setWarning,
setConfirmationDialog, setConfirmationDialog,
loading, loading,
loaded, loaded,
@ -213,12 +219,24 @@ export default {
client.waiting_list_items.createAll(items).then( client.waiting_list_items.createAll(items).then(
result => { result => {
if (result.length) { if (result.length) {
this.setMessage( if (result.length != items.length) {
this.$__("%s new items added.").format( this.setWarning(
result.length this.$__(
), "%s new items added. %s items not found."
true ).format(
) result.length,
items.length - result.length
),
true
)
} else {
this.setMessage(
this.$__("%s new items added.").format(
result.length
),
true
)
}
this.last_items = result this.last_items = result
if (this.$refs.table) { if (this.$refs.table) {
this.$refs.table.redraw( this.$refs.table.redraw(
@ -228,7 +246,7 @@ export default {
this.getCountWaitingListItems() this.getCountWaitingListItems()
} }
} else { } else {
this.setMessage(this.$__("No items added")) this.setWarning(this.$__("No items added"))
} }
}, },
error => {} error => {}