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

[2.0] fix: activities that are not getting updated when stages change. #1722

Open
wants to merge 2 commits into
base: 2.0
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
active-type="{{ $activeType }}"
@if($types):types='@json($types)'@endif
@if($extraTypes):extra-types='@json($extraTypes)'@endif
ref="activities"
>
<!-- Shimmer -->
<x-admin::shimmer.activities />
Expand Down Expand Up @@ -556,59 +557,53 @@ class="dark:mix-blend-exclusion dark:invert"
});
},

markAsDone: function(activity) {
let self = this;

markAsDone(activity) {
this.$emitter.emit('open-confirm-modal', {
agree: () => {
self.isUpdating[activity.id] = true;
this.isUpdating[activity.id] = true;

this.$axios.put("{{ route('admin.activities.update', 'replaceId') }}".replace('replaceId', activity.id), {
'is_done': 1
})
.then (function(response) {
self.isUpdating[activity.id] = false;
.then((response) => {
this.isUpdating[activity.id] = false;

activity.is_done = 1;

self.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
this.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
})
.catch (function (error) {
self.isUpdating[activity.id] = false;
.catch((error) => {
this.isUpdating[activity.id] = false;

self.$emitter.emit('add-flash', { type: 'error', message: error.response.data.message });
this.$emitter.emit('add-flash', { type: 'error', message: error.response.data.message });
});
},
});
},

remove: function(activity) {
let self = this;

remove(activity) {
this.$emitter.emit('open-confirm-modal', {
agree: () => {
self.isUpdating[activity.id] = true;
this.isUpdating[activity.id] = true;

this.$axios.delete("{{ route('admin.activities.delete', 'replaceId') }}".replace('replaceId', activity.id))
.then (function(response) {
self.isUpdating[activity.id] = false;
.then((response) => {
this.isUpdating[activity.id] = false;

self.activities.splice(self.activities.indexOf(activity), 1);
this.activities.splice(this.activities.indexOf(activity), 1);

self.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
this.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
})
.catch (function (error) {
self.isUpdating[activity.id] = false;
.catch((error) => {
this.isUpdating[activity.id] = false;

self.$emitter.emit('add-flash', { type: 'error', message: error.response.data.message });
this.$emitter.emit('add-flash', { type: 'error', message: error.response.data.message });
});
},
});
},

unlinkEmail: function(activity) {
let self = this;

unlinkEmail(activity) {
this.$emitter.emit('open-confirm-modal', {
agree: () => {
let emailId = activity.parent_id ?? activity.id;
Expand All @@ -618,26 +613,26 @@ class="dark:mix-blend-exclusion dark:invert"
email_id: emailId,
}
})
.then (response => {
let relatedActivities = self.activities.filter(activity => activity.parent_id == emailId || activity.id == emailId);
.then((response) => {
let relatedActivities = this.activities.filter(activity => activity.parent_id == emailId || activity.id == emailId);

relatedActivities.forEach(activity => {
const index = self.activities.findIndex(a => a === activity);
const index = this.activities.findIndex(a => a === activity);

if (index !== -1) {
self.activities.splice(index, 1);
this.activities.splice(index, 1);
}
});

self.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
this.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
})
.catch (error => {
self.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
.catch((error) => {
this.$emitter.emit('add-flash', { type: 'error', message: error.response.data.message });
});
}
});
},
}
},
});
</script>
@endPushOnce
Original file line number Diff line number Diff line change
Expand Up @@ -231,26 +231,26 @@ class="primary-button"

this.isUpdating = true;

let self = this;

this.$axios
.put("{{ route('admin.leads.stage.update', $lead->id) }}", params ?? {
'lead_pipeline_stage_id': stage.id
})
.then (function(response) {
self.isUpdating = false;
.then ((response) => {
this.isUpdating = false;

this.currentStage = stage;

self.currentStage = stage;
this.$parent.$refs.activities.get();

self.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
this.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
})
.catch (function (error) {
self.isUpdating = false;
.catch ((error) => {
this.isUpdating = false;

self.$emitter.emit('add-flash', { type: 'error', message: error.response.data.message });
this.$emitter.emit('add-flash', { type: 'error', message: error.response.data.message });
});
},
}
},
});
</script>
@endPushOnce
Loading