Skip to content

Commit 994ceaf

Browse files
committed
fix(SettingsSortContacts): update it to latest NcSelect
Signed-off-by: Grigory Vodyanov <[email protected]>
1 parent 22f2a13 commit 994ceaf

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

src/components/AppNavigation/Settings/SettingsSortContacts.vue

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
<IconList class="settings-line__icon" />
99
<NcSelect
1010
id="sort-by"
11-
:value="orderKeyOption"
11+
v-model="selected"
1212
:searchable="false"
1313
:allow-empty="false"
1414
:options="options"
15-
:custom-label="formatSortByLabel"
16-
:get-option-key="(option) => option.key"
15+
:input-label="t('contacts', 'Sort by')"
1716
label="label"
18-
@input="sortContacts" />
17+
@update:model-value="sortContacts" />
1918
</div>
2019
</template>
2120

@@ -31,57 +30,54 @@ export default {
3130
IconList,
3231
},
3332
33+
data() {
34+
return {
35+
selected: null,
36+
}
37+
},
38+
3439
computed: {
3540
/* Order Keys */
3641
options() {
3742
return [
3843
{
3944
label: t('contacts', 'First name'),
40-
key: 'firstName',
45+
value: 'firstName',
4146
},
4247
{
4348
label: t('contacts', 'Last name'),
44-
key: 'lastName',
49+
value: 'lastName',
4550
},
4651
{
4752
label: t('contacts', 'Phonetic first name'),
48-
key: 'phoneticFirstName',
53+
value: 'phoneticFirstName',
4954
},
5055
{
5156
label: t('contacts', 'Phonetic last name'),
52-
key: 'phoneticLastName',
57+
value: 'phoneticLastName',
5358
},
5459
{
5560
label: t('contacts', 'Display name'),
56-
key: 'displayName',
61+
value: 'displayName',
5762
},
5863
{
5964
label: t('contacts', 'Last modified'),
60-
key: 'rev',
65+
value: 'rev',
6166
},
6267
]
6368
},
69+
},
6470
65-
/* Current order Key */
66-
orderKey() {
67-
return this.$store.getters.getOrderKey
68-
},
69-
70-
orderKeyOption() {
71-
return this.options.filter((option) => option.key === this.orderKey)[0]
72-
},
71+
beforeMount() {
72+
this.selected = this.options.find((option) => option.value === this.$store.getters.getOrderKey)?.label ?? null
7373
},
7474
7575
methods: {
76-
sortContacts(orderKey) {
77-
const key = orderKey && orderKey.key ? orderKey.key : 'displayName'
78-
this.$store.commit('setOrder', key)
76+
sortContacts(selected) {
77+
const value = selected && selected.value ? selected.value : 'displayName'
78+
this.$store.commit('setOrder', value)
7979
this.$store.commit('sortContacts')
80-
localStorage.setItem('orderKey', key)
81-
},
82-
83-
formatSortByLabel(option) {
84-
return t('contacts', 'Sort by {sorting}', { sorting: option.label })
80+
localStorage.setItem('orderKey', value)
8581
},
8682
},
8783
}

0 commit comments

Comments
 (0)