Skip to content

Commit 14578c2

Browse files
committed
ZIP Imports: Added parent selector for page/chapter imports
1 parent 8f6f819 commit 14578c2

File tree

6 files changed

+62
-8
lines changed

6 files changed

+62
-8
lines changed

app/Exports/Controllers/ImportController.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,22 @@ public function show(int $id)
7272
]);
7373
}
7474

75-
public function run(int $id)
75+
public function run(int $id, Request $request)
7676
{
7777
// TODO - Test access/visibility
78-
7978
$import = $this->imports->findVisible($id);
79+
$parent = null;
80+
81+
if ($import->getType() === 'page' || $import->getType() === 'chapter') {
82+
$data = $this->validate($request, [
83+
'parent' => ['required', 'string']
84+
]);
85+
$parent = $data['parent'];
86+
}
8087

8188
// TODO - Run import
82-
// Validate again before
89+
// TODO - Validate again before
90+
// TODO - Check permissions before (create for main item, create for children, create for related items [image, attachments])
8391
// TODO - Redirect to result
8492
// TOOD - Or redirect back with errors
8593
}

lang/en/entities.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
'import_size' => 'Import ZIP Size:',
5757
'import_uploaded_at' => 'Uploaded:',
5858
'import_uploaded_by' => 'Uploaded by:',
59+
'import_location' => 'Import Location',
60+
'import_location_desc' => 'Select a target location for your imported content. You\'ll need the relevant permissions to create within the location you choose.',
5961
'import_delete_confirm' => 'Are you sure you want to delete this import?',
6062
'import_delete_desc' => 'This will delete the uploaded import ZIP file, and cannot be undone.',
6163

resources/sass/styles.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ $loadingSize: 10px;
138138
font-size: 16px;
139139
padding: $-s $-m;
140140
}
141+
input[type="text"]:focus {
142+
outline: 1px solid var(--color-primary);
143+
border-radius: 3px 3px 0 0;
144+
outline-offset: -1px;
145+
}
141146
.entity-list {
142147
overflow-y: scroll;
143148
height: 400px;
@@ -171,6 +176,19 @@ $loadingSize: 10px;
171176
font-size: 14px;
172177
}
173178
}
179+
&.small {
180+
.entity-list-item {
181+
padding: $-xs $-m;
182+
}
183+
.entity-list, .loading {
184+
height: 300px;
185+
}
186+
input[type="text"] {
187+
font-size: 13px;
188+
padding: $-xs $-m;
189+
height: auto;
190+
}
191+
}
174192
}
175193

176194
.fullscreen {

resources/views/entities/selector.blade.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
{{--
2+
$name - string
3+
$autofocus - boolean, optional
4+
$entityTypes - string, optional
5+
$entityPermission - string, optional
6+
$selectorEndpoint - string, optional
7+
$selectorSize - string, optional (compact)
8+
--}}
19
<div class="form-group entity-selector-container">
210
<div component="entity-selector"
311
refs="entity-selector-popup@selector"

resources/views/exports/import-show.blade.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22

33
@section('body')
44

5+
@php
6+
$type = $import->getType();
7+
@endphp
8+
59
<div class="container small">
610

711
<main class="card content-wrap auto-height mt-xxl">
812
<h1 class="list-heading">{{ trans('entities.import_continue') }}</h1>
913
<p class="text-muted">{{ trans('entities.import_continue_desc') }}</p>
1014

1115
<div class="mb-m">
12-
@php
13-
$type = $import->getType();
14-
@endphp
16+
<label class="setting-list-label">Import Details</label>
1517
<div class="flex-container-row items-center justify-space-between wrap">
16-
<div class="py-s">
18+
<div>
1719
<p class="text-{{ $type }} mb-xs bold">@icon($type) {{ $import->name }}</p>
1820
@if($type === 'book')
1921
<p class="text-chapter mb-xs ml-l">@icon('chapter') {{ trans_choice('entities.x_chapters', $import->chapter_count) }}</p>
@@ -22,7 +24,7 @@
2224
<p class="text-page mb-xs ml-l">@icon('page') {{ trans_choice('entities.x_pages', $import->page_count) }}</p>
2325
@endif
2426
</div>
25-
<div class="py-s">
27+
<div>
2628
<div class="opacity-80">
2729
<strong>{{ trans('entities.import_size') }}</strong>
2830
<span>{{ $import->getSizeString() }}</span>
@@ -45,6 +47,19 @@
4547
action="{{ $import->getUrl() }}"
4648
method="POST">
4749
{{ csrf_field() }}
50+
51+
@if($type === 'page' || $type === 'chapter')
52+
<hr>
53+
<label class="setting-list-label">{{ trans('entities.import_location') }}</label>
54+
<p class="small mb-m">{{ trans('entities.import_location_desc') }}</p>
55+
@include('entities.selector', [
56+
'name' => 'parent',
57+
'entityTypes' => $type === 'page' ? 'chapter,book' : 'book',
58+
'entityPermission' => "{$type}-create",
59+
'selectorSize' => 'compact small',
60+
])
61+
@include('form.errors', ['name' => 'parent'])
62+
@endif
4863
</form>
4964

5065
<div class="text-right">

resources/views/form/errors.blade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{{--
2+
$name - string
3+
--}}
14
@if($errors->has($name))
25
<div class="text-neg text-small">{{ $errors->first($name) }}</div>
36
@endif

0 commit comments

Comments
 (0)