FEATURE: add copying of templates

This commit is contained in:
Michal Kváček
2016-03-07 16:27:00 +01:00
parent fa97ccc032
commit 6e6be7f790
4 changed files with 111 additions and 10 deletions
+4 -2
View File
@@ -15,5 +15,7 @@ return [
'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.',
'newTemplateName' => 'Template name used in Blade templates',
'newTemplateNameSuffix' => 'copy'
];
'newTemplateNameSuffix' => 'copy',
'copySuccessfull' => 'Template :name successfully created by copying from other template.',
'copyFailed' => 'Cannot copy template into :name. Check write permissions to proper template path.'
];
@@ -40,12 +40,20 @@
var templateId = link.data ('template-id');
var templateName = link.data ('template-name');
var newTemplateName = prompt ("@lang('admin/templates.newTemplateName')", templateName + "_"+"@lang('admin/templates.newTemplateNameSuffix')");
var newTemplateName = prompt ("@lang('admin/templates.newTemplateName')", templateName + "_" + "@lang('admin/templates.newTemplateNameSuffix')");
// no name given - give up
if (newTemplateName == null) return;
$.ajax({
'url': '{{route('templates.copy')}}}'
// copy given template
$.post ('{{route('templates.postCopy')}}', {
templateId: templateId,
newName: newTemplateName,
_token: "{{csrf_token()}}"
}, function (data) {
if (data.status == 'success') {
location.reload ();
}
});
});
</script>