Skip to content

Commit 8abc711

Browse files
authored
Merge pull request #11208 from cdrini/fix/ia-identifiers
Fix ia identifier editing
2 parents 1f51a44 + b56431b commit 8abc711

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

openlibrary/components/IdentifiersInput.vue

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</option>
1616
<template v-if="hasPopularIds">
1717
<option
18-
v-for="entry in popularIds"
18+
v-for="entry in popularIds.filter(e => isAdmin || e.name !== 'ocaid')"
1919
:key="entry.name"
2020
:value="entry.name"
2121
>
@@ -32,6 +32,8 @@
3232
v-for="idConfig in identifierConfigsByKey"
3333
:key="idConfig.name"
3434
:value="idConfig.name"
35+
:disabled="!isAdmin && idConfig.name === 'ocaid'"
36+
:title="!isAdmin && idConfig.name === 'ocaid' ? 'Only librarians can edit this identifier' : ''"
3537
>
3638
{{ idConfig.label }}
3739
</option>
@@ -81,19 +83,11 @@
8183
>
8284
<td>{{ identifierConfigsByKey[name]?.label ?? name }}</td>
8385
<td>{{ item }}</td>
84-
<td v-if="!isAdmin">
86+
<td>
8587
<button
86-
v-if="name !== 'ocaid'"
8788
class="form-control"
88-
@click="removeIdentifier(name, idx)"
89-
>
90-
Remove
91-
</button>
92-
</td>
93-
<td v-else>
94-
<button
95-
class="form-control"
96-
@click="removeIdentifier(name, idx)"
89+
:disabled="!isAdmin && name === 'ocaid'"
90+
:title="!isAdmin && name === 'ocaid' ? 'Only librarians can edit this identifier' : ''"
9791
>
9892
Remove
9993
</button>
@@ -173,6 +167,7 @@ export default {
173167
selectedIdentifier: '', // Which identifier is selected in dropdown
174168
inputValue: '', // What user put into input
175169
assignedIdentifiers: {}, // IDs assigned to the entity Ex: {'viaf': '12632978'} or {'abaa': ['123456','789012']}
170+
isAdmin: false,
176171
}
177172
},
178173
@@ -190,14 +185,11 @@ export default {
190185
identifierConfigsByKey: function() {
191186
return Object.fromEntries(this.idConfigs.map(e => [e.name, e]));
192187
},
193-
isAdmin: function() {
194-
return this.admin.toLowerCase() === 'true';
195-
},
196188
saveIdentifiersAsList: function() {
197189
return this.multiple.toLowerCase() === 'true';
198190
},
199191
setButtonEnabled: function(){
200-
return this.selectedIdentifier !== '' && this.inputValue !== '';
192+
return this.selectedIdentifier !== '' && this.inputValue !== '' && (this.isAdmin || this.selectedIdentifier !== 'ocaid');
201193
},
202194
hasPopularIds: function() {
203195
return Object.keys(this.popularIds).length !== 0;
@@ -215,6 +207,7 @@ export default {
215207
},
216208
},
217209
created: function(){
210+
this.isAdmin = this.admin.toLowerCase() === 'true';
218211
this.assignedIdentifiers = JSON.parse(decodeURIComponent(this.assigned_ids_string));
219212
if (this.assignedIdentifiers.length === 0) {
220213
this.assignedIdentifiers = {}

0 commit comments

Comments
 (0)