From: Vincent Vanwaelscappel Date: Wed, 19 Oct 2022 10:36:18 +0000 (+0200) Subject: wip #5468 @7 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c5cb943338594e695c0cb2899ba9648bea898ac5;p=fluidbook-toolbox.git wip #5468 @7 --- diff --git a/app/Fields/FluidbookLinkEditor/LinkType.php b/app/Fields/FluidbookLinkEditor/LinkType.php index 146c22d65..4be979496 100644 --- a/app/Fields/FluidbookLinkEditor/LinkType.php +++ b/app/Fields/FluidbookLinkEditor/LinkType.php @@ -8,12 +8,14 @@ use Cubist\Backpack\Magic\Fields\SelectFromArray; class LinkType extends SelectFromArray { protected $_allowsHTML = true; + protected $_ajax = false; + protected $_allowNull = false; public function getOptions() { $res = []; foreach (Base::types() as $type) { - $res[$type['type']] = '' . $type['label'] . ''; + $res[$type['type']] = '' . $type['label'] . ''; } return $res; } diff --git a/app/SubForms/Link/Base.php b/app/SubForms/Link/Base.php index c58051f45..8855a3605 100644 --- a/app/SubForms/Link/Base.php +++ b/app/SubForms/Link/Base.php @@ -8,9 +8,9 @@ use App\Fields\FluidbookLinkEditor\MultimediaIntegration; use Cubist\Backpack\Magic\Fields\FormSection; use Cubist\Backpack\Magic\Fields\Number; use Cubist\Backpack\Magic\Fields\Text; -use Cubist\Backpack\Magic\SubForm; +use Cubist\Backpack\Magic\Form; -class Base extends SubForm +class Base extends Form { const WEB_INFOS = 1; const PRODUCT = 1; @@ -68,10 +68,10 @@ class Base extends SubForm public static function types() { return [ - ['type' => self::WEB_INFOS, 'label' => __('Lien web « plus d\'infos »'), 'color' => '#ff0000', 'class' => WebInfos::class, 'class' => Web::class], - ['type' => self::WEB, 'label' => __('Lien web'), 'color' => '#3399cc', 'class' => Web::class, 'class' => Web::class], - ['type' => self::EMAIL, 'label' => __('Adresse e-mail'), 'color' => '#6c6360', 'class' => Web::class], - ['type' => self::VIDEO, 'label' => __('Vidéo'), 'color' => '#33ff00', 'class' => Web::class], + ['type' => self::WEB_INFOS, 'label' => __('Lien web « plus d\'infos »'), 'color' => '#ff0000', 'class' => WebInfos::class], + ['type' => self::WEB, 'label' => __('Lien web'), 'color' => '#3399cc', 'class' => Web::class], + ['type' => self::EMAIL, 'label' => __('Adresse e-mail'), 'color' => '#6c6360', 'class' => Email::class], + ['type' => self::VIDEO, 'label' => __('Vidéo'), 'color' => '#33ff00', 'class' => Video::class], ['type' => self::INTERNAL, 'label' => __('Lien vers une page'), 'color' => '#c7b405', 'class' => Web::class], ['type' => self::MULTIMEDIA, 'label' => __('Multimédia'), 'color' => '#ff00ff', 'class' => Web::class], ['type' => self::CUSTOM, 'label' => __('Lien personnalisé'), 'color' => '#14511a', 'class' => Web::class], @@ -183,4 +183,18 @@ class Base extends SubForm { $this->addField('header_settings', FormSection::class, __('Autres paramètres')); } + + public function getType() + { + return $this->getValue('type'); + } + + /** + * @return string + */ + + public function render(callable $callback = null) + { + return view('fluidbook_publication.link_editor_form', ['form' => $this, 'crud' => $this->crud])->render($callback); + } } diff --git a/resources/linkeditor/style/form.sass b/resources/linkeditor/style/form.sass new file mode 100644 index 000000000..00af59c33 --- /dev/null +++ b/resources/linkeditor/style/form.sass @@ -0,0 +1,14 @@ +#linkeditor-form-templates + display: block + + +.linkeditor-linktype + &::before + display: inline-block + width: 20px + height: 20px + border-radius: 2px + margin: 0 10px 0 0 + content: "" + vertical-align: top + position: relative diff --git a/resources/linkeditor/style/style.sass b/resources/linkeditor/style/style.sass index 2164e1565..f707ade68 100644 --- a/resources/linkeditor/style/style.sass +++ b/resources/linkeditor/style/style.sass @@ -144,3 +144,4 @@ body, #linkeditor, html @import "toolbar" @import "rulers" @import "links" +@import "form" diff --git a/resources/views/fluidbook_publication/link_editor.blade.php b/resources/views/fluidbook_publication/link_editor.blade.php index b3c9d1115..a3d47ed0c 100644 --- a/resources/views/fluidbook_publication/link_editor.blade.php +++ b/resources/views/fluidbook_publication/link_editor.blade.php @@ -115,6 +115,18 @@
+
+ @foreach(\App\SubForms\Link\Base::types() as $f) + @if(isset($f['disabled']) && $f['disabled']) + @continue; + @endif + @php + $instance=new $f['class'](); + $instance->setValue('type',$f['type']); + echo $instance->render(); + @endphp + @endforeach +
@endsection @push('after_scripts') @@ -131,10 +143,13 @@ @push('after_styles') getTitle()); + $action='create'; + $fields=$crud->fields(); +@endphp + +@if($form->getTitle()) +

{{$form->getTitle()}}

+@endif +
+ + + @if($form->isCsrf()) + @csrf + @endif + @include('crud::form_content') +
+@php + stop_measure('Render form '.$form->getTitle()); +@endphp