Some Work Done
This commit is contained in:
parent
a5f84beb1c
commit
e10abcafa4
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"/js/admin.js": "/js/admin.js?id=8bcdcf3b86191d1739a5",
|
||||
"/js/admin.js": "/js/admin.js?id=9d5c14f53644a400f8c6",
|
||||
"/css/admin.css": "/css/admin.css?id=59ebf5021195a90c8760"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Admin\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class TinyMCEController extends Controller
|
||||
{
|
||||
/**
|
||||
* Storage folder path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $storagePath = 'tinymce';
|
||||
|
||||
/**
|
||||
* Upload file from tinymce.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function upload()
|
||||
{
|
||||
$media = $this->storeMedia();
|
||||
|
||||
if (! empty($media)) {
|
||||
return response()->json([
|
||||
'location' => $media['file_url']
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store media.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function storeMedia()
|
||||
{
|
||||
if (request()->hasFile('file')) {
|
||||
return [
|
||||
'file' => $path = request()->file('file')->store($this->storagePath),
|
||||
'file_name' => request()->file('file')->getClientOriginalName(),
|
||||
'file_url' => Storage::url($path),
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
@ -38,6 +38,12 @@ Route::group(['middleware' => ['web', 'admin_locale']], function () {
|
|||
'redirect' => 'admin.session.create',
|
||||
])->name('admin.session.destroy');
|
||||
|
||||
/**
|
||||
* Tinymce file upload handler.
|
||||
*/
|
||||
Route::post('tinymce/upload', 'Webkul\Admin\Http\Controllers\TinyMCEController@upload')
|
||||
->name('admin.tinymce.upload');
|
||||
|
||||
// Dashboard Route
|
||||
Route::get('dashboard', 'Webkul\Admin\Http\Controllers\DashboardController@index')->defaults('_config', [
|
||||
'view' => 'admin::dashboard.index',
|
||||
|
|
|
|||
|
|
@ -55,6 +55,11 @@ Vue.component(
|
|||
);
|
||||
|
||||
$(function() {
|
||||
/**
|
||||
* Define a mixin object.
|
||||
*/
|
||||
Vue.mixin(require('./mixins/tinymce-helpers'));
|
||||
|
||||
Vue.config.ignoredElements = ['option-wrapper', 'group-form', 'group-list'];
|
||||
|
||||
let app = new Vue({
|
||||
|
|
|
|||
|
|
@ -0,0 +1,88 @@
|
|||
module.exports = {
|
||||
methods: {
|
||||
initTinyMCE: function (config) {
|
||||
let self = this;
|
||||
|
||||
tinymce.init({
|
||||
...config,
|
||||
|
||||
file_picker_callback: function(cb, value, meta) {
|
||||
self.filePickerCallback(config, cb, value, meta);
|
||||
},
|
||||
|
||||
images_upload_handler: function (blobInfo, success, failure, progress) {
|
||||
self.uploadImageHandler(config, blobInfo, success, failure, progress);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
filePickerCallback: function(config, cb, value, meta) {
|
||||
let input = document.createElement('input');
|
||||
input.setAttribute('type', 'file');
|
||||
input.setAttribute('accept', 'image/*');
|
||||
|
||||
input.onchange = function() {
|
||||
let file = this.files[0];
|
||||
|
||||
let reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = function () {
|
||||
let id = 'blobid' + (new Date()).getTime();
|
||||
let blobCache = tinymce.activeEditor.editorUpload.blobCache;
|
||||
let base64 = reader.result.split(',')[1];
|
||||
let blobInfo = blobCache.create(id, file, base64);
|
||||
blobCache.add(blobInfo);
|
||||
cb(blobInfo.blobUri(), {title: file.name});
|
||||
};
|
||||
};
|
||||
input.click();
|
||||
},
|
||||
|
||||
uploadImageHandler: function(config, blobInfo, success, failure, progress) {
|
||||
let xhr, formData;
|
||||
|
||||
xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.withCredentials = false;
|
||||
|
||||
xhr.open('POST', config.uploadRoute);
|
||||
|
||||
xhr.upload.onprogress = function (e) {
|
||||
progress(e.loaded / e.total * 100);
|
||||
};
|
||||
|
||||
xhr.onload = function() {
|
||||
let json;
|
||||
|
||||
if (xhr.status === 403) {
|
||||
failure('HTTP Error: ' + xhr.status, { remove: true });
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status < 200 || xhr.status >= 300) {
|
||||
failure('HTTP Error: ' + xhr.status);
|
||||
return;
|
||||
}
|
||||
|
||||
json = JSON.parse(xhr.responseText);
|
||||
|
||||
if (! json || typeof json.location != 'string') {
|
||||
failure('Invalid JSON: ' + xhr.responseText);
|
||||
return;
|
||||
}
|
||||
|
||||
success(json.location);
|
||||
};
|
||||
|
||||
xhr.onerror = function () {
|
||||
failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status);
|
||||
};
|
||||
|
||||
formData = new FormData();
|
||||
formData.append('_token', config.csrfToken);
|
||||
formData.append('file', blobInfo.blob(), blobInfo.filename());
|
||||
|
||||
xhr.send(formData);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -9,7 +9,7 @@ $accordian-header: #fbfbfb;
|
|||
// Buttons
|
||||
$btn-primary: $white;
|
||||
$btn-primary-bg: #0041FF;
|
||||
$btn-danger-bg: $red;
|
||||
$btn-danger-bg: red;
|
||||
|
||||
// Cards
|
||||
$card-title: #a2a2a2;
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@
|
|||
|
||||
@section('content')
|
||||
<div class="content">
|
||||
|
||||
<form method="POST" action="{{ route('admin.catalog.categories.store') }}" @submit.prevent="onSubmit" enctype="multipart/form-data">
|
||||
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>
|
||||
|
|
@ -28,13 +26,13 @@
|
|||
<div class="page-content">
|
||||
<div class="form-container">
|
||||
@csrf()
|
||||
|
||||
<input type="hidden" name="locale" value="all"/>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.general.before') !!}
|
||||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.general') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.general.controls.before') !!}
|
||||
|
||||
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
|
||||
|
|
@ -63,18 +61,15 @@
|
|||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.general.controls.after') !!}
|
||||
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.general.after') !!}
|
||||
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.description_images.before') !!}
|
||||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.description-and-images') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.description_images.controls.before') !!}
|
||||
|
||||
<div class="control-group" :class="[errors.has('display_mode') ? 'has-error' : '']">
|
||||
|
|
@ -105,19 +100,15 @@
|
|||
@php echo str_replace($key, 'Image', $message[0]); @endphp
|
||||
@endforeach
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.description_images.controls.after') !!}
|
||||
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.description_images.after') !!}
|
||||
|
||||
|
||||
@if ($categories->count())
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.parent_category.before') !!}
|
||||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.parent-category') }}'" :active="true">
|
||||
|
|
@ -133,12 +124,10 @@
|
|||
</accordian>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.parent_category.after') !!}
|
||||
|
||||
@endif
|
||||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.filterable-attributes') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
<?php $selectedaAtributes = old('attributes') ? old('attributes') : ['11'] ?>
|
||||
|
||||
<div class="control-group" :class="[errors.has('attributes[]') ? 'has-error' : '']">
|
||||
|
|
@ -163,7 +152,6 @@
|
|||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.seo') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.seo.controls.before') !!}
|
||||
|
||||
<div class="control-group">
|
||||
|
|
@ -188,15 +176,12 @@
|
|||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.seo.controls.after') !!}
|
||||
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.seo.after') !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
@stop
|
||||
|
|
@ -205,29 +190,15 @@
|
|||
<script src="{{ asset('vendor/webkul/admin/assets/js/tinyMCE/tinymce.min.js') }}"></script>
|
||||
|
||||
<script type="text/x-template" id="description-template">
|
||||
|
||||
<div class="control-group" :class="[errors.has('description') ? 'has-error' : '']">
|
||||
<label for="description" :class="isRequired ? 'required' : ''">{{ __('admin::app.catalog.categories.description') }}</label>
|
||||
<textarea v-validate="isRequired ? 'required' : ''" class="control" id="description" name="description" data-vv-as=""{{ __('admin::app.catalog.categories.description') }}"">{{ old('description') }}</textarea>
|
||||
<span class="control-error" v-if="errors.has('description')">@{{ errors.first('description') }}</span>
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
tinymce.init({
|
||||
selector: 'textarea#description',
|
||||
height: 200,
|
||||
width: "100%",
|
||||
plugins: 'image imagetools media wordcount save fullscreen code table lists link hr',
|
||||
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor link hr | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | code | table',
|
||||
image_advtab: true
|
||||
});
|
||||
});
|
||||
|
||||
Vue.component('description', {
|
||||
|
||||
template: '#description-template',
|
||||
|
||||
inject: ['$validator'],
|
||||
|
|
@ -235,22 +206,33 @@
|
|||
data: function() {
|
||||
return {
|
||||
isRequired: true,
|
||||
tinyMCEConfig: {
|
||||
selector: 'textarea#description',
|
||||
height: 200,
|
||||
width: "100%",
|
||||
plugins: 'image imagetools media wordcount save fullscreen code table lists link hr',
|
||||
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor link hr | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | code | table',
|
||||
uploadRoute: '{{ route('admin.tinymce.upload') }}',
|
||||
csrfToken: '{{ csrf_token() }}',
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
created: function () {
|
||||
var this_this = this;
|
||||
let self = this;
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#display_mode').on('change', function (e) {
|
||||
if ($('#display_mode').val() != 'products_only') {
|
||||
this_this.isRequired = true;
|
||||
self.isRequired = true;
|
||||
} else {
|
||||
this_this.isRequired = false;
|
||||
self.isRequired = false;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
self.initTinyMCE(self.tinyMCEConfig);
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
@endphp
|
||||
|
||||
<form method="POST" action="" @submit.prevent="onSubmit" enctype="multipart/form-data">
|
||||
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>
|
||||
|
|
@ -43,13 +42,13 @@
|
|||
<div class="page-content">
|
||||
<div class="form-container">
|
||||
@csrf()
|
||||
|
||||
<input name="_method" type="hidden" value="PUT">
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.general.before', ['category' => $category]) !!}
|
||||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.general') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.general.controls.before', ['category' => $category]) !!}
|
||||
|
||||
<div class="control-group" :class="[errors.has('{{$locale}}[name]') ? 'has-error' : '']">
|
||||
|
|
@ -80,18 +79,15 @@
|
|||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.general.controls.after', ['category' => $category]) !!}
|
||||
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.general.after', ['category' => $category]) !!}
|
||||
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.description_images.before', ['category' => $category]) !!}
|
||||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.description-and-images') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.description_images.controls.before', ['category' => $category]) !!}
|
||||
|
||||
<div class="control-group" :class="[errors.has('display_mode') ? 'has-error' : '']">
|
||||
|
|
@ -122,18 +118,15 @@
|
|||
@php echo str_replace($key, 'Image', $message[0]); @endphp
|
||||
@endforeach
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.description_images.controls.after', ['category' => $category]) !!}
|
||||
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.description_images.after', ['category' => $category]) !!}
|
||||
|
||||
@if ($categories->count())
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.parent_category.before', ['category' => $category]) !!}
|
||||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.parent-category') }}'" :active="true">
|
||||
|
|
@ -149,12 +142,10 @@
|
|||
</accordian>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.parent_category.after', ['category' => $category]) !!}
|
||||
|
||||
@endif
|
||||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.filterable-attributes') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
<?php $selectedaAtributes = old('attributes') ?? $category->filterableAttributes->pluck('id')->toArray() ?>
|
||||
|
||||
<div class="control-group" :class="[errors.has('attributes[]') ? 'has-error' : '']">
|
||||
|
|
@ -179,7 +170,6 @@
|
|||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.seo') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.seo.controls.before', ['category' => $category]) !!}
|
||||
|
||||
<div class="control-group">
|
||||
|
|
@ -212,15 +202,12 @@
|
|||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.seo.controls.after', ['category' => $category]) !!}
|
||||
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.seo.after', ['category' => $category]) !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
@stop
|
||||
|
|
@ -229,7 +216,6 @@
|
|||
<script src="{{ asset('vendor/webkul/admin/assets/js/tinyMCE/tinymce.min.js') }}"></script>
|
||||
|
||||
<script type="text/x-template" id="description-template">
|
||||
|
||||
<div class="control-group" :class="[errors.has('{{$locale}}[description]') ? 'has-error' : '']">
|
||||
<label for="description" :class="isRequired ? 'required' : ''">{{ __('admin::app.catalog.categories.description') }}
|
||||
<span class="locale">[{{ $locale }}]</span>
|
||||
|
|
@ -237,23 +223,10 @@
|
|||
<textarea v-validate="isRequired ? 'required' : ''" class="control" id="description" name="{{$locale}}[description]" data-vv-as=""{{ __('admin::app.catalog.categories.description') }}"">{{ old($locale)['description'] ?? ($category->translate($locale)['description'] ?? '') }}</textarea>
|
||||
<span class="control-error" v-if="errors.has('{{$locale}}[description]')">@{{ errors.first('{!!$locale!!}[description]') }}</span>
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
tinymce.init({
|
||||
selector: 'textarea#description',
|
||||
height: 200,
|
||||
width: "100%",
|
||||
plugins: 'image imagetools media wordcount save fullscreen code table lists link hr',
|
||||
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor link hr | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | code | table',
|
||||
image_advtab: true
|
||||
});
|
||||
});
|
||||
|
||||
Vue.component('description', {
|
||||
|
||||
template: '#description-template',
|
||||
|
||||
inject: ['$validator'],
|
||||
|
|
@ -261,28 +234,39 @@
|
|||
data: function() {
|
||||
return {
|
||||
isRequired: true,
|
||||
tinyMCEConfig: {
|
||||
selector: 'textarea#description',
|
||||
height: 200,
|
||||
width: "100%",
|
||||
plugins: 'image imagetools media wordcount save fullscreen code table lists link hr',
|
||||
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor link hr | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | code | table',
|
||||
uploadRoute: '{{ route('admin.tinymce.upload') }}',
|
||||
csrfToken: '{{ csrf_token() }}',
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
created: function () {
|
||||
var this_this = this;
|
||||
let self = this;
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#display_mode').on('change', function (e) {
|
||||
if ($('#display_mode').val() != 'products_only') {
|
||||
this_this.isRequired = true;
|
||||
self.isRequired = true;
|
||||
} else {
|
||||
this_this.isRequired = false;
|
||||
self.isRequired = false;
|
||||
}
|
||||
})
|
||||
|
||||
if ($('#display_mode').val() != 'products_only') {
|
||||
this_this.isRequired = true;
|
||||
self.isRequired = true;
|
||||
} else {
|
||||
this_this.isRequired = false;
|
||||
self.isRequired = false;
|
||||
}
|
||||
|
||||
self.initTinyMCE(self.tinyMCEConfig);
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
Loading…
Reference in New Issue