FEATURE: add basic funcionality for template copies.
This commit contains only basic funcionality.
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use App\Http\Requests;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
class CopyTemplate extends Controller
|
||||||
|
{
|
||||||
|
public function createCopy(Requests\CopyTemplateRequest $request) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
class CopyTemplateRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'templateId' => 'required|exists:templates,id',
|
||||||
|
'newTemplateName' => 'required'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -55,8 +55,8 @@ Route::group([
|
|||||||
Route::get('templates/overview/path/{id}', 'TemplateOverview@getPath')
|
Route::get('templates/overview/path/{id}', 'TemplateOverview@getPath')
|
||||||
->name('templates.overview');
|
->name('templates.overview');
|
||||||
|
|
||||||
Route::get('templates/copy/{id}', 'TemplateOverview@getPath')
|
Route::post('templates/copy', 'CopyTemplate@createCopy')
|
||||||
->name('templates.copy');
|
->name('templates.postCopy');
|
||||||
|
|
||||||
Route::get('templates/new/{pathId}', 'TemplateOverview@getPath')
|
Route::get('templates/new/{pathId}', 'TemplateOverview@getPath')
|
||||||
->name('templates.new');
|
->name('templates.new');
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
'core' => 'Core templates',
|
'core' => 'Core templates',
|
||||||
'homepage' => 'Home page',
|
'homepage' => 'Home page',
|
||||||
'overview' => 'Templates',
|
'overview' => 'Templates',
|
||||||
'noSubdirectories' => 'No directories available',
|
'noSubdirectories' => 'No directories available',
|
||||||
'parentDirectory' => 'Parent directory',
|
'parentDirectory' => 'Parent directory',
|
||||||
'noTemplates' => 'No templates available',
|
'noTemplates' => 'No templates available',
|
||||||
'new' => 'New template',
|
'new' => 'New template',
|
||||||
'subdirectories' => 'Subdirectories',
|
'subdirectories' => 'Subdirectories',
|
||||||
'edit' => 'Edit template :name',
|
'edit' => 'Edit template :name',
|
||||||
'name' => 'Template name',
|
'name' => 'Template name',
|
||||||
'description' => 'Template description',
|
'description' => 'Template description',
|
||||||
'editSuccessfull' => 'Template successfully edited.',
|
'editSuccessfull' => 'Template successfully edited.',
|
||||||
'notWritable' => 'Cannot write to :file. Any submited changes in this file will <strong>not</strong> be saved!',
|
'notWritable' => 'Cannot write to :file. Any submited changes in this file will <strong>not</strong> be saved!',
|
||||||
'cannotWriteContent' => 'Cannot save template content, directory has unsufficient permissions. Meta information were saved.'
|
'cannotWriteContent' => 'Cannot save template content, directory has unsufficient permissions. Meta information were saved.',
|
||||||
|
'newTemplateName' => 'Template name used in Blade templates',
|
||||||
|
'newTemplateNameSuffix' => 'copy'
|
||||||
];
|
];
|
||||||
@@ -12,12 +12,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="controls row">
|
<div class="controls row">
|
||||||
<a href="{{route('templates.copy', ['id' => $template->id])}}" class="button text-center primary column large-6" title="@lang('admin/templates.copy')">
|
<a data-template-id="{{$template->id}}" data-template-name="{{$template->template_name}}"
|
||||||
|
class="button primary column large-6 copy-template"
|
||||||
|
title="@lang('admin/templates.copy')">
|
||||||
<i class="fa fa-copy"></i>
|
<i class="fa fa-copy"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@if ($template->editable)
|
@if ($template->editable)
|
||||||
<a href="{{route('templates.edit', ['id' => $template->id])}}" class="button text-center success column large-6" title="@lang('admin/templates.edit')">
|
<a href="{{route('templates.edit', ['id' => $template->id])}}"
|
||||||
|
class="button success column large-6" title="@lang('admin/templates.edit')">
|
||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
@@ -29,3 +32,21 @@
|
|||||||
<em>@lang('admin/templates.noTemplates')</em>
|
<em>@lang('admin/templates.noTemplates')</em>
|
||||||
@endforelse
|
@endforelse
|
||||||
</div>
|
</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');
|
||||||
|
|
||||||
|
var newTemplateName = prompt ("@lang('admin/templates.newTemplateName')", templateName + "_"+"@lang('admin/templates.newTemplateNameSuffix')");
|
||||||
|
|
||||||
|
if (newTemplateName == null) return;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
'url': '{{route('templates.copy')}}}'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
Reference in New Issue
Block a user