]> _ Git - cubist_cms-back.git/commitdiff
wip #3263 @0:10
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Dec 2019 17:17:56 +0000 (18:17 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Dec 2019 17:17:56 +0000 (18:17 +0100)
src/resources/views/fields/dropzone_media.blade.php

index 9d1a5e265a8b42a0c961fa5d7a071b38b964bf58..16c40b711e7578775a32ba159d728b328567ae58 100644 (file)
 <?php
 $collection = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? [];
-?>
 
-<div class="form-group col-md-12">
-    <strong>{{ $field['label'] }}</strong> <br>
-    <input type="hidden" value="{{$collection}}" name="{{$field['name']}}"/>
-    <div data-url="{{ url($crud->route . '/' . $entry->id . '/media') }}"
-         data-options='@json($field['options'])'
-         class="dropzone dz-clickable sortable">
-        <div class="dz-message">
-            Drop files here or click to upload.
+?>
+@if(isset($entry))
+    <div class="form-group col-md-12">
+        <strong>{{ $field['label'] }}</strong> <br>
+        <input type="hidden" value="{{$collection}}" name="{{$field['name']}}"/>
+        <div data-url="{{ url($crud->route . '/' . $entry->id . '/media') }}"
+             data-options='@json($field['options'])'
+             class="dropzone dz-clickable sortable">
+            <div class="dz-message">
+                Drop files here or click to upload.
+            </div>
         </div>
     </div>
-</div>
-
-{{-- ########################################## --}}
-{{-- Extra CSS and JS for this particular field --}}
-{{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}}
-@if ($crud->checkIfFieldIsFirstOfItsType($field))
-
-    <div id="dz-template-container" style="display: none;">
-        <div class="dz-preview dz-file-preview">
-            <div data-dz-remove>+</div>
-            <div class="dz-image">
-                <img data-dz-thumbnail/>
-            </div>
-            <div class="dz-details">
-                <div class="dz-size">
-                    <span data-dz-size></span>
+
+    {{-- ########################################## --}}
+    {{-- Extra CSS and JS for this particular field --}}
+    {{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}}
+    @if ($crud->checkIfFieldIsFirstOfItsType($field))
+
+        <div id="dz-template-container" style="display: none;">
+            <div class="dz-preview dz-file-preview">
+                <div data-dz-remove>+</div>
+                <div class="dz-image">
+                    <img data-dz-thumbnail/>
                 </div>
-                <div class="dz-filename">
-                    <span data-dz-name></span>
+                <div class="dz-details">
+                    <div class="dz-size">
+                        <span data-dz-size></span>
+                    </div>
+                    <div class="dz-filename">
+                        <span data-dz-name></span>
+                    </div>
                 </div>
-            </div>
-            <div class="dz-progress">
-                <span class="dz-upload" data-dz-uploadprogress></span>
-            </div>
-            <div class="dz-error-message">
-                <span data-dz-errormessage></span>
-            </div>
-            <div class="dz-success-mark">
-                <svg width="54px" height="54px" viewBox="0 0 54 54" version="1.1" xmlns="http://www.w3.org/2000/svg"
-                     xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
-                    <title>Check</title>
-                    <defs></defs>
-                    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
-                        <path
-                            d="M23.5,31.8431458 L17.5852419,25.9283877 C16.0248253,24.3679711 13.4910294,24.366835 11.9289322,25.9289322 C10.3700136,27.4878508 10.3665912,30.0234455 11.9283877,31.5852419 L20.4147581,40.0716123 C20.5133999,40.1702541 20.6159315,40.2626649 20.7218615,40.3488435 C22.2835669,41.8725651 24.794234,41.8626202 26.3461564,40.3106978 L43.3106978,23.3461564 C44.8771021,21.7797521 44.8758057,19.2483887 43.3137085,17.6862915 C41.7547899,16.1273729 39.2176035,16.1255422 37.6538436,17.6893022 L23.5,31.8431458 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z"
-                            id="Oval-2" stroke-opacity="0.198794158" stroke="#747474" fill-opacity="0.816519475"
-                            fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
-                    </g>
-                </svg>
-            </div>
-            <div class="dz-error-mark">
-                <svg width="54px" height="54px" viewBox="0 0 54 54" version="1.1" xmlns="http://www.w3.org/2000/svg"
-                     xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
-                    <title>Error</title>
-                    <defs></defs>
-                    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
-                        <g id="Check-+-Oval-2" sketch:type="MSLayerGroup" stroke="#747474" stroke-opacity="0.198794158"
-                           fill="#FFFFFF" fill-opacity="0.816519475">
+                <div class="dz-progress">
+                    <span class="dz-upload" data-dz-uploadprogress></span>
+                </div>
+                <div class="dz-error-message">
+                    <span data-dz-errormessage></span>
+                </div>
+                <div class="dz-success-mark">
+                    <svg width="54px" height="54px" viewBox="0 0 54 54" version="1.1" xmlns="http://www.w3.org/2000/svg"
+                         xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
+                        <title>Check</title>
+                        <defs></defs>
+                        <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
                             <path
-                                d="M32.6568542,29 L38.3106978,23.3461564 C39.8771021,21.7797521 39.8758057,19.2483887 38.3137085,17.6862915 C36.7547899,16.1273729 34.2176035,16.1255422 32.6538436,17.6893022 L27,23.3431458 L21.3461564,17.6893022 C19.7823965,16.1255422 17.2452101,16.1273729 15.6862915,17.6862915 C14.1241943,19.2483887 14.1228979,21.7797521 15.6893022,23.3461564 L21.3431458,29 L15.6893022,34.6538436 C14.1228979,36.2202479 14.1241943,38.7516113 15.6862915,40.3137085 C17.2452101,41.8726271 19.7823965,41.8744578 21.3461564,40.3106978 L27,34.6568542 L32.6538436,40.3106978 C34.2176035,41.8744578 36.7547899,41.8726271 38.3137085,40.3137085 C39.8758057,38.7516113 39.8771021,36.2202479 38.3106978,34.6538436 L32.6568542,29 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z"
-                                id="Oval-2" sketch:type="MSShapeGroup"></path>
+                                d="M23.5,31.8431458 L17.5852419,25.9283877 C16.0248253,24.3679711 13.4910294,24.366835 11.9289322,25.9289322 C10.3700136,27.4878508 10.3665912,30.0234455 11.9283877,31.5852419 L20.4147581,40.0716123 C20.5133999,40.1702541 20.6159315,40.2626649 20.7218615,40.3488435 C22.2835669,41.8725651 24.794234,41.8626202 26.3461564,40.3106978 L43.3106978,23.3461564 C44.8771021,21.7797521 44.8758057,19.2483887 43.3137085,17.6862915 C41.7547899,16.1273729 39.2176035,16.1255422 37.6538436,17.6893022 L23.5,31.8431458 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z"
+                                id="Oval-2" stroke-opacity="0.198794158" stroke="#747474" fill-opacity="0.816519475"
+                                fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
                         </g>
-                    </g>
-                </svg>
+                    </svg>
+                </div>
+                <div class="dz-error-mark">
+                    <svg width="54px" height="54px" viewBox="0 0 54 54" version="1.1" xmlns="http://www.w3.org/2000/svg"
+                         xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
+                        <title>Error</title>
+                        <defs></defs>
+                        <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
+                            <g id="Check-+-Oval-2" sketch:type="MSLayerGroup" stroke="#747474" stroke-opacity="0.198794158"
+                               fill="#FFFFFF" fill-opacity="0.816519475">
+                                <path
+                                    d="M32.6568542,29 L38.3106978,23.3461564 C39.8771021,21.7797521 39.8758057,19.2483887 38.3137085,17.6862915 C36.7547899,16.1273729 34.2176035,16.1255422 32.6538436,17.6893022 L27,23.3431458 L21.3461564,17.6893022 C19.7823965,16.1255422 17.2452101,16.1273729 15.6862915,17.6862915 C14.1241943,19.2483887 14.1228979,21.7797521 15.6893022,23.3461564 L21.3431458,29 L15.6893022,34.6538436 C14.1228979,36.2202479 14.1241943,38.7516113 15.6862915,40.3137085 C17.2452101,41.8726271 19.7823965,41.8744578 21.3461564,40.3106978 L27,34.6568542 L32.6538436,40.3106978 C34.2176035,41.8744578 36.7547899,41.8726271 38.3137085,40.3137085 C39.8758057,38.7516113 39.8771021,36.2202479 38.3106978,34.6538436 L32.6568542,29 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z"
+                                    id="Oval-2" sketch:type="MSShapeGroup"></path>
+                            </g>
+                        </g>
+                    </svg>
+                </div>
             </div>
         </div>
-    </div>
 
 
-    {{-- FIELD CSS - will be loaded in the after_styles section --}}
-    @push('crud_fields_styles')
-        <!-- include dropzone css-->
-        <link rel="stylesheet"
-              href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/min/dropzone.min.css"/>
-        <style type="text/css">
-            .dropzone {
-                border: 1px solid #d2d6de;
-            }
+        {{-- FIELD CSS - will be loaded in the after_styles section --}}
+        @push('crud_fields_styles')
+            <!-- include dropzone css-->
+            <link rel="stylesheet"
+                  href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/min/dropzone.min.css"/>
+            <style type="text/css">
+                .dropzone {
+                    border: 1px solid #d2d6de;
+                }
 
-            .dropzone.dz-drag-hover {
-                border-style: dashed;
-                background-color: #efefef;
-            }
+                .dropzone.dz-drag-hover {
+                    border-style: dashed;
+                    background-color: #efefef;
+                }
 
-            .dropzone .dz-preview [data-dz-remove] {
-                position: absolute;
-                top: -13px;
-                right: -13px;
-                width: 26px;
-                height: 26px;
-                border-radius: 50%;
-                background: #b50005;
-                color: #fff;
-                text-align: center;
-                font-weight: 700;
-                font-size: 24px;
-                line-height: 1em;
-                z-index: 11;
-                transform: rotate(45deg);
-                cursor: pointer;
-            }
+                .dropzone .dz-preview [data-dz-remove] {
+                    position: absolute;
+                    top: -13px;
+                    right: -13px;
+                    width: 26px;
+                    height: 26px;
+                    border-radius: 50%;
+                    background: #b50005;
+                    color: #fff;
+                    text-align: center;
+                    font-weight: 700;
+                    font-size: 24px;
+                    line-height: 1em;
+                    z-index: 11;
+                    transform: rotate(45deg);
+                    cursor: pointer;
+                }
 
-            .dropzone .dz-preview .dz-image {
-                background-color: #eee;
-            }
-        </style>
-    @endpush
-
-    {{-- FIELD JS - will be loaded in the after_scripts section --}}
-    @push('crud_fields_scripts')
-        <?php
-
-        $files = [];
-        $filesrand = 'files_' . rand(1, 10000);
-        foreach ($entry->getAllMedia() as $media) {
-            $collection = $media->collection_name;
-            if (!isset($files[$collection])) {
-                $files[$collection] = [];
+                .dropzone .dz-preview .dz-image {
+                    background-color: #eee;
+                }
+            </style>
+        @endpush
+
+        {{-- FIELD JS - will be loaded in the after_scripts section --}}
+        @push('crud_fields_scripts')
+            <?php
+
+            $files = [];
+            $filesrand = 'files_' . rand(1, 10000);
+            foreach ($entry->getAllMedia() as $media) {
+                $collection = $media->collection_name;
+                if (!isset($files[$collection])) {
+                    $files[$collection] = [];
+                }
+                $files[$collection][] = [
+                    'id' => $media->id,
+                    'order_column' => $media->order_column,
+                    'size' => $media->size,
+                    'name' => $media->file_name,
+                    'full_url' => $media->getUrl(),
+                    'thumb_url' => $media->getUrl($field['thumb_collection'] ?? ''),
+                ];
             }
-            $files[$collection][] = [
-                'id' => $media->id,
-                'order_column' => $media->order_column,
-                'size' => $media->size,
-                'name' => $media->file_name,
-                'full_url' => $media->getUrl(),
-                'thumb_url' => $media->getUrl($field['thumb_collection'] ?? ''),
-            ];
-        }
-
-        ?>
-        <!-- include dropzone js-->
-        <script
-            src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/min/dropzone.min.js"></script>
-        <script
-            src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.9.0/Sortable.js"></script>
-        <script type="text/javascript">
-
-            Dropzone.autoDiscover = false;
-
-            jQuery(document).ready(function () {
-
-                var uniqid = function () {
-                    return (new Date().getTime() + Math.floor((Math.random() * 10000) + 1)).toString(16);
-                };
+
+            ?>
+            <!-- include dropzone js-->
+            <script
+                src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/min/dropzone.min.js"></script>
+            <script
+                src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.9.0/Sortable.js"></script>
+            <script type="text/javascript">
 
                 Dropzone.autoDiscover = false;
-                var f_{{$filesrand}} = @json($files);
-
-                function initAllDropzones() {
-                    $(".dropzone").each(function (){
-                        if($(this).closest('.sample').length===0) {
-                            var collectionInput = $(this).prev('input');
-                            if (collectionInput.val() === '_TBD_') {
-                                collectionInput.val(uniqid());
-                            }
-                            if ($(this).data('dropzone') === undefined) {
-                                $(this).attr('id', 'dz-' + Math.round(Math.random() * 10000000));
-                                $(this).data('dropzone', initOneDropzone(this));
-                            }
-                        }
-                    });
-                }
 
-                function initOneDropzone(el) {
-                    var el = $(el);
-                    var base_url = el.data('url');
-                    var el_id = $(el).attr('id');
-                    var collection = $(el).prev().val();
-                    var dOptions = {
-                        url: base_url,
-                        previewTemplate: $("#dz-template-container").html(),
+                jQuery(document).ready(function () {
+
+                    var uniqid = function () {
+                        return (new Date().getTime() + Math.floor((Math.random() * 10000) + 1)).toString(16);
+                    };
 
+                    Dropzone.autoDiscover = false;
+                    var f_{{$filesrand}} = @json($files);
 
-                        init: function () {
-                            var files = f_{{$filesrand}}[collection];
-                            if (files === undefined) {
-                                files = [];
+                    function initAllDropzones() {
+                        $(".dropzone").each(function (){
+                            if($(this).closest('.sample').length===0) {
+                                var collectionInput = $(this).prev('input');
+                                if (collectionInput.val() === '_TBD_') {
+                                    collectionInput.val(uniqid());
+                                }
+                                if ($(this).data('dropzone') === undefined) {
+                                    $(this).attr('id', 'dz-' + Math.round(Math.random() * 10000000));
+                                    $(this).data('dropzone', initOneDropzone(this));
+                                }
                             }
+                        });
+                    }
+
+                    function initOneDropzone(el) {
+                        var el = $(el);
+                        var base_url = el.data('url');
+                        var el_id = $(el).attr('id');
+                        var collection = $(el).prev().val();
+                        var dOptions = {
+                            url: base_url,
+                            previewTemplate: $("#dz-template-container").html(),
+
+
+                            init: function () {
+                                var files = f_{{$filesrand}}[collection];
+                                if (files === undefined) {
+                                    files = [];
+                                }
+
+                                for (var i = 0; i < files.length; i++) {
+                                    var file = files[i];
 
-                            for (var i = 0; i < files.length; i++) {
-                                var file = files[i];
+                                    this.emit('addedfile', file);
 
-                                this.emit('addedfile', file);
+                                    if (typeof file.full_url != 'undefined') {
+                                        this.emit('thumbnail', file, file.thumb_url);
+                                    }
 
-                                if (typeof file.full_url != 'undefined') {
-                                    this.emit('thumbnail', file, file.thumb_url);
+                                    this.emit('success', file, {success: true, media: file});
+                                    this.emit('complete', file);
                                 }
 
-                                this.emit('success', file, {success: true, media: file});
-                                this.emit('complete', file);
-                            }
+                                if (this.options.maxFiles !== null) {
+                                    this.options.maxFiles = this.options.maxFiles - files.length;
+                                }
+                            },
+                            sending: function (file, xhr, formData) {
+                                console.log(this);
+                                formData.append('_token', $('meta[name="csrf-token"]').attr('content'));
+                                if (collection !== undefined && collection !== null && collection !== '') {
+                                    formData.append('collection', collection);
+                                }
+                            },
+                            success: function (file, response) {
+                                if (typeof response != 'undefined' && response.success == true) {
+                                    file.media = response.media;
+                                    file.previewElement.setAttribute('data-id', response.media.id);
+                                    file.previewElement.setAttribute('data-position', response.media.order_column);
+                                }
+    $(this.element).trigger('change');
+                                if (file.previewElement) {
+                                    return file.previewElement.classList.add("dz-success");
+                                }
+                            },
+                            removedfile: function (file) {
+                                if (typeof file.media != 'undefined') {
+                                    $.ajax({
+                                        url: base_url + '/' + file.media.id,
+                                        type: 'DELETE'
+                                    })
+                                        .done(function (response) {
+                                            var notification_type;
 
-                            if (this.options.maxFiles !== null) {
-                                this.options.maxFiles = this.options.maxFiles - files.length;
-                            }
-                        },
-                        sending: function (file, xhr, formData) {
-                            console.log(this);
-                            formData.append('_token', $('meta[name="csrf-token"]').attr('content'));
-                            if (collection !== undefined && collection !== null && collection !== '') {
-                                formData.append('collection', collection);
-                            }
-                        },
-                        success: function (file, response) {
-                            if (typeof response != 'undefined' && response.success == true) {
-                                file.media = response.media;
-                                file.previewElement.setAttribute('data-id', response.media.id);
-                                file.previewElement.setAttribute('data-position', response.media.order_column);
-                            }
-$(this.element).trigger('change');
-                            if (file.previewElement) {
-                                return file.previewElement.classList.add("dz-success");
-                            }
-                        },
-                        removedfile: function (file) {
-                            if (typeof file.media != 'undefined') {
-                                $.ajax({
-                                    url: base_url + '/' + file.media.id,
-                                    type: 'DELETE'
-                                })
-                                    .done(function (response) {
-                                        var notification_type;
-
-                                        if (response.success == true) {
-                                            notification_type = 'success';
-
-                                            if (file.previewElement != null && file.previewElement.parentNode != null) {
-                                                file.previewElement.parentNode.removeChild(file.previewElement);
+                                            if (response.success == true) {
+                                                notification_type = 'success';
+
+                                                if (file.previewElement != null && file.previewElement.parentNode != null) {
+                                                    file.previewElement.parentNode.removeChild(file.previewElement);
+                                                }
+                                            } else {
+                                                notification_type = 'error';
                                             }
-                                        } else {
-                                            notification_type = 'error';
-                                        }
 
-                                        new PNotify({
-                                            text: response.message,
-                                            type: notification_type,
-                                            icon: false
-                                        });
-                                    })
-                                    .fail(function (xhr) {
-                                        var message = 'Deletion failed';
+                                            new PNotify({
+                                                text: response.message,
+                                                type: notification_type,
+                                                icon: false
+                                            });
+                                        })
+                                        .fail(function (xhr) {
+                                            var message = 'Deletion failed';
 
-                                        if (xhr.responseJSON != 'undefined' && xhr.responseJSON.message != 'undefined') {
-                                            message = xhr.responseJSON.message;
-                                        }
+                                            if (xhr.responseJSON != 'undefined' && xhr.responseJSON.message != 'undefined') {
+                                                message = xhr.responseJSON.message;
+                                            }
 
-                                        new PNotify({
-                                            text: message,
-                                            type: 'error',
-                                            icon: false
+                                            new PNotify({
+                                                text: message,
+                                                type: 'error',
+                                                icon: false
+                                            });
                                         });
-                                    });
+                                    $(this.element).trigger('change');
+                                    return this._updateMaxFilesReachedClass();
+                                }
+
+                                if (file.previewElement != null && file.previewElement.parentNode != null) {
+                                    file.previewElement.parentNode.removeChild(file.previewElement);
+                                }
                                 $(this.element).trigger('change');
                                 return this._updateMaxFilesReachedClass();
-                            }
+                            },
+                        };
 
-                            if (file.previewElement != null && file.previewElement.parentNode != null) {
-                                file.previewElement.parentNode.removeChild(file.previewElement);
-                            }
-                            $(this.element).trigger('change');
-                            return this._updateMaxFilesReachedClass();
-                        },
-                    };
 
+                        var dropzone = new Dropzone("#" + el_id, jQuery.extend(dOptions, $(el).data('option')));
+                        dropzone.on("maxfilesexceeded", function (file) {
+                            this.removeFile(file);
+                            alert('You can\'t add new files !')
+                        });
 
-                    var dropzone = new Dropzone("#" + el_id, jQuery.extend(dOptions, $(el).data('option')));
-                    dropzone.on("maxfilesexceeded", function (file) {
-                        this.removeFile(file);
-                        alert('You can\'t add new files !')
-                    });
 
+                        var dropzone_sortable = new Sortable(document.getElementById(el_id), {
+                            handle: ".dz-preview",
+                            draggable: ".dz-preview",
+                            onEnd: function (evt) {
+                                var ids = this.toArray();
 
-                    var dropzone_sortable = new Sortable(document.getElementById(el_id), {
-                        handle: ".dz-preview",
-                        draggable: ".dz-preview",
-                        onEnd: function (evt) {
-                            var ids = this.toArray();
+                                if (ids.length > 0) {
+                                    $.ajax({
+                                        url: base_url + "/reorder",
+                                        type: 'POST',
+                                        data: {
+                                            ids: ids
+                                        }
+                                    })
+                                        .done(function (response) {
+                                            var notification_type;
 
-                            if (ids.length > 0) {
-                                $.ajax({
-                                    url: base_url + "/reorder",
-                                    type: 'POST',
-                                    data: {
-                                        ids: ids
-                                    }
-                                })
-                                    .done(function (response) {
-                                        var notification_type;
+                                            if (response.success != true) {
+                                                var message = 'Order failed';
+
+                                                if (response.message != 'undefined') {
+                                                    message = response.message;
+                                                }
+
+                                                new PNotify({
+                                                    text: message,
+                                                    type: 'error',
+                                                    icon: false
+                                                });
+                                            }
 
-                                        if (response.success != true) {
+
+                                        })
+                                        .fail(function (xhr) {
                                             var message = 'Order failed';
 
-                                            if (response.message != 'undefined') {
-                                                message = response.message;
+                                            if (xhr.responseJSON != 'undefined' && xhr.responseJSON.message != 'undefined') {
+                                                message = xhr.responseJSON.message;
                                             }
 
                                             new PNotify({
@@ -303,39 +320,24 @@ $(this.element).trigger('change');
                                                 type: 'error',
                                                 icon: false
                                             });
-                                        }
-
-
-                                    })
-                                    .fail(function (xhr) {
-                                        var message = 'Order failed';
-
-                                        if (xhr.responseJSON != 'undefined' && xhr.responseJSON.message != 'undefined') {
-                                            message = xhr.responseJSON.message;
-                                        }
-
-                                        new PNotify({
-                                            text: message,
-                                            type: 'error',
-                                            icon: false
                                         });
-                                    });
+                                }
                             }
-                        }
-                    });
+                        });
 
-                    return dropzone;
-                }
-
-                initAllDropzones();
-                $(document).on('cubist.bunchmultiple.added', function () {
+                        return dropzone;
+                    }
 
                     initAllDropzones();
-                });
+                    $(document).on('cubist.bunchmultiple.added', function () {
 
-            });
+                        initAllDropzones();
+                    });
+
+                });
 
-        </script>
-    @endpush
+            </script>
+        @endpush
 
+    @endif
 @endif