@endpush
{{-- Show the file picker on CREATE form. --}}
-<div class="freefile-file">
+<div class="freefile-file @if($field['downloadbase'])
+hasdownload
+@endif">
<input type="file" multiple name="upload[]"
@if(isset($field['accept']) && $field['accept'])
accept="{{$field['accept']}}"
@if(isset($field['accept']) && $field['accept'] && stristr($field['accept'],'.zip'))
<input type="file" multiple directory webkitdirectory name="directory[]" class="freefile-file-input-directory"
form="{{$form_id}}">
- <a class="upload" href="#" data-tooltip="{{__('Clic pour charger un ou plusieurs fichiers, Ctrl+Clic pour charger un dossier')}}"></a>
+ <a class="upload" href="#"
+ data-tooltip="{{__('Clic pour charger un ou plusieurs fichiers, Ctrl+Clic pour charger un dossier')}}"></a>
@endif
<input type="text" name="{{ $field['name'] }}"
@include('crud::fields.inc.attributes', ['default_class' => 'form-control freefile-text-input'])
>
<label class="freefile-file-label" for="customFile"></label>
+ @if($field['downloadbase'])
+ <a href="#" class="freefile-file-download" data-downloadbase="{{$field['downloadbase']}}"><i
+ class="las la-download"></i></a>
+ @endif
</div>
{{-- HINT --}}
margin: 0;
left: 0;
width: 85%;
- top:2px;
+ top: 2px;
border-color: transparent;
background-color: transparent;
}
width: calc(100% - 87px);
}
+ .freefile-file.hasdownload .freefile-text-input:lang(en) {
+ width: calc(100% - 74px - 38px);
+ }
+
+ .freefile-file.hasdownload .freefile-text-input:lang(fr) {
+ width: calc(100% - 87px - 38px);
+ }
+
.freefile-file-input:lang(en) {
width: 74px;
}
width: 87px;
}
+ .freefile-file-download {
+ position: absolute;
+ display: none;
+ top: 0;
+ height: 100%;
+ width: 38px;
+ cursor: pointer;
+ background-color: #f0f3f9;
+ border: 1px solid #e4e7ea;
+ border-right-width: 0;
+ color: #5c6873;
+ z-index: 3;
+ line-height: 38px;
+ text-align: center;
+ font-size: 19px;
+
+ }
+
+ .freefile-file.hasdownload .freefile-file-download {
+ display: block;
+ }
+
+ .freefile-text-input:focus ~ .freefile-file-download {
+ border-color: #2f66b3;
+ }
+
+ .freefile-file-download:lang(en) {
+ right: 74px;
+ }
+
+ .freefile-file-download:lang(fr) {
+ right: 87px;
+ }
+
.freefile-text-input:focus ~ .freefile-file-label {
border-color: #2f66b3;
box-shadow: 0 0 0 0rem rgba(70, 127, 208, 0.25);
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
jQuery(document).ready(function ($) {
+ function updateDownload() {
+ $('.freefile-file').each(function () {
+ if ($(this).find('.freefile-file-download').length === 0) {
+ return;
+ }
+ let v = $(this).find('.freefile-text-input').val();
+ if (v === '' || v.indexOf('http') === 0) {
+ $(this).removeClass('hasdownload');
+ } else {
+ $(this).addClass('hasdownload');
+ }
+ });
+ }
+
$(document).on('change', '.freefile-file-input', function () {
var parent = $(this).closest('.freefile-file');
$(parent).addClass('loading');
tf.val(data[0]);
tf.trigger('change');
$(parent).removeClass('loading');
+ updateDownload();
});
});
+
+ $(document).on('change', '.freefile-text-input', function () {
+ updateDownload();
+ });
+
+ $(document).on('click', '.freefile-file-download', function () {
+ let v = $(this).closest('.freefile-file').find('.freefile-text-input').val();
+ let url = $(this).data('downloadbase');
+ url += v;
+ url=url.replace(/(\$id)/g, $('input[name="id"]').val());
+ $('<a href="' + url + '" download="' + v + '"></a>').get('0').click();
+ return false;
+ });
+
+ updateDownload();
});
</script>
@endpush