Skip to content

Commit

Permalink
fix(copy): Hide not copyable addressbooks in copy select
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Merkel <[email protected]>
  • Loading branch information
JohannesGGE committed Jun 22, 2023
1 parent 9e839b6 commit b588aac
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/components/ContactDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
<NcSelect ref="pickAddressbook"
v-model="pickedAddressbook"
:allow-empty="false"
:options="addressbooksOptions"
:options="copyableAddressbooksOptions"
:placeholder="t('contacts', 'Select address book')"
track-by="id"
label="name" />
Expand Down Expand Up @@ -245,6 +245,8 @@
empty property because this is a required prop on regular property-select. But since
we are hijacking this... (this is supposed to be used with a ICAL.property, but to avoid code
duplication, we created a fake propModel and property with our own options here) -->
<!-- We need to pass all addressbooksOptions not only writable ones. Otherwise the the name
can't be displayed for readOnly addressbooks -->
<PropertySelect :prop-model="addressbookModel"
:options="addressbooksOptions"
:value.sync="addressbook"
Expand Down Expand Up @@ -531,6 +533,24 @@ export default {
})
},

/**
* Store getters filtered and mapped to usable object
* This is the list of addressbooks that are available to copy to
*
* @return {{id: string, name: string}[]}
*/
copyableAddressbooksOptions() {
return this.addressbooksOptions
.filter(option => !option.readOnly)
.filter(option => option.id !== this.contact.addressbook.id)
.map(addressbook => {
return {
id: addressbook.id,
name: addressbook.name,
}
})
},

// store getter
addressbooks() {
return this.$store.getters.getAddressbooks
Expand Down

0 comments on commit b588aac

Please sign in to comment.