Skip to content

Commit e4a1a5a

Browse files
committed
fix(ContactsSettings): redo
Signed-off-by: Grigory Vodyanov <[email protected]>
1 parent e7389b7 commit e4a1a5a

File tree

4 files changed

+128
-142
lines changed

4 files changed

+128
-142
lines changed

src/components/AppNavigation/ContactsSettings.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,27 @@
99
v-model:open="showSettings"
1010
:name="t('contacts', 'Contacts settings')"
1111
:show-navigation="true">
12-
<AppSettingsSection id="general-settings" :name="t('contacts', 'General settings')">
12+
<AppSettingsSection id="general-settings" :name="t('contacts', 'General')">
13+
<SettingsSortContacts class="contacts-settings-modal__form__row" />
1314
<CheckboxRadioSwitch
1415
:model-value="enableSocialSync"
1516
:loading="enableSocialSyncLoading"
1617
:disabled="enableSocialSyncLoading"
18+
type="switch"
1719
class="social-sync__checkbox contacts-settings-modal__form__row"
20+
:description="t('contacts', 'Refreshed once per week')"
1821
@update:model-value="toggleSocialSync">
1922
<div class="social-sync__checkbox__label">
2023
<span>
2124
{{ t('contacts', 'Update avatars from social media') }}
22-
<em>{{ t('contacts', '(refreshed once per week)') }}</em>
2325
</span>
2426
</div>
2527
</CheckboxRadioSwitch>
26-
<SettingsSortContacts class="contacts-settings-modal__form__row" />
28+
<SettingsImportContacts
29+
:addressbooks="addressbooks"
30+
class="contacts-settings-modal__form__row"
31+
@clicked="onClickImport"
32+
@file-loaded="onLoad" />
2733
</AppSettingsSection>
2834
<AppSettingsSection id="address-books" :name="t('contacts', 'Address books')">
2935
<div class="contacts-settings-modal__form">
@@ -33,11 +39,6 @@
3339
</ul>
3440
</div>
3541
<SettingsNewAddressbook class="contacts-settings-modal__form__row settings-new-addressbook" :addressbooks="addressbooks" />
36-
<SettingsImportContacts
37-
:addressbooks="addressbooks"
38-
class="contacts-settings-modal__form__row"
39-
@clicked="onClickImport"
40-
@file-loaded="onLoad" />
4142
</div>
4243
</AppSettingsSection>
4344
</AppSettingsDialog>

src/components/AppNavigation/Settings/SettingsAddressbook.vue

Lines changed: 35 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,38 @@
44
-->
55
<template>
66
<div class="settings-addressbook-list">
7-
<IconContactPlus class="settings-line__icon" />
8-
<li :class="{ 'addressbook--disabled': !addressbook.enabled }" class="addressbook">
9-
<div class="addressbook__content">
10-
<!-- addressbook name -->
11-
<span class="addressbook__name" :title="addressbook.displayName">
12-
{{ addressbook.enabled ? addressbook.displayName : t('contacts', '{addressbookname} (Hidden)', { addressbookname: addressbook.displayName }) }}
7+
<NcListItem :class="{ 'addressbook--disabled': !addressbook.enabled }" :force-display-actions="true">
8+
<template #icon>
9+
<IconContactPlus class="settings-line__icon" />
10+
</template>
11+
<template #name :title="addressbook.displayName">
12+
{{ addressbook.enabled ? addressbook.displayName : t('contacts', '{addressbookname} (Hidden)', { addressbookname: addressbook.displayName }) }} </template>
13+
14+
<template #subname>
15+
<span v-if="addressbook.dav.description">{{ addressbook.dav.description }}, </span>
16+
<span v-if="addressbook.enabled" class="addressbook__count-wrapper">
17+
<span class="addressbook__count">{{ n('contacts', '%n contact', '%n contacts', contactsCount) }}</span>
18+
<span class="addressbook__count"> - {{ n('contacts', '%n group', '%n groups', groupsCount) }}</span>
1319
</span>
20+
</template>
1421

15-
<div v-if="addressbook.dav.description" class="addressbook__description">
16-
{{ addressbook.dav.description }}
17-
</div>
18-
<!-- counters -->
19-
<div v-if="addressbook.enabled" class="addressbook__count-wrapper">
20-
<span class="addressbook__count">{{ n('contacts', '%n contact', '%n contacts', contactsCount) }}</span>
21-
<span class="addressbook__count">- {{ n('contacts', '%n group', '%n groups', groupsCount) }}</span>
22-
</div>
23-
</div>
24-
25-
<!-- sharing Ncbutton -->
26-
<NcButton
27-
v-if="!addressbook.readOnly && !isSharedWithMe"
28-
v-tooltip.top="sharedWithTooltip"
29-
:class="{ 'addressbook__share--shared': hasShares }"
30-
:name="sharedWithTooltip"
31-
href="#"
32-
class="addressbook__share"
33-
@click="toggleShare">
34-
<template #icon>
35-
<IconShare :size="20" />
36-
</template>
37-
</NcButton>
22+
<template #extra-actions>
23+
<!-- sharing Ncbutton -->
24+
<ActionButton
25+
v-if="!addressbook.readOnly && !isSharedWithMe"
26+
:title="sharedWithTooltip"
27+
:class="{ 'addressbook__share--shared': hasShares }"
28+
variant="tertiary"
29+
href="#"
30+
class="addressbook__share"
31+
@click="toggleShare">
32+
<template #icon>
33+
<IconShare :size="20" />
34+
</template>
35+
</ActionButton>
36+
</template>
3837

39-
<!-- popovermenu -->
40-
<Actions class="addressbook__menu" menu-align="right">
38+
<template #actions>
4139
<!-- copy addressbook link -->
4240
<ActionLink
4341
:href="addressbook.url"
@@ -111,10 +109,9 @@
111109
</template>
112110
{{ t('contacts', 'Delete') }}
113111
</ActionButton>
114-
</Actions>
115-
<!-- sharing input -->
116-
<ShareAddressBook v-if="shareOpen && !addressbook.readOnly" :addressbook="addressbook" />
117-
</li>
112+
</template>
113+
</NcListItem>
114+
<ShareAddressBook v-if="shareOpen && !addressbook.readOnly" :addressbook="addressbook" />
118115
</div>
119116
</template>
120117

@@ -128,6 +125,7 @@ import {
128125
NcActions as Actions,
129126
NcLoadingIcon as IconLoading,
130127
NcButton,
128+
NcListItem,
131129
} from '@nextcloud/vue'
132130
import IconContactPlus from 'vue-material-design-icons/AccountMultiplePlusOutline.vue'
133131
import IconRename from 'vue-material-design-icons/PencilOutline.vue'
@@ -155,6 +153,7 @@ export default {
155153
IconShare,
156154
IconLoading,
157155
ShareAddressBook,
156+
NcListItem,
158157
},
159158
160159
mixins: [CopyToClipboardMixin],
@@ -358,88 +357,8 @@ export default {
358357
</script>
359358

360359
<style lang="scss" scoped>
361-
.addressbook {
362-
display: flex;
363-
flex-wrap: wrap;
364-
align-items: center;
365-
white-space: nowrap;
366-
text-overflow: ellipsis;
367-
padding: var(--default-grid-baseline) 0;
368-
369-
> .addressbook__content {
370-
+ a,
371-
+ div {
372-
// put actions at the end
373-
margin-inline-start: auto;
374-
}
375-
}
376-
377-
&__name {
378-
display: block;
379-
flex: 0 1 auto;
380-
white-space: nowrap;
381-
overflow: hidden;
382-
text-overflow: ellipsis;
383-
}
384-
385-
&__content {
386-
display: flex;
387-
flex-wrap: wrap;
388-
flex-direction: column;
389-
flex: 0 1 auto;
390-
max-width: calc(100% - 2 * 44px);
391-
}
392-
393-
&__description {
394-
color: var(--color-text-lighter);
395-
}
396-
397-
&__count-wrapper {
398-
display: flex;
399-
}
400-
401-
&__count {
402-
margin-inline-start: calc(var(--default-grid-baseline) * 0.5);
403-
font-size: smaller;
404-
color: var(--color-text-lighter);
405-
}
406-
407-
&__count:not(:last-child) {
408-
margin-inline-end: var(--default-grid-baseline);
409-
}
410-
411-
&__share,
412-
&__menu .icon-more {
413-
opacity: .5;
414-
&:hover,
415-
&:focus,
416-
&:active {
417-
opacity: .7;
418-
}
419-
}
420-
&__share {
421-
background-color: transparent;
422-
border: none;
423-
box-shadow: none;
424-
425-
&--shared {
426-
opacity: .7;
427-
}
428-
}
429-
&--disabled &__name {
430-
opacity: .5;
431-
}
432-
}
433-
434360
.settings-addressbook-list {
435361
display: flex;
436-
width: 100%;
437-
.material-design-icon {
438-
justify-content: flex-start;
439-
}
440-
}
441-
442-
.addressbook-shares {
443-
padding-top: calc(var(--default-grid-baseline) * 2);
362+
flex-direction: column;
444363
}
445364
</style>

src/components/AppNavigation/Settings/SettingsNewAddressbook.vue

Lines changed: 76 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,42 @@
55

66
<template>
77
<div class="new-addressbook-entry">
8-
<IconLoading v-if="loading" :size="20" />
9-
<NcInputField
10-
v-model:model-value="displayName"
11-
class="new-addressbook"
12-
:disabled="loading"
13-
:label="t('contacts', 'Add new address book')"
14-
:show-trailing-button="true"
15-
:trailing-button-label="t('contacts', 'Add')"
16-
:error="inputErrorState"
17-
type="text"
18-
autocomplete="off"
19-
autocorrect="off"
20-
spellcheck="false"
21-
@trailing-button-click="addAddressbook">
22-
<template #trailing-button-icon>
8+
<NcButton v-if="!modalOpen && !loading" @click="openModal">
9+
<template #icon>
2310
<IconAdd :size="20" />
2411
</template>
25-
</NcInputField>
12+
{{ t('contacts', 'New address book') }}
13+
</NcButton>
14+
<IconLoading v-if="loading" :size="20" />
15+
16+
<NcModal v-if="modalOpen" @close="onModalCancel" size="small">
17+
<div class="new-addressbook-modal">
18+
<NcInputField
19+
v-model:model-value="displayName"
20+
class="new-addressbook"
21+
:disabled="loading"
22+
:label="t('contacts', 'Add new address book')"
23+
type="text"
24+
autocomplete="off"
25+
autocorrect="off"
26+
spellcheck="false" />
27+
28+
<div class="new-addressbook-modal__buttons">
29+
<NcButton variant="tertiary" :disabled="loading" @click="onModalCancel">
30+
{{ t('contacts', 'Cancel') }}
31+
</NcButton>
32+
<NcButton variant="primary" :disabled="loading || inputErrorState" @click="onModalSubmit">
33+
{{ t('contacts', 'Add') }}
34+
</NcButton>
35+
</div>
36+
</div>
37+
</NcModal>
2638
</div>
2739
</template>
2840

2941
<script>
3042
import { showError } from '@nextcloud/dialogs'
31-
import { NcInputField } from '@nextcloud/vue'
43+
import { NcButton, NcInputField, NcModal } from '@nextcloud/vue'
3244
import IconLoading from 'vue-material-design-icons/Loading.vue'
3345
import IconAdd from 'vue-material-design-icons/Plus.vue'
3446
@@ -38,12 +50,15 @@ export default {
3850
NcInputField,
3951
IconAdd,
4052
IconLoading,
53+
NcButton,
54+
NcModal,
4155
},
4256
4357
data() {
4458
return {
4559
loading: false,
4660
displayName: '',
61+
modalOpen: false,
4762
}
4863
},
4964
@@ -59,6 +74,21 @@ export default {
5974
},
6075
6176
methods: {
77+
openModal() {
78+
this.modalOpen = true
79+
},
80+
81+
onModalCancel() {
82+
this.modalOpen = false
83+
this.displayName = ''
84+
this.loading = false
85+
},
86+
87+
async onModalSubmit() {
88+
await this.addAddressbook()
89+
this.modalOpen = false
90+
},
91+
6292
/**
6393
* Add a new address book
6494
*/
@@ -82,3 +112,32 @@ export default {
82112
},
83113
}
84114
</script>
115+
116+
<style lang="scss" scoped>
117+
118+
.new-addressbook-entry {
119+
display: flex;
120+
width: 100%;
121+
justify-content: stretch;
122+
margin-top: calc(var(--default-grid-baseline) * 2);
123+
124+
> * {
125+
flex-grow: 1;
126+
}
127+
}
128+
129+
.new-addressbook-modal {
130+
padding: calc(var(--default-grid-baseline) * 4);
131+
padding-top: calc(var(--default-grid-baseline) * 8);
132+
> * {
133+
width: 100%;
134+
}
135+
136+
&__buttons {
137+
display: flex;
138+
justify-content: end;
139+
gap: calc(var(--default-grid-baseline) * 2);
140+
margin-top: calc(var(--default-grid-baseline) * 2);
141+
}
142+
}
143+
</style>

src/components/AppNavigation/Settings/SettingsSortContacts.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
<template>
77
<div class="sort-contacts">
8-
<IconList class="settings-line__icon" />
98
<NcSelect
109
id="sort-by"
1110
:value="orderKeyOption"
@@ -14,6 +13,7 @@
1413
:options="options"
1514
:custom-label="formatSortByLabel"
1615
:get-option-key="(option) => option.key"
16+
:input-label="t('contacts', 'Sort by')"
1717
label="label"
1818
@input="sortContacts" />
1919
</div>
@@ -89,6 +89,13 @@ export default {
8989

9090
<style lang="scss" scoped>
9191
.sort-contacts {
92+
width: 100%;
9293
display: flex;
94+
justify-content: stretch;
95+
margin-bottom: calc(var(--default-grid-baseline) * 2);
96+
97+
#sort-by {
98+
flex-grow: 1;
99+
}
93100
}
94101
</style>

0 commit comments

Comments
 (0)