2 <div class="page-section" id="agreement_user_roles">
3 <legend>{{ $__("Users") }}</legend>
6 v-for="(user_role, counter) in user_roles"
10 {{ $__("Agreement user %s").format(counter + 1) }}
11 <a href="#" @click.prevent="deleteUser(counter)"
12 ><i class="fa fa-trash"></i>
13 {{ $__("Remove this user") }}</a
18 <label :for="`user_id_${counter}`"
19 >{{ $__("User") }}:</label
22 {{ user_role.patron_str }}
26 @click="selectUser(counter)"
27 class="btn btn-default"
28 >{{ $__("Select user") }}</a
32 <label :for="`user_role_${counter}`"
33 >{{ $__("Role") }}:</label
36 :id="`user_role_${counter}`"
37 v-model="user_role.role"
39 :reduce="av => av.authorised_value"
40 :options="av_agreement_user_roles"
42 <template #search="{ attributes, events }">
44 :required="!user_role.role"
51 <span class="required">{{ $__("Required") }}</span>
57 name="selected_patron_id"
58 id="selected_patron_id"
60 <a class="btn btn-default" @click="addUser"
61 ><font-awesome-icon icon="plus" /> {{ $__("Add new user") }}</a
67 import { fetchPatron } from "../../fetch"
70 name: "AgreementUserRoles",
72 av_agreement_user_roles: Array,
76 this.user_roles.forEach(u => {
77 u.patron_str = $patron_to_html(u.patron)
82 this.user_roles.push({
89 this.user_roles.splice(counter, 1)
92 let select_user_window = window.open(
93 "/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=select&filter=erm_users",
95 "width=740,height=450,location=yes,toolbar=no," +
96 "scrollbars=yes,resize=yes"
98 // This is a bit dirty, the "select user" window should be rewritten and be a Vue component
99 // but that's not for now...
100 select_user_window.addEventListener(
102 this.newUserSelected,
105 select_user_window.counter = counter
108 let c = e.currentTarget.counter
109 let selected_patron_id =
110 document.getElementById("selected_patron_id").value
112 // FIXME We are missing a "loading..."
113 fetchPatron(selected_patron_id).then(p => {
115 this.user_roles[c].patron = patron
116 this.user_roles[c].patron_str = $patron_to_html(patron)
117 this.user_roles[c].user_id = patron.patron_id