Bugzilla – Attachment 189035 Details for
Bug 41178
SIP2 module does not notify that linked accounts are deleted when deleting an institution
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41178: (VueJS framework): Add beforeDoResourceDelete method
Bug-41178-VueJS-framework-Add-beforeDoResourceDele.patch (text/plain), 5.99 KB, created by
Pedro Amorim
on 2025-11-04 15:51:42 UTC
(
hide
)
Description:
Bug 41178: (VueJS framework): Add beforeDoResourceDelete method
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2025-11-04 15:51:42 UTC
Size:
5.99 KB
patch
obsolete
>From 8096b641ab372a1a194c769cdc90cfe41873beed Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Tue, 4 Nov 2025 12:21:16 -0100 >Subject: [PATCH] Bug 41178: (VueJS framework): Add beforeDoResourceDelete > method > >--- > .../SIP2/SIP2InstitutionResource.vue | 20 +++++ > .../prog/js/vue/composables/base-resource.js | 84 +++++++++++-------- > 2 files changed, 71 insertions(+), 33 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/SIP2InstitutionResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/SIP2InstitutionResource.vue >index 3931113864a..17a371ab45b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/SIP2InstitutionResource.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/SIP2InstitutionResource.vue >@@ -44,6 +44,8 @@ export default { > resourceTableUrl: > APIClient.sip2.httpClient._baseURL + "institutions", > }, >+ beforeDoResourceDelete: resource => >+ beforeDoResourceDelete(resource), > resourceAttrs: [ > { > name: "name", >@@ -154,6 +156,24 @@ export default { > props: props, > }); > >+ const beforeDoResourceDelete = async resource => { >+ const accounts = await APIClient.sip2.accounts.getAll({ >+ sip_institution_id: resource.sip_institution_id, >+ }); >+ >+ if (accounts.length > 0) { >+ baseResource.i18n.deleteConfirmationMessage = $__( >+ "You're removing institution %s. <br> It has %s associated accounts (%s), which will also be removed. Are you sure?" >+ ).format( >+ resource.name, >+ accounts.length, >+ accounts.map(a => a.login_id).join(", ") >+ ); >+ } else { >+ baseResource.i18n.deleteConfirmationBody = null; >+ } >+ }; >+ > const tableOptions = { > url: () => baseResource.getResourceTableUrl(), > table_settings: institutions_table_settings, >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js b/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js >index 3c0188f4841..eead7ca2386 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js >@@ -238,41 +238,59 @@ export function useBaseResource(resourceConfig) { > * @return {void} > */ > const doResourceDelete = (resource, callback) => { >- let resourceId = resource >- ? resource[resourceConfig.idAttr] >- : resourceConfig.newResource[resourceConfig.idAttr]; >- let resourceName = resource >- ? resource[resourceConfig.nameAttr] >- : resourceConfig.newResource[resourceConfig.nameAttr]; >- >- setConfirmationDialog( >- { >- title: i18n.deleteConfirmationMessage, >- message: resourceName, >- accept_label: $__("Yes, delete"), >- cancel_label: $__("No, do not delete"), >- }, >- () => { >- resourceConfig.apiClient.delete(resourceId).then( >- success => { >- setMessage( >- i18n.deleteSuccessMessage.format(resourceName), >- true >- ); >- if (typeof callback === "function") { >- callback(); >- } else { >- if (resourceConfig.props.routeAction === "list") { >- callback.ajax.reload(); >+ const runBeforeDelete = () => { >+ if ( >+ resourceConfig && >+ typeof resourceConfig.beforeDoResourceDelete === "function" >+ ) { >+ const result = resourceConfig.beforeDoResourceDelete(resource); >+ if (result && typeof result.then === "function") { >+ return result; >+ } >+ } >+ return Promise.resolve(); >+ }; >+ >+ runBeforeDelete().then(() => { >+ let resourceId = resource >+ ? resource[resourceConfig.idAttr] >+ : resourceConfig.newResource[resourceConfig.idAttr]; >+ let resourceName = resource >+ ? resource[resourceConfig.nameAttr] >+ : resourceConfig.newResource[resourceConfig.nameAttr]; >+ >+ setConfirmationDialog( >+ { >+ title: i18n.deleteConfirmationMessage, >+ message: resourceName, >+ accept_label: $__("Yes, delete"), >+ cancel_label: $__("No, do not delete"), >+ }, >+ () => { >+ resourceConfig.apiClient.delete(resourceId).then( >+ success => { >+ setMessage( >+ i18n.deleteSuccessMessage.format(resourceName), >+ true >+ ); >+ >+ if (typeof after_delete_callback === "function") { >+ after_delete_callback(); > } else { >- goToResourceList(); >+ if ( >+ resourceConfig.props.routeAction === "list" >+ ) { >+ callback.ajax.reload(); >+ } else { >+ goToResourceList(); >+ } > } >- } >- }, >- error => {} >- ); >- } >- ); >+ }, >+ error => {} >+ ); >+ } >+ ); >+ }); > }; > > /** >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41178
:
189034
| 189035 |
189036