diff --git a/resources/views/import.blade.php b/resources/views/import.blade.php index ff127c7..a53eae1 100644 --- a/resources/views/import.blade.php +++ b/resources/views/import.blade.php @@ -1,125 +1,5 @@ @extends(BaseHelper::getAdminMasterLayoutTemplate()) @section('content') - @php - /** @var \Botble\DataSynchronize\Importer\Importer $importer */ - - $acceptedFiles = Arr::join(array_map(fn ($item) => $item, $importer->getAcceptedFiles()), ','); - @endphp - - {!! apply_filters('data_synchronize_import_page_before', null, $importer) !!} - - - - @if($importer->getHeading()) - - - {{ $importer->getHeading() }} - - - @endif - - - @if($importer->getExportUrl()) - - {!! BaseHelper::clean(trans( - 'packages/data-synchronize::data-synchronize.import.form.quick_export_message', - [ - 'label' => $importer->getLabel(), - 'export_csv_link' => Html::tag('button', trans('packages/data-synchronize::data-synchronize.import.form.quick_export_button', ['format' => 'CSV']), [ - 'class' => 'data-synchronize-quick-export-button', - 'data-bb-toggle' => 'quick-export', - 'data-value' => 'csv', - ]), - 'export_excel_link' => Html::tag('button', trans('packages/data-synchronize::data-synchronize.import.form.quick_export_button', ['format' => 'Excel']), [ - 'class' => 'data-synchronize-quick-export-button', - 'data-bb-toggle' => 'quick-export', - 'data-value' => 'xlsx', - ]), - ] - )) !!} - - @endif - - {!! apply_filters('data_synchronize_import_form_before', null, $importer) !!} - - - - - {{ trans('packages/data-synchronize::data-synchronize.import.form.dropzone_message') }} - - - - - {{ trans('packages/data-synchronize::data-synchronize.import.form.allowed_extensions', ['extensions' => Arr::join($importer->getFileExtensions(), ', ')]) }} - - - - {!! apply_filters('data_synchronize_import_form_after', null, $importer) !!} - - - - - - {{ trans('packages/data-synchronize::data-synchronize.import.form.import_button') }} - - - - - - - - - - {!! apply_filters('data_synchronize_import_page_after', null, $importer) !!} - - @if($importer->getExportUrl()) - - @endif - - @if ($importer->getExamples()) - @include('packages/data-synchronize::partials.example') - @endif - - @includeWhen($importer->showRulesCheatSheet(), 'packages/data-synchronize::partials.rules') + @include('packages/data-synchronize::partials.importer') @stop - -@push('footer') - - - - - - - - - - - - - - - - - {!! apply_filters('data_synchronize_import_page_footer', null, $importer) !!} -@endpush diff --git a/resources/views/partials/importer.blade.php b/resources/views/partials/importer.blade.php new file mode 100644 index 0000000..506fbcf --- /dev/null +++ b/resources/views/partials/importer.blade.php @@ -0,0 +1,119 @@ +@php + /** @var \Botble\DataSynchronize\Importer\Importer $importer */ + + $acceptedFiles = Arr::join(array_map(fn ($item) => $item, $importer->getAcceptedFiles()), ','); +@endphp + +{!! apply_filters('data_synchronize_import_page_before', null, $importer) !!} + + + + @if($importer->getHeading()) + + + {{ $importer->getHeading() }} + + + @endif + + + @if($importer->getExportUrl()) + + {!! BaseHelper::clean(trans( + 'packages/data-synchronize::data-synchronize.import.form.quick_export_message', + [ + 'label' => $importer->getLabel(), + 'export_csv_link' => Html::tag('button', trans('packages/data-synchronize::data-synchronize.import.form.quick_export_button', ['format' => 'CSV']), [ + 'class' => 'data-synchronize-quick-export-button', + 'data-bb-toggle' => 'quick-export', + 'data-value' => 'csv', + ]), + 'export_excel_link' => Html::tag('button', trans('packages/data-synchronize::data-synchronize.import.form.quick_export_button', ['format' => 'Excel']), [ + 'class' => 'data-synchronize-quick-export-button', + 'data-bb-toggle' => 'quick-export', + 'data-value' => 'xlsx', + ]), + ] + )) !!} + + @endif + + {!! apply_filters('data_synchronize_import_form_before', null, $importer) !!} + + + + + {{ trans('packages/data-synchronize::data-synchronize.import.form.dropzone_message') }} + + + + + {{ trans('packages/data-synchronize::data-synchronize.import.form.allowed_extensions', ['extensions' => Arr::join($importer->getFileExtensions(), ', ')]) }} + + + + {!! apply_filters('data_synchronize_import_form_after', null, $importer) !!} + + + + + + {{ trans('packages/data-synchronize::data-synchronize.import.form.import_button') }} + + + + + + + + + +{!! apply_filters('data_synchronize_import_page_after', null, $importer) !!} + +@if($importer->getExportUrl()) + +@endif + +@if ($importer->getExamples()) + @include('packages/data-synchronize::partials.example') +@endif + +@includeWhen($importer->showRulesCheatSheet(), 'packages/data-synchronize::partials.rules') + + + + + + + + + + + + + + + + + +{!! apply_filters('data_synchronize_import_page_footer', null, $importer) !!} diff --git a/src/Importer/Importer.php b/src/Importer/Importer.php index ca7d267..75aa304 100644 --- a/src/Importer/Importer.php +++ b/src/Importer/Importer.php @@ -22,6 +22,8 @@ abstract class Importer { + protected bool $renderWithoutLayout = false; + abstract public function columns(): array; abstract public function getValidateUrl(): string; @@ -110,6 +112,13 @@ public function getHeading(): string ); } + public function renderWithoutLayout(): View + { + $this->renderWithoutLayout = true; + + return $this->render(); + } + public function render(): View { Assets::addStylesDirectly('vendor/core/packages/data-synchronize/css/data-synchronize.css') @@ -117,8 +126,14 @@ public function render(): View ->addScripts('dropzone') ->addStyles('dropzone'); + $view = 'packages/data-synchronize::import'; + + if ($this->renderWithoutLayout) { + $view = 'packages/data-synchronize::partials.importer'; + } + return view( - apply_filters('data_synchronize_importer_view', 'packages/data-synchronize::import'), + apply_filters('data_synchronize_importer_view', $view), ['importer' => $this] ); }