From 5d478bda6a3bd610aeefb5f7cb6bd7c6c3a6440a Mon Sep 17 00:00:00 2001 From: marco76tv Date: Tue, 18 Apr 2023 12:10:29 +0200 Subject: [PATCH 01/19] up --- Models/MenuItem.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Models/MenuItem.php b/Models/MenuItem.php index e953ceb26..ad4d83d9f 100755 --- a/Models/MenuItem.php +++ b/Models/MenuItem.php @@ -19,6 +19,9 @@ * @property int $id * @property string|null $label * @property string|null $link + * @property string $roles + * @property string $icon + * @property bool $active * @property int|null $menu * @property int|null $sort * @property int|null $parent @@ -66,7 +69,10 @@ class MenuItem extends Model { 'menu', 'depth', 'role_id', - 'allowed_roles', + // 'allowed_roles', + 'roles', + 'active', + 'icon', ]; /** @@ -84,7 +90,10 @@ class MenuItem extends Model { 'menu' => 'int', 'depth' => 'int', 'role_id' => 'int', - 'allowed_roles' => 'string', + // 'allowed_roles' => 'string', + 'roles' => 'string', + 'active' => 'bool', + 'icon' => 'string', ]; /* public function __construct(array $attributes = []) @@ -126,7 +135,8 @@ public function getRows(): array { 'menu' => 0, 'depth' => 0, 'role_id' => 0, - 'allowed_roles' => '', + // 'allowed_roles' => '', + 'roles' => '', ], ]; } From 663b5dc53068746e2a7eb3e35ddff2badb179fad Mon Sep 17 00:00:00 2001 From: marco76tv Date: Tue, 18 Apr 2023 14:41:59 +0200 Subject: [PATCH 02/19] up --- Actions/GetRulesWithParamsAction.php | 45 ++++++++++----------------- Datas/FieldData.php | 2 +- Http/Livewire/Progressbar.php | 5 +++ View/Components/Promo/CounterItem.php | 6 ++-- View/Components/Table/Th/Spatie.php | 24 ++++++-------- 5 files changed, 35 insertions(+), 47 deletions(-) diff --git a/Actions/GetRulesWithParamsAction.php b/Actions/GetRulesWithParamsAction.php index 53f5decfa..468d4b738 100644 --- a/Actions/GetRulesWithParamsAction.php +++ b/Actions/GetRulesWithParamsAction.php @@ -1,47 +1,37 @@ getMethods(ReflectionMethod::IS_PUBLIC)) + $r = collect($validatorClass->getMethods(\ReflectionMethod::IS_PUBLIC)) ->filter(function ($method) { return Str::startsWith($method->name, 'validate'); }) ->map(function ($method) { - - //$param_names = collect($method->getParameters())->pluck('name', 'name')->except(['attribute', 'value']); + // $param_names = collect($method->getParameters())->pluck('name', 'name')->except(['attribute', 'value']); $method_name = str_replace('validate_', '', Str::snake($method->name)); $params = $this->getParamsType($method_name); if (null != $params) { - - $start = strpos($method->getDocComment(), 'Validate'); - $end = strpos($method->getDocComment(), '@'); + $start = strpos((string) $method->getDocComment(), 'Validate'); + $end = strpos((string) $method->getDocComment(), '@'); $comment = ''; if (is_int($start)) { - $comment = substr($method->getDocComment(), $start, $end - $start); + $comment = substr((string) $method->getDocComment(), $start, $end - $start); $comment = preg_replace('/\s\s+/', ' ', $comment); $comment = str_replace('* ', '', $comment); $comment = trim($comment); @@ -50,24 +40,22 @@ public function execute(): array return [ 'name' => $method_name, 'comment' => $comment, - 'params' => $params + 'params' => $params, ]; } })->filter(function ($v) { - return $v !== null; + return null !== $v; })->toArray(); - //dd($r); + // dd($r); return $r; } /** - * @param string $method_name * @return array|null */ - public function getParamsType(string $method_name) - { + public function getParamsType(string $method_name) { $parameters = [ 'accepted' => [''], 'active_url' => [''], @@ -83,14 +71,14 @@ public function getParamsType(string $method_name) 'date_equals' => ['date' => 'text'], 'decimal' => [ 'min' => 'number', - 'max' => 'number' + 'max' => 'number', ], 'declined' => [''], 'different' => ['field' => 'text'], 'digits' => ['value' => 'number'], 'digits_between' => [ 'min' => 'number', - 'max' => 'number' + 'max' => 'number', ], 'email' => [''], 'filled' => [''], @@ -123,7 +111,6 @@ public function getParamsType(string $method_name) 'uppercase' => [''], 'url' => [''], 'uuid' => [''], - ]; if (isset($parameters[$method_name])) { @@ -131,6 +118,6 @@ public function getParamsType(string $method_name) } return null; - //return ['json' => 'json']; + // return ['json' => 'json']; } } diff --git a/Datas/FieldData.php b/Datas/FieldData.php index 973b66673..18449ec06 100755 --- a/Datas/FieldData.php +++ b/Datas/FieldData.php @@ -71,7 +71,7 @@ public function getLabel(): string { $trans_key = 'pub_theme::txt.'.$this->name.'.label'; $trans = trans($trans_key); if ($trans != $trans_key) { - $this->label = $trans; + $this->label = (string) $trans; return $trans; } diff --git a/Http/Livewire/Progressbar.php b/Http/Livewire/Progressbar.php index ff58c58a8..dc26d5147 100755 --- a/Http/Livewire/Progressbar.php +++ b/Http/Livewire/Progressbar.php @@ -59,6 +59,11 @@ public function init(): void { } } + /** + * Undocumented function. + * + * @return mixed + */ public function complete() { if ('true' === $this->autocomplete && '' != $this->onComplete) { return $this->{$this->onComplete}(); diff --git a/View/Components/Promo/CounterItem.php b/View/Components/Promo/CounterItem.php index 7e959dd20..d5071e899 100644 --- a/View/Components/Promo/CounterItem.php +++ b/View/Components/Promo/CounterItem.php @@ -5,6 +5,7 @@ namespace Modules\UI\View\Components\Promo; use Illuminate\View\Component; +use Modules\Cms\Actions\GetViewAction; /** * Undocumented class. @@ -29,8 +30,9 @@ public function __construct(int $counter) { public function render() { $view = app(GetViewAction::class)->execute(); $view_params = [ - 'view'=>$view + 'view' => $view, ]; - return view($view,$view_params ); + + return view($view, $view_params); } } diff --git a/View/Components/Table/Th/Spatie.php b/View/Components/Table/Th/Spatie.php index a5e5ccc9b..914ca8c84 100644 --- a/View/Components/Table/Th/Spatie.php +++ b/View/Components/Table/Th/Spatie.php @@ -4,15 +4,12 @@ namespace Modules\UI\View\Components\Table\Th; - +use Illuminate\Contracts\Support\Renderable; use Illuminate\Support\Str; use Illuminate\View\Component; use Modules\Cms\Actions\GetViewAction; -use Illuminate\Contracts\Support\Renderable; -use Modules\Cms\Actions\GetStyleClassByViewAction; -class Spatie extends Component -{ +class Spatie extends Component { public string $name; public string $tpl; @@ -20,12 +17,11 @@ class Spatie extends Component public string $label; public string $icon; - public function __construct(string $name, string $tpl = 'v1') - { + public function __construct(string $name, string $tpl = 'v1') { $this->name = $name; $this->tpl = $tpl; $icon = ''; - $sort = request('sort', ''); + $sort = (string) request('sort', ''); $sort_by = $sort; $order = 'asc'; if (Str::startsWith($sort_by, '-')) { @@ -33,13 +29,12 @@ public function __construct(string $name, string $tpl = 'v1') $order = 'desc'; $sort = $name; } else { - $sort = '-' . $name; + $sort = '-'.$name; } if ($sort_by == $name) { - $icon = ' '; + .('asc' == $order ? 'up' : 'down') + .'">'; } $url = request()->fullUrlWithQuery([ @@ -51,12 +46,11 @@ public function __construct(string $name, string $tpl = 'v1') $this->icon = $icon; } - public function render(): Renderable - { + public function render(): Renderable { /** * @phpstan-var view-string */ - $view = app(GetViewAction::class)->execute($this->tpl); + $view = app(GetViewAction::class)->execute($this->tpl); $view_params = []; From 5a006ef34500eb483eb735d2d47988b32259912b Mon Sep 17 00:00:00 2001 From: marco76tv Date: Tue, 18 Apr 2023 15:06:15 +0200 Subject: [PATCH 03/19] up --- Actions/GetRulesWithParamsAction.php | 2 +- Datas/FieldData.php | 5 ++++- Http/Livewire/Input/Email/Verified.php | 2 +- Http/Livewire/Input/Sms/Verified.php | 7 +++---- View/Components/Input/Freeze.php | 7 ++++--- View/Components/Input/Label.php | 6 +++++- View/Components/Table/Th/Spatie.php | 2 +- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Actions/GetRulesWithParamsAction.php b/Actions/GetRulesWithParamsAction.php index 468d4b738..2bcc66813 100644 --- a/Actions/GetRulesWithParamsAction.php +++ b/Actions/GetRulesWithParamsAction.php @@ -33,7 +33,7 @@ public function execute(): array { if (is_int($start)) { $comment = substr((string) $method->getDocComment(), $start, $end - $start); $comment = preg_replace('/\s\s+/', ' ', $comment); - $comment = str_replace('* ', '', $comment); + $comment = str_replace('* ', '', (string) $comment); $comment = trim($comment); } diff --git a/Datas/FieldData.php b/Datas/FieldData.php index 18449ec06..9ba997641 100755 --- a/Datas/FieldData.php +++ b/Datas/FieldData.php @@ -71,7 +71,10 @@ public function getLabel(): string { $trans_key = 'pub_theme::txt.'.$this->name.'.label'; $trans = trans($trans_key); if ($trans != $trans_key) { - $this->label = (string) $trans; + if (! is_string($trans)) { + throw new \Exception('['.__LINE__.']['.__FILE__.']'); + } + $this->label = $trans; return $trans; } diff --git a/Http/Livewire/Input/Email/Verified.php b/Http/Livewire/Input/Email/Verified.php index 2ddb14cf7..91cc7c337 100644 --- a/Http/Livewire/Input/Email/Verified.php +++ b/Http/Livewire/Input/Email/Verified.php @@ -42,7 +42,7 @@ public function mount(?string $tpl = 'v1', ?array $attrs = []) { $this->myEmailAddresses(); } - public static function getName() { + public static function getName(): string { return 'input.email.verified'; } diff --git a/Http/Livewire/Input/Sms/Verified.php b/Http/Livewire/Input/Sms/Verified.php index 72e1973de..d18d59a13 100644 --- a/Http/Livewire/Input/Sms/Verified.php +++ b/Http/Livewire/Input/Sms/Verified.php @@ -35,14 +35,13 @@ class Verified extends Component { * @return void */ public function mount(?string $tpl = 'v1', ?array $attrs = []) { - // non sapevo in che altro modo passarlo $this->user_id = (string) Auth::id(); $this->form_data = (array) session()->get('form_data') ?? []; $this->tpl = $tpl; $this->mySmsAddresses(); } - public static function getName() { + public static function getName(): string { return 'input.sms.verified'; } @@ -73,9 +72,9 @@ public function verify_sms(): void { return; } $row = new Contact(); - $row->token = $this->form_data['confirm_token']; + $row->token = (string) $this->form_data['confirm_token']; $row->model_type = 'profile'; - $row->model_id = ProfileService::make()->getProfile()->id; + $row->model_id = ProfileService::make()->getProfile()?->id; $row->user_id = $this->user_id; $row->contact_type = 'mobile'; $row->value = $this->form_data['add_mobile']; diff --git a/View/Components/Input/Freeze.php b/View/Components/Input/Freeze.php index 9c68e90c3..ebc97b9b0 100755 --- a/View/Components/Input/Freeze.php +++ b/View/Components/Input/Freeze.php @@ -92,7 +92,7 @@ public function render(): Renderable { if (is_string($this->value) && class_exists($this->value)) { // && $this->value instanceof \Spatie\ModelStates\State $reflection_class = new \ReflectionClass($this->value); - $parent = $reflection_class?->getParentClass(); + $parent = $reflection_class->getParentClass(); // dddx([ // 'value_type' => $value_type, @@ -102,7 +102,7 @@ public function render(): Renderable { // 'rf_parent' => $reflection_class->getParentClass()->getName(), // ]); - if (false != $parent && false != $parent?->getParentClass()) { + if (false != $parent && false != $parent->getParentClass()) { $str = $parent ->getParentClass() ->getName(); @@ -113,7 +113,8 @@ public function render(): Renderable { break; default: throw new \Exception('['.$str.']['.__LINE__.']['.__FILE__.']'); - break; + // Unreachable statement - code above always terminates. + // break; } } } diff --git a/View/Components/Input/Label.php b/View/Components/Input/Label.php index ecd954f77..2a17748bd 100755 --- a/View/Components/Input/Label.php +++ b/View/Components/Input/Label.php @@ -72,12 +72,16 @@ public function renderData(array $data): string { $this->attrs['class'] = app(GetStyleClassByViewAction::class)->execute($view); if (isset($attributes) && is_object($attributes)) { + /*75 Call to an undefined method object::get(). + 76 Call to an undefined method object::get(). + 77 Call to an undefined method object::get(). + */ $label = $attributes->get('label'); $name = $attributes->get('name'); $this->attrs['for'] = $attributes->get('id'); } - if (isset($name) && !isset($label)) { + if (isset($name) && ! isset($label)) { $trans_key = $this->tradKey.'.'.$name.'.label'; $label = trans($trans_key); // if ($trans_key == $name_lang) { diff --git a/View/Components/Table/Th/Spatie.php b/View/Components/Table/Th/Spatie.php index 914ca8c84..de6862770 100644 --- a/View/Components/Table/Th/Spatie.php +++ b/View/Components/Table/Th/Spatie.php @@ -21,7 +21,7 @@ public function __construct(string $name, string $tpl = 'v1') { $this->name = $name; $this->tpl = $tpl; $icon = ''; - $sort = (string) request('sort', ''); + $sort = strval(request('sort', '')); $sort_by = $sort; $order = 'asc'; if (Str::startsWith($sort_by, '-')) { From 02dcaacfeb8de1460f94eb678a3052397f94fea6 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Tue, 18 Apr 2023 23:07:20 +0200 Subject: [PATCH 04/19] up --- Datas/FieldData.php | 25 ++++++++++--- Http/Livewire/Input/Email/Verified.php | 49 ++++++++++++++++++-------- Http/Livewire/Input/Sms/Verified.php | 46 ++++++++++++++++-------- Models/Menu.php | 2 -- Models/MenuItem.php | 2 -- 5 files changed, 87 insertions(+), 37 deletions(-) diff --git a/Datas/FieldData.php b/Datas/FieldData.php index 9ba997641..0fc788434 100755 --- a/Datas/FieldData.php +++ b/Datas/FieldData.php @@ -8,7 +8,8 @@ use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; -class FieldData extends Data { +class FieldData extends Data +{ public string $name; public ?string $label = null; public ?string $name_dot = null; @@ -58,13 +59,15 @@ public function __construct( } */ - public function getNameDot(): string { + public function getNameDot(): string + { $this->name_dot = bracketsToDotted($this->name); return $this->name_dot; } - public function getLabel(): string { + public function getLabel(): string + { if (null !== $this->label) { return $this->label; } @@ -82,20 +85,32 @@ public function getLabel(): string { return $this->name; } - public function getInputClass(): string { + public function getInputClass(): string + { return 'form-control'; } /** * @return DataCollection */ - public function getFields(?string $act = null): DataCollection { + public function getFields(?string $act = null): DataCollection + { if (null == $act) { $act = RouteService::getAct(); } + if (null == $this->fields) { + throw new \Exception('['.__LINE__.']['.__FILE__.']'); + } return $this->fields->filter( + /** + * @param FieldData $item + */ function ($item) use ($act) { + if (! $item instanceof FieldData) { + throw new \Exception('['.__LINE__.']['.__FILE__.']'); + } + return ! in_array($act, $item->except); } ); diff --git a/Http/Livewire/Input/Email/Verified.php b/Http/Livewire/Input/Email/Verified.php index 91cc7c337..63506efac 100644 --- a/Http/Livewire/Input/Email/Verified.php +++ b/Http/Livewire/Input/Email/Verified.php @@ -19,12 +19,13 @@ /** * Class Arr // Array is reserved. */ -class Verified extends Component { +class Verified extends Component +{ use InteractsWithConfirmationModal; public array $form_data = []; public int $step = 2; - public ?string $tpl = ''; + public string $tpl = ''; public string $user_id = ''; public Collection $my_validated_email_addresses; public array $attrs = []; @@ -34,29 +35,38 @@ class Verified extends Component { * * @return void */ - public function mount(?string $tpl = 'v1', ?array $attrs = []) { + public function mount(string $tpl = 'v1') + { // non sapevo in che altro modo passarlo $this->user_id = (string) Auth::id(); - $this->form_data = session()->get('form_data') ?? []; + $form_data = session()->get('form_data'); + if (! is_array($form_data)) { + $form_data = []; + } + $this->form_data = $form_data; $this->tpl = $tpl; $this->myEmailAddresses(); } - public static function getName(): string { + public static function getName(): string + { return 'input.email.verified'; } - public function myEmailAddresses(): void { + public function myEmailAddresses(): void + { $this->my_validated_email_addresses = Contact::where('user_id', $this->user_id)->where('contact_type', 'email')->where('verified_at', '!=', null)->get(); // Debugbar::info($this->my_validated_email_addresses); } - public function updateFormData(): void { + public function updateFormData(): void + { $this->emit('updateFormData', $this->form_data); } - public function verify_email(): void { - $this->form_data['confirm_token'] = rand(10000, 99999); + public function verify_email(): void + { + $this->form_data['confirm_token'] = strval(rand(10000, 99999)); if (Contact::where('user_id', $this->user_id)->where('contact_type', 'email')->where('verified_at', '!=', null)->firstWhere('value', $this->form_data['add_email'])) { $this->askForConfirmation( @@ -76,21 +86,30 @@ public function verify_email(): void { $row = new Contact(); $row->token = $this->form_data['confirm_token']; $row->model_type = 'profile'; - $row->model_id = ProfileService::make()->getProfile()->id; + $row->model_id = strval(ProfileService::make()->getProfile()->id); $row->user_id = $this->user_id; $row->contact_type = 'email'; $row->value = $this->form_data['add_email']; $row->save(); - Notification::route('mail', $row->value)->notify(new HtmlNotification(config('mail.from.address'), 'Verify Email Address', '

Verification Code

'.$row->token.'

')); + Notification::route('mail', $row->value)->notify(new HtmlNotification(strval(config('mail.from.address')), 'Verify Email Address', '

Verification Code

'.$row->token.'

')); $this->step = 3; } - public function verify_code() { + /** + * Undocumented function. + * + * @return void + */ + public function verify_code() + { $is_valid_contact = Contact::where('user_id', $this->user_id)->where('contact_type', 'email')->where('verified_at', null)->where('value', $this->form_data['add_email'])->where('token', $this->form_data['token'] ?? '')->get(); if (false == $is_valid_contact->isEmpty()) { $row = $is_valid_contact->first(); + if (null == $row) { + throw new \Exception('['.__LINE__.']['.__FILE__.']'); + } $row->verified_at = now(); $row->save(); @@ -107,14 +126,16 @@ public function verify_code() { $this->myEmailAddresses(); } - public function add() { + public function add(): void + { $this->step = 2; } /** * Undocumented function. */ - public function render(): Renderable { + public function render(): Renderable + { /** * @phpstan-var view-string */ diff --git a/Http/Livewire/Input/Sms/Verified.php b/Http/Livewire/Input/Sms/Verified.php index d18d59a13..36bd3376a 100644 --- a/Http/Livewire/Input/Sms/Verified.php +++ b/Http/Livewire/Input/Sms/Verified.php @@ -19,12 +19,13 @@ /** * Class Arr // Array is reserved. */ -class Verified extends Component { +class Verified extends Component +{ use InteractsWithConfirmationModal; public array $form_data = []; public int $step = 2; - public ?string $tpl = ''; + public string $tpl; public string $user_id = ''; public Collection $my_validated_sms_addresses; public array $attrs = []; @@ -34,28 +35,33 @@ class Verified extends Component { * * @return void */ - public function mount(?string $tpl = 'v1', ?array $attrs = []) { + public function mount(string $tpl = 'v1') + { $this->user_id = (string) Auth::id(); - $this->form_data = (array) session()->get('form_data') ?? []; + $this->form_data = (array) session()->get('form_data', []); $this->tpl = $tpl; $this->mySmsAddresses(); } - public static function getName(): string { + public static function getName(): string + { return 'input.sms.verified'; } - public function mySmsAddresses(): void { + public function mySmsAddresses(): void + { $this->my_validated_sms_addresses = Contact::where('user_id', $this->user_id)->where('contact_type', 'mobile')->where('verified_at', '!=', null)->get(); // Debugbar::info($this->my_validated_email_addresses); } - public function updateFormData(): void { + public function updateFormData(): void + { $this->emit('updateFormData', $this->form_data); } - public function verify_sms(): void { - $this->form_data['confirm_token'] = rand(10000, 99999); + public function verify_sms(): void + { + $this->form_data['confirm_token'] = strval(rand(10000, 99999)); if (Contact::where('user_id', $this->user_id)->where('contact_type', 'mobile')->where('verified_at', '!=', null)->firstWhere('value', $this->form_data['add_mobile'])) { $this->askForConfirmation( @@ -74,8 +80,8 @@ public function verify_sms(): void { $row = new Contact(); $row->token = (string) $this->form_data['confirm_token']; $row->model_type = 'profile'; - $row->model_id = ProfileService::make()->getProfile()?->id; - $row->user_id = $this->user_id; + $row->model_id = strval(ProfileService::make()->getProfile()->id); + $row->user_id = (string) $this->user_id; $row->contact_type = 'mobile'; $row->value = $this->form_data['add_mobile']; $row->save(); @@ -87,7 +93,13 @@ public function verify_sms(): void { $this->step = 3; } - public function verify_code() { + /** + * Undocumented function. + * + * @return void + */ + public function verify_code() + { $is_valid_contact = Contact::where('user_id', $this->user_id)->where('contact_type', 'mobile')->where('verified_at', null)->where('value', $this->form_data['add_mobile'])->where('token', $this->form_data['token'] ?? '')->get(); // 73 Called 'isEmpty' on Laravel collection, but could have been retrieved as a query. @@ -95,6 +107,10 @@ public function verify_code() { $row = $is_valid_contact->first(); $row = $is_valid_contact->first(); + if (null == $row) { + throw new \Exception('['.__LINE__.']['.__FILE__.']'); + } + // Access to an undefined property Modules\Notify\Models\Contact::$verified_at $row->verified_at = now(); $row->save(); @@ -111,14 +127,16 @@ public function verify_code() { $this->mySmsAddresses(); } - public function add() { + public function add(): void + { $this->step = 2; } /** * Undocumented function. */ - public function render(): Renderable { + public function render(): Renderable + { /** * @phpstan-var view-string */ diff --git a/Models/Menu.php b/Models/Menu.php index 6873b814c..ad2462713 100755 --- a/Models/Menu.php +++ b/Models/Menu.php @@ -19,13 +19,11 @@ * @property string|null $name * @property \Illuminate\Database\Eloquent\Collection|\Modules\UI\Models\MenuItem[] $items * @property int|null $items_count - * * @method static Builder|Menu newModelQuery() * @method static Builder|Menu newQuery() * @method static Builder|Menu query() * @method static Builder|Menu whereId($value) * @method static Builder|Menu whereName($value) - * * @mixin \Eloquent */ class Menu extends Model diff --git a/Models/MenuItem.php b/Models/MenuItem.php index ad4d83d9f..b805a9467 100755 --- a/Models/MenuItem.php +++ b/Models/MenuItem.php @@ -31,7 +31,6 @@ * @property Collection|MenuItem[] $child * @property int|null $child_count * @property \Modules\UI\Models\Menu|null $parent_menu - * * @method static \Illuminate\Database\Eloquent\Builder|MenuItem newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|MenuItem newQuery() * @method static \Illuminate\Database\Eloquent\Builder|MenuItem query() @@ -44,7 +43,6 @@ * @method static \Illuminate\Database\Eloquent\Builder|MenuItem whereParent($value) * @method static \Illuminate\Database\Eloquent\Builder|MenuItem whereRoleId($value) * @method static \Illuminate\Database\Eloquent\Builder|MenuItem whereSort($value) - * * @mixin \Eloquent */ class MenuItem extends Model { From ce3286edb8ae7b9bc83553d3973cfa6ef52c8d14 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Wed, 19 Apr 2023 21:40:25 +0200 Subject: [PATCH 05/19] up --- View/Components/Card.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/View/Components/Card.php b/View/Components/Card.php index 94bdd27cd..ef91362c4 100755 --- a/View/Components/Card.php +++ b/View/Components/Card.php @@ -8,16 +8,19 @@ use Illuminate\View\Component; use Modules\Cms\Actions\GetViewAction; -class Card extends Component { +class Card extends Component +{ public string $tpl; // = 'card'; public array $attrs = []; - public function __construct(string $tpl = 'card') { + public function __construct(string $tpl = 'card') + { $this->tpl = $tpl; } - public function render(): Renderable { + public function render(): Renderable + { /** * @phpstan-var view-string */ From d8bfb4dc852ce04344cdbb85cb31a324d203d525 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Thu, 20 Apr 2023 23:08:04 +0200 Subject: [PATCH 06/19] up --- Actions/GetRulesWithParamsAction.php | 64 ++++++++++--------- Actions/GetViewAction.php | 17 +++-- .../fields/cell/collapse/field.blade.php | 44 ++++++------- .../fields/cell/field_collapse.blade.php | 59 +++++++++-------- .../fields/cell/field_label.blade.php | 44 ++++++------- .../fields/cell/label/field.blade.php | 10 +-- .../fields/select/field_parent.blade.php | 37 ++++++----- .../default/admin/create_ajax/item.blade.php | 13 ++-- .../default/admin/index_attach/item.blade.php | 62 +++++++++--------- 9 files changed, 187 insertions(+), 163 deletions(-) diff --git a/Actions/GetRulesWithParamsAction.php b/Actions/GetRulesWithParamsAction.php index 2bcc66813..51a3b4d30 100644 --- a/Actions/GetRulesWithParamsAction.php +++ b/Actions/GetRulesWithParamsAction.php @@ -8,44 +8,47 @@ use Illuminate\Validation\Concerns\ValidatesAttributes; use Spatie\QueueableAction\QueueableAction; -class GetRulesWithParamsAction { +class GetRulesWithParamsAction +{ use QueueableAction; - public function execute(): array { + public function execute(): array + { $validatorClass = new \ReflectionClass(ValidatesAttributes::class); $r = collect($validatorClass->getMethods(\ReflectionMethod::IS_PUBLIC)) ->filter(function ($method) { return Str::startsWith($method->name, 'validate'); }) - ->map(function ($method) { - // $param_names = collect($method->getParameters())->pluck('name', 'name')->except(['attribute', 'value']); - - $method_name = str_replace('validate_', '', Str::snake($method->name)); - - $params = $this->getParamsType($method_name); - - if (null != $params) { - $start = strpos((string) $method->getDocComment(), 'Validate'); - $end = strpos((string) $method->getDocComment(), '@'); - - $comment = ''; - if (is_int($start)) { - $comment = substr((string) $method->getDocComment(), $start, $end - $start); - $comment = preg_replace('/\s\s+/', ' ', $comment); - $comment = str_replace('* ', '', (string) $comment); - $comment = trim($comment); + ->map( + function ($method) { + // $param_names = collect($method->getParameters())->pluck('name', 'name')->except(['attribute', 'value']); + + $method_name = str_replace('validate_', '', Str::snake($method->name)); + + $params = $this->getParamsType($method_name); + + if (null != $params) { + $start = strpos((string) $method->getDocComment(), 'Validate'); + $end = strpos((string) $method->getDocComment(), '@'); + + $comment = ''; + if (is_int($start)) { + $comment = substr((string) $method->getDocComment(), $start, $end - $start); + $comment = preg_replace('/\s\s+/', ' ', $comment); + $comment = str_replace('* ', '', (string) $comment); + $comment = trim($comment); + } + + return [ + 'name' => $method_name, + 'comment' => $comment, + 'params' => $params, + ]; } - - return [ - 'name' => $method_name, - 'comment' => $comment, - 'params' => $params, - ]; - } - })->filter(function ($v) { - return null !== $v; - })->toArray(); + })->filter(function ($v) { + return null !== $v; + })->toArray(); // dd($r); @@ -55,7 +58,8 @@ public function execute(): array { /** * @return array|null */ - public function getParamsType(string $method_name) { + public function getParamsType(string $method_name) + { $parameters = [ 'accepted' => [''], 'active_url' => [''], diff --git a/Actions/GetViewAction.php b/Actions/GetViewAction.php index 65aa3cd51..ed0838209 100644 --- a/Actions/GetViewAction.php +++ b/Actions/GetViewAction.php @@ -8,13 +8,15 @@ use Modules\Xot\Services\FileService; use Spatie\QueueableAction\QueueableAction; -class GetViewAction { +class GetViewAction +{ use QueueableAction; /** * PER ORA FUNZIONA SOLO CON LIVEWIRE. */ - public function execute(string $tpl = ''): string { + public function execute(string $tpl = ''): string + { $backtrace = debug_backtrace(); $file0 = FileService::fixpath($backtrace[0]['file'] ?? ''); $file0 = Str::after($file0, base_path()); @@ -29,12 +31,13 @@ public function execute(string $tpl = ''): string { $mod = $arr[1]; $tmp = array_slice($arr, 3); - $tmp = collect($tmp)->map(function ($item) { - $item = str_replace('.php', '', $item); - $item = Str::slug(Str::snake($item)); + $tmp = collect($tmp)->map( + function ($item) { + $item = str_replace('.php', '', $item); + $item = Str::slug(Str::snake($item)); - return $item; - })->implode('.'); + return $item; + })->implode('.'); $view = Str::lower($mod).'::'.$tmp; if ('' != $tpl) { diff --git a/Resources/views/collective/fields/cell/collapse/field.blade.php b/Resources/views/collective/fields/cell/collapse/field.blade.php index 659c4f467..4d4fa98cd 100755 --- a/Resources/views/collective/fields/cell/collapse/field.blade.php +++ b/Resources/views/collective/fields/cell/collapse/field.blade.php @@ -1,29 +1,29 @@ @php -$fields = $attributes['fields']; -$model = Form::getModel(); -$disabled = isset($attributes['disabled']) ? 'disabled' : ''; -$fields = collect($fields) - ->filter(function ($item) { - if (!isset($item->except)) { - $item->except = []; - } - return //!in_array($item->type,['Password']) && - !in_array('edit', $item->except); //controllare azione route - //&& !in_array($item->name,$excepts) - }) - ->all(); -if ($disabled) { + $fields = $attributes['fields']; + $model = Form::getModel(); + $disabled = isset($attributes['disabled']) ? 'disabled' : ''; $fields = collect($fields) - ->map(function ($item) { - if (!isset($item->attributes)) { - $item->attributes = []; + ->filter(function ($item) { + if (!isset($item->except)) { + $item->except = []; } - $item->attributes = array_merge($item->attributes, ['readonly' => 'readonly']); - return $item; + return //!in_array($item->type,['Password']) && + !in_array('edit', $item->except); //controllare azione route + //&& !in_array($item->name,$excepts) }) ->all(); -} - + if ($disabled) { + $fields = collect($fields) + ->map(function ($item) { + if (!isset($item->attributes)) { + $item->attributes = []; + } + $item->attributes = array_merge($item->attributes, ['readonly' => 'readonly']); + return $item; + }) + ->all(); + } + @endphp

+

\ No newline at end of file + diff --git a/Resources/views/collective/fields/cell/field_label.blade.php b/Resources/views/collective/fields/cell/field_label.blade.php index 76429422f..bfc5e4079 100755 --- a/Resources/views/collective/fields/cell/field_label.blade.php +++ b/Resources/views/collective/fields/cell/field_label.blade.php @@ -1,29 +1,29 @@ @php -$fields = $attributes['fields']; -$model = Form::getModel(); -$disabled = isset($attributes['disabled']) ? 'disabled' : ''; -$fields = collect($fields) - ->filter(function ($item) { - if (!isset($item->except)) { - $item->except = []; - } - return //!in_array($item->type,['Password']) && - !in_array('edit', $item->except); //controllare azione route - //&& !in_array($item->name,$excepts) - }) - ->all(); -if ($disabled) { + $fields = $attributes['fields']; + $model = Form::getModel(); + $disabled = isset($attributes['disabled']) ? 'disabled' : ''; $fields = collect($fields) - ->map(function ($item) { - if (!isset($item->attributes)) { - $item->attributes = []; + ->filter(function ($item) { + if (!isset($item->except)) { + $item->except = []; } - $item->attributes = array_merge($item->attributes, ['readonly' => 'readonly']); - return $item; + return //!in_array($item->type,['Password']) && + !in_array('edit', $item->except); //controllare azione route + //&& !in_array($item->name,$excepts) }) ->all(); -} - + if ($disabled) { + $fields = collect($fields) + ->map(function ($item) { + if (!isset($item->attributes)) { + $item->attributes = []; + } + $item->attributes = array_merge($item->attributes, ['readonly' => 'readonly']); + return $item; + }) + ->all(); + } + @endphp
@@ -32,7 +32,7 @@
@foreach ($fields as $k => $field) - {!! Theme::inputHtml($field,$model) !!} + {!! Theme::inputHtml($field, $model) !!} @endforeach
diff --git a/Resources/views/collective/fields/cell/label/field.blade.php b/Resources/views/collective/fields/cell/label/field.blade.php index f04cb6a6d..dd7d43548 100755 --- a/Resources/views/collective/fields/cell/label/field.blade.php +++ b/Resources/views/collective/fields/cell/label/field.blade.php @@ -1,8 +1,8 @@ @php - - $row=Form::getModel(); + + $row = Form::getModel(); $fields = $attributes['fields']; - + //dddx([$attributes['fields'],$row]) /*$fields = $attributes['fields']; $model = Form::getModel(); @@ -18,7 +18,8 @@ ->all(); if ($disabled) { $fields = collect($fields) - ->map(function ($item) { + ->map( +function ($item) { if (!isset($item->attributes)) { $item->attributes = []; } @@ -28,6 +29,7 @@ ->all(); } */ + @endphp
diff --git a/Resources/views/collective/fields/select/field_parent.blade.php b/Resources/views/collective/fields/select/field_parent.blade.php index e1615543c..758727f4f 100755 --- a/Resources/views/collective/fields/select/field_parent.blade.php +++ b/Resources/views/collective/fields/select/field_parent.blade.php @@ -1,11 +1,12 @@ @php -/* + /* NOTA BENE: per utilizzare questo componente, la tabella/modello utilizzato deve avere un/il campo "parent_id" esempio di utilizzo -(object) [ +(object) +[ 'type' => 'SelectParent', 'name' => 'parent_id', 'comment' => null, @@ -13,17 +14,18 @@ ], */ -//dddx(get_defined_vars()); -//$options = []; -extract($attributes); -$field = transFields(get_defined_vars()); -//dddx($field); -$row = Form::getModel(); -//dddx($row); -$row_panel = Panel::make()->get($row); -$row_panel->setBuilder($row->with(['post'])); -/* - $options=$row->get()->map(function($item) use ($row_panel){ + //dddx(get_defined_vars()); + //$options = []; + extract($attributes); + $field = transFields(get_defined_vars()); + //dddx($field); + $row = Form::getModel(); + //dddx($row); + $row_panel = Panel::make()->get($row); + $row_panel->setBuilder($row->with(['post'])); + /* + $options=$row->get()->map( +function($item) use ($row_panel){ return [ 'id'=>$row_panel->optionId($item), 'parent_id'=>$item->parent_id, @@ -45,10 +47,11 @@ } $options=collect($tmp)->pluck('title','id')->prepend('Root',0); */ -$options = $row_panel->optionsTree(); - -//dddx($blade_component); -//dddx($options); + $options = $row_panel->optionsTree(); + + //dddx($blade_component); + //dddx($options); + @endphp @component($blade_component, get_defined_vars()) diff --git a/Resources/views/layouts/default/admin/create_ajax/item.blade.php b/Resources/views/layouts/default/admin/create_ajax/item.blade.php index 0f1f2ec9d..46bbe30a2 100755 --- a/Resources/views/layouts/default/admin/create_ajax/item.blade.php +++ b/Resources/views/layouts/default/admin/create_ajax/item.blade.php @@ -1,8 +1,8 @@ @php -if (!is_object($row)) { - return ''; -} -$fields = $_panel->getFields('create'); + if (!is_object($row)) { + return ''; + } + $fields = $_panel->getFields('create'); @endphp {!! Form::bsOpen($row, 'store') !!} @@ -10,7 +10,8 @@ @foreach ($fields as $field) {{-- @php $input='bs'.Str::studly($field->type); - $input_name=collect(explode('.',$field->name))->map(function ($v, $k){ + $input_name=collect(explode('.',$field->name))->map( +function ($v, $k){ return $k==0?$v:'['.$v.']'; })->implode(''); $input_value=(isset($field->value)?$field->value:null); @@ -18,7 +19,7 @@
{!! Form::$input($input_name,$input_value) !!}
--}} - {!! Theme::inputHtml($field,$row) !!} + {!! Theme::inputHtml($field, $row) !!} @endforeach diff --git a/Resources/views/layouts/default/admin/index_attach/item.blade.php b/Resources/views/layouts/default/admin/index_attach/item.blade.php index c28cb6e86..031fac6a9 100755 --- a/Resources/views/layouts/default/admin/index_attach/item.blade.php +++ b/Resources/views/layouts/default/admin/index_attach/item.blade.php @@ -1,32 +1,36 @@ -{!! Form::bsOpen($row,'store') !!} +{!! Form::bsOpen($row, 'store') !!}
-@php - //* - $excludes=$_panel->pivot_key_names; - $fields=collect($_panel->fields()) - ->filter(function($item) use($excludes) { - return !in_array($item->name,$excludes); - }) - ->all() - ; - //*/ - -@endphp -@foreach($fields as $field) -@php - $input='bs'.Str::studly($field->type); - $input_name=collect(explode('.',$field->name))->map(function ($v, $k){ - return $k==0?$v:'['.$v.']'; - })->implode(''); - $input_value=(isset($field->value)?$field->value:null); - if(!isset($field->col_size))$field->col_size=12; - if(!isset($field->attributes)) $field->attributes=[]; - $input_attrs=$field->attributes; -@endphp -
- {!! Form::$input($input_name,$input_value,$input_attrs) !!} -
-@endforeach + @php + //* +$excludes = $_panel->pivot_key_names; +$fields = collect($_panel->fields()) + ->filter(function ($item) use ($excludes) { + return !in_array($item->name, $excludes); + }) + ->all(); +//*/ + @endphp + @foreach ($fields as $field) + @php + $input = 'bs' . Str::studly($field->type); + $input_name = collect(explode('.', $field->name)) + ->map(function ($v, $k) { + return $k == 0 ? $v : '[' . $v . ']'; + }) + ->implode(''); + $input_value = isset($field->value) ? $field->value : null; + if (!isset($field->col_size)) { + $field->col_size = 12; + } + if (!isset($field->attributes)) { + $field->attributes = []; + } + $input_attrs = $field->attributes; + @endphp +
+ {!! Form::$input($input_name, $input_value, $input_attrs) !!} +
+ @endforeach
{{-- @@ -37,5 +41,5 @@ --}} -{{Form::bsSubmit('save')}} +{{ Form::bsSubmit('save') }} {!! Form::close() !!} From e7918ca76b5ffe5c1ef0bf772f705085ce39b1ae Mon Sep 17 00:00:00 2001 From: marco76tv Date: Thu, 20 Apr 2023 23:39:01 +0200 Subject: [PATCH 07/19] up --- .github/dependabot.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index bc3ab5c13..0c754e510 100755 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,3 +4,18 @@ updates: directory: "/" schedule: interval: "daily" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + labels: + - "dependencies" + + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" + labels: + - "npm" + - "dependencies" From c6f7393f00770296b7ba7b723a2ca6855bc43d89 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Thu, 20 Apr 2023 23:50:18 +0200 Subject: [PATCH 08/19] up --- .github/workflows/update-changelog.yml | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/update-changelog.yml diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml new file mode 100644 index 000000000..8c12ba9ee --- /dev/null +++ b/.github/workflows/update-changelog.yml @@ -0,0 +1,31 @@ +name: "Update Changelog" + +on: + release: + types: [released] + +permissions: + contents: write + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: main + + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@v1 + with: + latest-version: ${{ github.event.release.name }} + release-notes: ${{ github.event.release.body }} + + - name: Commit updated CHANGELOG + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: main + commit_message: Update CHANGELOG + file_pattern: CHANGELOG.md From c04ade5815b49d430792c68bca81e051ef076520 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Fri, 21 Apr 2023 10:19:33 +0200 Subject: [PATCH 09/19] up --- View/Components/Input/Label.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/View/Components/Input/Label.php b/View/Components/Input/Label.php index 2a17748bd..6e63b024e 100755 --- a/View/Components/Input/Label.php +++ b/View/Components/Input/Label.php @@ -5,6 +5,7 @@ namespace Modules\UI\View\Components\Input; use Illuminate\View\Component; +use Illuminate\View\ComponentAttributeBag; use Modules\Cms\Actions\GetStyleClassByViewAction; use Modules\Cms\Actions\GetViewAction; use Modules\Cms\Services\PanelService; @@ -12,7 +13,8 @@ /** * Undocumented class. */ -class Label extends Component { +class Label extends Component +{ public array $attrs = []; public string $tpl; public string $tradKey; @@ -20,7 +22,8 @@ class Label extends Component { /** * Undocumented function. */ - public function __construct(string $tpl = 'v1') { + public function __construct(string $tpl = 'v1') + { $this->tpl = $tpl; /* $this->attrs['name'] = $this->name; @@ -41,7 +44,8 @@ public function __construct(string $tpl = 'v1') { /** * Get the view / contents that represents the component. */ - public function render() { + public function render() + { // * return function (array &$data) { return $this->renderData($data); @@ -63,7 +67,8 @@ public function render() { // return view($view, $view_params); } - public function renderData(array $data): string { + public function renderData(array $data): string + { extract($data); /** * @phpstan-var view-string @@ -71,7 +76,7 @@ public function renderData(array $data): string { $view = app(GetViewAction::class)->execute($this->tpl); $this->attrs['class'] = app(GetStyleClassByViewAction::class)->execute($view); - if (isset($attributes) && is_object($attributes)) { + if (isset($attributes) && $attributes instanceof ComponentAttributeBag) { /*75 Call to an undefined method object::get(). 76 Call to an undefined method object::get(). 77 Call to an undefined method object::get(). From 3a48303cd97cbacb08fe3674b81d9a13accfc2dc Mon Sep 17 00:00:00 2001 From: marco76tv Date: Fri, 21 Apr 2023 15:25:53 +0200 Subject: [PATCH 10/19] up --- Http/Livewire/Import/Xls/Model.php | 33 +- Services/FormService.bak | 479 +++++++++++++++++++++++++++++ Services/FormService.php | 212 +------------ 3 files changed, 506 insertions(+), 218 deletions(-) create mode 100644 Services/FormService.bak diff --git a/Http/Livewire/Import/Xls/Model.php b/Http/Livewire/Import/Xls/Model.php index 051424178..f9daed2e4 100755 --- a/Http/Livewire/Import/Xls/Model.php +++ b/Http/Livewire/Import/Xls/Model.php @@ -8,7 +8,6 @@ namespace Modules\UI\Http\Livewire\Import\Xls; -use Exception; use Illuminate\Contracts\Support\Renderable; use Illuminate\Support\Collection; use Livewire\Component; @@ -21,7 +20,8 @@ * * @property Collection $data */ -class Model extends Component { +class Model extends Component +{ use WithFileUploads; /** @@ -42,7 +42,8 @@ class Model extends Component { * * @return void */ - public function mount(string $modelClass, ?array $fields, ?array $trans) { + public function mount(string $modelClass, ?array $fields, ?array $trans) + { $this->modelClass = $modelClass; $this->fillable = app($modelClass)->getFillable(); $this->fillable = array_combine($this->fillable, $this->fillable); @@ -59,7 +60,8 @@ public function mount(string $modelClass, ?array $fields, ?array $trans) { /** * Undocumented function. */ - public function getDataProperty(): Collection { + public function getDataProperty(): Collection + { $path = $this->myfile->getRealPath(); if (false !== $path) { @@ -74,7 +76,8 @@ public function getDataProperty(): Collection { /** * Undocumented function. */ - public function render(): Renderable { + public function render(): Renderable + { /** * @phpstan-var view-string */ @@ -89,7 +92,8 @@ public function render(): Renderable { * * @return void */ - public function import() { + public function import() + { $model = app($this->modelClass); $rows = $this->data; @@ -99,19 +103,20 @@ public function import() { */ $rows = $rows->filter( function ($item) { - // if(!method_exists($item,'toArray')){ - // throw new Exception('['.__LINE__.']['.__FILE__.']'); - // } + /*if (! ($item instanceof Collection)) { + throw new \InvalidArgumentException('Il parametro $item non รจ una collezione'); + }*/ + try { $items = $item->toArray(); } catch (\Exception $e) { throw new \Exception('['.__LINE__.']['.__FILE__.']'); } - foreach ($items as $key => $value) { - if (null !== $value) { - return $item; - } - } + foreach ($items as $key => $value) { + if (null !== $value) { + return $item; + } + } } ); diff --git a/Services/FormService.bak b/Services/FormService.bak new file mode 100644 index 000000000..64fcae75f --- /dev/null +++ b/Services/FormService.bak @@ -0,0 +1,479 @@ +getForeignKeyName(); + } + if (method_exists($rows, 'getForeignPivotKeyName')) { + $fields_exclude[] = $rows->getForeignPivotKeyName(); + } + if (method_exists($rows, 'getRelatedPivotKeyName')) { + $fields_exclude[] = $rows->getRelatedPivotKeyName(); + } + if (method_exists($rows, 'getMorphType')) { + $fields_exclude[] = $rows->getMorphType(); + } + $fields_exclude[] = 'related_type'; // -- ?? + + return $fields_exclude; + } + + public static function getCollectiveComponents(): array + { + $view_path = __DIR__.'/../Resources/views/collective/fields'; + $prefix = 'ui::'; + + return app(GetCollectiveComponents::class)->execute($view_path, $prefix); + } + + /*-- to separate component + public static function inputFreeze(FieldData $field, Model $row): Renderable + { + $field->name_dot = bracketsToDotted($field->name); + + + try { + $field->value = Arr::get($row, $field->name_dot); + if (null === $field->value) { + $field->value = Arr::get((array) $row, $field->name_dot); + } + + } catch (\Exception $e) { + $field->value = '---['.$field->name_dot.']['.$e->getMessage().']['.__LINE__.'-'.basename(__FILE__).']['.$row->{$field->name_dot}.']--'; + } + + $tmp = Str::snake($field->type); + + * + * --- da fare contratto etc etc (interface). + * + * @var FieldContract|null + * + $comp_field = Arr::first( + self::getCollectiveComponents(), + function ($item) use ($field) { + return $item->name === 'bs'.$field->type; + } + ); + ** + * @phpstan-var view-string + * + $error_view = 'ui::components.alert.error'; + + if (null === $comp_field) { + $msg = 'not registered component [bs'.$field->type.']'; + + return view($error_view, ['msg' => $msg]); + } + + ** + * @phpstan-var view-string + * + $view = Str::beforeLast((string) $comp_field->view, '.field').'.freeze'; + if (! View::exists($view)) { + return view($error_view, ['msg' => '['.$view.'] NOT EXISTS !!!']); + } + + $view_params = []; + + $view_params['row'] = $row; + $view_params['field'] = $field; + $field->method = Str::camel($field->name); + + if (\is_object($field->value)) { + $is_collection = ('Illuminate\Database\Eloquent\Collection' === \get_class($field->value)); + } else { + $is_collection = false; + } + if ($is_collection) { + $rows = $row->{$field->method}(); // cachare tutto per accellerare + $related = $rows->getRelated(); + // $related=$field->value->first(); + // /////////////////////////////////// + $params['rows'] = $rows; + + // $view_params['rows']=$rows->get(); + $view_params['rows'] = $field->value; + + $fields_exclude = self::fieldsExcludeRows($rows); + $related_panel = ThemeService::panelModel($related); + // 220 Else branch is unreachable because previous condition is always true. + // if (is_object($related_panel)) { + $related_fields = $related_panel->fields(); + // } else { + // $related_fields = []; + // } + $related_fields = collect($related_fields) + ->filter( + function ($item) use ($fields_exclude) { + return ! \in_array($item->name, $fields_exclude, true); + } + ) + ->all(); + + $related_name = Str::singular($field->name); + // $view_params['related']=$related->get(); + $view_params['related_name'] = $related_name; + $view_params['related_fields'] = $related_fields; + + $url = '#'; + + $view_params['manage_url'] = $url; + + if (method_exists((object) $rows, 'getPivotClass')) { + // dddx($rows); + $pivot_class = $rows->getPivotClass(); + if (! Str::startsWith($pivot_class, 'Modules\\')) { + $get_related_class = get_class($rows->getRelated()); + if (false == $get_related_class) { + throw new \Exception('['.__LINE__.']['.__FILE__.']'); + } + $pivot1 = implode('\\', \array_slice(explode('\\', $get_related_class), 0, -1)).'\\'; + $pivot1 .= Str::studly(Str::singular($rows->getTable())); + + if (! class_exists($pivot1)) { + dddx( + [ + // 'rows' => $rows, + 'pivot_class' => $pivot_class, + 'related' => $rows->getRelated(), + 'getMorphClass' => $rows->getMorphClass(), + 'getMorphType' => $rows->getMorphType(), + 'table' => $rows->getTable(), + 'methods' => get_class_methods($rows), + 'pivot1' => $pivot1, + 'pivot1_exists' => class_exists($pivot1), + ] + ); + } + $pivot_class = $pivot1; + } + // $pivot = new $pivot_class(); + // dddx($pivot_class); + $pivot = app($pivot_class); + + + // dddx($pivot); + $pivot_panel = ThemeService::panelModel($pivot); + // ogni tanto ThemeService::panelModel($pivot) rilascia una stringa e non un oggetto + // ci ho messo una pezza, ma forse dovrebbe aggiornare morph_map? + if (! \is_object($pivot_panel)) { + $pivot_panel = app($pivot_panel); + // dddx($pivot_panel); + } + $pivot_fields = $pivot_panel->fields(); + $pivot_fields = collect($pivot_fields)->filter( + function ($item) use ($fields_exclude) { + return ! \in_array($item->name, $fields_exclude, true); + } + )->all(); + $view_params['pivot'] = $pivot; + $view_params['pivot_panel'] = $pivot_panel; + $view_params['pivot_fields'] = $pivot_fields; + } + + // dddx($field->fields); + // $field->fields=$field->value; + } + + $field->view = $view; + $view_params['field'] = $field; + + return view($view, $view_params); + } + */ + /** + * Undocumented function. + * + * @return \Illuminate\Contracts\Support\Renderable|\Illuminate\Support\HtmlString + */ + public static function inputHtml(FieldData $field, Model $row) + { + $input_type = 'bs'.Str::studly($field->type); + if (isset($field->sub_type)) { + $input_type .= Str::studly($field->sub_type); + } + + $input_name = collect(explode('.', $field->name))->map( + function ($v, $k) { + return 0 === $k ? $v : '['.$v.']'; + } + )->implode(''); + $input_value = $field->value ?? null; + + $col_size = isset($field->col_size) ? $field->col_size : 12; + $field->col_size = $col_size; + + if (! isset($field->attributes) || ! \is_array($field->attributes)) { + $field->attributes = []; + } + $input_attrs = $field->attributes; + if (isset($field->fields)) { + $input_attrs['fields'] = $field->fields; + } + $div_exludes = ['Hidden', 'Cell']; + $input_opts = ['field' => $field]; + + if (isset($field->label)) { + $input_attrs['label'] = $field->label; + } + + return Form::$input_type($input_name, $input_value, $input_attrs, $input_opts); + } + + public static function btnHtml(array $params): string + { + $class = 'btn btn-primary mb-2'; + $icon = null; // icona a sx del titolo + $label = null; + $data_title = null; // titolo del modal e tooltip + $title = null; // stringa che appare nel tasto + $lang = app()->getLocale(); + $error_label = 'default'; + $tooltip = null; + extract($params); + if (! isset($panel)) { + throw new \Exception('panel is missing'); + } + if (! isset($method)) { + throw new \Exception('method is missing'); + } + if (! isset($act)) { + throw new \Exception('act is missing'); + } + if (! isset($url)) { + throw new \Exception('url is missing'); + } + + if (null === $data_title) { + $data_title = $title; + } + $row = $panel->getRow(); + if ('default' === $error_label) { + $error_label = '['.\get_class($row).']['.$method.']'; + } + $module_name = getModuleNameFromModel($row); + if (null === $tooltip) { + $tooltip = trans(strtolower($module_name.'::'.class_basename($row)).'.btn.'.$data_title); + } + // $url = RouteService::urlPanel(['panel' => $panel, 'act' => $act]); + // $method = Str::camel($act); + + if (\in_array($act, ['destroy', 'delete', 'detach'], true)) { + $class .= ' btn-danger btn-confirm-delete'; + } + + if (! Gate::allows($method, $panel)) { + // Strict comparison using === between false and string will always evaluate to false. + // dddx([$method.'policy non esiste', ! Gate::allows($method, $panel), $method, $panel]); + + return ''; + /* + if (false == $error_label) { + return null; + } + if ('production' == App::environment()) { + return null; + } + $policy_class = PolicyService::get($panel)->createIfNotExists()->getClass(); + + return '['.$policy_class.']['.$method.']'; + */ + } + + if (isset($modal)) { + // if (strlen((string)$data_title) <1 ) { + $title = trans($module_name.'::'.strtolower(class_basename($row)).'.act.'.$act); + // } + } + + if (isset($guest_url) && ! \Auth::check()) { + $url = $guest_url; + } + if (isset($guest_notice) && $guest_notice && ! \Auth::check()) { + $url = route('login', ['lang' => $lang, 'referrer' => $url]); + } + + /*-- deprecated + if (isset($modal)) { + $url = url_queries(['format' => $modal], $url); + $target = ''; + switch ($modal) { + case 'iframe': $target = 'myModalIframe'; + break; + case 'ajax': $target = 'myModalAjax'; + break; + } + + return + ' + + '; + } + */ + // data-href serve per le chiamate ajax + // dddx($params, $title, $data_title); + // $title = trans(strtolower($module_name.'::'.class_basename($row)).'.act.'.$title); + // $data_title = $title; + + return ' + '.$icon.' '.$title.' + '; + } + + public static function btnMassiveAction(array $params): string + { + $class = 'btn btn-primary mb-2'; + $icon = null; // icona a sx del titolo + $label = null; + $data_title = null; // titolo del modal e tooltip + $title = null; // stringa che appare nel tasto + $lang = app()->getLocale(); + $error_label = 'default'; + $tooltip = null; + extract($params); + if (! isset($panel)) { + throw new \Exception('panel is missing'); + } + if (! isset($method)) { + throw new \Exception('method is missing'); + } + if (! isset($act)) { + throw new \Exception('act is missing'); + } + if (! isset($url)) { + throw new \Exception('url is missing'); + } + + if (null === $data_title) { + $data_title = $title; + } + $row = $panel->getRow(); + if ('default' === $error_label) { + $error_label = '['.\get_class($row).']['.$method.']'; + } + $module_name = getModuleNameFromModel($row); + if (null === $tooltip) { + $tooltip = trans(strtolower($module_name.'::'.class_basename($row)).'.btn.'.$data_title); + } + + if (\in_array($act, ['destroy', 'delete', 'detach'], true)) { + $class .= ' btn-danger btn-confirm-delete'; + } + + if (! Gate::allows($method, $panel)) { + return ''; + } + + if (isset($modal)) { + // if (strlen((string)$data_title) <1 ) { + $title = trans($module_name.'::'.strtolower(class_basename($row)).'.act.'.$act); + // } + } + + if (isset($guest_url) && ! \Auth::check()) { + $url = $guest_url; + } + if (isset($guest_notice) && $guest_notice && ! \Auth::check()) { + $url = route('login', ['lang' => $lang, 'referrer' => $url]); + } + + if (isset($modal)) { + $url = url_queries(['format' => $modal], $url); + $target = ''; + switch ($modal) { + case 'iframe': $target = 'myModalIframe'; + break; + case 'ajax': $target = 'myModalAjax'; + break; + } + + return + ' + + '; + } + + // href="'.$url.'" + $form_open = Form::open(['method' => 'post', 'url' => $url]); + $form_hidden = Form::hidden('model_ids', ''); + $form_close = Form::close(); + + return $form_open.$form_hidden.''.$form_close; + } +}// end class diff --git a/Services/FormService.php b/Services/FormService.php index 651bf1a73..0741424fc 100755 --- a/Services/FormService.php +++ b/Services/FormService.php @@ -19,19 +19,17 @@ use Illuminate\Support\Arr; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\File; -use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\View; use Illuminate\Support\Str; -use Modules\Cms\Services\RouteService; use Modules\UI\Actions\GetCollectiveComponents; use Modules\UI\Contracts\FieldContract; use Modules\UI\Datas\FieldData; -use Modules\Xot\Services\PolicyService; /** * Class FormService. */ -class FormService { +class FormService +{ /** * ora selectRelationshipOne * da select/field_relationship_one.blade.php @@ -49,7 +47,8 @@ class FormService { /** * @param BelongsTo|HasManyThrough|HasOneOrMany|BelongsToMany|MorphOneOrMany|MorphPivot|MorphTo|MorphToMany $rows */ - public static function fieldsExcludeRows($rows): array { + public static function fieldsExcludeRows($rows): array + { $fields_exclude = []; $fields_exclude[] = 'id'; @@ -71,7 +70,8 @@ public static function fieldsExcludeRows($rows): array { return $fields_exclude; } - public static function getCollectiveComponents(): array { + public static function getCollectiveComponents(): array + { $view_path = __DIR__.'/../Resources/views/collective/fields'; $prefix = 'ui::'; @@ -239,7 +239,8 @@ function ($item) use ($fields_exclude) { * * @return \Illuminate\Contracts\Support\Renderable|\Illuminate\Support\HtmlString */ - public static function inputHtml(FieldData $field, Model $row) { + public static function inputHtml(FieldData $field, Model $row) + { $input_type = 'bs'.Str::studly($field->type); if (isset($field->sub_type)) { $input_type .= Str::studly($field->sub_type); @@ -271,201 +272,4 @@ function ($v, $k) { return Form::$input_type($input_name, $input_value, $input_attrs, $input_opts); } - - public static function btnHtml(array $params): string { - $class = 'btn btn-primary mb-2'; - $icon = null; // icona a sx del titolo - $label = null; - $data_title = null; // titolo del modal e tooltip - $title = null; // stringa che appare nel tasto - $lang = app()->getLocale(); - $error_label = 'default'; - $tooltip = null; - extract($params); - if (! isset($panel)) { - throw new \Exception('panel is missing'); - } - if (! isset($method)) { - throw new \Exception('method is missing'); - } - if (! isset($act)) { - throw new \Exception('act is missing'); - } - if (! isset($url)) { - throw new \Exception('url is missing'); - } - - if (null === $data_title) { - $data_title = $title; - } - $row = $panel->getRow(); - if ('default' === $error_label) { - $error_label = '['.\get_class($row).']['.$method.']'; - } - $module_name = getModuleNameFromModel($row); - if (null === $tooltip) { - $tooltip = trans(strtolower($module_name.'::'.class_basename($row)).'.btn.'.$data_title); - } - // $url = RouteService::urlPanel(['panel' => $panel, 'act' => $act]); - // $method = Str::camel($act); - - if (\in_array($act, ['destroy', 'delete', 'detach'], true)) { - $class .= ' btn-danger btn-confirm-delete'; - } - - if (! Gate::allows($method, $panel)) { - // Strict comparison using === between false and string will always evaluate to false. - // dddx([$method.'policy non esiste', ! Gate::allows($method, $panel), $method, $panel]); - - return ''; - /* - if (false == $error_label) { - return null; - } - if ('production' == App::environment()) { - return null; - } - $policy_class = PolicyService::get($panel)->createIfNotExists()->getClass(); - - return '['.$policy_class.']['.$method.']'; - */ - } - - if (isset($modal)) { - // if (strlen((string)$data_title) <1 ) { - $title = trans($module_name.'::'.strtolower(class_basename($row)).'.act.'.$act); - // } - } - - if (isset($guest_url) && ! \Auth::check()) { - $url = $guest_url; - } - if (isset($guest_notice) && $guest_notice && ! \Auth::check()) { - $url = route('login', ['lang' => $lang, 'referrer' => $url]); - } - - if (isset($modal)) { - $url = url_queries(['format' => $modal], $url); - $target = ''; - switch ($modal) { - case 'iframe': $target = 'myModalIframe'; - break; - case 'ajax': $target = 'myModalAjax'; - break; - } - - return - ' - - '; - } - // data-href serve per le chiamate ajax - // dddx($params, $title, $data_title); - // $title = trans(strtolower($module_name.'::'.class_basename($row)).'.act.'.$title); - // $data_title = $title; - - return ' - '.$icon.' '.$title.' - '; - } - - public static function btnMassiveAction(array $params): string { - $class = 'btn btn-primary mb-2'; - $icon = null; // icona a sx del titolo - $label = null; - $data_title = null; // titolo del modal e tooltip - $title = null; // stringa che appare nel tasto - $lang = app()->getLocale(); - $error_label = 'default'; - $tooltip = null; - extract($params); - if (! isset($panel)) { - throw new \Exception('panel is missing'); - } - if (! isset($method)) { - throw new \Exception('method is missing'); - } - if (! isset($act)) { - throw new \Exception('act is missing'); - } - if (! isset($url)) { - throw new \Exception('url is missing'); - } - - if (null === $data_title) { - $data_title = $title; - } - $row = $panel->getRow(); - if ('default' === $error_label) { - $error_label = '['.\get_class($row).']['.$method.']'; - } - $module_name = getModuleNameFromModel($row); - if (null === $tooltip) { - $tooltip = trans(strtolower($module_name.'::'.class_basename($row)).'.btn.'.$data_title); - } - - if (\in_array($act, ['destroy', 'delete', 'detach'], true)) { - $class .= ' btn-danger btn-confirm-delete'; - } - - if (! Gate::allows($method, $panel)) { - return ''; - } - - if (isset($modal)) { - // if (strlen((string)$data_title) <1 ) { - $title = trans($module_name.'::'.strtolower(class_basename($row)).'.act.'.$act); - // } - } - - if (isset($guest_url) && ! \Auth::check()) { - $url = $guest_url; - } - if (isset($guest_notice) && $guest_notice && ! \Auth::check()) { - $url = route('login', ['lang' => $lang, 'referrer' => $url]); - } - - if (isset($modal)) { - $url = url_queries(['format' => $modal], $url); - $target = ''; - switch ($modal) { - case 'iframe': $target = 'myModalIframe'; - break; - case 'ajax': $target = 'myModalAjax'; - break; - } - - return - ' - - '; - } - - // href="'.$url.'" - $form_open = Form::open(['method' => 'post', 'url' => $url]); - $form_hidden = Form::hidden('model_ids', ''); - $form_close = Form::close(); - - return $form_open.$form_hidden.''.$form_close; - } }// end class From e0b10485466a78d6cdea719bf9abbd801bace99f Mon Sep 17 00:00:00 2001 From: marco76tv Date: Fri, 21 Apr 2023 16:30:18 +0200 Subject: [PATCH 11/19] up --- Http/Livewire/Import/Xls/Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Http/Livewire/Import/Xls/Model.php b/Http/Livewire/Import/Xls/Model.php index f9daed2e4..f79728954 100755 --- a/Http/Livewire/Import/Xls/Model.php +++ b/Http/Livewire/Import/Xls/Model.php @@ -102,7 +102,7 @@ public function import() * controllo che non vengano erroneamente importati contatti con tutti campi null. */ $rows = $rows->filter( - function ($item) { + function (Collection $item) { /*if (! ($item instanceof Collection)) { throw new \InvalidArgumentException('Il parametro $item non รจ una collezione'); }*/ From 202d8e20f324457fa1656df159df86959f91d4c3 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Fri, 21 Apr 2023 17:08:48 +0200 Subject: [PATCH 12/19] up --- Http/Livewire/Import/Xls/Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Http/Livewire/Import/Xls/Model.php b/Http/Livewire/Import/Xls/Model.php index f79728954..f9daed2e4 100755 --- a/Http/Livewire/Import/Xls/Model.php +++ b/Http/Livewire/Import/Xls/Model.php @@ -102,7 +102,7 @@ public function import() * controllo che non vengano erroneamente importati contatti con tutti campi null. */ $rows = $rows->filter( - function (Collection $item) { + function ($item) { /*if (! ($item instanceof Collection)) { throw new \InvalidArgumentException('Il parametro $item non รจ una collezione'); }*/ From 2737bf9f66d8f12774e9c5b47d9853ec92f5d800 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Fri, 21 Apr 2023 17:59:41 +0200 Subject: [PATCH 13/19] up --- .../views/collective/fields/_components.json | 2 +- .../collective/fields/float/field.blade.php | 14 +++++++ .../collective/fields/float/freeze.blade.php | 1 + View/Components/Input/Money.php | 39 +++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 Resources/views/collective/fields/float/field.blade.php create mode 100644 Resources/views/collective/fields/float/freeze.blade.php create mode 100644 View/Components/Input/Money.php diff --git a/Resources/views/collective/fields/_components.json b/Resources/views/collective/fields/_components.json index 1e4e2e774..078f1b529 100755 --- a/Resources/views/collective/fields/_components.json +++ b/Resources/views/collective/fields/_components.json @@ -1 +1 @@ -[{"name":"bsAddress","view":"ui::collective.fields.address.field"},{"name":"bsAddressAlgolia","view":"ui::collective.fields.address.algolia.field"},{"name":"bsAddressGoogle","view":"ui::collective.fields.address.google.field"},{"name":"bsAddressPlace","view":"ui::collective.fields.address.place.field"},{"name":"bsArray","view":"ui::collective.fields.array.field"},{"name":"bsArrayElastic","view":"ui::collective.fields.array.elastic.field"},{"name":"bsArrayElasticFilter","view":"ui::collective.fields.array.elastic.filter.field"},{"name":"bsBoolean","view":"ui::collective.fields.boolean.field"},{"name":"bsCell","view":"ui::collective.fields.cell.field"},{"name":"bsCellAccordion","view":"ui::collective.fields.cell.accordion.field"},{"name":"bsCellCollapse","view":"ui::collective.fields.cell.collapse.field"},{"name":"bsCellLabel","view":"ui::collective.fields.cell.label.field"},{"name":"bsCheckbox","view":"ui::collective.fields.checkbox.field"},{"name":"bsCheckboxAccept","view":"ui::collective.fields.checkbox.accept.field"},{"name":"bsCheckboxAndHide","view":"ui::collective.fields.checkbox.and_hide.field"},{"name":"bsCheckboxBoolean","view":"ui::collective.fields.checkbox.boolean.field"},{"name":"bsCheckboxBooleanAccept","view":"ui::collective.fields.checkbox.boolean.accept.field"},{"name":"bsCheckboxBooleanSwitchery","view":"ui::collective.fields.checkbox.boolean.switchery.field"},{"name":"bsCheckboxChecklist","view":"ui::collective.fields.checkbox.checklist.field"},{"name":"bsCheckboxDualOption","view":"ui::collective.fields.checkbox.dual_option.field"},{"name":"bsCheckboxGrouped","view":"ui::collective.fields.checkbox.grouped.field"},{"name":"bsCheckboxMultiCheckbox","view":"ui::collective.fields.checkbox.multi_checkbox.field"},{"name":"bsCheckboxOptions","view":"ui::collective.fields.checkbox.options.field"},{"name":"bsCheckboxOptionsConsents","view":"ui::collective.fields.checkbox.options.consents.field"},{"name":"bsCheckboxRelationship","view":"ui::collective.fields.checkbox.relationship.field"},{"name":"bsCheckboxRelationshipMulti","view":"ui::collective.fields.checkbox.relationship.multi.field"},{"name":"bsCheckboxRelationshipMultiGrouped","view":"ui::collective.fields.checkbox.relationship.multi.grouped.field"},{"name":"bsCheckboxRelationshipMulti","view":"ui::collective.fields.checkbox.relationship_multi.field"},{"name":"bsCheckboxRelationshipMultiGrouped","view":"ui::collective.fields.checkbox.relationship_multi_grouped.field"},{"name":"bsCheckboxSiNo","view":"ui::collective.fields.checkbox.si_no.field"},{"name":"bsCustom","view":"ui::collective.fields.custom.field"},{"name":"bsCustomServices","view":"ui::collective.fields.custom.services.field"},{"name":"bsCustomServicesConsent","view":"ui::collective.fields.custom.services.consent.field"},{"name":"bsDate","view":"ui::collective.fields.date.field"},{"name":"bsDateDateTime","view":"ui::collective.fields.date.date_time.field"},{"name":"bsDateDatetime","view":"ui::collective.fields.date.datetime.field"},{"name":"bsDateDatetimeRange","view":"ui::collective.fields.date.datetime.range.field"},{"name":"bsDateList","view":"ui::collective.fields.date.list.field"},{"name":"bsDateMonth","view":"ui::collective.fields.date.month.field"},{"name":"bsDateV1","view":"ui::collective.fields.date.v1.field"},{"name":"bsDateWeek","view":"ui::collective.fields.date.week.field"},{"name":"bsDecimal","view":"ui::collective.fields.decimal.field"},{"name":"bsDecimalFloat","view":"ui::collective.fields.decimal.float.field"},{"name":"bsDecimalFloatStar","view":"ui::collective.fields.decimal.float.star.field"},{"name":"bsDecimalFloatVue","view":"ui::collective.fields.decimal.float.vue.field"},{"name":"bsDecimalFloatVueStar","view":"ui::collective.fields.decimal.float.vue.star.field"},{"name":"bsDecimalStar","view":"ui::collective.fields.decimal.star.field"},{"name":"bsDecimalVue","view":"ui::collective.fields.decimal.vue.field"},{"name":"bsDecimalVueStar","view":"ui::collective.fields.decimal.vue.star.field"},{"name":"bsEmail","view":"ui::collective.fields.email.field"},{"name":"bsEmailVerified","view":"ui::collective.fields.email.verified.field"},{"name":"bsExtra","view":"ui::collective.fields.extra.field"},{"name":"bsExtraFields","view":"ui::collective.fields.extra.fields.field"},{"name":"bsExtraFieldsGroups","view":"ui::collective.fields.extra.fields.groups.field"},{"name":"bsHidden","view":"ui::collective.fields.hidden.field"},{"name":"bsId","view":"ui::collective.fields.id.field"},{"name":"bsInteger","view":"ui::collective.fields.integer.field"},{"name":"bsIntegerBigInt","view":"ui::collective.fields.integer.big_int.field"},{"name":"bsIntegerBigint","view":"ui::collective.fields.integer.bigint.field"},{"name":"bsIntegerNumber","view":"ui::collective.fields.integer.number.field"},{"name":"bsIntegerSmallInt","view":"ui::collective.fields.integer.small_int.field"},{"name":"bsJson","view":"ui::collective.fields.json.field"},{"name":"bsList","view":"ui::collective.fields.list.field"},{"name":"bsListColor","view":"ui::collective.fields.list.color.field"},{"name":"bsListRelated","view":"ui::collective.fields.list.related.field"},{"name":"bsListRelatedModel","view":"ui::collective.fields.list.related.model.field"},{"name":"bsListRelatedModelMulti","view":"ui::collective.fields.list.related.model.multi.field"},{"name":"bsNumber","view":"ui::collective.fields.number.field"},{"name":"bsPassword","view":"ui::collective.fields.password.field"},{"name":"bsPasswordEye","view":"ui::collective.fields.password.eye.field"},{"name":"bsPasswordWith","view":"ui::collective.fields.password.with.field"},{"name":"bsPasswordWithConfirm","view":"ui::collective.fields.password.with.confirm.field"},{"name":"bsRadio","view":"ui::collective.fields.radio.field"},{"name":"bsRadioAnimated","view":"ui::collective.fields.radio.animated.field"},{"name":"bsRadioAnimatedSwitch","view":"ui::collective.fields.radio.animated.switch.field"},{"name":"bsRadioOptions","view":"ui::collective.fields.radio.options.field"},{"name":"bsRange","view":"ui::collective.fields.range.field"},{"name":"bsRating","view":"ui::collective.fields.rating.field"},{"name":"bsRatingMulti","view":"ui::collective.fields.rating.multi.field"},{"name":"bsRatingMultiVue","view":"ui::collective.fields.rating.multi.vue.field"},{"name":"bsRatingOne","view":"ui::collective.fields.rating.one.field"},{"name":"bsRole","view":"ui::collective.fields.role.field"},{"name":"bsRule","view":"ui::collective.fields.rule.field"},{"name":"bsSelect","view":"ui::collective.fields.select.field"},{"name":"bsSelect2","view":"ui::collective.fields.select.2.field"},{"name":"bsSelect2Sides","view":"ui::collective.fields.select.2_sides.field"},{"name":"bsSelect2SidesRows","view":"ui::collective.fields.select.2_sides.rows.field"},{"name":"bsSelectCategories","view":"ui::collective.fields.select.categories.field"},{"name":"bsSelectColor","view":"ui::collective.fields.select.color.field"},{"name":"bsSelectIconPicker","view":"ui::collective.fields.select.icon_picker.field"},{"name":"bsSelectMultiple","view":"ui::collective.fields.select.multiple.field"},{"name":"bsSelectMultipleRelationship","view":"ui::collective.fields.select.multiple.relationship.field"},{"name":"bsSelectMultipleRelationship2","view":"ui::collective.fields.select.multiple.relationship_2.field"},{"name":"bsSelectOptions","view":"ui::collective.fields.select.options.field"},{"name":"bsSelectParent","view":"ui::collective.fields.select.parent.field"},{"name":"bsSelectRelationship","view":"ui::collective.fields.select.relationship.field"},{"name":"bsSelectRelationshipOne","view":"ui::collective.fields.select.relationship.one.field"},{"name":"bsSms","view":"ui::collective.fields.sms.field"},{"name":"bsSmsVerified","view":"ui::collective.fields.sms.verified.field"},{"name":"bsStatic","view":"ui::collective.fields.static.field"},{"name":"bsStaticMulti","view":"ui::collective.fields.static.multi.field"},{"name":"bsString","view":"ui::collective.fields.string.field"},{"name":"bsSubmit","view":"ui::collective.fields.submit.field"},{"name":"bsSubmitRight","view":"ui::collective.fields.submit.right.field"},{"name":"bsSubmitRightBig","view":"ui::collective.fields.submit.right.big.field"},{"name":"bsSubmitRightBigShow","view":"ui::collective.fields.submit.right.big.show.field"},{"name":"bsSubmitRightBigShowHide","view":"ui::collective.fields.submit.right.big.show.hide.field"},{"name":"bsTags","view":"ui::collective.fields.tags.field"},{"name":"bsTel","view":"ui::collective.fields.tel.field"},{"name":"bsTest","view":"ui::collective.fields.test.field"},{"name":"bsTestEnum","view":"ui::collective.fields.test.enum.field"},{"name":"bsTestError","view":"ui::collective.fields.test.error.field"},{"name":"bsTestPageOrLink","view":"ui::collective.fields.test.page_or_link.field"},{"name":"bsTestPivotFields","view":"ui::collective.fields.test.pivot_fields.field"},{"name":"bsTestRelatedFields","view":"ui::collective.fields.test.related_fields.field"},{"name":"bsTestStatus","view":"ui::collective.fields.test.status.field"},{"name":"bsTestStatusSelect","view":"ui::collective.fields.test.status.select.field"},{"name":"bsTestStatusSelectSingle","view":"ui::collective.fields.test.status.select.single.field"},{"name":"bsTestSwiper","view":"ui::collective.fields.test.swiper.field"},{"name":"bsTestTable","view":"ui::collective.fields.test.table.field"},{"name":"bsTestUrl","view":"ui::collective.fields.test.url.field"},{"name":"bsTestVideo","view":"ui::collective.fields.test.video.field"},{"name":"bsTestView","view":"ui::collective.fields.test.view.field"},{"name":"bsText","view":"ui::collective.fields.text.field"},{"name":"bsTextBlob","view":"ui::collective.fields.text.blob.field"},{"name":"bsTextNolabel","view":"ui::collective.fields.text.nolabel.field"},{"name":"bsTextTags","view":"ui::collective.fields.text.tags.field"},{"name":"bsTextarea","view":"ui::collective.fields.textarea.field"},{"name":"bsTime","view":"ui::collective.fields.time.field"},{"name":"bsUpload","view":"ui::collective.fields.upload.field"},{"name":"bsUploadBrowse","view":"ui::collective.fields.upload.browse.field"},{"name":"bsUploadBrowseMultiple","view":"ui::collective.fields.upload.browse.multiple.field"},{"name":"bsUploadChunkUpload","view":"ui::collective.fields.upload.chunk_upload.field"},{"name":"bsUploadCsv","view":"ui::collective.fields.upload.csv.field"},{"name":"bsUploadDoc","view":"ui::collective.fields.upload.doc.field"},{"name":"bsUploadDocWithNameFile","view":"ui::collective.fields.upload.doc.with_name_file.field"},{"name":"bsUploadFile","view":"ui::collective.fields.upload.file.field"},{"name":"bsUploadImage","view":"ui::collective.fields.upload.image.field"},{"name":"bsUploadImageDropzone","view":"ui::collective.fields.upload.image.dropzone.field"},{"name":"bsUploadImageV1","view":"ui::collective.fields.upload.image.v1.field"},{"name":"bsUploadMulti","view":"ui::collective.fields.upload.multi.field"},{"name":"bsUploadMultiWith","view":"ui::collective.fields.upload.multi.with.field"},{"name":"bsUploadMultiWithLabel","view":"ui::collective.fields.upload.multi.with.label.field"},{"name":"bsUploadPdf","view":"ui::collective.fields.upload.pdf.field"},{"name":"bsUploadPlupload","view":"ui::collective.fields.upload.plupload.field"},{"name":"bsUploadSingleFileUpload","view":"ui::collective.fields.upload.single_file_upload.field"},{"name":"bsUploadUnisharp","view":"ui::collective.fields.upload.unisharp.field"},{"name":"bsUploadUnisharpImg","view":"ui::collective.fields.upload.unisharp.img.field"},{"name":"bsUploadUpload","view":"ui::collective.fields.upload.upload.field"},{"name":"bsWysiwyg","view":"ui::collective.fields.wysiwyg.field"},{"name":"bsWysiwygSceditor","view":"ui::collective.fields.wysiwyg.sceditor.field"},{"name":"bsWysiwygSummer","view":"ui::collective.fields.wysiwyg.summer.field"},{"name":"bsWysiwygSummerNote","view":"ui::collective.fields.wysiwyg.summer.note.field"},{"name":"bsWysiwygVue","view":"ui::collective.fields.wysiwyg.vue.field"}] \ No newline at end of file +[{"name":"bsAddress","view":"ui::collective.fields.address.field"},{"name":"bsAddressAlgolia","view":"ui::collective.fields.address.algolia.field"},{"name":"bsAddressGoogle","view":"ui::collective.fields.address.google.field"},{"name":"bsAddressPlace","view":"ui::collective.fields.address.place.field"},{"name":"bsArray","view":"ui::collective.fields.array.field"},{"name":"bsArrayElastic","view":"ui::collective.fields.array.elastic.field"},{"name":"bsArrayElasticFilter","view":"ui::collective.fields.array.elastic.filter.field"},{"name":"bsBoolean","view":"ui::collective.fields.boolean.field"},{"name":"bsCell","view":"ui::collective.fields.cell.field"},{"name":"bsCellAccordion","view":"ui::collective.fields.cell.accordion.field"},{"name":"bsCellCollapse","view":"ui::collective.fields.cell.collapse.field"},{"name":"bsCellLabel","view":"ui::collective.fields.cell.label.field"},{"name":"bsCheckbox","view":"ui::collective.fields.checkbox.field"},{"name":"bsCheckboxAccept","view":"ui::collective.fields.checkbox.accept.field"},{"name":"bsCheckboxAndHide","view":"ui::collective.fields.checkbox.and_hide.field"},{"name":"bsCheckboxBoolean","view":"ui::collective.fields.checkbox.boolean.field"},{"name":"bsCheckboxBooleanAccept","view":"ui::collective.fields.checkbox.boolean.accept.field"},{"name":"bsCheckboxBooleanSwitchery","view":"ui::collective.fields.checkbox.boolean.switchery.field"},{"name":"bsCheckboxChecklist","view":"ui::collective.fields.checkbox.checklist.field"},{"name":"bsCheckboxDualOption","view":"ui::collective.fields.checkbox.dual_option.field"},{"name":"bsCheckboxGrouped","view":"ui::collective.fields.checkbox.grouped.field"},{"name":"bsCheckboxMultiCheckbox","view":"ui::collective.fields.checkbox.multi_checkbox.field"},{"name":"bsCheckboxOptions","view":"ui::collective.fields.checkbox.options.field"},{"name":"bsCheckboxOptionsConsents","view":"ui::collective.fields.checkbox.options.consents.field"},{"name":"bsCheckboxRelationship","view":"ui::collective.fields.checkbox.relationship.field"},{"name":"bsCheckboxRelationshipMulti","view":"ui::collective.fields.checkbox.relationship.multi.field"},{"name":"bsCheckboxRelationshipMultiGrouped","view":"ui::collective.fields.checkbox.relationship.multi.grouped.field"},{"name":"bsCheckboxRelationshipMulti","view":"ui::collective.fields.checkbox.relationship_multi.field"},{"name":"bsCheckboxRelationshipMultiGrouped","view":"ui::collective.fields.checkbox.relationship_multi_grouped.field"},{"name":"bsCheckboxSiNo","view":"ui::collective.fields.checkbox.si_no.field"},{"name":"bsCustom","view":"ui::collective.fields.custom.field"},{"name":"bsCustomServices","view":"ui::collective.fields.custom.services.field"},{"name":"bsCustomServicesConsent","view":"ui::collective.fields.custom.services.consent.field"},{"name":"bsDate","view":"ui::collective.fields.date.field"},{"name":"bsDateDateTime","view":"ui::collective.fields.date.date_time.field"},{"name":"bsDateDatetime","view":"ui::collective.fields.date.datetime.field"},{"name":"bsDateDatetimeRange","view":"ui::collective.fields.date.datetime.range.field"},{"name":"bsDateList","view":"ui::collective.fields.date.list.field"},{"name":"bsDateMonth","view":"ui::collective.fields.date.month.field"},{"name":"bsDateV1","view":"ui::collective.fields.date.v1.field"},{"name":"bsDateWeek","view":"ui::collective.fields.date.week.field"},{"name":"bsDecimal","view":"ui::collective.fields.decimal.field"},{"name":"bsDecimalFloat","view":"ui::collective.fields.decimal.float.field"},{"name":"bsDecimalFloatStar","view":"ui::collective.fields.decimal.float.star.field"},{"name":"bsDecimalFloatVue","view":"ui::collective.fields.decimal.float.vue.field"},{"name":"bsDecimalFloatVueStar","view":"ui::collective.fields.decimal.float.vue.star.field"},{"name":"bsDecimalStar","view":"ui::collective.fields.decimal.star.field"},{"name":"bsDecimalVue","view":"ui::collective.fields.decimal.vue.field"},{"name":"bsDecimalVueStar","view":"ui::collective.fields.decimal.vue.star.field"},{"name":"bsEmail","view":"ui::collective.fields.email.field"},{"name":"bsEmailVerified","view":"ui::collective.fields.email.verified.field"},{"name":"bsExtra","view":"ui::collective.fields.extra.field"},{"name":"bsExtraFields","view":"ui::collective.fields.extra.fields.field"},{"name":"bsExtraFieldsGroups","view":"ui::collective.fields.extra.fields.groups.field"},{"name":"bsFloat","view":"ui::collective.fields.float.field"},{"name":"bsHidden","view":"ui::collective.fields.hidden.field"},{"name":"bsId","view":"ui::collective.fields.id.field"},{"name":"bsInteger","view":"ui::collective.fields.integer.field"},{"name":"bsIntegerBigInt","view":"ui::collective.fields.integer.big_int.field"},{"name":"bsIntegerBigint","view":"ui::collective.fields.integer.bigint.field"},{"name":"bsIntegerNumber","view":"ui::collective.fields.integer.number.field"},{"name":"bsIntegerSmallInt","view":"ui::collective.fields.integer.small_int.field"},{"name":"bsJson","view":"ui::collective.fields.json.field"},{"name":"bsList","view":"ui::collective.fields.list.field"},{"name":"bsListColor","view":"ui::collective.fields.list.color.field"},{"name":"bsListRelated","view":"ui::collective.fields.list.related.field"},{"name":"bsListRelatedModel","view":"ui::collective.fields.list.related.model.field"},{"name":"bsListRelatedModelMulti","view":"ui::collective.fields.list.related.model.multi.field"},{"name":"bsNumber","view":"ui::collective.fields.number.field"},{"name":"bsPassword","view":"ui::collective.fields.password.field"},{"name":"bsPasswordEye","view":"ui::collective.fields.password.eye.field"},{"name":"bsPasswordWith","view":"ui::collective.fields.password.with.field"},{"name":"bsPasswordWithConfirm","view":"ui::collective.fields.password.with.confirm.field"},{"name":"bsRadio","view":"ui::collective.fields.radio.field"},{"name":"bsRadioAnimated","view":"ui::collective.fields.radio.animated.field"},{"name":"bsRadioAnimatedSwitch","view":"ui::collective.fields.radio.animated.switch.field"},{"name":"bsRadioOptions","view":"ui::collective.fields.radio.options.field"},{"name":"bsRange","view":"ui::collective.fields.range.field"},{"name":"bsRating","view":"ui::collective.fields.rating.field"},{"name":"bsRatingMulti","view":"ui::collective.fields.rating.multi.field"},{"name":"bsRatingMultiVue","view":"ui::collective.fields.rating.multi.vue.field"},{"name":"bsRatingOne","view":"ui::collective.fields.rating.one.field"},{"name":"bsRole","view":"ui::collective.fields.role.field"},{"name":"bsRule","view":"ui::collective.fields.rule.field"},{"name":"bsSelect","view":"ui::collective.fields.select.field"},{"name":"bsSelect2","view":"ui::collective.fields.select.2.field"},{"name":"bsSelect2Sides","view":"ui::collective.fields.select.2_sides.field"},{"name":"bsSelect2SidesRows","view":"ui::collective.fields.select.2_sides.rows.field"},{"name":"bsSelectCategories","view":"ui::collective.fields.select.categories.field"},{"name":"bsSelectColor","view":"ui::collective.fields.select.color.field"},{"name":"bsSelectIconPicker","view":"ui::collective.fields.select.icon_picker.field"},{"name":"bsSelectMultiple","view":"ui::collective.fields.select.multiple.field"},{"name":"bsSelectMultipleRelationship","view":"ui::collective.fields.select.multiple.relationship.field"},{"name":"bsSelectMultipleRelationship2","view":"ui::collective.fields.select.multiple.relationship_2.field"},{"name":"bsSelectOptions","view":"ui::collective.fields.select.options.field"},{"name":"bsSelectParent","view":"ui::collective.fields.select.parent.field"},{"name":"bsSelectRelationship","view":"ui::collective.fields.select.relationship.field"},{"name":"bsSelectRelationshipOne","view":"ui::collective.fields.select.relationship.one.field"},{"name":"bsSms","view":"ui::collective.fields.sms.field"},{"name":"bsSmsVerified","view":"ui::collective.fields.sms.verified.field"},{"name":"bsStatic","view":"ui::collective.fields.static.field"},{"name":"bsStaticMulti","view":"ui::collective.fields.static.multi.field"},{"name":"bsString","view":"ui::collective.fields.string.field"},{"name":"bsSubmit","view":"ui::collective.fields.submit.field"},{"name":"bsSubmitRight","view":"ui::collective.fields.submit.right.field"},{"name":"bsSubmitRightBig","view":"ui::collective.fields.submit.right.big.field"},{"name":"bsSubmitRightBigShow","view":"ui::collective.fields.submit.right.big.show.field"},{"name":"bsSubmitRightBigShowHide","view":"ui::collective.fields.submit.right.big.show.hide.field"},{"name":"bsTags","view":"ui::collective.fields.tags.field"},{"name":"bsTel","view":"ui::collective.fields.tel.field"},{"name":"bsTest","view":"ui::collective.fields.test.field"},{"name":"bsTestEnum","view":"ui::collective.fields.test.enum.field"},{"name":"bsTestError","view":"ui::collective.fields.test.error.field"},{"name":"bsTestPageOrLink","view":"ui::collective.fields.test.page_or_link.field"},{"name":"bsTestPivotFields","view":"ui::collective.fields.test.pivot_fields.field"},{"name":"bsTestRelatedFields","view":"ui::collective.fields.test.related_fields.field"},{"name":"bsTestStatus","view":"ui::collective.fields.test.status.field"},{"name":"bsTestStatusSelect","view":"ui::collective.fields.test.status.select.field"},{"name":"bsTestStatusSelectSingle","view":"ui::collective.fields.test.status.select.single.field"},{"name":"bsTestSwiper","view":"ui::collective.fields.test.swiper.field"},{"name":"bsTestTable","view":"ui::collective.fields.test.table.field"},{"name":"bsTestUrl","view":"ui::collective.fields.test.url.field"},{"name":"bsTestVideo","view":"ui::collective.fields.test.video.field"},{"name":"bsTestView","view":"ui::collective.fields.test.view.field"},{"name":"bsText","view":"ui::collective.fields.text.field"},{"name":"bsTextBlob","view":"ui::collective.fields.text.blob.field"},{"name":"bsTextNolabel","view":"ui::collective.fields.text.nolabel.field"},{"name":"bsTextTags","view":"ui::collective.fields.text.tags.field"},{"name":"bsTextarea","view":"ui::collective.fields.textarea.field"},{"name":"bsTime","view":"ui::collective.fields.time.field"},{"name":"bsUpload","view":"ui::collective.fields.upload.field"},{"name":"bsUploadBrowse","view":"ui::collective.fields.upload.browse.field"},{"name":"bsUploadBrowseMultiple","view":"ui::collective.fields.upload.browse.multiple.field"},{"name":"bsUploadChunkUpload","view":"ui::collective.fields.upload.chunk_upload.field"},{"name":"bsUploadCsv","view":"ui::collective.fields.upload.csv.field"},{"name":"bsUploadDoc","view":"ui::collective.fields.upload.doc.field"},{"name":"bsUploadDocWithNameFile","view":"ui::collective.fields.upload.doc.with_name_file.field"},{"name":"bsUploadFile","view":"ui::collective.fields.upload.file.field"},{"name":"bsUploadImage","view":"ui::collective.fields.upload.image.field"},{"name":"bsUploadImageDropzone","view":"ui::collective.fields.upload.image.dropzone.field"},{"name":"bsUploadImageV1","view":"ui::collective.fields.upload.image.v1.field"},{"name":"bsUploadMulti","view":"ui::collective.fields.upload.multi.field"},{"name":"bsUploadMultiWith","view":"ui::collective.fields.upload.multi.with.field"},{"name":"bsUploadMultiWithLabel","view":"ui::collective.fields.upload.multi.with.label.field"},{"name":"bsUploadPdf","view":"ui::collective.fields.upload.pdf.field"},{"name":"bsUploadPlupload","view":"ui::collective.fields.upload.plupload.field"},{"name":"bsUploadSingleFileUpload","view":"ui::collective.fields.upload.single_file_upload.field"},{"name":"bsUploadUnisharp","view":"ui::collective.fields.upload.unisharp.field"},{"name":"bsUploadUnisharpImg","view":"ui::collective.fields.upload.unisharp.img.field"},{"name":"bsUploadUpload","view":"ui::collective.fields.upload.upload.field"},{"name":"bsWysiwyg","view":"ui::collective.fields.wysiwyg.field"},{"name":"bsWysiwygSceditor","view":"ui::collective.fields.wysiwyg.sceditor.field"},{"name":"bsWysiwygSummer","view":"ui::collective.fields.wysiwyg.summer.field"},{"name":"bsWysiwygSummerNote","view":"ui::collective.fields.wysiwyg.summer.note.field"},{"name":"bsWysiwygVue","view":"ui::collective.fields.wysiwyg.vue.field"}] \ No newline at end of file diff --git a/Resources/views/collective/fields/float/field.blade.php b/Resources/views/collective/fields/float/field.blade.php new file mode 100644 index 000000000..c2217216b --- /dev/null +++ b/Resources/views/collective/fields/float/field.blade.php @@ -0,0 +1,14 @@ +@php + $field = transFields(get_defined_vars()); + //dddx($blade_component); + //dddx(get_defined_vars()); + $field->attributes['step'] = '0.01'; +@endphp +@component($blade_component, get_defined_vars()) + @slot('label') + {{ Form::label($name, $field->label, ['class' => 'control-label form-label']) }} + @endslot + @slot('input') + {{ Form::number($name, $value, $field->attributes) }} + @endslot +@endcomponent diff --git a/Resources/views/collective/fields/float/freeze.blade.php b/Resources/views/collective/fields/float/freeze.blade.php new file mode 100644 index 000000000..d16916a99 --- /dev/null +++ b/Resources/views/collective/fields/float/freeze.blade.php @@ -0,0 +1 @@ +{{ $field->value }} \ No newline at end of file diff --git a/View/Components/Input/Money.php b/View/Components/Input/Money.php new file mode 100644 index 000000000..aae2d7798 --- /dev/null +++ b/View/Components/Input/Money.php @@ -0,0 +1,39 @@ +amount = $amount; + $this->currency = $currency; + $this->locale = $locale ?? app()->getLocale(); + } + + public function render() + { + $money = new Money($this->amount, new Currency(Str::upper($this->currency))); + + $numberFormatter = new \NumberFormatter($this->locale, \NumberFormatter::CURRENCY); + $moneyFormatter = new IntlMoneyFormatter($numberFormatter, new ISOCurrencies()); + + return $moneyFormatter->format($money); + } +} From 22c69cbb4d891ae9af03642e89c24f18e00a3c90 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Mon, 24 Apr 2023 10:42:34 +0200 Subject: [PATCH 14/19] up --- View/Components/Input/{Money.php => Money.to_up} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename View/Components/Input/{Money.php => Money.to_up} (100%) diff --git a/View/Components/Input/Money.php b/View/Components/Input/Money.to_up similarity index 100% rename from View/Components/Input/Money.php rename to View/Components/Input/Money.to_up From 45c3e3ca37288f4af2ab437b1b4582e16515569d Mon Sep 17 00:00:00 2001 From: marco76tv Date: Mon, 24 Apr 2023 11:07:19 +0200 Subject: [PATCH 15/19] up --- .../collective/fields/upload/image/base64_image.blade.php | 3 ++- Resources/views/collective/fields/upload/image/image.blade.php | 3 ++- docs/listeners/GenerateSitemap.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Resources/views/collective/fields/upload/image/base64_image.blade.php b/Resources/views/collective/fields/upload/image/base64_image.blade.php index 5b976fe23..976da3451 100755 --- a/Resources/views/collective/fields/upload/image/base64_image.blade.php +++ b/Resources/views/collective/fields/upload/image/base64_image.blade.php @@ -114,7 +114,8 @@ @endpush diff --git a/Resources/views/collective/fields/address/address_google.blade.php b/Resources/views/collective/fields/address/address_google.blade.php index 7d2b380be..bac8712c6 100755 --- a/Resources/views/collective/fields/address/address_google.blade.php +++ b/Resources/views/collective/fields/address/address_google.blade.php @@ -11,7 +11,7 @@ @include('crud::inc.field_translatable_icon') @if (isset($field['prefix']) || isset($field['suffix'])) @@ -28,7 +28,7 @@ @endif @if (isset($field['suffix'])) @@ -60,7 +60,6 @@ .ap-input-icon.ap-icon-clear { right: 10px !important; } - @endpush @@ -71,53 +70,55 @@ function initAutocomplete() { - $('[data-google-address]').each(function() { + $('[data-google-address]').each( + function() { - var $this = $(this), - $addressConfig = $this.data('google-address'), - $field = $('[name="' + $addressConfig.field + '"]'); + var $this = $(this), + $addressConfig = $this.data('google-address'), + $field = $('[name="' + $addressConfig.field + '"]'); - if ($field.val().length) { - var existingData = JSON.parse($field.val()); - $this.val(existingData.value); - } + if ($field.val().length) { + var existingData = JSON.parse($field.val()); + $this.val(existingData.value); + } - var $autocomplete = new google.maps.places.Autocomplete( - ($this[0]), { - types: ['geocode'] - }); + var $autocomplete = new google.maps.places.Autocomplete( + ($this[0]), { + types: ['geocode'] + }); - $autocomplete.addListener('place_changed', function fillInAddress() { + $autocomplete.addListener('place_changed', function fillInAddress() { - var place = $autocomplete.getPlace(); - var value = $this.val(); - var latlng = place.geometry.location; - var data = { - "value": value, - "latlng": latlng - }; + var place = $autocomplete.getPlace(); + var value = $this.val(); + var latlng = place.geometry.location; + var data = { + "value": value, + "latlng": latlng + }; - for (var i = 0; i < place.address_components.length; i++) { - var addressType = place.address_components[i].types[0]; - data[addressType] = place.address_components[i]['long_name']; - } - $field.val(JSON.stringify(data)); + for (var i = 0; i < place.address_components.length; i++) { + var addressType = place.address_components[i].types[0]; + data[addressType] = place.address_components[i]['long_name']; + } + $field.val(JSON.stringify(data)); - }); + }); - $this.change(function() { - if (!$this.val().length) { - $field.val(""); - } - }); + $this.change(function() { + if (!$this.val().length) { + $field.val(""); + } + }); - }); + }); } - + @endpush @endif {{-- End of Extra CSS and JS --}} diff --git a/Resources/views/collective/fields/address/field_algolia.blade.php b/Resources/views/collective/fields/address/field_algolia.blade.php index 3cf5727c7..9ff84b6fa 100755 --- a/Resources/views/collective/fields/address/field_algolia.blade.php +++ b/Resources/views/collective/fields/address/field_algolia.blade.php @@ -32,7 +32,8 @@ $(document).ready(function(){ window.AlgoliaPlaces = window.AlgoliaPlaces || {}; - $('[data-address]').each(function(){ + $('[data-address]').each( +function(){ var $this = $(this), $addressConfig = $this.data('address'), diff --git a/Resources/views/collective/fields/address/field_google_linked.blade.php b/Resources/views/collective/fields/address/field_google_linked.blade.php index 589241717..d801ca860 100755 --- a/Resources/views/collective/fields/address/field_google_linked.blade.php +++ b/Resources/views/collective/fields/address/field_google_linked.blade.php @@ -1,21 +1,21 @@ @php - -/* + + /* input utilizzato con la tabella places */ - -$field = transFields(get_defined_vars()); -$val = Form::getValueAttribute($name); -/* + + $field = transFields(get_defined_vars()); + $val = Form::getValueAttribute($name); + /* dddx($val); if(is_object($val)){ $val=json_encode($val); }; */ -if (is_object($val)) { - $val = $val->toJson(); -} -$value = $val; + if (is_object($val)) { + $val = $val->toJson(); + } + $value = $val; @endphp @component($blade_component, get_defined_vars()) @slot('label') @@ -38,9 +38,7 @@ .ap-input-icon.ap-icon-clear { right: 10px !important; } - - @endpush @push('scripts') @@ -48,80 +46,81 @@ //Function that will be called by Google Places Library function initAutocomplete() { - $('[data-google-address]').each(function() { - var $this = $(this), - $addressConfig = $this.data('google-address'), - $field = $('[name="' + $addressConfig.field + '"]'); - var $extra_fields = $('#' + $addressConfig.field + '_fields'); - - if ($field.val().length) { - //console.log($field.val()); - var existingData = JSON.parse($field.val()); - $this.val(existingData.value); - } - - var $autocomplete = new google.maps.places.Autocomplete( - ($this[0]), { - types: ['geocode'] - }); - - $autocomplete.addListener('place_changed', function fillInAddress() { - - var place = $autocomplete.getPlace(); - console.log(place); - var value = $this.val(); - var latlng = place.geometry.location; - var data = { - "value": value, - "latlng": latlng - }; + $('[data-google-address]').each( + function() { + var $this = $(this), + $addressConfig = $this.data('google-address'), + $field = $('[name="' + $addressConfig.field + '"]'); + var $extra_fields = $('#' + $addressConfig.field + '_fields'); + + if ($field.val().length) { + //console.log($field.val()); + var existingData = JSON.parse($field.val()); + $this.val(existingData.value); + } - for (var i = 0; i < place.address_components.length; i++) { - var addressType = place.address_components[i].types[0]; - data[addressType] = place.address_components[i]['long_name']; - data[addressType + '_short'] = place.address_components[i]['short_name']; + var $autocomplete = new google.maps.places.Autocomplete( + ($this[0]), { + types: ['geocode'] + }); + + $autocomplete.addListener('place_changed', function fillInAddress() { + + var place = $autocomplete.getPlace(); + console.log(place); + var value = $this.val(); + var latlng = place.geometry.location; + var data = { + "value": value, + "latlng": latlng + }; + + for (var i = 0; i < place.address_components.length; i++) { + var addressType = place.address_components[i].types[0]; + data[addressType] = place.address_components[i]['long_name']; + data[addressType + '_short'] = place.address_components[i]['short_name']; + + $('').attr({ + 'type': 'text', + 'name': '{{ $name }}[' + addressType + ']', + 'value': data[addressType] + }).appendTo($extra_fields); + + $('').attr({ + 'type': 'text', + 'name': '{{ $name }}[' + addressType + '_short]', + 'value': data[addressType + '_short'] + }).appendTo($extra_fields); + + } $('').attr({ 'type': 'text', - 'name': '{{ $name }}[' + addressType + ']', - 'value': data[addressType] + 'name': '{{ $name }}[latitude]', + 'value': latlng.lat, }).appendTo($extra_fields); - $('').attr({ 'type': 'text', - 'name': '{{ $name }}[' + addressType + '_short]', - 'value': data[addressType + '_short'] + 'name': '{{ $name }}[longitude]', + 'value': latlng.lng, }).appendTo($extra_fields); - } - $('').attr({ - 'type': 'text', - 'name': '{{ $name }}[latitude]', - 'value': latlng.lat, - }).appendTo($extra_fields); - $('').attr({ - 'type': 'text', - 'name': '{{ $name }}[longitude]', - 'value': latlng.lng, - }).appendTo($extra_fields); + $field.val(JSON.stringify(data)); + }); - $field.val(JSON.stringify(data)); + $this.change(function() { + if (!$this.val().length) { + $field.val(""); + } + $extra_fields.empty(); + }); - }); - $this.change(function() { - if (!$this.val().length) { - $field.val(""); - } - $extra_fields.empty(); }); - - }); - } - - -@endpush \ No newline at end of file + + +@endpush diff --git a/Resources/views/collective/fields/checkbox/boolean/switchery/field.blade.php b/Resources/views/collective/fields/checkbox/boolean/switchery/field.blade.php index bad424188..d265a3b39 100755 --- a/Resources/views/collective/fields/checkbox/boolean/switchery/field.blade.php +++ b/Resources/views/collective/fields/checkbox/boolean/switchery/field.blade.php @@ -38,9 +38,10 @@ class="js-switch" @endpush diff --git a/Resources/views/collective/fields/checkbox/checklist/checklist_dependency.blade.php b/Resources/views/collective/fields/checkbox/checklist/checklist_dependency.blade.php index aec677c5d..185c3f7c5 100755 --- a/Resources/views/collective/fields/checkbox/checklist/checklist_dependency.blade.php +++ b/Resources/views/collective/fields/checkbox/checklist/checklist_dependency.blade.php @@ -1,19 +1,20 @@ -
+
@include('crud::inc.field_translatable_icon') getModel(); - + $entity_model = $crud->getModel(); + // short name for dependency fields $primary_dependency = $field['subfields']['primary']; $secondary_dependency = $field['subfields']['secondary']; - + // all items with relation $dependencies = $primary_dependency['model']::with($primary_dependency['entity_secondary'])->get(); - + $dependencyArray = []; - + // convert dependency array to simple matrix ( prymary id as key and array with secondaries id ) foreach ($dependencies as $primary) { $dependencyArray[$primary->id] = []; @@ -21,21 +22,22 @@ $dependencyArray[$primary->id][] = $secondary->id; } } - + // for update form, get initial state of the entity if (isset($id) && $id) { // get entity with relations for primary dependency - $entity_dependencies = $entity_model->with($primary_dependency['entity']) - ->with($primary_dependency['entity'].'.'.$primary_dependency['entity_secondary']) + $entity_dependencies = $entity_model + ->with($primary_dependency['entity']) + ->with($primary_dependency['entity'] . '.' . $primary_dependency['entity_secondary']) ->find($id); - + $secondaries_from_primary = []; - + // convert relation in array $primary_array = $entity_dependencies->{$primary_dependency['entity']}->toArray(); - + $secondary_ids = []; - + // create secondary dependency from primary relation, used to check what chekbox must be check from second checklist if (old($primary_dependency['name'])) { foreach (old($primary_dependency['name']) as $primary_item) { @@ -43,7 +45,8 @@ $secondary_ids[$second_item] = $second_item; } } - } else { // create dependecies from relation if not from validate error + } else { + // create dependecies from relation if not from validate error foreach ($primary_array as $primary_item) { foreach ($primary_item[$secondary_dependency['entity']] as $second_item) { $secondary_ids[$second_item['id']] = $second_item['id']; @@ -51,57 +54,58 @@ } } } - + // json encode of dependency matrix $dependencyJson = json_encode($dependencyArray); ?> -
+
-
- @if(isset($field['value'])) - @if(old($primary_dependency['name'])) - @foreach( old($primary_dependency['name']) as $item ) - - @endforeach - @else - @foreach( $field['value'][0]->pluck('id', 'id')->toArray() as $item ) - - @endforeach +
+ @if (isset($field['value'])) + @if (old($primary_dependency['name'])) + @foreach (old($primary_dependency['name']) as $item) + + @endforeach + @else + @foreach ($field['value'][0]->pluck('id', 'id')->toArray() as $item) + + @endforeach + @endif @endif - @endif
- @foreach ($primary_dependency['model']::all() as $connected_entity_entry) -
-
-
- @endforeach + @endforeach
@@ -110,43 +114,47 @@ class = 'primary_list'
- @if(isset($field['value'])) - @if(old($secondary_dependency['name'])) - @foreach( old($secondary_dependency['name']) as $item ) - - @endforeach - @else - @foreach( $field['value'][1]->pluck('id', 'id')->toArray() as $item ) - - @endforeach + @if (isset($field['value'])) + @if (old($secondary_dependency['name'])) + @foreach (old($secondary_dependency['name']) as $item) + + @endforeach + @else + @foreach ($field['value'][1]->pluck('id', 'id')->toArray() as $item) + + @endforeach + @endif @endif - @endif
@foreach ($secondary_dependency['model']::all() as $connected_entity_entry) -
+
@@ -158,7 +166,7 @@ class = 'secondary_list'

{!! $field['hint'] !!}

@endif -
+
{{-- ########################################## --}} {{-- Extra CSS and JS for this particular field --}} @@ -166,7 +174,7 @@ class = 'secondary_list' @push('crud_fields_scripts') @endpush @@ -178,88 +186,99 @@ class = 'secondary_list' {{-- FIELD JS - will be loaded in the after_scripts section --}} @push('crud_fields_scripts') - - + + @endpush @endif diff --git a/Resources/views/collective/fields/list/field.blade.php b/Resources/views/collective/fields/list/field.blade.php index cc9790e4e..fd495dabf 100755 --- a/Resources/views/collective/fields/list/field.blade.php +++ b/Resources/views/collective/fields/list/field.blade.php @@ -1,11 +1,11 @@ @php -if (isset($options['field'])) { - $options = $options['field']->options; -} -extract($attributes); -$field = transFields(get_defined_vars()); -$value = Form::getValueAttribute($name); - + if (isset($options['field'])) { + $options = $options['field']->options; + } + extract($attributes); + $field = transFields(get_defined_vars()); + $value = Form::getValueAttribute($name); + @endphp @@ -21,11 +21,12 @@
{{ $v['label'] }}
-
    - @foreach($v['sons'] as $son) -
  • - {{ $son['label'] }} -
  • +
      + @foreach ($v['sons'] as $son) +
    • + {{ $son['label'] }} +
    • @endforeach
@@ -44,9 +45,10 @@ $(document).ready(function() { let values = $('input[name="{{ $name }}"]').val().split(','); - values.forEach(function(v) { - $('.list_checkbox_{{ $name }} input[name="' + v + '"]').prop('checked', true); - }); + values.foreach( + function(v) { + $('.list_checkbox_{{ $name }} input[name="' + v + '"]').prop('checked', true); + }); console.log(values); }); @@ -55,13 +57,14 @@ let list = new Array(); - $(this).find('input[type="checkbox"]').each(function(i, e) { + $(this).find('input[type="checkbox"]').each( + function(i, e) { - if (e.checked === true) { - list.push(e.value); - } + if (e.checked === true) { + list.push(e.value); + } - }); + }); $('input[name="{{ $name }}"]').val(list.join()); diff --git a/Resources/views/collective/fields/select/select2.blade.php b/Resources/views/collective/fields/select/select2.blade.php index 4404fce87..7c23dd0e9 100755 --- a/Resources/views/collective/fields/select/select2.blade.php +++ b/Resources/views/collective/fields/select/select2.blade.php @@ -1,8 +1,8 @@ @php - $current_value = old($field['name']) ?? $field['value'] ?? $field['default'] ?? ''; - $entity_model = $crud->getRelationModel($field['entity'], - 1); - + $current_value = old($field['name']) ?? ($field['value'] ?? ($field['default'] ?? '')); + $entity_model = $crud->getRelationModel($field['entity'], -1); + if (!isset($field['options'])) { $options = $field['model']::all(); } else { @@ -10,16 +10,12 @@ } @endphp -
+
@include('crud::inc.field_translatable_icon') - 'form-control select2_field'])> @if ($entity_model::isColumnNullable($field['name'])) @@ -27,7 +23,7 @@ @if (count($options)) @foreach ($options as $option) - @if($current_value == $option->getKey()) + @if ($current_value == $option->getKey()) @else @@ -46,12 +42,13 @@ {{-- Extra CSS and JS for this particular field --}} {{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}} @if ($crud->checkIfFieldIsFirstOfItsType($field)) - {{-- FIELD CSS - will be loaded in the after_styles section --}} @push('crud_fields_styles') - - + + @endpush {{-- FIELD JS - will be loaded in the after_scripts section --}} @@ -61,18 +58,17 @@ @endpush - @endif {{-- End of Extra CSS and JS --}} {{-- ########################################## --}} diff --git a/Resources/views/collective/fields/select/select2_from_ajax.blade.php b/Resources/views/collective/fields/select/select2_from_ajax.blade.php index 7cf50439a..e15a8320b 100755 --- a/Resources/views/collective/fields/select/select2_from_ajax.blade.php +++ b/Resources/views/collective/fields/select/select2_from_ajax.blade.php @@ -1,20 +1,16 @@ @php - $connected_entity = new $field['model']; + $connected_entity = new $field['model'](); $connected_entity_key_name = $connected_entity->getKeyName(); - $old_value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? false; + $old_value = old(square_brackets_to_dots($field['name'])) ?? ($field['value'] ?? ($field['default'] ?? false)); @endphp -
+
model; ?> - 'form-control'])> @if ($old_value) @php @@ -22,16 +18,16 @@ @endphp @if ($item) - {{-- allow clear --}} - @if ($entity_model::isColumnNullable($field['name'])) - - @endif + {{-- allow clear --}} + @if ($entity_model::isColumnNullable($field['name'])) + + @endif - + @endif @endif @@ -49,104 +45,108 @@ {{-- FIELD CSS - will be loaded in the after_styles section --}} @push('crud_fields_styles') - - - - {{-- allow clear --}} - @if ($entity_model::isColumnNullable($field['name'])) - - @endif + + + + {{-- allow clear --}} + @if ($entity_model::isColumnNullable($field['name'])) + + @endif @endpush {{-- FIELD JS - will be loaded in the after_scripts section --}} @push('crud_fields_scripts') - - + + @endpush @endif @push('crud_fields_scripts') - + @endpush {{-- End of Extra CSS and JS --}} {{-- ########################################## --}} diff --git a/Resources/views/collective/fields/select/select2_from_ajax_multiple.blade.php b/Resources/views/collective/fields/select/select2_from_ajax_multiple.blade.php index dd94b0f53..053ed1e56 100755 --- a/Resources/views/collective/fields/select/select2_from_ajax_multiple.blade.php +++ b/Resources/views/collective/fields/select/select2_from_ajax_multiple.blade.php @@ -1,19 +1,15 @@ @php - $connected_entity = new $field['model']; + $connected_entity = new $field['model'](); $connected_entity_key_name = $connected_entity->getKeyName(); - $old_value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? false; + $old_value = old(square_brackets_to_dots($field['name'])) ?? ($field['value'] ?? ($field['default'] ?? false)); @endphp -
+
@include('crud::inc.field_translatable_icon') - 'form-control']) multiple> @if ($old_value) @foreach ($old_value as $item) @@ -40,82 +36,84 @@ {{-- Extra CSS and JS for this particular field --}} {{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}} @if ($crud->checkIfFieldIsFirstOfItsType($field)) - {{-- FIELD CSS - will be loaded in the after_styles section --}} @push('crud_fields_styles') - - - + + + @endpush {{-- FIELD JS - will be loaded in the after_scripts section --}} @push('crud_fields_scripts') - - + + @endpush - @endif @push('crud_fields_scripts') - + @if (isset($field['dependencies'])) + @foreach (array_wrap($field['dependencies']) as $dependency) + $('input[name={{ $dependency }}], select[name={{ $dependency }}], checkbox[name={{ $dependency }}], radio[name={{ $dependency }}], textarea[name={{ $dependency }}]') + .change(function() { + $("#select2_ajax_multiple_{{ $field['name'] }}").val(null).trigger("change"); + }); + @endforeach + @endif + }); + @endpush {{-- End of Extra CSS and JS --}} {{-- ########################################## --}} diff --git a/Resources/views/collective/fields/select/select2_from_array.blade.php b/Resources/views/collective/fields/select/select2_from_array.blade.php index fa3a4458a..6a785238a 100755 --- a/Resources/views/collective/fields/select/select2_from_array.blade.php +++ b/Resources/views/collective/fields/select/select2_from_array.blade.php @@ -66,7 +66,8 @@ @endpush - @endif {{-- End of Extra CSS and JS --}} {{-- ########################################## --}} diff --git a/Resources/views/collective/fields/select/select_and_order.blade.php b/Resources/views/collective/fields/select/select_and_order.blade.php index 499131078..d6fd98e7d 100755 --- a/Resources/views/collective/fields/select/select_and_order.blade.php +++ b/Resources/views/collective/fields/select/select_and_order.blade.php @@ -1,40 +1,42 @@ @php - $values = isset($field['value']) ? (array)$field['value'] : []; + $values = isset($field['value']) ? (array) $field['value'] : []; @endphp -
+
@include('crud::inc.field_translatable_icon')
-
    - @if(old($field["name"])) - @if(is_array(old($field["name"]))) - @foreach (old($field["name"]) as $key) - @if(array_key_exists($key,$field['options'])) -
  • {{ $field['options'][$key] }}
  • +
      + @if (old($field['name'])) + @if (is_array(old($field['name']))) + @foreach (old($field['name']) as $key) + @if (array_key_exists($key, $field['options'])) +
    • {{ $field['options'][$key] }} +
    • @endif @endforeach @endif @elseif (is_array($values)) @foreach ($values as $key) - @if(array_key_exists($key,$field['options'])) -
    • {{ $field['options'][$key] }}
    • + @if (array_key_exists($key, $field['options'])) +
    • {{ $field['options'][$key] }}
    • @endif @endforeach @endif
      - @if(old($field["name"])) + @if (old($field['name'])) @foreach ($field['options'] as $key => $value) - @if(!is_array(old($field["name"])) || !in_array($key, old($field["name"]))) -
    • {{ $value }}
    • + @if (!is_array(old($field['name'])) || !in_array($key, old($field['name']))) +
    • {{ $value }}
    • @endif @endforeach @elseif (isset($field['options'])) @foreach ($field['options'] as $key => $value) - @if(is_array($values) && !in_array($key, $values)) -
    • {{ $value }}
    • + @if (is_array($values) && !in_array($key, $values)) +
    • {{ $value }}
    • @endif @endforeach @endif @@ -59,96 +61,101 @@ {{-- Extra CSS and JS for this particular field --}} {{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}} @if ($crud->checkIfFieldIsFirstOfItsType($field, $fields)) - {{-- FIELD CSS - will be loaded in the after_styles section --}} @push('crud_fields_styles') - + .select_and_order_all { + border: none; + } + + .select_and_order_all li, + .select_and_order_selected li { + border: 1px solid #eee; + margin-top: 5px; + padding: 5px; + font-size: 1em; + overflow: hidden; + cursor: grab; + border-style: dashed; + } + + .select_and_order_all li { + background: #fbfbfb; + color: grey; + } + + .select_and_order_selected li { + border-style: solid; + } + + .select_and_order_all li.ui-sortable-helper, + .select_and_order_selected li.ui-sortable-helper { + color: #3c8dbc; + border-collapse: #3c8dbc; + z-index: 9999; + } + + .select_and_order_all .ui-sortable-placeholder, + .select_and_order_selected .ui-sortable-placeholder { + border: 1px dashed #3c8dbc; + visibility: visible !important; + } + + .ui-sortable-handle { + -ms-touch-action: none; + touch-action: none; + } + @endpush @push('crud_fields_scripts') - + @endpush - @endif {{-- FIELD JS - will be loaded in the after_scripts section --}} @push('crud_fields_scripts') - + }).disableSelection(); + }); + @endpush {{-- End of Extra CSS and JS --}} diff --git a/Resources/views/collective/fields/test/table/table.blade.php b/Resources/views/collective/fields/test/table/table.blade.php index a633f4fe1..9237010e9 100755 --- a/Resources/views/collective/fields/test/table/table.blade.php +++ b/Resources/views/collective/fields/test/table/table.blade.php @@ -2,7 +2,7 @@ // $max = isset($field['max']) && (int) $field['max'] > 0 ? $field['max'] : -1; $min = isset($field['min']) && (int) $field['min'] > 0 ? $field['min'] : -1; -$item_name = strtolower(isset($field['entity_singular']) && ! empty($field['entity_singular']) ? $field['entity_singular'] : $field['label']); +$item_name = strtolower(isset($field['entity_singular']) && !empty($field['entity_singular']) ? $field['entity_singular'] : $field['label']); $items = old(square_brackets_to_dots($field['name'])) ?? ($field['value'] ?? ($field['default'] ?? '')); @@ -14,7 +14,7 @@ } else { $items = '[]'; } -} elseif (is_string($items) && ! is_array(json_decode($items))) { +} elseif (is_string($items) && !is_array(json_decode($items))) { $items = '[]'; } @@ -66,8 +66,8 @@ class="fa fa-sort" role="presentation" aria-hidden="true"> + ng-click="removeItem(item);">delete item @@ -119,9 +119,10 @@ class="fa fa-trash" role="presentation" aria-hidden="true"> handle: '.sort-handle', axis: 'y', helper: function(e, ui) { - ui.children().each(function() { - $(this).width($(this).width()); - }); + ui.children().each( + function() { + $(this).width($(this).width()); + }); return ui; }, }; diff --git a/Resources/views/collective/fields/test/video/video.blade.php b/Resources/views/collective/fields/test/video/video.blade.php index 36185f6c7..948de1369 100755 --- a/Resources/views/collective/fields/test/video/video.blade.php +++ b/Resources/views/collective/fields/test/video/video.blade.php @@ -19,8 +19,7 @@ @include('crud::inc.field_translatable_icon')
      - 'video-link form-control']) type="text" - id="{{ $field['name'] }}_link"> + 'video-link form-control']) type="text" id="{{ $field['name'] }}_link">
      @@ -96,7 +95,6 @@ background-size: cover; background-position: center center; } - @endpush @@ -112,12 +110,12 @@ // RegExps for YouTube link forms var youtubeStandardExpr = - /^https?:\/\/(www\.)?youtube.com\/watch\?v=([^?&]+)/i; // Group 2 is video ID + /^https?:\/\/(www\.)?youtube.com\/watch\?v=([^?&]+)/i; // Group 2 is video ID var youtubeAlternateExpr = - /^https?:\/\/(www\.)?youtube.com\/v\/([^\/\?]+)/i; // Group 2 is video ID + /^https?:\/\/(www\.)?youtube.com\/v\/([^\/\?]+)/i; // Group 2 is video ID var youtubeShortExpr = /^https?:\/\/youtu.be\/([^\/]+)/i; // Group 1 is video ID var youtubeEmbedExpr = - /^https?:\/\/(www\.)?youtube.com\/embed\/([^\/]+)/i; // Group 2 is video ID + /^https?:\/\/(www\.)?youtube.com\/embed\/([^\/]+)/i; // Group 2 is video ID var match = link.match(youtubeStandardExpr); @@ -295,62 +293,63 @@ }; // Loop through all instances of the video field - $("[data-video]").each(function(index) { - - var $this = $(this), - jsonField = $this.find('.video-json'), - linkField = $this.find('.video-link'), - pDummy = $this.find('.video-dummy'), - pWrap = $this.find('.video-preview'); - - try { - var videoJson = JSON.parse(jsonField.val()); - jsonField.val(JSON.stringify(videoJson)); - linkField.val(videoJson.url); - updateVideoPreview(videoJson, $this); - } catch (e) { - pDummy.show(); - pWrap.hide(); - jsonField.val(''); - linkField.val(''); - } + $("[data-video]").each( + function(index) { + + var $this = $(this), + jsonField = $this.find('.video-json'), + linkField = $this.find('.video-link'), + pDummy = $this.find('.video-dummy'), + pWrap = $this.find('.video-preview'); + + try { + var videoJson = JSON.parse(jsonField.val()); + jsonField.val(JSON.stringify(videoJson)); + linkField.val(videoJson.url); + updateVideoPreview(videoJson, $this); + } catch (e) { + pDummy.show(); + pWrap.hide(); + jsonField.val(''); + linkField.val(''); + } - linkField.on('focus', function() { - linkField.originalState = linkField.val(); - }); + linkField.on('focus', function() { + linkField.originalState = linkField.val(); + }); - linkField.on('change', function() { + linkField.on('change', function() { - if (linkField.originalState != linkField.val()) { + if (linkField.originalState != linkField.val()) { - if (linkField.val().length) { + if (linkField.val().length) { - videoParsing = true; + videoParsing = true; - parseVideoLink(linkField.val(), function(videoJson) { + parseVideoLink(linkField.val(), function(videoJson) { - if (videoJson.success) { - linkField.val(videoJson.data.url); - jsonField.val(JSON.stringify(videoJson.data)); - updateVideoPreview(videoJson.data, $this); - } else { - pDummy.show(); - pWrap.hide(); - alert(videoJson.message); - } + if (videoJson.success) { + linkField.val(videoJson.data.url); + jsonField.val(JSON.stringify(videoJson.data)); + updateVideoPreview(videoJson.data, $this); + } else { + pDummy.show(); + pWrap.hide(); + alert(videoJson.message); + } + videoParsing = false; + }); + } else { videoParsing = false; - }); - } else { - videoParsing = false; - jsonField.val(''); - $this.find('.video-preview').fadeOut(); - pDummy.show(); - pWrap.hide(); + jsonField.val(''); + $this.find('.video-preview').fadeOut(); + pDummy.show(); + pWrap.hide(); + } } - } + }); }); - }); var videoParsing = false; diff --git a/Resources/views/collective/fields/upload/browse/browse_multiple.blade.php b/Resources/views/collective/fields/upload/browse/browse_multiple.blade.php index 1bb8ca100..7902e6dec 100755 --- a/Resources/views/collective/fields/upload/browse/browse_multiple.blade.php +++ b/Resources/views/collective/fields/upload/browse/browse_multiple.blade.php @@ -1,21 +1,22 @@ @php -$multiple = array_get($field, 'multiple', true); -$value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? ''; - -if (!$multiple && is_array($value)) { - $value = array_first($value); -} + $multiple = array_get($field, 'multiple', true); + $value = old(square_brackets_to_dots($field['name'])) ?? ($field['value'] ?? ($field['default'] ?? '')); + + if (!$multiple && is_array($value)) { + $value = array_first($value); + } @endphp -
      +
      @include('crud::inc.field_translatable_icon') @if ($multiple) - @foreach((array)$value as $v) + @foreach ((array) $value as $v) @if ($v)
      - +