-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e2b8f3
commit 15a89ce
Showing
27 changed files
with
357 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<template> | ||
<div class="flex w-full flex-grow"> | ||
<MainSidebar /> | ||
<MainContent class="flex-1" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<template> | ||
<div> | ||
<MainContentHeader /> | ||
<MainContentBody /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<div class="px-4 py-6"> | ||
<TasksList :tasks="$tasksList.tasks" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<div class="bg-gray-300 px-4 py-6"> | ||
<h1>{{ $tasksList.name }}</h1> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<template> | ||
<div class="flex flex-col border-r border-gray-400 bg-gray-200"> | ||
<MainSidebarHeader /> | ||
<MainSidebarNav /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<div class="bg-gray-300 px-4 py-6"> | ||
{{ $workspace.name }} | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<template> | ||
<nav class="px-4 py-6"> | ||
<ul> | ||
<li v-for="list of $workspace.lists" :key="list.id"> | ||
{{ list.name }} | ||
<span v-if="$tasksList.id === list.id">(active)</span> | ||
</li> | ||
</ul> | ||
</nav> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<template> | ||
<ul v-if="tasks.length"> | ||
<TasksListItem v-for="task of tasks" :key="task.id" :task="task" /> | ||
</ul> | ||
|
||
<AGMarkdown v-else lang-key="tasks.empty" /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { requiredArrayProp } from '@aerogel/core'; | ||
import type Task from '@/models/Task'; | ||
defineProps({ tasks: requiredArrayProp<Task>() }); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<template> | ||
<li> | ||
{{ task.name }} | ||
</li> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { requiredObjectProp } from '@aerogel/core'; | ||
import type Task from '@/models/Task'; | ||
defineProps({ task: requiredObjectProp<Task>() }); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { FieldType, defineModelSchema } from 'soukai'; | ||
|
||
export default defineModelSchema({ | ||
fields: { | ||
name: { | ||
type: FieldType.String, | ||
required: true, | ||
}, | ||
taskIds: { | ||
type: FieldType.Array, | ||
items: FieldType.Key, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { BelongsToManyRelation, Relation } from 'soukai'; | ||
|
||
import Task from '@/models/Task'; | ||
|
||
import Model from './TasksList.schema'; | ||
|
||
export default class TasksList extends Model { | ||
|
||
public declare tasks?: Task[]; | ||
public declare relatedTasks: BelongsToManyRelation<this, Task, typeof Task>; | ||
|
||
public tasksRelationship(): Relation { | ||
return this.belongsToMany(Task); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import type { BelongsToManyRelation, Relation } from 'soukai'; | ||
|
||
import Task from '@/models/Task'; | ||
import TasksList from '@/models/TasksList'; | ||
|
||
import Model from './Workspace.schema'; | ||
|
||
export default class Workspace extends Model { | ||
|
||
public declare tasks?: Task[]; | ||
public declare relatedTasks: BelongsToManyRelation<this, Task, typeof Task>; | ||
public declare lists?: TasksList[]; | ||
public declare relatedLists: BelongsToManyRelation<this, TasksList, typeof TasksList>; | ||
|
||
public tasksRelationship(): Relation { | ||
return this.belongsToMany(Task); | ||
public listsRelationship(): Relation { | ||
return this.belongsToMany(TasksList, 'listIds'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { defineServiceState } from '@aerogel/core'; | ||
import type { Key } from 'soukai'; | ||
|
||
import Workspaces from '@/services/Workspaces'; | ||
|
||
export default defineServiceState({ | ||
name: 'tasks-lists', | ||
persist: ['currentTasksListId'], | ||
initialState: { | ||
currentTasksListId: null as Key | null, | ||
}, | ||
computed: { | ||
current({ currentTasksListId }) { | ||
const lists = Workspaces.current?.lists ?? []; | ||
|
||
return lists.find((list) => list.id === currentTasksListId) ?? null; | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { facade } from '@noeldemartin/utils'; | ||
import { watchEffect } from 'vue'; | ||
|
||
import Workspaces from '@/services/Workspaces'; | ||
import type TasksList from '@/models/TasksList'; | ||
|
||
import Service from './TasksLists.state'; | ||
|
||
export class TasksListsService extends Service { | ||
|
||
public async open(list: TasksList): Promise<void> { | ||
await list.loadRelationIfUnloaded('tasks'); | ||
|
||
this.currentTasksListId = list.id; | ||
} | ||
|
||
protected async boot(): Promise<void> { | ||
await Workspaces.booted; | ||
|
||
this.current && (await this.open(this.current)); | ||
|
||
watchEffect(async () => { | ||
const lists = Workspaces.current?.lists ?? []; | ||
const current = lists.find((list) => list.id === this.currentTasksListId) ?? lists[0] ?? null; | ||
|
||
if (!current) { | ||
this.currentTasksListId = null; | ||
|
||
return; | ||
} | ||
|
||
await this.open(current); | ||
}); | ||
} | ||
|
||
} | ||
|
||
export default facade(new TasksListsService()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
import { lazyRequireProxy } from '@/utils'; | ||
|
||
import Workspaces from './Workspaces'; | ||
import TasksLists from './TasksLists'; | ||
|
||
export const globals = { | ||
$workspace: lazyRequireProxy(() => Workspaces.current, 'Current workspace is missing, can\'t use $workspace'), | ||
$tasksList: lazyRequireProxy(() => TasksLists.current, 'Current tasks list is missing, can\'t use $tasksList'), | ||
}; | ||
|
||
export const services = { | ||
$workspaces: Workspaces, | ||
$tasksLists: TasksLists, | ||
}; | ||
|
||
export type AppGlobals = typeof globals; | ||
export type AppServices = typeof services; | ||
|
||
declare module '@vue/runtime-core' { | ||
interface ComponentCustomProperties extends AppServices {} | ||
interface ComponentCustomProperties extends AppGlobals, AppServices {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { fail } from '@noeldemartin/utils'; | ||
import type { ValueWithoutEmpty } from '@noeldemartin/utils'; | ||
|
||
export function lazyRequireProxy<T extends object | null | undefined>( | ||
get: () => T, | ||
message: string = 'Lazy required value is missing', | ||
): ValueWithoutEmpty<T> { | ||
return new Proxy( | ||
{}, | ||
{ | ||
get(_, property, receiver) { | ||
const model = get() ?? fail<ValueWithoutEmpty<T>>(message); | ||
|
||
return Reflect.get(model, property, receiver); | ||
}, | ||
set(_, property, value, receiver) { | ||
const model = get() ?? fail<ValueWithoutEmpty<T>>(message); | ||
|
||
return Reflect.set(model, property, value, receiver); | ||
}, | ||
}, | ||
) as ValueWithoutEmpty<T>; | ||
} |