FEATURE: make own page for template overview

This commit is contained in:
Michal Kváček
2017-09-15 13:32:09 +02:00
parent 4d68156a73
commit ba55702585
14 changed files with 151 additions and 100 deletions
@@ -0,0 +1,24 @@
@if($directory->parent_id)
<a href="{{route('templates.overview', ['path' => $directory->parent_id])}}" class="button full-width secondary">
@lang('admin/templates.parentDirectory') <i class="fa fa-level-up"></i>
</a>
<br />
@endif
<h4>@lang($directory->name)</h4>
{{--@if (true || isset($isWritable) && $isWritable)--}}
{{--<div class="text-right">--}}
{{--<a href="{{route('templates.new', ['pathId' => $directory->id])}}"><i class="fa fa-plus"></i> @lang('admin/templates.new')</a> <br />--}}
{{--</div>--}}
{{--@endif--}}
<div>
<ul>
@forelse($directory->subdirectories as $subdirectory)
<li><a href="{{route('templates.overview', ['path' => $subdirectory->id])}}">{{trans($subdirectory->name)}}</a></li>
@empty
<li><em>@lang('admin/templates.noSubdirectories')</em></li>
@endforelse
</ul>
</div>
@@ -0,0 +1,45 @@
@if (!$isWritable)
<div class="alert alert-warning">
@lang('admin/templates.notWritable', ['file' => $path->path])
</div>
@endif
<form action="{{route('templates.postEdit', ['id' => $template->id])}}" method="POST">
{!! csrf_field() !!}
<div class="row">
<div class="col-lg-8">
@if($template->editable)
@include('admin.snippets.aceEditor', [
'value' => old('templateContent', $templateContent),
'theme' => 'xcode',
'mode' => 'html',
'name' => 'templateContent',
'rows' => '20'
])
@else
<code>
<pre>{{$templateContent}}</pre>
</code>
@endif
</div>
<div class="col-lg-4">
<label class="label-control">
@lang('admin/templates.name')
</label>
<input type="text" class="form-control" name="name" value="{{old('name', $template->name)}}" />
<label class="label-control">
@lang('admin/templates.description')
</label>
<textarea class="form-control" name="description"
rows="3">{{old('description', $template->description)}}</textarea>
<button type="submit" class="btn btn-primary">
@lang('admin/templates.edit', ['name' => $template->template_name])
</button>
</div>
</div>
</form>
@@ -0,0 +1,70 @@
<div class="tile-overview sameheight-container">
@forelse($directory->templates as $template)
<div class="col-lg-3">
<div class="text-center bold" data-toggle="tooltip" title="{{$template->name}}">
{{str_limit($template->name, 15)}}
</div>
<div class="text-center sameheight-item">
{{str_limit($template->description, 150)}}
</div>
@can('copy', \App\Models\Templates\Template::class)
@if($isWritable)
<a data-template-id="{{$template->id}}" data-template-name="{{$template->template_name}}"
class="btn btn-pill-left btn-secondary col-lg-6 copy-template" data-toggle="tooltip"
title="@lang('admin/templates.copy')">
<i class="fa fa-copy"></i>
</a>
@else
<a href="#" class="btn btn-pill-left btn-secondary disabled col-lg-6" data-toggle="tooltip"
title="@lang('admin/templates.cannotCopy')">
<i class="fa fa-copy"></i>
</a>
@endif
@endcan
@can('update', $template)
<a href="{{route('templates.edit', ['id' => $template->id])}}"
class="btn btn-primary btn-pill-right col-lg-6" data-toggle="tooltip"
title="@lang('admin/templates.edit', ['name' => $template->name])">
@if ($template->editable)
<i class="fa fa-edit"></i>
@else
<i class="fa fa-info"></i>
@endif
</a>
@endcan
</div>
@empty
<div class="alert alert-info">
<em>@lang('admin/templates.noTemplates')</em>
</div>
@endforelse
</div>
@section('javascripts')
<script type="text/javascript">
$ ('.copy-template').click (function () {
var link = $ (this);
var templateId = link.data ('template-id');
var templateName = link.data ('template-name');
templateName = templateName.substr (templateName.search ('::') + 2, templateName.length);
var newTemplateName = prompt ("@lang('admin/templates.newTemplateName')", templateName + "_" + "@lang('admin/templates.newTemplateNameSuffix')");
// no name given - give up
if (newTemplateName === null) return;
// copy given template
$.post ('{{route('templates.postCopy')}}', {
template: templateId,
newName: newTemplateName,
_token: "{{csrf_token()}}"
}, function (data) {
if (data.status === 'success') {
location.reload ();
}
});
});
</script>
@endsection