Commit d23c006c by Jonathan Thomas

Added file name to UI, made file search box work, added some path parsing (to…

Added file name to UI, made file search box work, added some path parsing (to get file name with ellipses)
parent 83b0a62e
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
<h3>Files <button type="button" class="btn btn-primary upload-btn" @click="chooseFiles">Upload</button></h3> <h3>Files <button type="button" class="btn btn-primary upload-btn" @click="chooseFiles">Upload</button></h3>
<div class="col-sm-12"> <div class="col-sm-12">
<div class="form-floating mb-3"> <div class="form-floating mb-3">
<input type="text" class="form-control" id="floatingInput" placeholder="Search"> <input type="text" class="form-control" id="floatingInput" placeholder="Search" v-model="search">
<label for="floatingInput">Search</label> <label for="floatingInput">Search</label>
</div> </div>
</div> </div>
<div v-for="file in files" :key="file.id" class="col-4"> <div v-for="file in searchedFiles" :key="file.id" class="col-4">
<img @click="toggleSelection(file)" :class="getSelectedClass(file)" class="file-thumbnail img-fluid img-thumbnail" :title="file.name" :src="file.thumbnail"/> <img @click="toggleSelection(file)" :class="getSelectedClass(file)" class="file-thumbnail img-fluid img-thumbnail" :title="file.name" :src="file.thumbnail"/>
<figcaption class="figure-caption">{{ getFileName(file) }}</figcaption>
</div> </div>
<div v-for="upload in uploads" :key="upload.id" class="col-4"> <div v-for="upload in uploads" :key="upload.id" class="col-4">
<div class="row h-100"> <div class="row h-100">
...@@ -25,12 +26,15 @@ ...@@ -25,12 +26,15 @@
<script> <script>
import { mapActions, mapState, mapMutations } from "vuex"; import { mapActions, mapState, mapMutations } from "vuex";
import path from 'path'
export default { export default {
name: "Files.vue", name: "Files.vue",
props: ['project'], props: ['project'],
data() { data() {
return {} return {
search: ""
}
}, },
methods: { methods: {
chooseFiles() { chooseFiles() {
...@@ -71,10 +75,21 @@ export default { ...@@ -71,10 +75,21 @@ export default {
return '' return ''
} }
}, },
getFileName(fileObject) {
let base = path.basename(fileObject.media)
if (base.length < 20) {
return base
} else {
return `${base.substr(0, 18)}...`
}
},
...mapActions(['loadFiles', 'createFile']), ...mapActions(['loadFiles', 'createFile']),
...mapMutations((['setPreviewFile'])) ...mapMutations((['setPreviewFile']))
}, },
computed: { computed: {
searchedFiles() {
return this.files.filter(file => path.basename(file.media).toLowerCase().includes(this.search.toLowerCase()))
},
...mapState(['files', 'previewFile', 'uploads']) ...mapState(['files', 'previewFile', 'uploads'])
}, },
mounted() { mounted() {
...@@ -97,6 +112,9 @@ export default { ...@@ -97,6 +112,9 @@ export default {
.selected { .selected {
border: #0d6efd 4px solid; border: #0d6efd 4px solid;
} }
.figure-caption {
font-size: 0.8em;
}
.file-thumbnail { .file-thumbnail {
cursor: pointer; cursor: pointer;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment