-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp content file mgt #4872
base: unstable
Are you sure you want to change the base?
Revamp content file mgt #4872
Changes from all commits
b9048c3
bbebc7d
b452431
3bd10ed
5d48c6f
0a2db6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -680,4 +680,8 @@ | |
margin-top: -4px !important; | ||
} | ||
|
||
/deep/ .v-dialog__content { | ||
z-index: 5 !important; | ||
} | ||
|
||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,32 @@ | |
</VCardText> | ||
</VCard> | ||
<VLayout v-else row wrap> | ||
<VFlex sm12 md6 lg5 xl4> | ||
<VFlex sm12 md12 lg12 xl12> | ||
<p> | ||
<ContentNodeIcon :kind="node.kind" includeText /> | ||
</p> | ||
</VFlex> | ||
<VFlex sm12 md6 lg7 xl7 class="pr-4"> | ||
<h3> | ||
{{ $tr('filesHeader') }} | ||
</h3> | ||
<VList threeLine> | ||
<FileUploadItem | ||
v-for="item in primaryFileMapping" | ||
:key="item.preset.id" | ||
:file="item.file" | ||
:preset="item.preset" | ||
:allowFileRemove="allowFileRemove" | ||
:uploadCompleteHandler="handleUploadComplete" | ||
@selected="selected = item.file.id" | ||
@remove="handleRemoveFile" | ||
/> | ||
</VList> | ||
</VFlex> | ||
<VFlex sm12 md6 lg5 xl5> | ||
<h3 v-if="selectedFilename" class="mb-3"> | ||
{{ selectedFilename }} | ||
</h3> | ||
<div class="preview-wrapper"> | ||
<VCard v-if="!primaryFileCount" flat class="mb-2 message-card"> | ||
<VLayout align-center justify-center fill-height> | ||
|
@@ -39,31 +61,6 @@ | |
/> | ||
</div> | ||
</VFlex> | ||
<VFlex sm12 md6 lg7 xl8> | ||
<VContainer fluid> | ||
<VLayout alignStart> | ||
<VRadioGroup | ||
v-model="selected" | ||
hide-details | ||
:label="$tr('filesHeader')" | ||
class="subheading" | ||
> | ||
<VList threeLine> | ||
<FileUploadItem | ||
v-for="item in primaryFileMapping" | ||
:key="item.preset.id" | ||
:file="item.file" | ||
:preset="item.preset" | ||
:allowFileRemove="allowFileRemove" | ||
:uploadCompleteHandler="handleUploadComplete" | ||
@selected="selected = item.file.id" | ||
@remove="handleRemoveFile" | ||
/> | ||
</VList> | ||
</VRadioGroup> | ||
</VLayout> | ||
</VContainer> | ||
</VFlex> | ||
</VLayout> | ||
</div> | ||
|
||
|
@@ -134,6 +131,10 @@ | |
'order' | ||
); | ||
}, | ||
selectedFilename() { | ||
const file = this.files.find(f => f.id === this.selected); | ||
return file ? file.original_filename : ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any opinion of not using use nullish coalescing here? |
||
}, | ||
}, | ||
watch: { | ||
'files.length'(newCount, oldCount) { | ||
|
@@ -171,7 +172,7 @@ | |
}, | ||
}, | ||
$trs: { | ||
filesHeader: 'Preview files', | ||
filesHeader: 'Files', | ||
fileError: 'Unsupported file type', | ||
noFileText: 'Missing files', | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,27 +11,19 @@ | |
<VListTile | ||
data-test="list-item" | ||
v-bind="$attrs" | ||
tabindex="0" | ||
@click.stop="file ? $emit('selected') : openFileDialog()" | ||
> | ||
<VListTileAction> | ||
<VRadio | ||
v-if="file" | ||
:key="file.id" | ||
:value="file.id" | ||
color="primary" | ||
data-test="radio" | ||
/> | ||
</VListTileAction> | ||
<VListTileContent> | ||
<VListTileSubTitle>{{ translateConstant(preset.id) }}</VListTileSubTitle> | ||
<VListTileTitle> | ||
<ActionLink | ||
<VListTileTitle class="file-display"> | ||
<span | ||
v-if="fileDisplay" | ||
class="notranslate" | ||
:text="formattedFileDisplay" | ||
data-test="file-link" | ||
@click="openFileDialog" | ||
/> | ||
data-test="file-name" | ||
> | ||
{{ formattedFileDisplay }} | ||
</span> | ||
<ActionLink | ||
v-else | ||
data-test="upload-link" | ||
|
@@ -53,15 +45,20 @@ | |
</VListTileContent> | ||
<VSpacer /> | ||
<VListTileAction v-if="fileDisplay"> | ||
<div v-if="allowFileRemove" class="remove-icon"> | ||
<IconButton | ||
icon="clear" | ||
color="grey" | ||
:text="$tr('removeFileButton')" | ||
data-test="remove" | ||
@click="$emit('remove', file)" | ||
/> | ||
</div> | ||
<KIconButton | ||
size="small" | ||
icon="optionsHorizontal" | ||
appearance="flat-button" | ||
data-test="show-file-options" | ||
> | ||
<template #menu> | ||
<KDropdownMenu | ||
:options="previewFilesOptions" | ||
data-test="file-options" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are passing I assumed when the download option is clicked, |
||
@select="(option) => option.onClick(openFileDialog)" | ||
/> | ||
</template> | ||
</KIconButton> | ||
</VListTileAction> | ||
</VListTile> | ||
</FileDropzone> | ||
|
@@ -75,7 +72,6 @@ | |
import { mapGetters } from 'vuex'; | ||
import FileStatusText from 'shared/views/files/FileStatusText'; | ||
import Uploader from 'shared/views/files/Uploader'; | ||
import IconButton from 'shared/views/IconButton'; | ||
import { constantsTranslationMixin, fileSizeMixin, fileStatusMixin } from 'shared/mixins'; | ||
import FileDropzone from 'shared/views/files/FileDropzone'; | ||
|
||
|
@@ -85,7 +81,6 @@ | |
Uploader, | ||
FileDropzone, | ||
FileStatusText, | ||
IconButton, | ||
}, | ||
mixins: [constantsTranslationMixin, fileSizeMixin, fileStatusMixin], | ||
props: { | ||
|
@@ -150,6 +145,36 @@ | |
} | ||
return null; | ||
}, | ||
previewFilesOptions() { | ||
const options = [ | ||
{ | ||
label: this.$tr('replaceFileMenuOptionLabel'), | ||
value: 'REPLACE_FILE', | ||
onClick: replaceFile => { | ||
replaceFile(); | ||
}, | ||
condition: this.fileDisplay, | ||
}, | ||
{ | ||
label: this.$tr('downloadMenuOptionLabel'), | ||
value: 'DOWNLOAD_FILE', | ||
onClick: () => { | ||
this.downloadFile(); | ||
}, | ||
condition: this.fileDisplay, | ||
}, | ||
{ | ||
label: this.$tr('removeMenuOptionLabel'), | ||
value: 'REMOVE_FILE', | ||
onClick: () => { | ||
this.removeFile(); | ||
}, | ||
condition: this.fileDisplay && this.allowFileRemove, | ||
}, | ||
]; | ||
|
||
return options.filter(option => option.condition); | ||
}, | ||
}, | ||
watch: { | ||
'file.id': { | ||
|
@@ -167,11 +192,20 @@ | |
uploadingHandler(fileUpload) { | ||
this.fileUploadId = fileUpload.id; | ||
}, | ||
downloadFile() { | ||
window.open(this.fileDisplay.url, '_blank'); | ||
}, | ||
removeFile() { | ||
this.$emit('remove', this.file); | ||
}, | ||
}, | ||
$trs: { | ||
uploadButton: 'Select file', | ||
removeFileButton: 'Remove', | ||
replaceFileMenuOptionLabel: 'Replace file', | ||
downloadMenuOptionLabel: 'Download', | ||
removeMenuOptionLabel: 'Remove', | ||
/* eslint-disable kolibri/vue-no-unused-translations */ | ||
removeFileButton: 'Remove', | ||
retryUpload: 'Retry upload', | ||
uploadFailed: 'Upload failed', | ||
unknownFile: 'Unknown filename', | ||
|
@@ -183,36 +217,32 @@ | |
|
||
<style lang="less" scoped> | ||
|
||
.layout .section-header { | ||
padding: 0 15px; | ||
font-weight: bold; | ||
color: var(--v-darken-3); | ||
} | ||
|
||
button { | ||
margin: 0; | ||
} | ||
|
||
/deep/ .v-list__tile { | ||
height: max-content !important; | ||
min-height: 64px; | ||
padding: 5px 16px; | ||
|
||
.remove-icon { | ||
display: none; | ||
} | ||
|
||
&:hover .remove-icon { | ||
display: block; | ||
&:focus { | ||
background-color: var(--v-grey-lighten5); | ||
outline-color: var(--v-primary-base); | ||
} | ||
|
||
.v-list__tile__title { | ||
height: max-content; | ||
height: 30px; | ||
} | ||
|
||
.v-list__tile__sub-title { | ||
margin-left: 1px; | ||
white-space: unset; | ||
} | ||
} | ||
|
||
.file-display { | ||
margin-left: 1px; | ||
|
||
span { | ||
font-size: 15px; | ||
} | ||
} | ||
|
||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rtibbles noting here that linting doesn't seem to recorgnize ::v-deep (
Unexpected unknown pseudo-element selector
) So reverted to/deep/
for now