]> BookStack Code Mirror - bookstack/commitdiff
ZIP Imports: Added parent selector for page/chapter imports
authorDan Brown <redacted>
Mon, 4 Nov 2024 16:21:22 +0000 (16:21 +0000)
committerDan Brown <redacted>
Mon, 4 Nov 2024 16:21:22 +0000 (16:21 +0000)
app/Exports/Controllers/ImportController.php
lang/en/entities.php
resources/sass/styles.scss
resources/views/entities/selector.blade.php
resources/views/exports/import-show.blade.php
resources/views/form/errors.blade.php

index 787fd1b27e08227f5556d21dd9bcc10e061d8ad0..a2389c725f3107785ed59848037391638125d705 100644 (file)
@@ -72,14 +72,22 @@ class ImportController extends Controller
         ]);
     }
 
-    public function run(int $id)
+    public function run(int $id, Request $request)
     {
         // TODO - Test access/visibility
-
         $import = $this->imports->findVisible($id);
+        $parent = null;
+
+        if ($import->getType() === 'page' || $import->getType() === 'chapter') {
+            $data = $this->validate($request, [
+                'parent' => ['required', 'string']
+            ]);
+            $parent = $data['parent'];
+        }
 
         // TODO  - Run import
-           // Validate again before
+           // TODO - Validate again before
+           // TODO - Check permissions before (create for main item, create for children, create for related items [image, attachments])
         // TODO - Redirect to result
         // TOOD - Or redirect back with errors
     }
index 4f5a530049bc9cf45be6f4694d4f6d602e686994..065eb043a11bf7bb9de25c443cc67f843c1729b0 100644 (file)
@@ -56,6 +56,8 @@ return [
     'import_size' => 'Import ZIP Size:',
     'import_uploaded_at' => 'Uploaded:',
     'import_uploaded_by' => 'Uploaded by:',
+    'import_location' => 'Import Location',
+    'import_location_desc' => 'Select a target location for your imported content. You\'ll need the relevant permissions to create within the location you choose.',
     'import_delete_confirm' => 'Are you sure you want to delete this import?',
     'import_delete_desc' => 'This will delete the uploaded import ZIP file, and cannot be undone.',
 
index 636367e3aeb0f14cce35fa77e4f903455914335d..942265d04d8bf16ceaae4d51f0ccd4a43eb943ca 100644 (file)
@@ -138,6 +138,11 @@ $loadingSize: 10px;
     font-size: 16px;
     padding: $-s $-m;
   }
+  input[type="text"]:focus {
+    outline: 1px solid var(--color-primary);
+    border-radius: 3px 3px 0 0;
+    outline-offset: -1px;
+  }
   .entity-list {
     overflow-y: scroll;
     height: 400px;
@@ -171,6 +176,19 @@ $loadingSize: 10px;
       font-size: 14px;
     }
   }
+  &.small {
+    .entity-list-item {
+      padding: $-xs $-m;
+    }
+    .entity-list, .loading {
+      height: 300px;
+    }
+    input[type="text"] {
+      font-size: 13px;
+      padding: $-xs $-m;
+      height: auto;
+    }
+  }
 }
 
 .fullscreen {
index c1280cfb2f7934b7c26ccb1d4060a08ea0198521..0cdf4376cc7ea38b07bfbd2ee31fb73590bfbbf8 100644 (file)
@@ -1,3 +1,11 @@
+{{--
+$name - string
+$autofocus - boolean, optional
+$entityTypes - string, optional
+$entityPermission - string, optional
+$selectorEndpoint - string, optional
+$selectorSize - string, optional (compact)
+--}}
 <div class="form-group entity-selector-container">
     <div component="entity-selector"
          refs="entity-selector-popup@selector"
index ac1b8a45d062d893b9a2bf93855ef67961c08dde..63977947dbacacf21f56b571fa317b37672becbb 100644 (file)
@@ -2,6 +2,10 @@
 
 @section('body')
 
+    @php
+        $type = $import->getType();
+    @endphp
+
     <div class="container small">
 
         <main class="card content-wrap auto-height mt-xxl">
@@ -9,11 +13,9 @@
             <p class="text-muted">{{ trans('entities.import_continue_desc') }}</p>
 
             <div class="mb-m">
-                @php
-                    $type = $import->getType();
-                @endphp
+                <label class="setting-list-label">Import Details</label>
                 <div class="flex-container-row items-center justify-space-between wrap">
-                    <div class="py-s">
+                    <div>
                         <p class="text-{{ $type }} mb-xs bold">@icon($type) {{ $import->name }}</p>
                         @if($type === 'book')
                             <p class="text-chapter mb-xs ml-l">@icon('chapter') {{ trans_choice('entities.x_chapters', $import->chapter_count) }}</p>
@@ -22,7 +24,7 @@
                             <p class="text-page mb-xs ml-l">@icon('page') {{ trans_choice('entities.x_pages', $import->page_count) }}</p>
                         @endif
                     </div>
-                    <div class="py-s">
+                    <div>
                         <div class="opacity-80">
                             <strong>{{ trans('entities.import_size') }}</strong>
                             <span>{{ $import->getSizeString() }}</span>
                   action="{{ $import->getUrl() }}"
                   method="POST">
                 {{ csrf_field() }}
+
+                @if($type === 'page' || $type === 'chapter')
+                    <hr>
+                    <label class="setting-list-label">{{ trans('entities.import_location') }}</label>
+                    <p class="small mb-m">{{ trans('entities.import_location_desc') }}</p>
+                    @include('entities.selector', [
+                        'name' => 'parent',
+                        'entityTypes' => $type === 'page' ? 'chapter,book' : 'book',
+                        'entityPermission' => "{$type}-create",
+                        'selectorSize' => 'compact small',
+                    ])
+                    @include('form.errors', ['name' => 'parent'])
+                @endif
             </form>
 
             <div class="text-right">
index 03cd4be88f08edbc3e61e1f988036709390e3de5..72d41ee56c74f887551ea857fe2b65d892a2d688 100644 (file)
@@ -1,3 +1,6 @@
+{{--
+$name - string
+--}}
 @if($errors->has($name))
     <div class="text-neg text-small">{{ $errors->first($name) }}</div>
 @endif
\ No newline at end of file
Morty Proxy This is a proxified and sanitized view of the page, visit original site.