Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show loading icon when deleting or renaming groups #4013

Merged
merged 1 commit into from
Jul 15, 2024
Merged
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
32 changes: 22 additions & 10 deletions src/components/AppNavigation/GroupNavigationItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
</template>
{{ t('contacts', 'Add contacts') }}
</ActionButton>
<ActionInput @submit="renameGroup" :value.sync="newGroupName">
<ActionInput @submit="renameGroup"
:value.sync="newGroupName"

Check warning on line 27 in src/components/AppNavigation/GroupNavigationItem.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Attribute ":value.sync" should go before "@submit"
:disabled="renaming">

Check warning on line 28 in src/components/AppNavigation/GroupNavigationItem.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Attribute ":disabled" should go before "@submit"
<template #icon>
<IconRename :size="20" />
<IconLoading v-if="renaming" :size="20" />
<IconRename v-else :size="20" />
</template>
{{ t('contacts', 'Rename') }}
</ActionInput>
Expand All @@ -48,9 +51,10 @@
</template>
{{ t('contacts', 'Send email as BCC') }}
</ActionButton>
<ActionButton @click="deleteGroup">
<ActionButton @click="deleteGroup" :disabled="deleting">

Check warning on line 54 in src/components/AppNavigation/GroupNavigationItem.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Attribute ":disabled" should go before "@click"
<template #icon>
<IconDelete :size="20" />
<IconLoading v-if="deleting" :size="20" />
<IconDelete v-else :size="20" />
</template>
{{ t('contacts', 'Delete') }}
</ActionButton>
Expand All @@ -77,6 +81,7 @@
NcCounterBubble,
NcAppNavigationItem as AppNavigationItem,
NcActionInput as ActionInput,
NcLoadingIcon as IconLoading,
} from '@nextcloud/vue'
import IconContact from 'vue-material-design-icons/AccountMultiple.vue'
import IconAdd from 'vue-material-design-icons/Plus.vue'
Expand All @@ -100,15 +105,18 @@
IconEmail,
IconRename,
IconDelete,
IconLoading,
},

data() {
return {
newGroupName: '',
renaming: false,
deleting: false,
}
},

props: {

Check warning on line 119 in src/components/AppNavigation/GroupNavigationItem.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The "props" property should be above the "data" property on line 111
group: {
type: Object,
required: true,
Expand All @@ -123,8 +131,8 @@

methods: {
/**
* @param groups

Check warning on line 134 in src/components/AppNavigation/GroupNavigationItem.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "groups" description
* @param groupId

Check warning on line 135 in src/components/AppNavigation/GroupNavigationItem.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "groupId" description
*/
isInGroup(groups, groupId) {
return groups.includes(groupId)
Expand Down Expand Up @@ -222,7 +230,7 @@
* Open mailto: for contacts in a group
*
* @param {object} group of contacts to be emailed
* @param {string} mode

Check warning on line 233 in src/components/AppNavigation/GroupNavigationItem.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "mode" description
*/
emailGroup(group, mode = 'to') {
const emails = []
Expand All @@ -248,12 +256,13 @@
/**
* Rename group in store and on server
*/
renameGroup() {
async renameGroup() {
if (this.newGroupName === '') {
return
}

this.group.contacts.forEach(async (key) => {
this.renaming = true
for (const key of this.group.contacts) {
const contact = this.$store.getters.getContact(key)

if (contact === undefined) {
Expand All @@ -265,19 +274,21 @@
} catch (e) {
console.error('Error renaming group', e)
}
})
}

this.$store.commit('renameGroup', {
oldGroupName: this.group.name,
newGroupName: this.newGroupName,
})
this.renaming = false
},

/**
* Delete group from store and on server
*/
deleteGroup() {
this.group.contacts.forEach(async (key) => {
async deleteGroup() {
this.deleting = true
for (const key of this.group.contacts) {
const contact = this.$store.getters.getContact(key)

if (contact === undefined) {
Expand All @@ -289,9 +300,10 @@
} catch (e) {
console.error('Error deleting group', e)
}
})
}

this.$store.commit('removeGroup', this.group.name)
this.deleting = false
},

},
Expand Down
Loading