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

Update related contacts on manager deletion #3077

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion src/components/AppContent/ContactsContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</template>

<!-- main contacts details -->
<ContactDetails :contact-key="selectedContact" :contacts="sortedContacts" />
<ContactDetails :contact-key="selectedContact" :sorted-contacts="sortedContacts" :contacts="contacts" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change really necessary for the fix?

</AppContent>
</template>
<script>
Expand Down
19 changes: 16 additions & 3 deletions src/components/ContactDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
:contact="contact"
:local-contact="localContact"
:update-contact="debounceUpdateContact"
:contacts="contacts"
:contacts="sortedContacts"
@resize="debounceRedrawMasonry" />
</div>

Expand Down Expand Up @@ -323,6 +323,10 @@ export default {
type: String,
default: undefined,
},
sortedContacts: {
type: Array,
default: () => [],
},
contacts: {
type: Array,
default: () => [],
Expand Down Expand Up @@ -660,8 +664,17 @@ export default {
/**
* Dispatch contact deletion request
*/
deleteContact() {
this.$store.dispatch('deleteContact', { contact: this.contact })
async deleteContact() {
// find all contacts which are related through Manager field
// for organization chart and remove reference of deleted contact
for (const key in this.contacts) {
if (this.contacts[key].managersName === this.contact.uid) {
this.contacts[key].vCard.removeProperty('x-managersname')
await this.$store.dispatch('updateContact', this.contacts[key])
}
}

await this.$store.dispatch('deleteContact', { contact: this.contact })
},

/**
Expand Down