Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/models/circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { CircleConfigs, MemberLevels, ROUTE_CIRCLE } from './constants.ts'
import { CircleConfigs, MemberLevels } from './constants.ts'
import Member from './member.ts'

type MemberList = Record<string, Member>
Expand Down Expand Up @@ -306,7 +306,7 @@ export default class Circle {
get router() {
return {
name: 'circle',
params: { selectedCircle: this.id, selectedGroup: ROUTE_CIRCLE },
params: { selectedCircle: this.id },
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/models/userGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { ROUTE_USER_GROUP } from './constants.ts'

export default class UserGroup {
private _data: object
private _members: string[]
Expand Down Expand Up @@ -61,7 +59,7 @@ export default class UserGroup {
get router(): object {
return {
name: 'user_group',
params: { selectedUserGroup: this.id, selectedGroup: ROUTE_USER_GROUP },
params: { selectedUserGroup: this.id },
}
}

Expand Down
42 changes: 16 additions & 26 deletions src/views/Contacts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,23 @@
<RootNavigation
:loading="loadingContacts || loadingCircles">
<div class="import-and-new-contact-buttons">
<SettingsImportContacts v-if="!loadingContacts && isEmptyGroup && !isChartView && !isCirclesView" />
<SettingsImportContacts v-if="!loadingContacts && importEnabled" />
<!-- new-contact-button -->
<NcButton
v-if="!loadingContacts"
v-if="!loadingContacts && addingContactEnabled"
:disabled="!defaultAddressbook"
variant="secondary"
wide
@click="newContact">
<template #icon>
<IconAdd :size="20" />
</template>
{{ isCirclesView ? t('contacts', 'Add member') : t('contacts', 'New contact') }}
{{ selectedCircle ? t('contacts', 'Add member') : t('contacts', 'New contact') }}
</NcButton>
</div>
</RootNavigation>

<!-- Main content: circle, chart or contacts -->
<UserGroupContent
v-if="selectedUserGroup"
:loding="loadingCircles" />
<CircleContent
v-if="selectedCircle || selectedUserGroup"
:loading="loadingCircles" />
Expand Down Expand Up @@ -75,7 +72,7 @@ import ContactsPicker from '../components/EntityPicker/ContactsPicker.vue'
import ImportView from './Processing/ImportView.vue'
import IsMobileMixin from '../mixins/IsMobileMixin.ts'
import RouterMixin from '../mixins/RouterMixin.js'
import { GROUP_ALL_CONTACTS, GROUP_NO_GROUP_CONTACTS, ROUTE_CIRCLE, ROUTE_USER_GROUP } from '../models/constants.ts'
import { GROUP_ALL_CONTACTS, GROUP_NO_GROUP_CONTACTS } from '../models/constants.ts'
import Contact from '../models/contact.js'
import rfcProps from '../models/rfcProps.js'
import client from '../services/cdav.js'
Expand Down Expand Up @@ -147,14 +144,6 @@ export default {
return this.$store.getters.getImportState
},

isEmptyGroup() {
return this.contactsList.length === 0
},

isChartView() {
return !!this.selectedChart
},

/**
* Are we importing contacts ?
*
Expand All @@ -173,6 +162,14 @@ export default {
return this.importState.stage === 'done'
},

importEnabled() {
return !this.selectedUserGroup && !this.selectedCircle && !this.selectedUserGroup && !this.selectedChart && this.contactsList.length === 0
},

addingContactEnabled() {
return !this.selectedUserGroup
},

// first enabled addressbook of the list
defaultAddressbook() {
return this.addressbooks.find((addressbook) => !addressbook.readOnly && addressbook.enabled)
Expand All @@ -191,20 +188,15 @@ export default {
return this.sortedContacts
} else if (this.selectedGroup === GROUP_NO_GROUP_CONTACTS) {
return this.ungroupedContacts.map((contact) => this.sortedContacts.find((item) => item.key === contact.key))
} else if (this.selectedGroup === ROUTE_CIRCLE || this.selectedGroup === ROUTE_USER_GROUP) {
return []
}

const group = this.groups.filter((group) => group.name === this.selectedGroup)[0]
if (group) {
return this.sortedContacts.filter((contact) => group.contacts.indexOf(contact.key) >= 0)
}
return []
},

isCirclesView() {
return this.selectedGroup === ROUTE_CIRCLE || this.selectedGroup === ROUTE_USER_GROUP
},

ungroupedContacts() {
return this.sortedContacts.filter((contact) => this.contacts[contact.key].groups && this.contacts[contact.key].groups.length === 0)
},
Expand Down Expand Up @@ -275,8 +267,8 @@ export default {

methods: {
async newContact() {
if (this.isCirclesView) {
emit('contacts:circles:append', this.selectedCircle.id)
if (this.selectedCircle) {
emit('contacts:circles:append', this.selectedCircle)
return
}

Expand Down Expand Up @@ -391,9 +383,7 @@ export default {
&& !this.selectedUserGroup
&& !this.groups.find((group) => group.name === this.selectedGroup)
&& GROUP_ALL_CONTACTS !== this.selectedGroup
&& GROUP_NO_GROUP_CONTACTS !== this.selectedGroup
&& ROUTE_CIRCLE !== this.selectedGroup
&& ROUTE_USER_GROUP !== this.selectedGroup) {
&& GROUP_NO_GROUP_CONTACTS !== this.selectedGroup) {
showError(t('contacts', 'Group {group} not found', { group: this.selectedGroup }))
console.error('Group not found', this.selectedGroup)

Expand Down