Skip to content

Commit 6d4d113

Browse files
fix: qoutes issues
1 parent 7bb2e53 commit 6d4d113

File tree

6 files changed

+102
-114
lines changed

6 files changed

+102
-114
lines changed

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

+19-35
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,13 @@ class="text-2xl text-gray-600"
7676
</div>
7777
7878
<!-- Hidden Input Entity Value -->
79-
<template v-if="attribute['code'].includes('organization_id') && ! selectedItem.id">
80-
<input
81-
type="hidden"
82-
:name="attribute['code'].replace('organization_id', 'organization_name')"
83-
v-model="selectedItem.name"
84-
/>
85-
</template>
86-
87-
<template v-else>
88-
<input
89-
type="hidden"
90-
:name="attribute['code']"
91-
v-model="selectedItem.id"
92-
/>
93-
</template>
79+
<x-admin::form.control-group.control
80+
type="hidden"
81+
::name="attribute['code']"
82+
v-model="selectedItem.id"
83+
::rules="validations"
84+
::label="attribute['name']"
85+
/>
9486
9587
<!-- Popup Box -->
9688
<div
@@ -175,6 +167,8 @@ class="cursor-pointer border-t border-gray-800 px-4 py-2 text-gray-500 hover:bg-
175167
176168
searchRoute: `{{ route('admin.settings.attributes.lookup') }}/${this.attribute.lookup_type}`,
177169
170+
lookupEntityRoute: `{{ route('admin.settings.attributes.lookup_entity') }}/${this.attribute.lookup_type}`,
171+
178172
isSearching: false,
179173
};
180174
},
@@ -191,19 +185,6 @@ class="cursor-pointer border-t border-gray-800 px-4 py-2 text-gray-500 hover:bg-
191185
searchTerm(newVal, oldVal) {
192186
this.search();
193187
},
194-
195-
value(newVal, oldVal) {
196-
if (newVal === undefined) {
197-
this.selectedItem = {
198-
id: '',
199-
name: ''
200-
};
201-
}
202-
203-
if (newVal) {
204-
this.getLookUpEntity();
205-
}
206-
},
207188
},
208189
209190
computed: {
@@ -256,13 +237,16 @@ class="cursor-pointer border-t border-gray-800 px-4 py-2 text-gray-500 hover:bg-
256237
},
257238
258239
getLookUpEntity() {
259-
this.$axios.get(this.searchRoute, {
260-
params: { query: this.value?.name ?? ""}
240+
this.$axios.get(this.lookupEntityRoute, {
241+
params: { query: this.value?.id ?? ""}
261242
})
262243
.then (response => {
263-
const [result] = response.data;
264-
265-
this.selectedItem = result;
244+
this.selectedItem = Object.keys(response.data).length
245+
? response.data
246+
: {
247+
id: '',
248+
name: ''
249+
};
266250
})
267251
.catch (error => {});
268252
},
@@ -274,7 +258,7 @@ class="cursor-pointer border-t border-gray-800 px-4 py-2 text-gray-500 hover:bg-
274258
275259
this.searchTerm = '';
276260
277-
this.$emit('lookup-added', result);
261+
this.$emit('lookup-added', this.selectedItem);
278262
},
279263
280264
handleFocusOut(e) {
@@ -294,7 +278,7 @@ class="cursor-pointer border-t border-gray-800 px-4 py-2 text-gray-500 hover:bg-
294278
name: ''
295279
};
296280
297-
this.$emit('lookup-removed');
281+
this.$emit('lookup-removed', this.selectedItem);
298282
},
299283
},
300284
});

packages/Webkul/Admin/src/Resources/views/leads/common/contact.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
name="person[name]"
3333
v-model="person.name"
3434
v-if="person.name"
35-
rules="required"
3635
/>
3736
3837
<x-admin::form.control-group.error control-name="person[id]" />
@@ -87,6 +86,7 @@
8786
<x-admin::attributes.edit.lookup />
8887
8988
<v-lookup-component
89+
:key="person.organization?.id"
9090
:attribute='@json($organizationAttribute)'
9191
:value="person.organization"
9292
:is-disabled="person?.id ? true : false"

packages/Webkul/Admin/src/Resources/views/quotes/edit.blade.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ class="flex flex-col gap-4"
110110
:entity="$quote"
111111
/>
112112
113-
114113
<x-admin::attributes
115114
:custom-attributes="app('Webkul\Attribute\Repositories\AttributeRepository')->findWhere([
116115
'entity_type' => 'quotes',
@@ -173,9 +172,11 @@ class="flex flex-col gap-4"
173172
</x-admin::form.control-group.label>
174173
175174
<v-lookup-component
175+
:key="leadEntity.id"
176176
:attribute="{'code': 'lead_id', 'name': 'Lead', 'lookup_type': 'leads'}"
177-
:value='@json($lookUpEntityData)'
177+
:value="leadEntity"
178178
can-add-new="true"
179+
@lookup-removed="setLeadEntity"
179180
></v-lookup-component>
180181
</x-admin::form.control-group>
181182
</div>
@@ -566,6 +567,8 @@ class="icon-delete cursor-pointer text-2xl"
566567
{ id: 'address-info', label: '@lang('admin::app.quotes.create.address-info')' },
567568
{ id: 'quote-items', label: '@lang('admin::app.quotes.create.quote-items')' }
568569
],
570+
571+
leadEntity: @json($lookUpEntityData ?? []),
569572
};
570573
},
571574
@@ -584,6 +587,10 @@ class="icon-delete cursor-pointer text-2xl"
584587
section.scrollIntoView({ behavior: 'smooth' });
585588
}
586589
},
590+
591+
setLeadEntity($event) {
592+
this.leadEntity = $event;
593+
},
587594
},
588595
});
589596

0 commit comments

Comments
 (0)