Skip to content

Commit

Permalink
Closes #598: Add new buttonOnTop option to medias, files and browser …
Browse files Browse the repository at this point in the history
…form fields
  • Loading branch information
ifox committed Jul 15, 2020
1 parent cf8ead0 commit 964c99a
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 9 deletions.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/assets/admin/js/chunk-common.e1bd8318.js

This file was deleted.

1 change: 1 addition & 0 deletions dist/assets/admin/js/chunk-common.fbbfd626.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/assets/admin/twill-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"Inter-MediumItalic.woff2": "/assets/admin/fonts/Inter-MediumItalic.7a7fd735.woff2",
"Inter-Regular.woff": "/assets/admin/fonts/Inter-Regular.aebfbb3c.woff",
"Inter-Regular.woff2": "/assets/admin/fonts/Inter-Regular.bffaed79.woff2",
"chunk-common.css": "/assets/admin/css/chunk-common.4188ad52.css",
"chunk-common.js": "/assets/admin/js/chunk-common.e1bd8318.js",
"chunk-common.css": "/assets/admin/css/chunk-common.720da74b.css",
"chunk-common.js": "/assets/admin/js/chunk-common.fbbfd626.js",
"chunk-vendors.css": "/assets/admin/css/chunk-vendors.e0f3ef32.css",
"chunk-vendors.js": "/assets/admin/js/chunk-vendors.aa8e5164.js",
"icons-files.svg": "/assets/admin/icons/icons-files.3cdbddfb2725088d.svg",
Expand Down
11 changes: 10 additions & 1 deletion frontend/js/components/BrowserField.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<div class="browserField">
<div class="browserField__trigger" v-if="buttonOnTop && remainingItems">
<a17-button type="button" variant="ghost" @click="openBrowser">{{ addLabel }}</a17-button>
<input type="hidden" :name="name" :value="itemsIds"/>
<span class="browserField__note f--small"><slot></slot></span>
</div>
<table class="browserField__table" v-if="items.length">
<draggable :tag="'tbody'" v-model="items">
<a17-browseritem v-for="(item, index) in items" :key="item.endpointType + '_' + item.id" class="item__content"
Expand All @@ -8,7 +13,7 @@
:showType="endpoints.length > 0" />
</draggable>
</table>
<div class="browserField__trigger" v-if="remainingItems">
<div class="browserField__trigger" v-if="!buttonOnTop && remainingItems">
<a17-button type="button" variant="ghost" @click="openBrowser">{{ addLabel }}</a17-button>
<input type="hidden" :name="name" :value="itemsIds"/>
<span class="browserField__note f--small"><slot></slot></span>
Expand Down Expand Up @@ -63,6 +68,10 @@
wide: {
type: Boolean,
default: false
},
buttonOnTop: {
type: Boolean,
default: false
}
},
data: function () {
Expand Down
5 changes: 5 additions & 0 deletions frontend/js/components/MediaFieldTranslated.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:cropContext="cropContext"
:max="max"
:required="required"
:buttonOnTop="buttonOnTop"
:withAddInfo="withAddInfo"
:withVideoUrl="withVideoUrl"
:withCaption="withCaption"
Expand Down Expand Up @@ -57,6 +58,10 @@
max: {
type: Number,
default: 1
},
buttonOnTop: {
type: Boolean,
default: false
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion frontend/js/components/Slideshow.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="slideshow">
<div class="slideshow__trigger" v-if="remainingSlides > 0">
<div class="slideshow__trigger" v-if="buttonOnTop && remainingSlides > 0">
<a17-button type="button" variant="ghost" @click="openMediaLibrary(remainingSlides)">{{ addLabel }}</a17-button>
<span class="slideshow__note f--small"><slot></slot></span>
</div>
Expand All @@ -27,6 +27,10 @@
</div>
</transition-group>
</draggable>
<div class="slideshow__trigger" v-if="!buttonOnTop && remainingSlides > 0">
<a17-button type="button" variant="ghost" @click="openMediaLibrary(remainingSlides)">{{ addLabel }}</a17-button>
<span class="slideshow__note f--small"><slot></slot></span>
</div>
</div>
</template>

Expand Down Expand Up @@ -58,6 +62,10 @@
max: {
type: Number,
default: 10
},
buttonOnTop: {
type: Boolean,
default: false
}
},
data: function () {
Expand Down
11 changes: 10 additions & 1 deletion frontend/js/components/files/FileField.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<template>
<a17-inputframe :error="error" :label="label" :locale="locale" @localize="updateLocale" :size="size" :name="name" :note="fieldNote">
<div class="fileField">
<div class="fileField__trigger" v-if="buttonOnTop && remainingItems">
<input type="hidden" :name="name" :value="itemsIds"/>
<a17-button type="button" variant="ghost" @click="openMediaLibrary(remainingItems)">{{ addLabel }}</a17-button>
<span class="fileField__note f--small">{{ note }}</span>
</div>
<table class="fileField__list" v-if="items.length">
<draggable :tag="'tbody'" v-model="items">
<a17-fileitem v-for="(item, index) in items" :key="item.id" class="item__content" :name="`${name}_${item.id}`" :draggable="isDraggable" :item="item" @delete="deleteItem(index)"></a17-fileitem>
</draggable>
</table>
<div class="fileField__trigger" v-if="remainingItems">
<div class="fileField__trigger" v-if="!buttonOnTop && remainingItems">
<input type="hidden" :name="name" :value="itemsIds"/>
<a17-button type="button" variant="ghost" @click="openMediaLibrary(remainingItems)">{{ addLabel }}</a17-button>
<span class="fileField__note f--small">{{ note }}</span>
Expand Down Expand Up @@ -67,6 +72,10 @@
filesizeMax: {
type: Number,
default: 0
},
buttonOnTop: {
type: Boolean,
default: false
}
},
data: () => {
Expand Down
2 changes: 2 additions & 0 deletions views/partials/form/_browser.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$fieldNote = $fieldNote ?? '';
$sortable = $sortable ?? true;
$wide = $wide ?? false;
$buttonOnTop = $buttonOnTop ?? false;
@endphp

<a17-inputframe label="{{ $label }}" name="browsers.{{ $name }}" note="{{ $fieldNote }}">
Expand All @@ -31,6 +32,7 @@
:endpoints="{{ json_encode($endpoints) }}"
modal-title="{{ twillTrans('twill::lang.fields.browser.attach') . ' ' . strtolower($label) }}"
:draggable="{{ json_encode($sortable) }}"
@if ($buttonOnTop) :button-on-top="true" @endif
>{{ $note }}</a17-browserfield>
</a17-inputframe>

Expand Down
6 changes: 4 additions & 2 deletions views/partials/form/_files.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
$note = $note ?? 'Add' . ($max > 1 ? " up to $max $itemLabel" : ' one ' . Str::singular($itemLabel));
$fieldNote = $fieldNote ?? '';
$filesizeMax = $filesizeMax ?? 0;
$buttonOnTop = $buttonOnTop ?? false;
@endphp

<a17-locale
type="a17-filefield"
:attributes="{
label: '{{ $label }}',
itemLabel: '{{ $itemLabel }}',
@include('twill::partials.form.utils._field_name', ['asAttributes' => true])
note: '{{ $note }}',
fieldNote: '{{ $fieldNote }}',
max: {{ $max }},
filesizeMax: {{ $filesizeMax }}
filesizeMax: {{ $filesizeMax }},
@if ($buttonOnTop) buttonOnTop: true, @endif
@include('twill::partials.form.utils._field_name', ['asAttributes' => true])
}"
></a17-locale>

Expand Down
3 changes: 3 additions & 0 deletions views/partials/form/_medias.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$multiple = $max > 1 || $max == 0;
$widthMin = $widthMin ?? 0;
$heightMin = $heightMin ?? 0;
$buttonOnTop = $buttonOnTop ?? false;
@endphp

@if (config('twill.media_library.translated_form_fields', $translated ?? false) && ($translated ?? true))
Expand All @@ -30,6 +31,7 @@
@if (!$withAddInfo) withAddInfo: false, @endif
@if (!$withVideoUrl) withVideoUrl: false, @endif
@if (!$withCaption) withCaption: false, @endif
@if ($buttonOnTop) buttonOnTop: true, @endif
@include('twill::partials.form.utils._field_name', ['asAttributes' => true])
}"
></a17-locale>
Expand Down Expand Up @@ -58,6 +60,7 @@
@if (!$withCaption) :with-caption="false" @endif
@if ($altTextMaxLength) :alt-text-max-length="{{ $altTextMaxLength }}" @endif
@if ($captionMaxLength) :caption-max-length="{{ $captionMaxLength }}" @endif
@if ($buttonOnTop) :button-on-top="true" @endif
>{{ $note }}@if($multiple) </a17-slideshow> @else </a17-mediafield> @endif
</a17-inputframe>

Expand Down

0 comments on commit 964c99a

Please sign in to comment.