Bug 38201: Fix PatronSearch

The event listener was being added infinitely. Meaning that when new realtionships were added, the previously added ones were still firing their previously registered events.

Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2025-02-17 14:34:50 -01:00 committed by Lucas Gass
parent c434e3041f
commit f517d6032e
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
3 changed files with 22 additions and 17 deletions

View File

@ -287,11 +287,6 @@ export default {
type: "resource",
value: null,
},
counter: {
type: "string",
value: "",
indexRequired: true,
},
label: {
type: "string",
value: __("User"),

View File

@ -188,11 +188,6 @@ export default {
type: "resource",
value: null,
},
counter: {
type: "string",
value: "",
indexRequired: true,
},
label: {
type: "string",
value: __("User"),

View File

@ -5,12 +5,17 @@
&nbsp;
<a
href="#patron_search_modal"
@click="selectUser(counter)"
@click="selectUser()"
class="btn btn-default"
data-bs-toggle="modal"
><i class="fa fa-plus"></i> {{ $__("Select user") }}</a
>
<input type="hidden" name="selected_patron_id" id="selected_patron_id" />
<input
v-if="shouldRenderInput"
type="hidden"
name="selected_patron_id"
id="selected_patron_id"
/>
</template>
<script>
@ -20,21 +25,31 @@ export default {
props: {
name: String,
resource: Object,
counter: String,
label: String,
required: Boolean,
},
beforeCreate() {
this.resource.patron_str = $patron_to_html(this.resource.patron);
},
computed: {
shouldRenderInput() {
return !document.getElementById("selected_patron_id");
},
},
methods: {
selectUser(counter) {
// This is a bit dirty, the "select user" window should be rewritten and be a Vue component
// but that's not for now...
selectUser() {
this.modalEventListener = () => {
this.newUserSelected();
$(document).off(
"hidden.bs.modal",
"#patron_search_modal",
this.modalEventListener
);
};
$(document).on(
"hidden.bs.modal",
"#patron_search_modal",
this.newUserSelected
this.modalEventListener
);
},
newUserSelected(e) {