Skip to content

Commit

Permalink
Merge pull request #1722 from suraj-webkul/stages
Browse files Browse the repository at this point in the history
[2.0] fix: activities that are not getting updated when stages change.
  • Loading branch information
devansh-webkul authored Jan 13, 2025
2 parents 04d1921 + 73d3662 commit 13691cc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 42 deletions.
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 @@ -237,26 +237,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

0 comments on commit 13691cc

Please sign in to comment.