FEATURE: make templates not-editable

This commit is contained in:
Michal Kváček
2016-09-21 00:58:03 +02:00
parent f5e1e24df8
commit 7d051d1f6a
4 changed files with 26 additions and 19 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ class EditTemplate extends Controller
} }
// save new content only if something was changed // save new content only if something was changed
if ($this->isContentDifferent($originalTemplate, $customTemplate, $request->templateContent)) { if ($template->editable && $this->isContentDifferent($originalTemplate, $customTemplate, $request->templateContent)) {
// create directory for custom updates // create directory for custom updates
if (!is_dir($customDir)) { if (!is_dir($customDir)) {
@@ -13,7 +13,6 @@ class EditTemplateRequest extends Request
{ {
return [ return [
'name' => 'required|max:128', 'name' => 'required|max:128',
'templateContent' => 'required'
]; ];
} }
} }
@@ -8,6 +8,7 @@
{!! csrf_field() !!} {!! csrf_field() !!}
<div class="row"> <div class="row">
<div class="col-lg-8"> <div class="col-lg-8">
@if($template->editable)
@include('admin.snippets.aceEditor', [ @include('admin.snippets.aceEditor', [
'value' => old('templateContent', $templateContent), 'value' => old('templateContent', $templateContent),
'theme' => 'xcode', 'theme' => 'xcode',
@@ -15,6 +16,11 @@
'name' => 'templateContent', 'name' => 'templateContent',
'rows' => '20' 'rows' => '20'
]) ])
@else
<code>
<pre>{{$templateContent}}</pre>
</code>
@endif
</div> </div>
<div class="col-lg-4"> <div class="col-lg-4">
@@ -1,33 +1,35 @@
<div class="tile-overview"> <div class="tile-overview">
@forelse($templates as $template) @forelse($templates as $template)
<div class="col-lg-3"> <div class="col-lg-3">
<div class="text-center" title="{{$template->name}}"> <div class="text-center bold" data-toggle="tooltip" title="{{$template->name}}">
{{str_limit($template->name, 15)}} {{str_limit($template->name, 15)}}
</div> </div>
<div> <div class="text-center">
{{str_limit($template->description, 150)}} {{str_limit($template->description, 150)}}
</div> </div>
@if($isWritable) @if($isWritable)
<a data-template-id="{{$template->id}}" data-template-name="{{$template->template_name}}" <a data-template-id="{{$template->id}}" data-template-name="{{$template->template_name}}"
class="btn btn-pill-left btn-primary col-lg-6 copy-template" class="btn btn-pill-left btn-secondary col-lg-6 copy-template" data-toggle="tooltip"
title="@lang('admin/templates.copy')"> title="@lang('admin/templates.copy')">
<i class="fa fa-copy"></i> <i class="fa fa-copy"></i>
</a> </a>
@else @else
<a href="#" class="btn btn-pill-left btn-primary disabled col-lg-6" <a href="#" class="btn btn-pill-left btn-secondary disabled col-lg-6" data-toggle="tooltip"
title="@lang('admin/templates.cannotCopy')"> title="@lang('admin/templates.cannotCopy')">
<i class="fa fa-copy"></i> <i class="fa fa-copy"></i>
</a> </a>
@endif @endif
@if ($template->editable)
<a href="{{route('templates.edit', ['id' => $template->id])}}" <a href="{{route('templates.edit', ['id' => $template->id])}}"
class="btn btn-primary btn-pill-right col-lg-6" class="btn btn-primary btn-pill-right col-lg-6" data-toggle="tooltip"
title="@lang('admin/templates.edit', ['name' => $template->name])"> title="@lang('admin/templates.edit', ['name' => $template->name])">
@if ($template->editable)
<i class="fa fa-edit"></i> <i class="fa fa-edit"></i>
</a> @else
<i class="fa fa-info"></i>
@endif @endif
</a>
</div> </div>
@empty @empty
<div class="alert alert-info"> <div class="alert alert-info">