Skip to content

Commit e3a4b22

Browse files
Merge pull request #1571 from suraj-webkul/fix-lookup-component
fix lookup component and add Convert empty string to null middleware.
2 parents 3ede95b + 5161927 commit e3a4b22

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

packages/Webkul/Admin/src/Http/Controllers/Lead/LeadController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ public function store(LeadForm $request): RedirectResponse
171171
$data['closed_at'] = Carbon::now();
172172
}
173173

174+
$data['person']['organization_id'] = empty($data['person']['organization_id']) ? null : $data['person']['organization_id'];
175+
174176
$lead = $this->leadRepository->create($data);
175177

176178
Event::dispatch('lead.create.after', $lead);
@@ -230,6 +232,8 @@ public function update(LeadForm $request, int $id): RedirectResponse|JsonRespons
230232
$data['lead_pipeline_stage_id'] = $stage->id;
231233
}
232234

235+
$data['person']['organization_id'] = empty($data['person']['organization_id']) ? null : $data['person']['organization_id'];
236+
233237
$lead = $this->leadRepository->update($data, $id);
234238

235239
Event::dispatch('lead.update.after', $lead);

packages/Webkul/Admin/src/Resources/views/components/attributes/edit/lookup.blade.php

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,16 @@ class="px-4 py-2 text-center text-gray-500"
131131
};
132132
},
133133
134+
mounted() {
135+
if (this.value) {
136+
this.selectedItem = this.value;
137+
}
138+
},
134139
135140
watch: {
136-
value(newValue, oldValue) {
137-
if (
138-
JSON.stringify(newValue)
139-
!== JSON.stringify(oldValue)
140-
) {
141-
this.searchTerm = newValue ? newValue['name'] : '';
142-
143-
this.entityId = newValue ? newValue['id'] : '';
144-
145-
if (this.searchTerm == '') {
146-
this.remove();
147-
} else {
148-
this.getLookUpEntity();
149-
}
150-
}
151-
}
141+
searchTerm(newVal, oldVal) {
142+
this.search();
143+
},
152144
},
153145
154146
mounted() {
@@ -235,8 +227,8 @@ class="px-4 py-2 text-center text-gray-500"
235227
this.searchedResults = [];
236228
237229
this.$emit('lookup-removed');
238-
}
239-
}
230+
},
231+
},
240232
});
241233
</script>
242234
@endPushOnce

packages/Webkul/Admin/src/Resources/views/components/lookup/index.blade.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ class="cursor-pointer border-t border-gray-800 px-4 py-2 text-gray-500 hover:bg-
177177
if (this.value) {
178178
this.selectedItem = this.value;
179179
}
180-
181-
console.log(this.selectedItem?.name == "");
182180
},
183181
184182
created() {

0 commit comments

Comments
 (0)