feat: visible date range
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, ref, shallowRef } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import { CollectionObject } from '@ChronoManager/models/collection'
|
||||
import { EntityObject } from '@ChronoManager/models/entity'
|
||||
@@ -9,6 +9,7 @@ import { useCollectionsStore } from '@ChronoManager/stores/collectionsStore'
|
||||
import { useEntitiesStore } from '@ChronoManager/stores/entitiesStore'
|
||||
import { useServicesStore } from '@ChronoManager/stores/servicesStore'
|
||||
import { useImportStore } from '@ChronoManager/stores/importStore'
|
||||
import type { VisibleDateRange } from '@/types'
|
||||
|
||||
type ChronoEntityProperties = EventObject | TaskObject
|
||||
|
||||
@@ -19,6 +20,7 @@ export const useChronoOperationsStore = defineStore('chronoOperationsStore', ()
|
||||
const importStore = useImportStore()
|
||||
|
||||
const loading = ref(false)
|
||||
const visibleRange = shallowRef<VisibleDateRange | null>(null)
|
||||
|
||||
const collections = computed(() => collectionsStore.collections)
|
||||
const entities = computed(() => entitiesStore.entities)
|
||||
@@ -43,6 +45,17 @@ export const useChronoOperationsStore = defineStore('chronoOperationsStore', ()
|
||||
})
|
||||
const filteredTasks = computed(() => tasks.value)
|
||||
|
||||
function setVisibleRange(range: VisibleDateRange) {
|
||||
if (
|
||||
visibleRange.value?.startMs === range.startMs
|
||||
&& visibleRange.value.endMs === range.endMs
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
visibleRange.value = { ...range }
|
||||
}
|
||||
|
||||
function prepareEntityProperties(entity: EntityObject): ChronoEntityProperties {
|
||||
const properties = entity.properties as ChronoEntityProperties
|
||||
const now = new Date().toISOString()
|
||||
@@ -154,6 +167,7 @@ export const useChronoOperationsStore = defineStore('chronoOperationsStore', ()
|
||||
|
||||
return {
|
||||
loading,
|
||||
visibleRange,
|
||||
collections,
|
||||
entities,
|
||||
calendars,
|
||||
@@ -162,6 +176,7 @@ export const useChronoOperationsStore = defineStore('chronoOperationsStore', ()
|
||||
tasks,
|
||||
filteredEvents,
|
||||
filteredTasks,
|
||||
setVisibleRange,
|
||||
saveEntity,
|
||||
deleteEntity,
|
||||
toggleCalendarVisibility,
|
||||
|
||||
Reference in New Issue
Block a user