Skip to content

Commit

Permalink
Merge pull request #1333 from suraj-webkul/inline-edit-views
Browse files Browse the repository at this point in the history
add missing lang.
  • Loading branch information
jitendra-webkul authored Aug 8, 2024
2 parents 958d5a5 + 3cd32a8 commit d5f70cf
Show file tree
Hide file tree
Showing 43 changed files with 3,494 additions and 298 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function store(AttributeForm $request): RedirectResponse

Event::dispatch('contacts.person.create.after', $person);

session()->flash('success', trans('admin::app.contacts.persons.create-success'));
session()->flash('success', trans('admin::app.contacts.persons.index.create-success'));

return redirect()->route('admin.contacts.persons.index');
}
Expand Down Expand Up @@ -86,15 +86,21 @@ public function edit(int $id): View
/**
* Update the specified resource in storage.
*/
public function update(AttributeForm $request, int $id): RedirectResponse
public function update(AttributeForm $request, int $id): RedirectResponse|JsonResponse
{
Event::dispatch('contacts.person.update.before', $id);

$person = $this->personRepository->update($this->sanitizeRequestedPersonData($request->all()), $id);

Event::dispatch('contacts.person.update.after', $person);

session()->flash('success', trans('admin::app.contacts.persons.update-success'));
if (request()->ajax()) {
return response()->json([
'message' => trans('admin::app.contacts.persons.index.update-success'),
], 200);
}

session()->flash('success', trans('admin::app.contacts.persons.index.update-success'));

return redirect()->route('admin.contacts.persons.index');
}
Expand Down Expand Up @@ -126,11 +132,11 @@ public function destroy(int $id): JsonResponse
Event::dispatch('contacts.person.delete.after', $id);

return response()->json([
'message' => trans('admin::app.response.destroy-success', ['name' => trans('admin::app.contacts.persons.person')]),
'message' => trans('admin::app.response.destroy-success', ['name' => trans('admin::app.contacts.persons.index.person')]),
], 200);
} catch (\Exception $exception) {
return response()->json([
'message' => trans('admin::app.response.destroy-failed', ['name' => trans('admin::app.contacts.persons.person')]),
'message' => trans('admin::app.response.destroy-failed', ['name' => trans('admin::app.contacts.persons.index.person')]),
], 400);
}
}
Expand All @@ -151,7 +157,7 @@ public function massDestroy(MassDestroyRequest $massDestroyRequest): JsonRespons
}

return response()->json([
'message' => trans('admin::app.response.destroy-success', ['name' => trans('admin::app.contacts.persons.title')]),
'message' => trans('admin::app.response.destroy-success', ['name' => trans('admin::app.contacts.persons.index.title')]),
]);
}

Expand All @@ -160,7 +166,9 @@ public function massDestroy(MassDestroyRequest $massDestroyRequest): JsonRespons
*/
private function sanitizeRequestedPersonData(array $data): array
{
$data['contact_numbers'] = collect($data['contact_numbers'])->filter(fn ($number) => ! is_null($number['value']))->toArray();
if (isset($data['contact_numbers'])) {
$data['contact_numbers'] = collect($data['contact_numbers'])->filter(fn ($number) => ! is_null($number['value']))->toArray();
}

return $data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function update(LeadForm $request, $id)

$data = request()->all();

if ($data['lead_pipeline_stage_id']) {
if (isset($data['lead_pipeline_stage_id'])) {
$stage = $this->stageRepository->findOrFail($data['lead_pipeline_stage_id']);

$data['lead_pipeline_id'] = $stage->lead_pipeline_id;
Expand Down
11 changes: 8 additions & 3 deletions packages/Webkul/Admin/src/Resources/lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,13 @@
'contacts' => [
'persons' => [
'index' => [
'title' => 'Persons',
'create-btn' => 'Create Person',
'title' => 'Persons',
'create-btn' => 'Create Person',
'create-success' => 'Person created successfully.',
'update-success' => 'Person updated successfully.',
'delete-success' => 'Person deleted successfully.',
'delete-failed' => 'Person can not be deleted.',


'datagrid' => [
'contact-numbers' => 'Contact Numbers',
Expand All @@ -398,7 +403,7 @@

'view' => [
'title' => ':name',
'about-lead' => 'About Lead',
'about-person' => 'About Person',

'activities' => [
'index' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,38 @@
/>
@break


@case('multiselect')
<x-admin::attributes.edit.multiselect
:attribute="$attribute"
:value="$value"
:validations="$validations"
/>
@break

@case('price')
<x-admin::attributes.edit.price
:attribute="$attribute"
:value="$value"
:validations="$validations"
/>
@break
{{--
@case('image')
<x-admin::attributes.edit.image
:attribute="$attribute"
:value="$value"
:validations="$validations"
/>
@break
@case('file')
<x-admin::attributes.edit.file
:attribute="$attribute"
:value="$value"
:validations="$validations"
/>
@break --}}

@case('textarea')
<x-admin::attributes.edit.textarea
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
<select
v-validate="'{{$validations}}'"
class="control"
@php
$options = $attribute->lookup_type
? app('Webkul\Attribute\Repositories\AttributeRepository')->getLookUpOptions($attribute->lookup_type)
: $attribute->options()->orderBy('sort_order')->get();
$selectedOption = old($attribute->code) ?: $value;
@endphp

<v-field
type="select"
id="{{ $attribute->code }}"
name="{{ $attribute->code }}[]"
data-vv-as="&quot;{{ $attribute->name }}&quot;"
rules="{{ $validations }}"
label="{{ $attribute->name }}"
placeholder="{{ $attribute->name }}"
multiple
value="{{ $selectedOption }}"
>
@php
$options = $attribute->lookup_type
? app('Webkul\Attribute\Repositories\AttributeRepository')->getLookUpOptions($attribute->lookup_type)
: $attribute->options()->orderBy('sort_order')->get();
$selectedOption = old($attribute->code) ?: $value;
@endphp

@foreach ($options as $option)
<option
value="{{ $option->id }}"
{{ in_array($option->id, explode(',', $selectedOption)) ? 'selected' : ''}}
>
{{ $option->name }}
</option>
@endforeach
</select>
<select
name="{{ $attribute->code }}[]"
class="flex min-h-[39px] w-full rounded-md border px-3 py-2 text-sm text-gray-600 transition-all hover:border-gray-400 focus:border-gray-400 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-300 dark:hover:border-gray-400 dark:focus:border-gray-400"
:class="[errors['options[sort]'] ? 'border border-red-600 hover:border-red-600' : '']"
multiple
>
@foreach ($options as $option)
<option
value="{{ $option->id }}"
{{ in_array($option->id, explode(',', $selectedOption)) ? 'selected' : ''}}
>
{{ $option->name }}
</option>
@endforeach
</select>
</v-field>
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class="cursor-pointer text-brandColor"
},
watch: {
value(newVal, oldVal) {
if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
this.contactNumbers = newVal || [{'value': '', 'label': 'work'}];
value(newValue, oldValue) {
if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
this.contactNumbers = newValue || [{'value': '', 'label': 'work'}];
}
},
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'customAttributes' => [],
'entity' => null,
'allowEdit' => false,
'url' => null,
])

<div class="flex flex-col gap-2">
Expand All @@ -13,7 +14,9 @@
<div class="font-medium">
@include ($typeView, [
'attribute' => $attribute,
'value' => isset($entity) ? $entity[$attribute->code] : null
'value' => isset($entity) ? $entity[$attribute->code] : null,
'allowEdit' => $allowEdit,
'url' => $url,
])
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
@if ($value)
{{ $value['address'] }}<br>
{{ $value['postcode'] . ' ' . $value['city'] }}<br>
{{ core()->state_name($value['state']) }}<br>
{{ core()->country_name($value['country']) }}<br>
@else
{{ __('admin::app.common.not-available') }}
@endif
<x-admin::form.control-group.controls.inline.address
::name="'{{ $attribute->code }}'"
:value="$value"
rules="required"
position="left"
:label="$attribute->name"
::errors="errors"
:placeholder="$attribute->name"
:url="$url"
/>
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
{{ $value ? __('admin::app.common.yes') : __('admin::app.common.no') }}
<x-admin::form.control-group.controls.inline.boolean
::name="'{{ $attribute->code }}'"
:value="json_encode($value)"
rules="required"
position="left"
:label="$attribute->name"
::errors="errors"
:placeholder="$attribute->name"
:url="$url"
/>
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
@php
$options = $attribute->lookup_type
? app('Webkul\Attribute\Repositories\AttributeRepository')->getLookUpEntity($attribute->lookup_type, explode(',', $value))
: $attribute->options()->whereIn('id', explode(',', $value))->get();
? app('Webkul\Attribute\Repositories\AttributeRepository')->getLookUpOptions($attribute->lookup_type)
: $attribute->options()->orderBy('sort_order')->get();
$selectedOption = old($attribute->code) ?: $value;
@endphp

@if (count($options))
@foreach ($options as $option)
<span class="multi-value">{{ $option->name }}</span>
@endforeach
@else
{{ __('admin::app.common.not-available') }}
@endif
<x-admin::form.control-group.controls.inline.multiselect
::name="'{{ $attribute->code }}'"
::value="'{{ $selectedOption }}'"
:data="$options"
rules="required"
position="left"
:label="$attribute->name"
::errors="errors"
:placeholder="$attribute->name"
:url="$url"
/>
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
{{ $value ?? __('admin::app.common.not-available')}}
<x-admin::form.control-group.controls.inline.date
::name="'{{ $attribute->code }}'"
::value="'{{ $value }}'"
rules="required"
position="left"
:label="$attribute->name"
::errors="errors"
:placeholder="$attribute->name"
:url="$url"
/>
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
{{ $value ?? __('admin::app.common.not-available')}}
<x-admin::form.control-group.controls.inline.datetime
::name="'{{ $attribute->code }}'"
::value="'{{ $value }}'"
rules="required"
position="left"
:label="$attribute->name"
::errors="errors"
:placeholder="$attribute->name"
:url="$url"
/>
Loading

0 comments on commit d5f70cf

Please sign in to comment.