1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-10 23:50:12 +00:00

made it possible to edit the a file name

This commit is contained in:
Bram Wiepjes 2020-12-16 12:54:07 +01:00
parent a0b04c9197
commit a15075ea13
7 changed files with 59 additions and 2 deletions
changelog.md
web-frontend/modules
core
assets/scss/components
components
database

View file

@ -9,6 +9,7 @@
* Fixed drifting context menu.
* Store updated and created timestamp for the groups, applications, tables, views,
fields and rows.
* Made the file name editable.
## Released (2020-12-01)

View file

@ -23,6 +23,12 @@
@include fixed-height($file-field-modal-head-height, 14px);
}
.file-field-modal__rename {
font-size: 12px;
margin-left: 4px;
color: $white;
}
.file-field-modal__close {
border-radius: 3px;
color: $white;

View file

@ -42,6 +42,7 @@ export default {
*/
edit() {
this.editing = true
this.$emit('editing', true)
this.$nextTick(() => {
focusEnd(this.$refs.editable)
})
@ -53,6 +54,7 @@ export default {
*/
change() {
this.editing = false
this.$emit('editing', false)
if (this.oldValue === this.newValue) {
return

View file

@ -8,7 +8,27 @@
<div class="file-field-modal">
<div class="file-field-modal__head">
<div class="file-field-modal__name">
<template v-if="preview">{{ preview.visible_name }}</template>
<template v-if="preview">
<Editable
ref="rename"
:value="preview.visible_name"
@change="
$emit('renamed', {
value: files,
index: selected,
value: $event.value,
})
"
@editing="renaming = $event"
></Editable>
<a
v-show="!renaming"
@click="$refs.rename.edit()"
class="file-field-modal__rename"
>
<i class="fa fa-pen"></i>
</a>
</template>
</div>
<a class="file-field-modal__close" @click="hide()">
<i class="fas fa-times"></i>
@ -97,6 +117,7 @@ export default {
},
data() {
return {
renaming: false,
selected: 0,
}
},
@ -137,6 +158,12 @@ export default {
}
},
keyup(event) {
// When we are renaming we want the arrow keys to be available to move the
// cursor.
if (this.renaming) {
return
}
// If left arrow
if (event.keyCode === 37) {
this.previous()

View file

@ -18,13 +18,24 @@
</div>
<div class="field-file__description">
<div class="field-file__name">
{{ file.visible_name }}
<Editable
:ref="'rename-' + index"
:value="file.visible_name"
@change="renameFile(value, index, $event.value)"
></Editable>
</div>
<div class="field-file__info">
{{ getDate(file.uploaded_at) }} - {{ file.size | formatBytes }}
</div>
</div>
<div class="field-file__actions">
<a
v-tooltip="'rename'"
class="field-file__action"
@click="$refs['rename-' + index][0].edit()"
>
<i class="fas fa-pen"></i>
</a>
<a
v-tooltip="'download'"
target="_blank"
@ -55,6 +66,7 @@
ref="fileModal"
:files="value"
@removed="removeFile(value, $event)"
@renamed="renameFile(value, $event.index, $event.value)"
></FileFieldModal>
</div>
</template>

View file

@ -66,6 +66,7 @@
:files="value"
@hidden="hideModal"
@removed="removeFile(value, $event)"
@renamed="renameFile(value, $event.index, $event.value)"
></FileFieldModal>
</div>
</template>

View file

@ -27,6 +27,14 @@ export default {
newValue.push(...files)
this.$emit('update', newValue, value)
},
/**
* Updates the visible name of the file with the given index.
*/
renameFile(value, index, newName) {
const newValue = JSON.parse(JSON.stringify(value))
newValue[index].visible_name = newName
this.$emit('update', newValue, value)
},
getIconClass(mimeType) {
return mimetype2fa(mimeType)
},