Create an use a textarea component to extract all complex logic out of the view(s)

Ability to use a custom component if needed
parent 363ed194
...@@ -13,6 +13,10 @@ class EditorIsRendering ...@@ -13,6 +13,10 @@ class EditorIsRendering
private $editorClass; private $editorClass;
private $editorJsPartial; private $editorJsPartial;
private $editorCssPartial; private $editorCssPartial;
private $editorComponents = [
'i18n' => 'core::components.i18n.textarea',
'normal' => 'core::components.textarea',
];
public function __construct(AssetPipeline $assetPipeline) public function __construct(AssetPipeline $assetPipeline)
{ {
...@@ -80,4 +84,24 @@ class EditorIsRendering ...@@ -80,4 +84,24 @@ class EditorIsRendering
{ {
$this->editorCssPartial = $editorCssPartial; $this->editorCssPartial = $editorCssPartial;
} }
public function getI18nComponentName()
{
return $this->editorComponents['i18n'];
}
public function setI18nComponentName($componentName)
{
$this->editorComponents['i18n'] = $componentName;
}
public function getNormalComponentName()
{
return $this->editorComponents['normal'];
}
public function setNormalComponentName($componentName)
{
$this->editorComponents['normal'] = $componentName;
}
} }
@if ($editor->getEditorCssPartial() !== null)
@include($editor->getEditorCssPartial())
@endif
<div class='{{ $errors->has("{$lang}.body") ? ' has-error' : '' }}'>
{!! Form::label("{$lang}[body]", trans('page::pages.form.body')) !!}
<textarea class="{{ $editor->getEditorClass() }}" name="{{$lang}}[body]" rows="10" cols="80">{{ $slot }}</textarea>
{!! $errors->first("{$lang}.body", '<span class="help-block">:message</span>') !!}
</div>
@if ($editor->getEditorJsPartial() !== null)
@include($editor->getEditorJsPartial())
@endif
...@@ -19,10 +19,6 @@ ...@@ -19,10 +19,6 @@
</style> </style>
@stop @stop
@if ($editor->getEditorCssPartial() !== null)
@include($editor->getEditorCssPartial())
@endif
@section('content') @section('content')
{!! Form::open(['route' => ['admin.page.page.store'], 'method' => 'post']) !!} {!! Form::open(['route' => ['admin.page.page.store'], 'method' => 'post']) !!}
<div class="row"> <div class="row">
...@@ -106,7 +102,3 @@ ...@@ -106,7 +102,3 @@
}); });
</script> </script>
@stop @stop
@if ($editor->getEditorJsPartial() !== null)
@include($editor->getEditorJsPartial())
@endif
...@@ -19,10 +19,6 @@ ...@@ -19,10 +19,6 @@
</style> </style>
@stop @stop
@if ($editor->getEditorCssPartial() !== null)
@include($editor->getEditorCssPartial())
@endif
@section('content') @section('content')
{!! Form::open(['route' => ['admin.page.page.update', $page->id], 'method' => 'put']) !!} {!! Form::open(['route' => ['admin.page.page.update', $page->id], 'method' => 'put']) !!}
<div class="row"> <div class="row">
...@@ -113,7 +109,3 @@ ...@@ -113,7 +109,3 @@
}); });
</script> </script>
@stop @stop
@if ($editor->getEditorJsPartial() !== null)
@include($editor->getEditorJsPartial())
@endif
...@@ -10,11 +10,10 @@ ...@@ -10,11 +10,10 @@
{!! Form::text("{$lang}[slug]", old("{$lang}.slug"), ['class' => 'form-control slug', 'data-slug' => 'target', 'placeholder' => trans('page::pages.form.slug')]) !!} {!! Form::text("{$lang}[slug]", old("{$lang}.slug"), ['class' => 'form-control slug', 'data-slug' => 'target', 'placeholder' => trans('page::pages.form.slug')]) !!}
{!! $errors->first("{$lang}.slug", '<span class="help-block">:message</span>') !!} {!! $errors->first("{$lang}.slug", '<span class="help-block">:message</span>') !!}
</div> </div>
<div class='{{ $errors->has("{$lang}.body") ? ' has-error' : '' }}'> @component($editor->getI18nComponentName(), compact('lang'))
{!! Form::label("{$lang}[body]", trans('page::pages.form.body')) !!} {{ old("{$lang}.body") }}
<textarea class="{{ $editor->getEditorClass() }}" name="{{$lang}}[body]" rows="10" cols="80">{{ old("{$lang}.body") }}</textarea> @endcomponent
{!! $errors->first("{$lang}.body", '<span class="help-block">:message</span>') !!}
</div>
<?php if (config('asgard.page.config.partials.translatable.create') !== []): ?> <?php if (config('asgard.page.config.partials.translatable.create') !== []): ?>
<?php foreach (config('asgard.page.config.partials.translatable.create') as $partial): ?> <?php foreach (config('asgard.page.config.partials.translatable.create') as $partial): ?>
@include($partial) @include($partial)
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
{!! Form::text("{$lang}[slug]", old("{$lang}.slug", $old), ['class' => 'form-control slug', 'data-slug' => 'target', 'placeholder' => trans('page::pages.form.slug')]) !!} {!! Form::text("{$lang}[slug]", old("{$lang}.slug", $old), ['class' => 'form-control slug', 'data-slug' => 'target', 'placeholder' => trans('page::pages.form.slug')]) !!}
{!! $errors->first("{$lang}.slug", '<span class="help-block">:message</span>') !!} {!! $errors->first("{$lang}.slug", '<span class="help-block">:message</span>') !!}
</div> </div>
<div class='{{ $errors->has("{$lang}.body") ? ' has-error' : '' }}'>
{!! Form::label("{$lang}[body]", trans('page::pages.form.body')) !!} @component($editor->getI18nComponentName(), compact('lang'))
<?php $old = $page->hasTranslation($lang) ? $page->translate($lang)->body : '' ?> <?php $old = $page->hasTranslation($lang) ? $page->translate($lang)->body : '' ?>
<textarea class="{{ $editor->getEditorClass() }}" name="{{$lang}}[body]" rows="10" cols="80">{!! old("$lang.body", $old) !!}</textarea> {!! old("$lang.body", $old) !!}
{!! $errors->first("{$lang}.body", '<span class="help-block">:message</span>') !!} @endcomponent
</div>
<?php if (config('asgard.page.config.partials.translatable.edit') !== []): ?> <?php if (config('asgard.page.config.partials.translatable.edit') !== []): ?>
<?php foreach (config('asgard.page.config.partials.translatable.edit') as $partial): ?> <?php foreach (config('asgard.page.config.partials.translatable.edit') as $partial): ?>
@include($partial) @include($partial)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment