feat: revamp collections ui

This commit is contained in:
liyasthomas
2021-07-08 13:00:41 +05:30
parent 6635d449a5
commit 207dc2b6a6
29 changed files with 821 additions and 579 deletions

View File

@@ -1,147 +1,170 @@
<template>
<div>
<div>
<div class="flex flex-col">
<div class="flex items-center group">
<span
class="
flex
justify-center
items-center
text-xs
w-10
truncate
cursor-pointer
"
@click="toggleShowChildren()"
>
<i class="material-icons">{{ getCollectionIcon }}</i>
</span>
<span
class="
py-3
cursor-pointer
pr-3
flex flex-1
min-w-0
text-xs
group-hover:text-secondaryDark
transition
"
@click="toggleShowChildren()"
>
<span class="truncate"> {{ collection.title }} </span>
</span>
<ButtonSecondary
:label="collection.title"
@click.native="toggleShowChildren"
v-if="doc && !selected"
v-tippy="{ theme: 'tooltip' }"
:title="$t('import')"
icon="check_box_outline_blank"
@click.native="$emit('select-collection')"
/>
<i v-show="!showChildren && !isFiltered" class="material-icons"
>arrow_right</i
<ButtonSecondary
v-if="doc && selected"
v-tippy="{ theme: 'tooltip' }"
:title="$t('delete')"
icon="check_box"
@click.native="$emit('unselect-collection')"
/>
<ButtonSecondary
v-if="collectionsType.selectedTeam.myRole !== 'VIEWER'"
v-tippy="{ theme: 'tooltip' }"
icon="create_new_folder"
:title="$t('new_folder')"
class="group-hover:inline-flex hidden"
@click.native="
$emit('add-folder', {
folder: collection,
path: `${collectionIndex}`,
})
"
/>
<tippy
v-if="collectionsType.selectedTeam.myRole !== 'VIEWER'"
ref="options"
interactive
tabindex="-1"
trigger="click"
theme="popover"
arrow
>
<i v-show="showChildren || isFiltered" class="material-icons"
>arrow_drop_down</i
>
<i v-if="isSelected" class="text-green-400 material-icons"
>check_circle</i
>
<i v-else class="material-icons">folder</i>
<div>
<ButtonSecondary
v-if="doc && !selected"
v-tippy="{ theme: 'tooltip' }"
:title="$t('import')"
icon="check_box_outline_blank"
@click.native="$emit('select-collection')"
<template #trigger>
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:title="$t('more')"
icon="more_vert"
/>
</template>
<SmartItem
v-if="collectionsType.selectedTeam.myRole !== 'VIEWER'"
icon="create_new_folder"
:label="$t('new_folder')"
@click.native="
$emit('add-folder', {
folder: collection,
path: `${collectionIndex}`,
})
$refs.options.tippy().hide()
"
/>
<ButtonSecondary
v-if="doc && selected"
v-tippy="{ theme: 'tooltip' }"
:title="$t('delete')"
icon="check_box"
@click.native="$emit('unselect-collection')"
<SmartItem
v-if="collectionsType.selectedTeam.myRole !== 'VIEWER'"
icon="create"
:label="$t('edit')"
@click.native="
$emit('edit-collection')
$refs.options.tippy().hide()
"
/>
<tippy
ref="options"
tabindex="-1"
trigger="click"
theme="popover"
arrow
>
<template #trigger>
<TabPrimary
v-if="collectionsType.selectedTeam.myRole !== 'VIEWER'"
v-tippy="{ theme: 'tooltip' }"
:title="$t('more')"
icon="more_vert"
/>
</template>
<SmartItem
v-if="collectionsType.selectedTeam.myRole !== 'VIEWER'"
icon="create_new_folder"
:label="$t('new_folder')"
@click.native="
$emit('add-folder', {
folder: collection,
path: `${collectionIndex}`,
})
$refs.options.tippy().hide()
"
/>
<SmartItem
v-if="collectionsType.selectedTeam.myRole !== 'VIEWER'"
icon="create"
:label="$t('edit')"
@click.native="
$emit('edit-collection')
$refs.options.tippy().hide()
"
/>
<SmartItem
v-if="collectionsType.selectedTeam.myRole !== 'VIEWER'"
icon="delete"
:label="$t('delete')"
@click.native="
confirmRemove = true
$refs.options.tippy().hide()
"
/>
</tippy>
</div>
<SmartItem
v-if="collectionsType.selectedTeam.myRole !== 'VIEWER'"
icon="delete"
:label="$t('delete')"
@click.native="
confirmRemove = true
$refs.options.tippy().hide()
"
/>
</tippy>
</div>
<div v-show="showChildren || isFiltered">
<ul class="flex-col">
<li
v-for="(folder, index) in collection.children"
:key="folder.title"
class="ml-8 border-l border-divider"
>
<CollectionsTeamsFolder
:folder="folder"
:folder-index="index"
:folder-path="`${collectionIndex}/${index}`"
:collection-index="collectionIndex"
:doc="doc"
:save-request="saveRequest"
:collections-type="collectionsType"
:is-filtered="isFiltered"
:picked="picked"
@add-folder="$emit('add-folder', $event)"
@edit-folder="$emit('edit-folder', $event)"
@edit-request="$emit('edit-request', $event)"
@select="$emit('select', $event)"
@expand-collection="expandCollection"
@remove-request="removeRequest"
/>
</li>
</ul>
<ul class="flex-col">
<li
v-for="(request, index) in collection.requests"
:key="index"
class="ml-8 border-l border-divider"
>
<CollectionsTeamsRequest
:request="request.request"
:collection-index="collectionIndex"
:folder-index="-1"
:folder-name="collection.name"
:request-index="request.id"
:doc="doc"
:save-request="saveRequest"
:collections-type="collectionsType"
:picked="picked"
@edit-request="editRequest($event)"
@select="$emit('select', $event)"
@remove-request="removeRequest"
/>
</li>
</ul>
<ul>
<li
v-if="
(collection.children == undefined ||
collection.children.length === 0) &&
(collection.requests == undefined ||
collection.requests.length === 0)
"
class="flex ml-8 border-l border-divider"
>
<p>
<i class="material-icons">not_interested</i>
{{ $t("collection_empty") }}
</p>
</li>
</ul>
<CollectionsTeamsFolder
v-for="(folder, index) in collection.children"
:key="folder.title"
class="ml-5 border-l border-dividerLight"
:folder="folder"
:folder-index="index"
:folder-path="`${collectionIndex}/${index}`"
:collection-index="collectionIndex"
:doc="doc"
:save-request="saveRequest"
:collections-type="collectionsType"
:is-filtered="isFiltered"
:picked="picked"
@add-folder="$emit('add-folder', $event)"
@edit-folder="$emit('edit-folder', $event)"
@edit-request="$emit('edit-request', $event)"
@select="$emit('select', $event)"
@expand-collection="expandCollection"
@remove-request="removeRequest"
/>
<CollectionsTeamsRequest
v-for="(request, index) in collection.requests"
:key="index"
class="ml-5 border-l border-dividerLight"
:request="request.request"
:collection-index="collectionIndex"
:folder-index="-1"
:folder-name="collection.name"
:request-index="request.id"
:doc="doc"
:save-request="saveRequest"
:collections-type="collectionsType"
:picked="picked"
@edit-request="editRequest($event)"
@select="$emit('select', $event)"
@remove-request="removeRequest"
/>
<div
v-if="
(collection.children == undefined ||
collection.children.length === 0) &&
(collection.requests == undefined || collection.requests.length === 0)
"
class="
flex
items-center
text-secondaryLight
flex-col
p-4
justify-center
ml-5
border-l border-dividerLight
"
>
<i class="material-icons opacity-50 pb-2">folder_open</i>
<span class="text-xs">
{{ $t("collection_empty") }}
</span>
</div>
</div>
<SmartConfirmModal
:show="confirmRemove"
@@ -167,7 +190,6 @@ export default {
data() {
return {
showChildren: false,
dragging: false,
selectedFolder: {},
confirmRemove: false,
prevCursor: "",
@@ -183,6 +205,12 @@ export default {
this.picked.collectionID === this.collection.id
)
},
getCollectionIcon() {
if (this.isSelected) return "check_circle"
else if (!this.showChildren && !this.isFiltered) return "arrow_right"
else if (this.showChildren || this.isFiltered) return "arrow_drop_down"
else return "folder"
},
},
methods: {
editRequest(event) {