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
private $editorClass;
private $editorJsPartial;
private $editorCssPartial;
private $editorComponents = [
'i18n' => 'core::components.i18n.textarea',
'normal' => 'core::components.textarea',
];
public function __construct(AssetPipeline $assetPipeline)
{
......@@ -80,4 +84,24 @@ class EditorIsRendering
{
$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 @@
</style>
@stop
@if ($editor->getEditorCssPartial() !== null)
@include($editor->getEditorCssPartial())
@endif
@section('content')
{!! Form::open(['route' => ['admin.page.page.store'], 'method' => 'post']) !!}
<div class="row">
......@@ -106,7 +102,3 @@
});
</script>
@stop
@if ($editor->getEditorJsPartial() !== null)
@include($editor->getEditorJsPartial())
@endif
......@@ -19,10 +19,6 @@
</style>
@stop
@if ($editor->getEditorCssPartial() !== null)
@include($editor->getEditorCssPartial())
@endif
@section('content')
{!! Form::open(['route' => ['admin.page.page.update', $page->id], 'method' => 'put']) !!}
<div class="row">
......@@ -113,7 +109,3 @@
});
</script>
@stop
@if ($editor->getEditorJsPartial() !== null)
@include($editor->getEditorJsPartial())
@endif
......@@ -10,11 +10,10 @@
{!! 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>') !!}
</div>
<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">{{ old("{$lang}.body") }}</textarea>
{!! $errors->first("{$lang}.body", '<span class="help-block">:message</span>') !!}
</div>
@component($editor->getI18nComponentName(), compact('lang'))
{{ old("{$lang}.body") }}
@endcomponent
<?php if (config('asgard.page.config.partials.translatable.create') !== []): ?>
<?php foreach (config('asgard.page.config.partials.translatable.create') as $partial): ?>
@include($partial)
......
......@@ -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')]) !!}
{!! $errors->first("{$lang}.slug", '<span class="help-block">:message</span>') !!}
</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 : '' ?>
<textarea class="{{ $editor->getEditorClass() }}" name="{{$lang}}[body]" rows="10" cols="80">{!! old("$lang.body", $old) !!}</textarea>
{!! $errors->first("{$lang}.body", '<span class="help-block">:message</span>') !!}
</div>
{!! old("$lang.body", $old) !!}
@endcomponent
<?php if (config('asgard.page.config.partials.translatable.edit') !== []): ?>
<?php foreach (config('asgard.page.config.partials.translatable.edit') as $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