Chunter: file browser additional fixes (#1547)

Signed-off-by: Ruslan Izhitsky <ruslan.izhitskiy@xored.com>
This commit is contained in:
Ruslan Izhitsky
2022-04-27 14:47:29 +06:00
committed by GitHub
parent 469ac85e99
commit ca2b5ba0f3
19 changed files with 658 additions and 261 deletions
@@ -0,0 +1,83 @@
<script lang="ts">
import { IntlString } from '@anticrm/platform'
import { Label, Menu, showPopup } from '@anticrm/ui'
import { FileBrowserSortMode } from '..'
import attachment from '../plugin'
export let selectedSort: FileBrowserSortMode
const sortModeToString = (sortMode: FileBrowserSortMode): IntlString<{}> => {
switch (sortMode) {
case FileBrowserSortMode.NewestFile:
return attachment.string.FileBrowserSortNewest
case FileBrowserSortMode.OldestFile:
return attachment.string.FileBrowserSortOldest
case FileBrowserSortMode.AscendingAlphabetical:
return attachment.string.FileBrowserSortAZ
case FileBrowserSortMode.DescendingAlphabetical:
return attachment.string.FileBrowserSortZA
case FileBrowserSortMode.SmallestSize:
return attachment.string.FileBrowserSortSmallest
case FileBrowserSortMode.BiggestSize:
return attachment.string.FileBrowserSortBiggest
}
}
const showSortMenu = async (ev: Event): Promise<void> => {
showPopup(
Menu,
{
actions: [
{
label: sortModeToString(FileBrowserSortMode.NewestFile),
action: () => {
selectedSort = FileBrowserSortMode.NewestFile
}
},
{
label: sortModeToString(FileBrowserSortMode.OldestFile),
action: () => {
selectedSort = FileBrowserSortMode.OldestFile
}
},
{
label: sortModeToString(FileBrowserSortMode.AscendingAlphabetical),
action: () => {
selectedSort = FileBrowserSortMode.AscendingAlphabetical
}
},
{
label: sortModeToString(FileBrowserSortMode.DescendingAlphabetical),
action: () => {
selectedSort = FileBrowserSortMode.DescendingAlphabetical
}
},
{
label: sortModeToString(FileBrowserSortMode.SmallestSize),
action: () => {
selectedSort = FileBrowserSortMode.SmallestSize
}
},
{
label: sortModeToString(FileBrowserSortMode.BiggestSize),
action: () => {
selectedSort = FileBrowserSortMode.BiggestSize
}
}
]
},
ev.target as HTMLElement
)
}
</script>
<div class="sortMenu" on:click={(event) => showSortMenu(event)}>
<Label label={attachment.string.FileBrowserSort} />
<Label label={sortModeToString(selectedSort)} />
</div>
<style lang="scss">
.sortMenu {
cursor: pointer;
}
</style>