Ignore:
Timestamp:
2022-01-07T15:04:19+13:00 (2 years ago)
Author:
cstephen
Message:

Allow removing files before macronisation

Location:
main/trunk/model-interfaces-dev/atea/macron-restoration/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/macron-restoration/src/components/FileUpload.vue

    r35772 r35900  
    33        <div class="input-bar">
    44            <div class="text-input-sl" style="cursor: pointer;" @click="openFilePicker">
    5                 <span class="text-placeholder material-icons" v-if="!anyFiles">attach_file</span>
     5                <span class="text-placeholder material-icons">attach_file</span>
    66                <span class="text-placeholder" v-if="!anyFiles">{{ translations.get("FileUpload_SelectFiles") }}</span>
    7                 <span v-if="anyFiles">{{ getFileNameList }}</span>
     7
     8                <div class="uploaded-file-listing" v-for="(file, index) in files" :key="file.name">
     9                    <span>{{ file.name }}</span>
     10                    <button type="button" @click="onFileRemove($event, index)" class="btn-pin">
     11                        <span class="material-icons mdi-s">close</span>
     12                    </button>
     13                </div>
    814            </div>
    915
     
    5763    gap: 0.5em;
    5864    grid-template-columns: 1fr auto;
     65}
     66
     67.uploaded-file-listing {
     68    display: flex;
     69    align-items: center;
     70
     71    padding: 3px;
     72    gap: 5px;
     73
     74    border: 1px solid var(--bg-color);
     75    border-radius: 3px;
     76    border-left: 4px solid var(--bg-color);
     77    background: rgba(var(--bg-color-raw), 0.1);
     78
     79    margin-right: 0.5em;
     80    &:last-child {
     81        margin-right: 0;
     82    }
    5983}
    6084
     
    135159            }
    136160        },
     161        /**
     162         * Invoked when a drop event occurs on the file upload panel.
     163         * @param {DragEvent} ev The drop event.
     164         */
     165        onFilesDropped(ev) {
     166            ev.preventDefault();
     167
     168            if (ev.dataTransfer.items) {
     169                for (let i = 0; i < ev.dataTransfer.items.length; i++) {
     170                    if (ev.dataTransfer.items[i].kind !== "file") {
     171                        continue;
     172                    }
     173
     174                    const file = ev.dataTransfer.items[i].getAsFile();
     175                    this.files.push(file);
     176                }
     177            }
     178            else {
     179                this.files.push(ev.dataTransfer.files);
     180            }
     181        },
     182        /**
     183         * Invoked when the user clicks a button to remove a file.
     184         * @param {MouseEvent} ev The mouse event.
     185         * @param {Number} index The index of the file to remove.
     186         */
     187        onFileRemove(ev, index) {
     188            ev.cancelBubble = true;
     189            this.files.splice(index, 1);
     190        },
    137191
    138192        async doMacronisation() {
  • main/trunk/model-interfaces-dev/atea/macron-restoration/src/styles/_material.scss

    r35729 r35900  
    131131    border-radius: 50%;
    132132    padding: 0.3em;
     133}
     134
     135.btn-pin {
     136    appearance: none;
     137    display: flex;
     138    align-items: center;
     139    justify-content: center;
     140
     141    margin: 0;
     142    padding: 2px;
     143    background: none;
     144    border: none;
     145    border-radius: 50%;
     146
     147    &:hover {
     148        background-color: rgba(30, 30, 30, 0.15);
     149    }
    133150}
    134151
Note: See TracChangeset for help on using the changeset viewer.