diff --git a/ckanext/file_upload_widget/assets/css/styles.css b/ckanext/file_upload_widget/assets/css/styles.css index d1cf1be..ba21d0d 100644 --- a/ckanext/file_upload_widget/assets/css/styles.css +++ b/ckanext/file_upload_widget/assets/css/styles.css @@ -1 +1 @@ -.file-upload-widget .fuw-main-window{display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;width:100%}.file-upload-widget .fuw-main-window .fuw-or{margin:1rem 0}.file-upload-widget .fuw-main-window .fuw-main-window__dropzone{padding:2rem;border-radius:.5rem;border:2px dashed #ccc;width:100%}.file-upload-widget .fuw-main-window .fuw-main-window__dropzone.active{border-color:#000}.file-upload-widget .fuw-main-window .fuw-main-window__alternative label.btn-file-input:after{display:none}.file-upload-widget .fuw-url-input{width:100%}.file-upload-widget .fuw-media-input{width:100%}.file-upload-widget .fuw-media-input .search-input{margin-bottom:1rem;position:relative}.file-upload-widget .fuw-media-input .search-input input{padding-left:2rem}.file-upload-widget .fuw-media-input .search-input .input-group-btn{position:absolute;left:10px;top:8px}.file-upload-widget .fuw-media-input .search-input .input-group-btn i{color:#6c757d}.file-upload-widget .fuw-media-input .fuw-media-input--files{display:flex;flex-direction:column;padding:0;border-radius:.5rem;height:250px;overflow-y:scroll}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item{display:flex;padding:7px 15px 7px 0;gap:1rem}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item label{display:flex;align-items:center;gap:.5rem;width:100%}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item label:after{display:none}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item label .highlight{background-color:#ff0}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item label object{width:30px;height:30px;object-fit:contain}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item label i{font-size:2rem}.file-upload-widget .fuw-media-input .fuw-media-input--empty{align-items:center;color:#939393;display:flex;height:250px;flex:1;flex-flow:column wrap;justify-content:center}.file-upload-widget .fuw-selected-files{position:absolute}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list{width:100%;height:310px;overflow-y:scroll;padding-right:1rem}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper{display:flex;align-items:center;gap:.5rem;border-bottom:1px solid #eaeaea;padding:.5rem 0;position:relative}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-preview{height:50px;width:50px;font-size:2rem;position:relative;background:#f0f8ff;box-shadow:0 1px 2px rgba(119,119,119,.4588235294);border-radius:3px;display:flex;flex-direction:column;justify-content:center}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-preview .file-tile--file-icon{display:flex;align-items:center;justify-content:center}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-preview object{width:100%;max-height:50px;object-fit:contain}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-info .fuw-selected-files--file-name{-webkit-font-smoothing:antialiased;word-wrap:anywhere;font-size:1rem;font-weight:bold;line-height:1.3;word-break:break-all}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-info .fuw-selected-files--file-size{font-size:.8rem;color:#757575;font-weight:400;line-height:1}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-control{display:flex;align-items:center}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-control .file-tile--file-remove,.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-control .file-tile--file-upload{cursor:pointer;position:absolute;right:0;background:#000;color:#fff;border:1px solid #000;border-radius:50%;width:25px;height:25px;display:flex;align-items:center;justify-content:center}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .file-tile--file-upload{right:30px}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list .fuw-selected-files--progress{position:absolute;bottom:0;width:100%}.file-upload-widget .fuw-cancel-btn,.file-upload-widget .fuw-close-selected-btn{cursor:pointer}.file-upload-widget .hidden{display:none !important}.file-upload-widget .modal .modal-header{gap:.5rem}.file-upload-widget .modal .modal-body{min-height:145px;display:flex;align-items:center;justify-content:center;flex-direction:column}.file-upload-widget .modal .modal-inner-footer{padding:.75rem 0 0 0}.file-upload-widget.form-group .btn{position:static}.file-upload-widget .fuw-upload-btn .fuw-uploaded-files-counter{background:#fff;color:#000;border-radius:50%;padding:4px 7px;line-height:1;font-weight:bold;width:22px;height:22px;display:inline-block} +.file-upload-widget .fuw-main-window{display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;width:100%}.file-upload-widget .fuw-main-window .fuw-or{margin:1rem 0}.file-upload-widget .fuw-main-window .fuw-main-window__dropzone{padding:2rem;border-radius:.5rem;border:2px dashed #ccc;width:100%}.file-upload-widget .fuw-main-window .fuw-main-window__dropzone.active{border-color:#000}.file-upload-widget .fuw-main-window .fuw-main-window__alternative label.btn-file-input:after{display:none}.file-upload-widget .fuw-url-input{width:100%;display:flex;flex-direction:column;align-items:end;gap:1rem}.file-upload-widget .fuw-media-input{width:100%}.file-upload-widget .fuw-media-input .search-input{margin-bottom:1rem;position:relative}.file-upload-widget .fuw-media-input .search-input input{padding-left:2rem}.file-upload-widget .fuw-media-input .search-input .input-group-btn{position:absolute;left:10px;top:8px}.file-upload-widget .fuw-media-input .search-input .input-group-btn i{color:#6c757d}.file-upload-widget .fuw-media-input .fuw-media-input--files{display:flex;flex-direction:column;padding:0;border-radius:.5rem;height:250px;overflow-y:scroll}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item{display:flex;padding:7px 15px 7px 0;gap:1rem}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item label{display:flex;align-items:center;gap:.5rem;width:100%;margin-bottom:0}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item label:after{display:none}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item label .highlight{background-color:#ff0}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item label object{width:30px;height:30px;object-fit:contain}.file-upload-widget .fuw-media-input .fuw-media-input--files .files--file-item label i{font-size:2rem}.file-upload-widget .fuw-media-input .fuw-media-input--empty{align-items:center;color:#939393;display:flex;height:250px;flex:1;flex-flow:column wrap;justify-content:center}.file-upload-widget .fuw-selected-files{position:absolute;top:0;width:100%}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list{width:100%;height:310px;overflow-y:scroll;padding-right:1rem}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper{display:flex;align-items:center;gap:.5rem;border-bottom:1px solid #eaeaea;padding:.5rem 0;position:relative;font-size:14px}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-preview{height:50px;width:50px;font-size:2rem;position:relative;background:#f0f8ff;box-shadow:0 1px 2px rgba(119,119,119,.4588235294);border-radius:3px;display:flex;flex-direction:column;justify-content:center}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-preview .file-tile--file-icon{display:flex;align-items:center;justify-content:center}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-preview object{width:100%;max-height:50px;object-fit:contain}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-info .fuw-selected-files--file-name{-webkit-font-smoothing:antialiased;word-wrap:anywhere;font-size:1em;font-weight:bold;line-height:1.3;word-break:break-all}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-info .fuw-selected-files--file-size{font-size:.8em;color:#757575;font-weight:400;line-height:1}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-control{display:flex;align-items:center;gap:1rem;margin-left:auto}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-control .file-tile--file-remove,.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list li.fuw-selected-files--file-item-wrapper .fuw-selected-files--file-control .file-tile--file-upload{cursor:pointer;background:#000;color:#fff;border:1px solid #000;border-radius:50%;width:25px;height:25px;display:flex;align-items:center;justify-content:center}.file-upload-widget .fuw-selected-files ul.fuw-selected-files--list .fuw-selected-files--progress{position:absolute;bottom:0;width:100%}.file-upload-widget .fuw-cancel-btn,.file-upload-widget .fuw-close-selected-btn{cursor:pointer}.file-upload-widget .hidden{display:none !important}.file-upload-widget .modal .modal-header{gap:.5rem;display:flex;align-items:center}.file-upload-widget .modal .modal-header .btn-close{padding:.5rem .5rem;margin:-0.5rem -0.5rem -0.5rem auto;box-sizing:content-box;width:1em;height:1em;padding:.25em .25em;color:#000;background:rgba(0,0,0,0) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;border:0;border-radius:.25rem;opacity:.5}.file-upload-widget .modal .modal-body{min-height:145px;display:flex;align-items:center;justify-content:center;flex-direction:column}.file-upload-widget .modal .modal-inner-footer{padding:.75rem 0 0 0}.file-upload-widget.form-group .btn{position:static}.file-upload-widget .fuw-upload-btn .fuw-uploaded-files-counter{background:#fff;color:#000;border-radius:50%;padding:4px 7px;line-height:1;font-weight:bold;width:22px;height:22px;display:flex;align-items:center;justify-content:center}@media(min-width: 576px){.file-upload-widget .modal-dialog{max-width:500px;margin:1.75rem auto}.file-upload-widget .modal-dialog-centered{min-height:calc(100% - 3.5rem)}} \ No newline at end of file diff --git a/ckanext/file_upload_widget/assets/js/file-upload-widget.js b/ckanext/file_upload_widget/assets/js/file-upload-widget.js index d0ea18a..616a9b5 100644 --- a/ckanext/file_upload_widget/assets/js/file-upload-widget.js +++ b/ckanext/file_upload_widget/assets/js/file-upload-widget.js @@ -96,8 +96,6 @@ ckan.module("file-upload-widget", function ($, _) { this.options.maxFiles = 9999; } - console.log(this.options); - window.fuwProgressBars = window.fuwProgressBars || {}; window.fuwProgressBars[this.options.instanceId] = {}; @@ -440,9 +438,7 @@ ckan.module("file-upload-widget", function ($, _) { if ( this._isFileNumLimitReached( e, - selectedFiles.length - - (this.options.maxFiles - - this._calculateSelectedFilesNum()), + selectedFiles.length - (this.options.maxFiles - this._calculateSelectedFilesNum()), `You can't select more files than the limit: ${this.options.maxFiles}.` ) ) { @@ -577,7 +573,6 @@ ckan.module("file-upload-widget", function ($, _) { }, _handleFile: function (file) { - console.log(file.type); this._addFileItem( file.id, file.name, @@ -1409,6 +1404,10 @@ ckan.module("file-upload-widget", function ($, _) { selectedNum = null, message = null ) { + if (selectedNum < 0) { + return false; + } + if ( selectedNum || this._calculateSelectedFilesNum() >= this.options.maxFiles diff --git a/ckanext/file_upload_widget/templates/scheming/form_snippets/files_upload_widget.html b/ckanext/file_upload_widget/templates/scheming/form_snippets/files_upload_widget.html index 95a671a..c6f1784 100644 --- a/ckanext/file_upload_widget/templates/scheming/form_snippets/files_upload_widget.html +++ b/ckanext/file_upload_widget/templates/scheming/form_snippets/files_upload_widget.html @@ -1,5 +1,4 @@ {% import 'macros/form.html' as form %} -{% from "macros/form/attributes.html" import attributes %} {% asset "file_upload_widget/css" %} {% asset "file_upload_widget/js" %} @@ -7,20 +6,25 @@ {% set attrs = field.get('form_attrs', {}) %} -