Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: shift system #94

Closed
wants to merge 89 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
7f5cd13
feat: added the shifts extension.
Theophile-Madet Dec 19, 2023
becd445
Added Qodana
Theophile-Madet Dec 19, 2023
a736f05
Revert "Added Qodana"
Theophile-Madet Dec 19, 2023
c9d6606
feat: shifts schema WIP
Theophile-Madet Jan 4, 2024
54fc6ba
Added the option to specify the field type when creation O2M relations.
Theophile-Madet Jan 5, 2024
4950243
Added example shift data and a link in the menu.
Theophile-Madet Jan 8, 2024
c3a29df
Added a simple shift overview page for a user.
Theophile-Madet Jan 8, 2024
2353da4
Added assignments to shift examples.
Theophile-Madet Jan 9, 2024
aa74a57
Updated the shift schema to represent shift templates and occurences.
Theophile-Madet Jan 9, 2024
ab49528
fix: run postinstall on shifts extension
jofmi Jan 10, 2024
ff98262
WIP shifts
Theophile-Madet Jan 11, 2024
4264fe8
First draft of calculating shift occurences.
Theophile-Madet Jan 11, 2024
b3d6e5c
Draft for shift cards.
Theophile-Madet Jan 12, 2024
00d3e2f
WIP Shift user type
Theophile-Madet Jan 15, 2024
ec7ec3b
WIP displaying assigments.
Theophile-Madet Jan 15, 2024
cb68350
Improved assignment display.
Theophile-Madet Jan 15, 2024
aaa061d
WIP user <-> skills
Theophile-Madet Jan 15, 2024
870468f
Display skills on the shifts page.
Theophile-Madet Jan 16, 2024
fd01131
Fixed shift calendar.
Theophile-Madet Jan 16, 2024
6033744
Typing improvements.
Theophile-Madet Jan 16, 2024
5c4b18c
Added shift logs and score calculation.
Theophile-Madet Jan 18, 2024
9e0f8af
Show last logs on the my shifts page.
Theophile-Madet Jan 18, 2024
01a7581
WIP calendar view with FullCalendar.
Theophile-Madet Jan 18, 2024
dd8a867
Improved calendar display.
Theophile-Madet Jan 19, 2024
ea58023
First draft for a shift detail page.
Theophile-Madet Jan 22, 2024
473052d
Moved the assignment list to a separate component.
Theophile-Madet Jan 22, 2024
84cf3b6
Removed the license file.
Theophile-Madet Jan 23, 2024
f8c6f3e
Avoid "await" calls in setup scripts, instead let the calls load in t…
Theophile-Madet Jan 23, 2024
44eddd6
Moved all components to a shifts/ subfolder.
Theophile-Madet Jan 23, 2024
854883a
In the shift calendar, use navigateTo instead of a raw URL in order t…
Theophile-Madet Jan 23, 2024
ac38036
Renamed types from Collectivo* to Shifts* and added them to Collectiv…
Theophile-Madet Mar 22, 2024
70bbfb4
Cleaned up shift examples.
Theophile-Madet Mar 22, 2024
742c1c4
WIP show required skills on shift page.
Theophile-Madet Mar 25, 2024
6ea5068
WIP show required skills on shift page.
Theophile-Madet Mar 26, 2024
54002b5
Show slot names and required skills on shift page.
Theophile-Madet Apr 9, 2024
24ceff5
Added assignee name to slots in shifts detail page.
Theophile-Madet Apr 9, 2024
5e6bb47
Fixed missing icons after rebase from main repo.
Theophile-Madet Apr 10, 2024
cce62cc
Fixed assignments on my_shifts page.
Theophile-Madet Apr 10, 2024
67d4048
Show assignments on occurrence cards.
Theophile-Madet Apr 10, 2024
2f3982f
Improved logs display on my_shifts page.
Theophile-Madet Apr 10, 2024
b347fbe
Added status fields for shifts, slots and assignments. Updated fronte…
Theophile-Madet Apr 17, 2024
e6b1d71
WIP directus flow shift cycle start.
Theophile-Madet Apr 17, 2024
d2e6c4a
Added automatic removal of points when a shift cycle starts.
Theophile-Madet Apr 18, 2024
424f776
First draft for assignment page.
Theophile-Madet Apr 19, 2024
f03a104
Added assignment editing.
Theophile-Madet Apr 19, 2024
0c51967
Formatting fix.
Theophile-Madet Apr 19, 2024
630186d
Moved assignment edit to a modal.
Theophile-Madet Apr 20, 2024
d8fa2e3
Fixed typing errors on the shift page.
Theophile-Madet Apr 20, 2024
c1b7136
WIP assignment creation.
Theophile-Madet Apr 20, 2024
ab09b88
Improvements to assignment creation.
Theophile-Madet Apr 22, 2024
b6a30b1
Added memberships as dependency (temporarilly, to be removed later)
Theophile-Madet Apr 22, 2024
5dbecc3
Added system-uicons library for the shifts calendar.
Theophile-Madet Apr 22, 2024
87ae849
Fixed assignments showing as current when the next occurrence is not …
Theophile-Madet Apr 22, 2024
57443a2
Show tooltip on slot card when it's not possible to assign yourself.
Theophile-Madet Apr 22, 2024
b17686f
Update shift page after an assignment has been created.
Theophile-Madet Apr 22, 2024
f92ebcf
WIP assignment edition improvement :
Theophile-Madet Apr 24, 2024
ba1a653
Updated AssignmentCreateModal.vue : check if at least one occurrence …
Theophile-Madet Apr 26, 2024
4feabe1
Merged AssignmentEditModal.vue and AssignmentCreateModal.vue.
Theophile-Madet Apr 26, 2024
a0e4ee4
Split the shifts.ts into shifts and assignments.
Theophile-Madet Apr 29, 2024
218a542
WIP
Theophile-Madet Apr 29, 2024
08e9489
Finished assignment creation & update fixes.
Theophile-Madet Apr 30, 2024
98fe857
Merge branch 'shifts' of https://github.com/Theophile-Madet/collectiv…
jofmi May 10, 2024
f71d2c1
Merge branch 'main' into shifts
jofmi May 22, 2024
c238c9e
feat: improve ux
jofmi May 23, 2024
84097b0
Merge branch 'main' into shifts
jofmi May 28, 2024
e1a41f3
feat: improve shift ux
jofmi May 28, 2024
75688b0
feat: add shift description
jofmi May 29, 2024
cee386a
feat: finalize shift card
jofmi May 29, 2024
7648dd4
feat: add absences
jofmi May 29, 2024
f9e7016
fix: translation config
jofmi May 29, 2024
74def25
fix: absence logic
jofmi May 29, 2024
97afd1f
feat: cycle logic based on last log
jofmi May 29, 2024
bf356ba
feat: cycle break logic
jofmi May 29, 2024
08b2c5e
feat: improve activity feed
jofmi May 29, 2024
e554761
feat: use DB SUM for score
jofmi May 29, 2024
9c0523f
feat: direct signup form
jofmi May 29, 2024
56a1f0e
feat: add simple signup form
jofmi May 29, 2024
5be4755
feat: load slots
jofmi May 30, 2024
0c5c6c4
feat: improve signup form
jofmi May 30, 2024
0077c2b
feat: fix date generation
jofmi May 31, 2024
49cdf4f
fix: include starting date
jofmi May 31, 2024
8abc6ef
fix: reload assignment modal
jofmi May 31, 2024
adc1806
fix: date and rrule mistakes
jofmi May 31, 2024
313a285
feat: include absences
jofmi May 31, 2024
15a0bd9
clean: testing code
jofmi May 31, 2024
8557040
Merge remote-tracking branch 'theo/shifts' into shifts
jofmi May 31, 2024
2825e03
fix: types
jofmi Jun 3, 2024
c02b2f6
fix: shifts example data
jofmi Jun 5, 2024
3963a51
lint
jofmi Jun 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
3 changes: 2 additions & 1 deletion collectivo/app/i18n.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default defineI18nConfig(() => ({
missingWarn: false,
silentTranslationWarn: true,
translationWarn: false,
fallbackWarn: false,
}));
1 change: 1 addition & 0 deletions collectivo/app/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default defineNuxtConfig({
"@collectivo/collectivo",
"@collectivo/payments",
"@collectivo/memberships",
"@collectivo/shifts",
],
i18n: {
lazy: true,
Expand Down
3 changes: 2 additions & 1 deletion collectivo/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"dependencies": {
"@collectivo/collectivo": "workspace:*",
"@collectivo/memberships": "workspace:*",
"@collectivo/payments": "workspace:*"
"@collectivo/payments": "workspace:*",
"@collectivo/shifts": "workspace:*"
},
"devDependencies": {
"@nuxt/devtools": "^1.3.1",
Expand Down
70 changes: 35 additions & 35 deletions collectivo/collectivo/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,41 +115,41 @@ export default defineAppConfig({
},
},
},
modal: {
wrapper: "relative z-50",
inner: "fixed inset-0 overflow-y-auto",
container:
"flex min-h-full items-end sm:items-center justify-center text-center",
padding: "p-4 sm:p-0",
margin: "sm:my-8",
base: "relative text-left rtl:text-right overflow-hidden w-full flex flex-col",
overlay: {
base: "fixed inset-0 transition-opacity",
background: "bg-primary/20 dark:bg-gray-800/75",
transition: {
enter: "ease-out duration-300",
enterFrom: "opacity-0",
enterTo: "opacity-100",
leave: "ease-in duration-200",
leaveFrom: "opacity-100",
leaveTo: "opacity-0",
},
},
background: "bg-white dark:bg-gray-900",
ring: "",
rounded: "border border-purple-500 rounded-xl",
shadow: "",
width: "sm:max-w-[520px]",
height: "",
transition: {
enter: "ease-out duration-300",
enterFrom: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
enterTo: "opacity-100 translate-y-0 sm:scale-100",
leave: "ease-in duration-200",
leaveFrom: "opacity-100 translate-y-0 sm:scale-100",
leaveTo: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
},
},
// modal: {
// wrapper: "relative z-50",
// inner: "fixed inset-0 overflow-y-auto",
// container:
// "flex min-h-full items-end sm:items-center justify-center text-center",
// padding: "p-4 sm:p-0",
// margin: "sm:my-8",
// base: "relative text-left rtl:text-right overflow-hidden w-full flex flex-col",
// overlay: {
// base: "fixed inset-0 transition-opacity",
// background: "bg-primary/20 dark:bg-gray-800/75",
// transition: {
// enter: "ease-out duration-300",
// enterFrom: "opacity-0",
// enterTo: "opacity-100",
// leave: "ease-in duration-200",
// leaveFrom: "opacity-100",
// leaveTo: "opacity-0",
// },
// },
// background: "bg-white dark:bg-gray-900",
// ring: "",
// rounded: "border border-purple-500 rounded-xl",
// shadow: "",
// width: "sm:max-w-[520px]",
// height: "",
// transition: {
// enter: "ease-out duration-300",
// enterFrom: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
// enterTo: "opacity-100 translate-y-0 sm:scale-100",
// leave: "ease-in duration-200",
// leaveFrom: "opacity-100 translate-y-0 sm:scale-100",
// leaveTo: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
// },
// },
Comment on lines +118 to +152
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robert Martin from "Clean Code" is very, errr, assertive about removing code instead of commenting it out 😛

It makes me crazy to see stretches of code that are commented out. Who knows how old it is? Who knows whether or not it’s meaningful? Yet no one will delete it because everyone assumes someone else needs it or has plans for it.

That code sits there and rots, getting less and less relevant with every passing day. It calls functions that no longer exist. It uses variables whose names have changed. It follows conventions that are long obsolete. It pollutes the modules that contain it and distracts the people who try to read it. Commented-out code is an abomination.

When you see commented-out code, delete it! Don’t worry; the source code control system still remembers it. If anyone really needs it, he or she can go back and check out a previous version. Don’t suffer commented-out code to survive.

https://www.informit.com/articles/article.aspx?p=1334908

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same opinion :)

pagination: {
wrapper: "flex items-center gap-1 lg:gap-2",
base: "h-8 w-8 lg:h-12 lg:w-12",
Expand Down
14 changes: 12 additions & 2 deletions collectivo/collectivo/composables/page.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
export const useCollectivoTitle = () =>
useState<string>("collectivoTitle", () => "");

export const setCollectivoTitle = (title: string) => {
useCollectivoTitle().value = title;
export const useCollectivoBackLink = () =>
useState<string | undefined>("collectivoBackLink", () => "");

interface CollectivoTitleOptions {
backLink?: string;
}

export const setCollectivoTitle = (
title: string,
options?: CollectivoTitleOptions,
) => {
useCollectivoTitle().value = title;
useCollectivoBackLink().value = options?.backLink;
useHead({
title: title + " - " + useAppConfig().collectivo.projectName,
});
Expand Down
48 changes: 48 additions & 0 deletions collectivo/collectivo/composables/toasts.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice generalisation :)

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
type types = "error" | "success" | "warn" | "info";
type colors = "red" | "green" | "yellow" | "blue";

const defaultTitles = {
error: "Error",
success: "Success",
warn: "Warning",
info: "Info",
};

const defaultDescriptions = {
error: "An error occurred",
success: "Operation successful",
warn: "",
info: "",
};

const defaultColors: { [index: string]: colors } = {
error: "red",
success: "green",
warn: "yellow",
info: "blue",
};

const defaultIcons = {
error: "i-heroicons-exclamation-triangle",
success: "i-heroicons-check",
warn: "i-heroicons-exclamation-triangle",
info: "i-heroicons-information-circle",
};

export function showCollectivoToast(options: {
type?: types;
title?: string;
description?: any;
icon?: string;
color?: colors;
}) {
const toast = useToast();
const type = options.type ?? "info";

toast.add({
title: options.title ?? defaultTitles[type],
description: options.description ?? defaultDescriptions[type],
icon: options.icon ?? defaultIcons[type],
color: options.color ?? defaultColors[type],
});
}
8 changes: 7 additions & 1 deletion collectivo/collectivo/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import Sidebar from "./components/Sidebar.vue";
import MobileHeader from "./components/MobileHeader.vue";
import MobileMenu from "./components/MobileMenu.vue";
import ProfileMenu from "./components/ProfileMenu.vue";
import { useCollectivoBackLink } from "~/composables/page";

const { t } = useI18n();
const config = useAppConfig();
const pageTitle = useCollectivoTitle();
const backLink = useCollectivoBackLink();
const sidebarWidthMd = String(config.collectivo.sidebarWidth + 65) + "px";
const sidebarWidthLg = String(config.collectivo.sidebarWidth + 90) + "px";
</script>
Expand Down Expand Up @@ -67,7 +69,11 @@ const sidebarWidthLg = String(config.collectivo.sidebarWidth + 90) + "px";
<div class="main">
<div class="main__top">
<div class="main__top__left">
<h1>
<h1 class="flex flex-wrap align-middle items-center gap-3">
<NuxtLink v-if="backLink" :to="backLink" class="flex items-center">
<UIcon name="i-heroicons-arrow-left-circle-16-solid" />
</NuxtLink>

{{ t(pageTitle) }}
</h1>
</div>
Expand Down
2 changes: 2 additions & 0 deletions collectivo/collectivo/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export default defineNuxtConfig({
public: {
debug: false,
collectivoUrl: process.env.COLLECTIVO_URL || "http://localhost:3000",
collectivoContactEmail:
process.env.COLLECTIVO_CONTACT_EMAIL || "[email protected]",
authService: process.env.COLLECTIVO_AUTH_SERVICE || "keycloak",
keycloakUrl: process.env.KEYCLOAK_URL || "http://keycloak:8080",
keycloakRealm: process.env.KEYCLOAK_REALM || "collectivo",
Expand Down
20 changes: 13 additions & 7 deletions collectivo/collectivo/server/utils/directusFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import type { DirectusField, NestedPartial } from "@directus/sdk";

type PartialField = NestedPartial<DirectusField<any>>;

export enum ItemStatus {
ARCHIVED = "archived",
DRAFT = "draft",
PUBLISHED = "published",
}

export function directusStatusField(
collection: string,
fieldName: string,
Expand All @@ -16,9 +22,9 @@ export function directusStatusField(
width: "full",
options: {
choices: [
{ text: "$t:published", value: "published" },
{ text: "$t:draft", value: "draft" },
{ text: "$t:archived", value: "archived" },
{ text: "$t:published", value: ItemStatus.PUBLISHED },
{ text: "$t:draft", value: ItemStatus.DRAFT },
{ text: "$t:archived", value: ItemStatus.ARCHIVED },
],
},
translations: [
Expand All @@ -33,27 +39,27 @@ export function directusStatusField(
choices: [
{
text: "$t:published",
value: "published",
value: ItemStatus.PUBLISHED,
foreground: "#FFFFFF",
background: "var(--primary)",
},
{
text: "$t:draft",
value: "draft",
value: ItemStatus.DRAFT,
foreground: "#18222F",
background: "#D3DAE4",
},
{
text: "$t:archived",
value: "archived",
value: ItemStatus.ARCHIVED,
foreground: "#FFFFFF",
background: "var(--warning)",
},
],
},
...field?.meta,
},
schema: { default_value: "draft", is_nullable: false },
schema: { default_value: ItemStatus.DRAFT, is_nullable: false },
};
}

Expand Down
7 changes: 6 additions & 1 deletion collectivo/extensions/memberships/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare global {
memberships: MembershipsMembership[] | number[];
}

interface MembershipsMembership {
export interface MembershipsMembership {
id: number;
name: string;
memberships_user: DirectusUser | number;
Expand All @@ -19,4 +19,9 @@ declare global {
}
}

// Types for input of app.config.ts
declare module "nuxt/schema" {
interface AppConfigInput {}
}

export {};
13 changes: 7 additions & 6 deletions collectivo/extensions/memberships/server/examples/examples.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createItem, deleteItems, readUsers } from "@directus/sdk";
import { MembershipStatus } from "@collectivo/memberships/server/schemas/memberships_01";

export default async function examples() {
console.info("Creating example data for memberships");
Expand All @@ -12,11 +13,11 @@ export default async function examples() {
console.info("Creating memberships");

const users = [
["Alice", "applied"],
["Bob", "approved"],
["Charlie", "approved"],
["Dave", "in-cancellation"],
["User", "approved"],
["Alice", MembershipStatus.APPLIED, null],
["Bob", MembershipStatus.APPROVED, new Date(2023, 1, 5)],
["Charlie", MembershipStatus.APPROVED, new Date(2023, 6, 12)],
["Dave", MembershipStatus.IN_CANCELLATION, new Date(2024, 1, 2)],
["User", MembershipStatus.APPROVED, new Date(2024, 3, 6)],
];

for (const user of users) {
Expand All @@ -26,12 +27,12 @@ export default async function examples() {
)[0];

// Create membership

await directus.request(
createItem("memberships", {
memberships_user: user_id,
memberships_type: "normal",
memberships_status: user[1],
memberships_date_approved: user[2],
}),
);
}
Expand Down
Loading
Loading