Skip to content

Commit c31a40a

Browse files
Merge pull request #2130 from krayin/qoutes-issue
fix: activity issue
2 parents b65afcd + efd80f4 commit c31a40a

File tree

6 files changed

+77
-51
lines changed

6 files changed

+77
-51
lines changed

packages/Webkul/Admin/src/Http/Controllers/Activity/ActivityController.php

+12-5
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,18 @@ public function update($id): RedirectResponse|JsonResponse
146146

147147
$activity = $this->activityRepository->update($data, $id);
148148

149-
$activity->leads()->sync(
150-
! empty($data['lead_id'])
151-
? [$data['lead_id']]
152-
: []
153-
);
149+
/**
150+
* We will not use `empty` directly here because `lead_id` can be a blank string
151+
* from the activity form. However, on the activity view page, we are only updating the
152+
* `is_done` field, so `lead_id` will not be present in that case.
153+
*/
154+
if (isset($data['lead_id'])) {
155+
$activity->leads()->sync(
156+
! empty($data['lead_id'])
157+
? [$data['lead_id']]
158+
: []
159+
);
160+
}
154161

155162
Event::dispatch('activity.update.after', $activity);
156163

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class="icon-more flex h-7 w-7 cursor-pointer items-center justify-center rounded
263263
<template v-if="activity.type != 'email'">
264264
@if (bouncer()->hasPermission('activities.edit'))
265265
<x-admin::dropdown.menu.item
266-
v-if="! activity.is_done"
266+
v-if="! activity.is_done && ['call', 'meeting', 'lunch'].includes(activity.type)"
267267
@click="markAsDone(activity)"
268268
>
269269
<div class="flex items-center gap-2">
@@ -273,7 +273,7 @@ class="icon-more flex h-7 w-7 cursor-pointer items-center justify-center rounded
273273
</div>
274274
</x-admin::dropdown.menu.item>
275275

276-
<x-admin::dropdown.menu.item>
276+
<x-admin::dropdown.menu.item v-if="['call', 'meeting', 'lunch'].includes(activity.type)">
277277
<a
278278
class="flex items-center gap-2"
279279
:href="'{{ route('admin.activities.edit', 'replaceId') }}'.replace('replaceId', activity.id)"

packages/Webkul/Admin/src/Resources/views/components/form/control-group/control.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class="peer h-5 w-9 cursor-pointer rounded-full bg-gray-200 after:absolute after
306306
@break
307307

308308
@case('inline')
309-
<x-admin::form.control-group.controls.inline.text {{ $attributes }}/>
309+
<x-admin::form.control-group.controls.inline.text {{ $attributes }} />
310310

311311
@break
312312

packages/Webkul/Admin/src/Resources/views/components/form/control-group/controls/inline/text.blade.php

+33-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<v-inline-text-edit
66
{{ $attributes }}
7-
:allow-edit="{{ $allowEdit }}"
7+
:allow-edit="{{ $allowEdit ? 'true' : 'false' }}"
88
>
99
<div class="group w-full max-w-full hover:rounded-sm">
1010
<div class="rounded-xs flex h-[34px] items-center pl-2.5 text-left">
@@ -37,11 +37,23 @@ class="group relative h-[18px] !w-full pl-2.5"
3737
:style="{ 'text-align': position }"
3838
>
3939
<span class="cursor-pointer truncate rounded">
40-
@{{ (valueLabel || inputValue || '').length > 20
41-
? (valueLabel || inputValue).substring(0, 20) + '...'
42-
: (valueLabel || inputValue) }}
40+
<template v-if="isDirty">
41+
@{{
42+
inputValue.length > 20
43+
? inputValue.substring(0, 20) + '...'
44+
: inputValue
45+
}}
46+
</template>
47+
48+
<template v-else>
49+
@{{
50+
(valueLabel || inputValue || '').length > 20
51+
? (valueLabel || inputValue).substring(0, 20) + '...'
52+
: (valueLabel || inputValue)
53+
}}
54+
</template>
4355
</span>
44-
56+
4557
<!-- Tooltip -->
4658
<div
4759
class="absolute bottom-0 mb-5 hidden flex-col group-hover:flex"
@@ -62,7 +74,7 @@ class="icon-edit cursor-pointer rounded p-0.5 text-2xl opacity-0 hover:bg-gray-2
6274
></i>
6375
</template>
6476
</div>
65-
77+
6678
<!-- Editing view -->
6779
<div
6880
class="relative w-full"
@@ -79,7 +91,7 @@ class="!h-[34px] !py-0 ltr:pr-16 rtl:pl-16"
7991
v-model="inputValue"
8092
ref="input"
8193
/>
82-
94+
8395
<!-- Action Buttons -->
8496
<div class="absolute top-[6px] flex gap-0.5 ltr:right-2 rtl:left-2">
8597
<button
@@ -89,7 +101,7 @@ class="flex items-center justify-center bg-green-100 p-1 hover:bg-green-200 ltr:
89101
>
90102
<i class="icon-tick text-md cursor-pointer font-bold text-green-600 dark:!text-green-600" />
91103
</button>
92-
104+
93105
<button
94106
type="button"
95107
class="flex items-center justify-center bg-red-100 p-1 hover:bg-red-200 ltr:rounded-r-md rtl:rounded-l-md"
@@ -172,15 +184,17 @@ class="flex items-center justify-center bg-red-100 p-1 hover:bg-red-200 ltr:roun
172184
173185
isEditing: false,
174186
187+
isDirty: false,
188+
175189
isRTL: document.documentElement.dir === 'rtl',
176190
};
177191
},
178192
179193
watch: {
180194
/**
181195
* Watch the value prop.
182-
*
183-
* @param {String} newValue
196+
*
197+
* @param {String} newValue
184198
*/
185199
value(newValue) {
186200
this.inputValue = newValue;
@@ -190,7 +204,7 @@ class="flex items-center justify-center bg-red-100 p-1 hover:bg-red-200 ltr:roun
190204
methods: {
191205
/**
192206
* Toggle the input.
193-
*
207+
*
194208
* @return {void}
195209
*/
196210
toggle() {
@@ -201,7 +215,7 @@ class="flex items-center justify-center bg-red-100 p-1 hover:bg-red-200 ltr:roun
201215
202216
/**
203217
* Save the input value.
204-
*
218+
*
205219
* @return {void}
206220
*/
207221
save() {
@@ -213,11 +227,13 @@ class="flex items-center justify-center bg-red-100 p-1 hover:bg-red-200 ltr:roun
213227
214228
if (this.url) {
215229
let formData = new FormData();
216-
230+
217231
formData.append(this.name, this.inputValue);
218232
219233
formData.append('_method', 'PUT');
220234
235+
this.isDirty = true;
236+
221237
this.$axios.post(this.url, {
222238
...this.params,
223239
...Object.fromEntries(formData),
@@ -226,10 +242,12 @@ class="flex items-center justify-center bg-red-100 p-1 hover:bg-red-200 ltr:roun
226242
this.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
227243
})
228244
.catch((error) => {
245+
this.isDirty = false;
246+
229247
this.inputValue = this.value;
230248
231249
this.$emitter.emit('add-flash', { type: 'error', message: error.response.data.message });
232-
});
250+
});
233251
}
234252
235253
this.$emit('on-change', {
@@ -240,7 +258,7 @@ class="flex items-center justify-center bg-red-100 p-1 hover:bg-red-200 ltr:roun
240258
241259
/**
242260
* Cancel the input value.
243-
*
261+
*
244262
* @return {void}
245263
*/
246264
cancel() {

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

+21-21
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
{!! view_render_event('admin.leads.create.products.form_controls.after') !!}
66

77
@pushOnce('scripts')
8-
<script
9-
type="text/x-template"
8+
<script
9+
type="text/x-template"
1010
id="v-product-list-template"
1111
>
1212
<div class="flex flex-col gap-4">
@@ -22,15 +22,15 @@
2222
<x-admin::table.th>
2323
@lang('admin::app.leads.common.products.product-name')
2424
</x-admin::table.th>
25-
25+
2626
<x-admin::table.th class="text-center">
2727
@lang('admin::app.leads.common.products.quantity')
2828
</x-admin::table.th>
29-
29+
3030
<x-admin::table.th class="text-center">
3131
@lang('admin::app.leads.common.products.price')
3232
</x-admin::table.th>
33-
33+
3434
<x-admin::table.th class="text-center">
3535
@lang('admin::app.leads.common.products.amount')
3636
</x-admin::table.th>
@@ -79,15 +79,15 @@ class="flex max-w-max items-center gap-2 text-brandColor"
7979
</div>
8080
</script>
8181

82-
<script
83-
type="text/x-template"
82+
<script
83+
type="text/x-template"
8484
id="v-product-item-template"
8585
>
8686
<x-admin::table.thead.tr>
8787
<!-- Product Name -->
8888
<x-admin::table.td>
8989
<x-admin::form.control-group class="!mb-0">
90-
<x-admin::lookup
90+
<x-admin::lookup
9191
::src="src"
9292
::name="`${inputName}[name]`"
9393
::params="params"
@@ -104,11 +104,11 @@ class="flex max-w-max items-center gap-2 text-brandColor"
104104
:label="trans('admin::app.leads.common.products.product-name')"
105105
:placeholder="trans('admin::app.leads.common.products.product-name')"
106106
/>
107-
107+
108108
<x-admin::form.control-group.error ::name="`${inputName}[product_id]`" />
109109
</x-admin::form.control-group>
110110
</x-admin::table.td>
111-
111+
112112
<!-- Product Quantity -->
113113
<x-admin::table.td class="text-right">
114114
<x-admin::form.control-group>
@@ -124,7 +124,7 @@ class="flex max-w-max items-center gap-2 text-brandColor"
124124
/>
125125
</x-admin::form.control-group>
126126
</x-admin::table.td>
127-
127+
128128
<!-- Price -->
129129
<x-admin::table.td class="text-right">
130130
<x-admin::form.control-group>
@@ -141,7 +141,7 @@ class="flex max-w-max items-center gap-2 text-brandColor"
141141
/>
142142
</x-admin::form.control-group>
143143
</x-admin::table.td>
144-
144+
145145
<!-- Amount -->
146146
<x-admin::table.td class="text-right">
147147
<x-admin::form.control-group>
@@ -153,7 +153,7 @@ class="flex max-w-max items-center gap-2 text-brandColor"
153153
:label="trans('admin::app.leads.common.products.total')"
154154
:placeholder="trans('admin::app.leads.common.products.total')"
155155
::value-label="$admin.formatPrice(product.price * product.quantity)"
156-
:allowEdit="'false'"
156+
:allowEdit="false"
157157
position="center"
158158
/>
159159
</x-admin::form.control-group>
@@ -162,7 +162,7 @@ class="flex max-w-max items-center gap-2 text-brandColor"
162162
<!-- Action -->
163163
<x-admin::table.td class="text-right">
164164
<x-admin::form.control-group >
165-
<i
165+
<i
166166
@click="removeProduct"
167167
class="icon-delete cursor-pointer text-2xl"
168168
></i>
@@ -194,7 +194,7 @@ class="icon-delete cursor-pointer text-2xl"
194194
amount: null,
195195
})
196196
},
197-
197+
198198
removeProduct (product) {
199199
const index = this.products.indexOf(product);
200200
this.products.splice(index, 1);
@@ -238,24 +238,24 @@ class="icon-delete cursor-pointer text-2xl"
238238
methods: {
239239
/**
240240
* Add the product.
241-
*
241+
*
242242
* @param {Object} result
243-
*
243+
*
244244
* @return {void}
245245
*/
246246
addProduct(result) {
247247
this.product.product_id = result.id;
248248
249249
this.product.name = result.name;
250-
250+
251251
this.product.price = result.price;
252-
252+
253253
this.product.quantity = result.quantity ?? 1;
254254
},
255-
255+
256256
/**
257257
* Remove the product.
258-
*
258+
*
259259
* @return {void}
260260
*/
261261
removeProduct () {

packages/Webkul/Admin/src/Resources/views/leads/view/products.blade.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,10 @@ class="secondary-button"
113113
<x-admin::table.tbody.tr class="border-b border-gray-200 align-top dark:border-gray-800">
114114
<!-- Product Name -->
115115
<x-admin::table.td class="!px-4">
116-
<v-form v-slot="{ errors }">
116+
<v-form v-slot="{ errors }" @keydown.enter.prevent>
117117
<x-admin::form.control-group class="!mb-0">
118-
<x-admin::lookup
118+
<x-admin::lookup
119+
::key="product.product_id"
119120
::src="src"
120121
name="name"
121122
::params="params"
@@ -133,15 +134,15 @@ class="secondary-button"
133134
:placeholder="trans('admin::app.leads.view.products.product-name')"
134135
::url="url(product)"
135136
/>
136-
137+
137138
<x-admin::form.control-group.error ::name="`${inputName}[product_id]`" />
138139
</x-admin::form.control-group>
139140
</v-form>
140141
</x-admin::table.td>
141142
142143
<!-- Product Quantity -->
143144
<x-admin::table.td class="!px-4 ltr:text-right rtl:text-left">
144-
<v-form v-slot="{ errors }">
145+
<v-form v-slot="{ errors }" @keydown.enter.prevent>
145146
<x-admin::form.control-group class="!mb-0">
146147
<x-admin::form.control-group.control
147148
type="inline"
@@ -162,7 +163,7 @@ class="secondary-button"
162163
163164
<!-- Price -->
164165
<x-admin::table.td class="!px-4 ltr:text-right rtl:text-left">
165-
<v-form v-slot="{ errors }">
166+
<v-form v-slot="{ errors }" @keydown.enter.prevent>
166167
<x-admin::form.control-group class="!mb-0">
167168
<x-admin::form.control-group.control
168169
type="inline"
@@ -184,7 +185,7 @@ class="secondary-button"
184185
185186
<!-- Total -->
186187
<x-admin::table.td class="!px-4 ltr:text-right rtl:text-left">
187-
<v-form v-slot="{ errors }">
188+
<v-form v-slot="{ errors }" @keydown.enter.prevent>
188189
<x-admin::form.control-group class="!mb-0">
189190
<x-admin::form.control-group.control
190191
type="inline"
@@ -193,7 +194,7 @@ class="secondary-button"
193194
rules="required|decimal:4"
194195
:label="trans('admin::app.leads.view.products.total')"
195196
:placeholder="trans('admin::app.leads.view.products.total')"
196-
::allowEdit="false"
197+
:allowEdit="false"
197198
::url="url(product)"
198199
position="left"
199200
::value-label="$admin.formatPrice(product.price * product.quantity)"

0 commit comments

Comments
 (0)