Skip to content

Commit

Permalink
Merge pull request krayin#1650 from suraj-webkul/leads-kanban
Browse files Browse the repository at this point in the history
fix lead kanban sort order issue.
  • Loading branch information
devansh-webkul authored Sep 27, 2024
2 parents 61f90da + 258660a commit 66ad95b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/Webkul/Admin/src/Http/Resources/StageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function toArray($request)
'lead_value' => $this->lead_value,
'formatted_lead_value' => core()->formatBasePrice($this->lead_value),
'is_user_defined' => $this->is_user_defined,
'sort_order' => $this->sort_order,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ class="rounded-xl bg-gray-200 px-2 py-1 text-xs font-medium dark:bg-gray-800"
this.get()
.then(response => {
for (let [stageId, data] of Object.entries(response.data)) {
this.stageLeads[stageId] = data;
for (let [sortOrder, data] of Object.entries(response.data)) {
this.stageLeads[sortOrder] = data;
}
});
},
Expand All @@ -397,8 +397,8 @@ class="rounded-xl bg-gray-200 px-2 py-1 text-xs font-medium dark:bg-gray-800"
this.get()
.then(response => {
for (let [stageId, data] of Object.entries(response.data)) {
this.stageLeads[stageId] = data;
for (let [sortOrder, data] of Object.entries(response.data)) {
this.stageLeads[sortOrder] = data;
}
});
},
Expand All @@ -412,13 +412,13 @@ class="rounded-xl bg-gray-200 px-2 py-1 text-xs font-medium dark:bg-gray-800"
append(params) {
this.get(params)
.then(response => {
for (let [stageId, data] of Object.entries(response.data)) {
if (! this.stageLeads[stageId]) {
this.stageLeads[stageId] = data;
for (let [sortOrder, data] of Object.entries(response.data)) {
if (! this.stageLeads[sortOrder]) {
this.stageLeads[sortOrder] = data;
} else {
this.stageLeads[stageId].leads.data = this.stageLeads[stageId].leads.data.concat(data.leads.data);
this.stageLeads[sortOrder].leads.data = this.stageLeads[sortOrder].leads.data.concat(data.leads.data);
this.stageLeads[stageId].leads.meta = data.leads.meta;
this.stageLeads[sortOrder].leads.meta = data.leads.meta;
}
}
});
Expand All @@ -439,14 +439,14 @@ class="rounded-xl bg-gray-200 px-2 py-1 text-xs font-medium dark:bg-gray-800"
if (event.removed) {
stage.lead_value = parseFloat(stage.lead_value) - parseFloat(event.removed.element.lead_value);
this.stageLeads[stage.id].leads.meta.total = this.stageLeads[stage.id].leads.meta.total - 1;
this.stageLeads[stage.sort_order].leads.meta.total = this.stageLeads[stage.sort_order].leads.meta.total - 1;
return;
}
stage.lead_value = parseFloat(stage.lead_value) + parseFloat(event.added.element.lead_value);
this.stageLeads[stage.id].leads.meta.total = this.stageLeads[stage.id].leads.meta.total + 1;
this.stageLeads[stage.sort_order].leads.meta.total = this.stageLeads[stage.sort_order].leads.meta.total + 1;
this.$axios
.put("{{ route('admin.leads.stage.update', 'replace') }}".replace('replace', event.added.element.id), {
Expand All @@ -468,20 +468,20 @@ class="rounded-xl bg-gray-200 px-2 py-1 text-xs font-medium dark:bg-gray-800"
* @returns {void}
*/
handleScroll(stage, event) {
const bottom = event.target.scrollHeight - event.target.scrollTop === event.target.clientHeight
const bottom = event.target.scrollHeight - event.target.scrollTop === event.target.clientHeight;
if (! bottom) {
return;
}
if (this.stageLeads[stage.id].leads.meta.current_page == this.stageLeads[stage.id].leads.meta.last_page) {
if (this.stageLeads[stage.sort_order].leads.meta.current_page == this.stageLeads[stage.sort_order].leads.meta.last_page) {
return;
}
this.append({
pipeline_stage_id: stage.id,
pipeline_id: stage.lead_pipeline_id,
page: this.stageLeads[stage.id].leads.meta.current_page + 1,
page: this.stageLeads[stage.sort_order].leads.meta.current_page + 1,
limit: 10,
});
},
Expand Down

0 comments on commit 66ad95b

Please sign in to comment.