Skip to content

Commit

Permalink
fixes, calendar view on board, board redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
NyaomiDEV committed Aug 12, 2024
1 parent a9fc658 commit b28d682
Show file tree
Hide file tree
Showing 11 changed files with 290 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/lib/db/entities/journalPosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type JournalPost = UUIDable & {
body: string,
cover?: File,
attachments?: Attachment[],
tags?: UUID[] // array of UUIDs
tags: UUID[] // array of UUIDs
}

export type Attachment = UUIDable & {
Expand Down
13 changes: 13 additions & 0 deletions src/lib/db/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export function getFilteredMembers(search: Ref<string>, members: ShallowRef<Memb

_members.value = members.value.filter(x => {

if(parsed.all)
return true;

if (!x.name.toLowerCase().startsWith(parsed.query.toLowerCase()))
return false;

Expand Down Expand Up @@ -111,6 +114,11 @@ export function getFilteredFrontingEntries(search: Ref<string>, frontingEntries:
for (const x of frontingEntries.value) {
const complete = await toFrontingEntryComplete(x);

if (parsed.all){
filtered.push(complete);
continue;
}

if (!complete.member.name.toLowerCase().startsWith(parsed.query.toLowerCase()))
continue;

Expand Down Expand Up @@ -202,6 +210,11 @@ export function getFilteredBoardMessages(search: Ref<string>, boardMessages: Sha
for (const x of boardMessages.value) {
const complete = await toBoardMessageComplete(x);

if (parsed.all) {
filtered.push(complete);
continue;
}

if (
![
x.title.toLowerCase().split(" "),
Expand Down
25 changes: 25 additions & 0 deletions src/lib/globalEvents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
type GlobalEventMap = {
"members:search": SearchEvent,
"journal:search": SearchEvent
}

export interface SearchEvent extends CustomEvent {
detail: {
search: string
}
}

interface GlobalEvents extends EventTarget {
addEventListener<K extends keyof GlobalEventMap>(
type: K,
listener: (ev: GlobalEventMap[K]) => void,
options?: boolean | AddEventListenerOptions
): void;
addEventListener(
type: string,
callback: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean
): void;
}

export const globalEvents: GlobalEvents = new EventTarget();
60 changes: 60 additions & 0 deletions src/lib/util/filterQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { UUID } from "../db/types";
export type MemberFilterQuery = {
query: string,
tags: string[],
all?: boolean,
isArchived?: boolean,
isCustomFront?: boolean,
pronouns?: string,
Expand All @@ -26,6 +27,25 @@ export async function parseMemberFilterQuery(search: string): Promise<MemberFilt
case "@":
const tokenParts = token.slice(1).split(":");
switch(tokenParts[0].toLowerCase()){
case "all":
if (tokenParts[1]) {
switch (tokenParts[1].toLowerCase()) {
case "yes":
case "true":
result.all = true;
break;
case "no":
case "false":
result.all = false;
break;
default:
queryTokens.push(token);
break;
}
} else
result.all = true;

break;
case "archived":
if(tokenParts[1]){
switch (tokenParts[1].toLowerCase()) {
Expand Down Expand Up @@ -96,6 +116,7 @@ export async function parseMemberFilterQuery(search: string): Promise<MemberFilt

export type FrontingHistoryFilterQuery = {
query: string,
all?: boolean,
startDateString?: string,
endDateString?: string,
startDay?: number,
Expand All @@ -122,6 +143,25 @@ export function parseFrontingHistoryFilterQuery(search: string) {
case "@":
const tokenParts = token.slice(1).split(":");
switch (tokenParts[0].toLowerCase()) {
case "all":
if (tokenParts[1]) {
switch (tokenParts[1].toLowerCase()) {
case "yes":
case "true":
result.all = true;
break;
case "no":
case "false":
result.all = false;
break;
default:
queryTokens.push(token);
break;
}
} else
result.all = true;

break;
case "current":
result.currentlyFronting = true;
break;
Expand Down Expand Up @@ -169,6 +209,7 @@ export function parseFrontingHistoryFilterQuery(search: string) {

export type BoardMessageFilterQuery = {
query: string,
all?: boolean,
dateString?: string,
day?: number,
month?: number,
Expand All @@ -190,6 +231,25 @@ export function parseBoardMessageFilterQuery(search: string) {
case "@":
const tokenParts = token.slice(1).split(":");
switch (tokenParts[0].toLowerCase()) {
case "all":
if (tokenParts[1]) {
switch (tokenParts[1].toLowerCase()) {
case "yes":
case "true":
result.all = true;
break;
case "no":
case "false":
result.all = false;
break;
default:
queryTokens.push(token);
break;
}
} else
result.all = true;

break;
case "date":
result.dateString = tokenParts[1];
break;
Expand Down
56 changes: 53 additions & 3 deletions src/modals/TagEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,31 @@
modalController,
IonModal,
IonSegment,
IonTextarea
IonTextarea,
useIonRouter
} from "@ionic/vue";
import MD3SegmentButton from "../components/MD3SegmentButton.vue";
import Color from "../components/Color.vue";
import {
saveOutline as saveIOS,
trashBinOutline as trashIOS
trashBinOutline as trashIOS,
personOutline as personIOS,
bookOutline as journalIOS
} from "ionicons/icons";
import saveMD from "@material-design-icons/svg/outlined/save.svg";
import trashMD from "@material-design-icons/svg/outlined/delete.svg";
import personMD from "@material-design-icons/svg/outlined/person.svg";
import journalMD from "@material-design-icons/svg/outlined/book.svg";
import { Tag, getTagsTable, newTag, removeTag } from '../lib/db/entities/tags';
import { ref, shallowRef, toRaw } from "vue";
import { ref, shallowRef } from "vue";
import { addMaterialColors, unsetMaterialColors } from "../lib/theme";
import { PartialBy } from "../lib/db/types";
import { globalEvents, SearchEvent } from "../lib/globalEvents";
import { getMembersTable } from "../lib/db/entities/members";
import { getJournalPostsTable } from "../lib/db/entities/journalPosts";
const props = defineProps<{
tag: PartialBy<Tag, "uuid">
Expand All @@ -40,6 +48,25 @@
const self = ref();
const router = useIonRouter();
const count = ref(0);
async function goBackAndSearchInMembers(search: string){
router.navigate("/members", "back", "push");
await modalController.dismiss();
globalEvents.dispatchEvent(new CustomEvent("members:search", { detail: {search} }) as SearchEvent)
}
async function goBackAndSearchInJournal(search: string){
// not yet sorry
return;
router.navigate("/journal", "back", "push");
await modalController.dismiss();
globalEvents.dispatchEvent(new CustomEvent("journal:search", { detail: {search} }))
}
async function save(){
const uuid = tag.value.uuid;
const _tag = tag.value;
Expand Down Expand Up @@ -70,6 +97,13 @@
function present() {
tag.value = props.tag;
if(tag.value.uuid){
if(tag.value.type === "member")
getMembersTable().filter(x => x.tags.includes(tag.value.uuid!)).count().then(c => count.value = c);
else //journal
getJournalPostsTable().filter(x => x.tags.includes(tag.value.uuid!)).count().then(c => count.value = c);
}
if(tag.value.color && tag.value.color !== "#000000"){
addMaterialColors(tag.value.color, self.value.$el);
} else {
Expand Down Expand Up @@ -123,6 +157,22 @@
</IonLabel>
</IonItem>

<IonItem button v-if="tag.uuid && tag.type === 'member'" @click="goBackAndSearchInMembers(`#${tag.name.toLowerCase().replace(/\s/g, '')}`)">
<IonIcon :ios="personIOS" :md="personMD" slot="start" aria-hidden="true" />
<IonLabel>
<h3>{{ $t("options:tagManagement.edit.actions.showMembers.title") }}</h3>
<p>{{ $t("options:tagManagement.edit.actions.showMembers.desc", { count }) }}</p>
</IonLabel>
</IonItem>

<IonItem button v-if="tag.uuid && tag.type === 'journal'" @click="goBackAndSearchInJournal(`#${tag.name.toLowerCase().replace(/\s/g, '')}`)">
<IonIcon :ios="journalIOS" :md="journalMD" slot="start" aria-hidden="true" />
<IonLabel>
<h3>{{ $t("options:tagManagement.edit.actions.showJournal.title") }}</h3>
<p>{{ $t("options:tagManagement.edit.actions.showJournal.desc", { count }) }}</p>
</IonLabel>
</IonItem>

<IonItem button v-if="tag.uuid" @click="deleteTag">
<IonIcon :ios="trashIOS" :md="trashMD" slot="start" aria-hidden="true" />
<IonLabel>
Expand Down
1 change: 0 additions & 1 deletion src/router/tabbedRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const tabbedRoutes: Array<RouteRecordRaw> = [
path: '/members',
name: 'Members',
component: () => import("../views/tabbed/Members.vue"),
props: route => ({ q: route.query.q })
},
{
path: '/journal',
Expand Down
2 changes: 1 addition & 1 deletion src/views/TabbedHomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import JournalMD from '@material-design-icons/svg/outlined/book.svg';
import HomeMD from '@material-design-icons/svg/outlined/home.svg';
import ChatMD from '@material-design-icons/svg/outlined/chat.svg';
import OptionsMD from '@material-design-icons/svg/outlined/menu.svg'
import OptionsMD from '@material-design-icons/svg/outlined/menu.svg';
</script>

<template>
Expand Down
13 changes: 12 additions & 1 deletion src/views/options/FrontHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@
});
}
function highlightInCalendar(_date: string){
const date = dayjs(_date).startOf("day");
if(filteredFrontingEntries.value?.filter(x => dayjs(x.startTime).startOf('day').valueOf() === date.valueOf()).length > 0){
return {
backgroundColor: "var(--ion-background-color-step-200)"
};
}
return undefined;
}
function getAtDate(_date: string){
const today = dayjs().startOf("day");
const date = dayjs(_date).startOf("day");
Expand Down Expand Up @@ -148,7 +159,7 @@
showCancelButton="focus" showClearButton="focus" :spellcheck="false" v-model="search" />
</IonToolbar>
<div class="container" v-if="isCalendarView">
<IonDatetime presentation="date" :firstDayOfWeek="firstWeekOfDayIsSunday ? 0 : 1" v-model="date" />
<IonDatetime presentation="date" :firstDayOfWeek="firstWeekOfDayIsSunday ? 0 : 1" :highlightedDates="highlightInCalendar" v-model="date" />
</div>
</IonHeader>

Expand Down
Loading

0 comments on commit b28d682

Please sign in to comment.