feat: unify collection creation
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -11,6 +11,7 @@ const props = defineProps<{
|
|||||||
|
|
||||||
// Emits
|
// Emits
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
|
'create': []
|
||||||
'select': [collection: CollectionObject]
|
'select': [collection: CollectionObject]
|
||||||
'edit': [collection: CollectionObject]
|
'edit': [collection: CollectionObject]
|
||||||
'toggle-visibility': [collection: CollectionObject]
|
'toggle-visibility': [collection: CollectionObject]
|
||||||
@@ -42,6 +43,12 @@ const displayIcon = computed(() => {
|
|||||||
return 'mdi-folder'
|
return 'mdi-folder'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const createLabel = computed(() => {
|
||||||
|
if (props.type === 'calendar') return 'New Calendar'
|
||||||
|
if (props.type === 'tasklist') return 'New Task List'
|
||||||
|
return 'New Collection'
|
||||||
|
})
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
const onCollectionSelect = (collection: CollectionObject) => {
|
const onCollectionSelect = (collection: CollectionObject) => {
|
||||||
console.log('[Chrono] - Collection selected', collection)
|
console.log('[Chrono] - Collection selected', collection)
|
||||||
@@ -60,10 +67,20 @@ const onToggleVisibility = (collection: CollectionObject) => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="collection-selector">
|
<div class="collection-selector">
|
||||||
<div class="collection-selector-header">
|
<div class="collection-selector-header">
|
||||||
<div class="d-flex align-center mb-3">
|
<div class="d-flex align-center justify-space-between mb-3">
|
||||||
|
<div class="d-flex align-center">
|
||||||
<v-icon :icon="displayIcon" size="small" class="mr-2" />
|
<v-icon :icon="displayIcon" size="small" class="mr-2" />
|
||||||
<span class="text-subtitle-2 font-weight-bold">{{ displayTitle }}</span>
|
<span class="text-subtitle-2 font-weight-bold">{{ displayTitle }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<v-btn
|
||||||
|
icon="mdi-plus"
|
||||||
|
size="x-small"
|
||||||
|
variant="text"
|
||||||
|
:aria-label="createLabel"
|
||||||
|
:title="createLabel"
|
||||||
|
@click="emit('create')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<v-divider class="my-2" />
|
<v-divider class="my-2" />
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ function selectSectionFromRoute() {
|
|||||||
:collections="collections"
|
:collections="collections"
|
||||||
:selected-collection="selectedCollection"
|
:selected-collection="selectedCollection"
|
||||||
type="calendar"
|
type="calendar"
|
||||||
|
@create="openCollectionEditor('calendar')"
|
||||||
@select="selectCollection"
|
@select="selectCollection"
|
||||||
@edit="openCollectionEditor('calendar', $event)"
|
@edit="openCollectionEditor('calendar', $event)"
|
||||||
@toggle-visibility="toggleCalendarVisibility"
|
@toggle-visibility="toggleCalendarVisibility"
|
||||||
@@ -221,34 +222,11 @@ function selectSectionFromRoute() {
|
|||||||
:collections="collections"
|
:collections="collections"
|
||||||
:selected-collection="selectedCollection"
|
:selected-collection="selectedCollection"
|
||||||
type="tasklist"
|
type="tasklist"
|
||||||
|
@create="openCollectionEditor('tasklist')"
|
||||||
@select="selectCollection"
|
@select="selectCollection"
|
||||||
@edit="openCollectionEditor('tasklist', $event)"
|
@edit="openCollectionEditor('tasklist', $event)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<v-btn
|
|
||||||
v-if="!isTasksSection"
|
|
||||||
variant="tonal"
|
|
||||||
color="primary"
|
|
||||||
block
|
|
||||||
class="mt-3"
|
|
||||||
@click="openCollectionEditor('calendar')"
|
|
||||||
>
|
|
||||||
<v-icon start>mdi-plus</v-icon>
|
|
||||||
New Calendar
|
|
||||||
</v-btn>
|
|
||||||
|
|
||||||
<v-btn
|
|
||||||
v-else
|
|
||||||
variant="tonal"
|
|
||||||
color="primary"
|
|
||||||
block
|
|
||||||
class="mt-3"
|
|
||||||
@click="openCollectionEditor('tasklist')"
|
|
||||||
>
|
|
||||||
<v-icon start>mdi-plus</v-icon>
|
|
||||||
New Task List
|
|
||||||
</v-btn>
|
|
||||||
|
|
||||||
<v-divider class="my-3" />
|
<v-divider class="my-3" />
|
||||||
<v-btn variant="text" prepend-icon="mdi-calendar-import" block class="justify-start" @click="handleImportStart">
|
<v-btn variant="text" prepend-icon="mdi-calendar-import" block class="justify-start" @click="handleImportStart">
|
||||||
Import iCalendar
|
Import iCalendar
|
||||||
|
|||||||
Reference in New Issue
Block a user