Skip to content

Commit b466b60

Browse files
committed
refactor: Reduce model file splitting
1 parent 81857a2 commit b466b60

16 files changed

Lines changed: 135 additions & 187 deletions

src/components/outfitRecommendationDialog.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Created Date: 2026-03-01 15:17:09
66
* Author: 3urobeat
77
*
8-
* Last Modified: 2026-03-26 18:24:37
8+
* Last Modified: 2026-03-27 19:03:05
99
* Modified By: 3urobeat
1010
*
1111
* Copyright (c) 2026 3urobeat <https://github.com/3urobeat>
@@ -77,8 +77,8 @@
7777
import { PhLightbulb } from '@phosphor-icons/vue';
7878
import type { Label } from '~/model/label';
7979
import type { Category } from '~/model/label-category';
80-
import { CategorySpecialityID, type CategorySpecialityLabelValueMap } from '~/model/label-category-speciality';
81-
import type { Outfit } from '~/model/outfit';
80+
import { CategorySpecialityID, type CategorySpecialityLabelValueMap } from '~/model/label-category';
81+
import type { Outfit } from '~/model/item';
8282
import { getWeatherFromServer } from '~/utils/utils';
8383
8484
const i18n = useI18n();

src/model/clothing.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/model/item.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Created Date: 2025-09-08 15:45:56
55
* Author: 3urobeat
66
*
7-
* Last Modified: 2026-02-02 21:32:26
7+
* Last Modified: 2026-03-27 18:59:27
88
* Modified By: 3urobeat
99
*
1010
* Copyright (c) 2025 - 2026 3urobeat <https://github.com/3urobeat>
@@ -15,6 +15,9 @@
1515
*/
1616

1717

18+
import type { Implements } from "./Implements"
19+
20+
1821
// Base type for Clothing & Outfit, used by generic components & composables.
1922
export type Item = {
2023
id: string,
@@ -23,3 +26,27 @@ export type Item = {
2326
addedTimestamp: number, // Used for sorting
2427
modifiedTimestamp: number
2528
}
29+
30+
31+
// Implements Item
32+
export type Clothing = Implements<Item, {
33+
id: string,
34+
title: string,
35+
description: string,
36+
imgPath: string,
37+
labelIDs: string[], // IMPORTANT: May reference non-existent labels if dataCleanUp job did not run yet!
38+
addedTimestamp: number,
39+
modifiedTimestamp: number
40+
}>
41+
42+
43+
// Implements Item
44+
export type Outfit = Implements<Item, {
45+
id: string,
46+
title: string,
47+
clothes: { order: number, clothingID: string }[], // IMPORTANT: May reference non-existent clothes if dataCleanUp job did not run yet!
48+
labelIDs: string[], // IMPORTANT: May reference non-existent labels if dataCleanUp job did not run yet!
49+
previewImgPath: string,
50+
addedTimestamp: number,
51+
modifiedTimestamp: number
52+
}>

src/model/label-category-speciality.ts

Lines changed: 0 additions & 95 deletions
This file was deleted.

src/model/label-category.ts

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Created Date: 2025-12-31 17:00:33
55
* Author: 3urobeat
66
*
7-
* Last Modified: 2026-02-02 21:32:26
7+
* Last Modified: 2026-03-27 19:01:56
88
* Modified By: 3urobeat
99
*
1010
* Copyright (c) 2025 - 2026 3urobeat <https://github.com/3urobeat>
@@ -16,7 +16,7 @@
1616

1717

1818
import type { Label } from "./label";
19-
import type { CategorySpecialityID } from "./label-category-speciality";
19+
import type { TemperatureKelvin } from "./unit";
2020

2121

2222
export type Category = {
@@ -35,3 +35,81 @@ export type Category = {
3535
export function getLabelsOfCategory(list: Label[], categoryID: string) {
3636
return list.filter((e) => e.categoryID == categoryID);
3737
}
38+
39+
40+
41+
// UUID for each category speciality
42+
export enum CategorySpecialityID {
43+
"No_Speciality" = "",
44+
"Body_Part" = "7d243965-be43-4ab6-b6ac-721e942f38d3", // No extra function on label
45+
"Color" = "ee83f116-fa27-40f7-bdb8-13a2084c1a6f", // Label should allow picking hex color
46+
"Season" = "9217222d-d61a-49fc-b989-46ec84af48a7" // Label should allow choosing temperature range
47+
}
48+
49+
// I dislike that this is a separately defined enum but I needed to iterate over it in labels page
50+
export enum CategorySpecialityBodyPartValue {
51+
Head = "Head",
52+
Arms = "Arms",
53+
Hands = "Hands",
54+
Torso = "Torso",
55+
Legs = "Legs",
56+
Feet = "Feet"
57+
}
58+
59+
60+
// Maps what a CategorySpeciality expects the label to save. If undefined, label should not display input field. - Thank you @DerDeathraven for TS magic!
61+
export type CategorySpecialityLabelValueMap<T extends CategorySpecialityID> = {
62+
[CategorySpecialityID.No_Speciality]: null;
63+
[CategorySpecialityID.Body_Part]: CategorySpecialityBodyPartValue;
64+
[CategorySpecialityID.Color]: `#${string}`;
65+
[CategorySpecialityID.Season]: { fromTemp: TemperatureKelvin | null, toTemp: TemperatureKelvin | null, fromTimestamp: number | null, toTimestamp: number | null }; // Null
66+
}[T]
67+
68+
69+
export type CategorySpeciality = {
70+
id: CategorySpecialityID,
71+
name: string,
72+
description: string, // Displayed on label
73+
value: CategorySpecialityLabelValueMap<CategorySpecialityID> // If undefined, label should not display any selector
74+
}
75+
76+
77+
// Default initialisations
78+
export const CategorySpecialityNoSpeciality: CategorySpeciality = {
79+
id: CategorySpecialityID.No_Speciality,
80+
name: "categorySpecialityNoneName",
81+
description: "",
82+
value: null
83+
} as const;
84+
85+
export const CategorySpecialityBodyPart: CategorySpeciality = {
86+
id: CategorySpecialityID.Body_Part,
87+
name: "categorySpecialityBodyPartName",
88+
description: "categorySpecialityBodyPartDescription",
89+
value: CategorySpecialityBodyPartValue.Head
90+
} as const;
91+
92+
export const CategorySpecialityColor: CategorySpeciality = {
93+
id: CategorySpecialityID.Color,
94+
name: "categorySpecialityColorName",
95+
description: "categorySpecialityColorDescription",
96+
value: "#000000",
97+
} as const;
98+
99+
export const CategorySpecialitySeason: CategorySpeciality = {
100+
id: CategorySpecialityID.Season,
101+
name: "categorySpecialitySeasonName",
102+
description: "categorySpecialitySeasonDescription",
103+
value: { fromTemp: null, toTemp: null, fromTimestamp: null, toTimestamp: null }
104+
} as const;
105+
106+
export const CategorySpecialityMap = {
107+
[CategorySpecialityID.No_Speciality]: CategorySpecialityNoSpeciality,
108+
[CategorySpecialityID.Body_Part]: CategorySpecialityBodyPart,
109+
[CategorySpecialityID.Color]: CategorySpecialityColor,
110+
[CategorySpecialityID.Season]: CategorySpecialitySeason
111+
} as const;
112+
// I don't like this, I feel like this could be done better
113+
114+
// All supported specialities in an array to iterate over it in labels page
115+
export const CategorySpecialities: CategorySpeciality[] = Object.values(CategorySpecialityMap);

src/model/label.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Created Date: 2025-09-09 21:59:50
55
* Author: 3urobeat
66
*
7-
* Last Modified: 2026-02-02 21:32:26
7+
* Last Modified: 2026-03-27 19:03:19
88
* Modified By: 3urobeat
99
*
1010
* Copyright (c) 2025 - 2026 3urobeat <https://github.com/3urobeat>
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import type { Category } from "./label-category";
18-
import { CategorySpecialityMap } from "./label-category-speciality";
18+
import { CategorySpecialityMap } from "./label-category";
1919

2020

2121
/**

src/model/outfit.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/pages/clothing/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Created Date: 2024-03-23 13:03:16
66
* Author: 3urobeat
77
*
8-
* Last Modified: 2026-03-26 18:24:18
8+
* Last Modified: 2026-03-27 19:02:23
99
* Modified By: 3urobeat
1010
*
1111
* Copyright (c) 2024 - 2026 3urobeat <https://github.com/3urobeat>
@@ -84,7 +84,7 @@
8484
import { PhBinoculars, PhMagnifyingGlass, PhPlus } from "@phosphor-icons/vue";
8585
import ImgLazy from "~/components/imgLazy.vue";
8686
import TitleBarFull from "~/components/titleBarFull.vue";
87-
import type { Clothing } from "~/model/clothing";
87+
import type { Clothing } from "~/model/item";
8888
import type { Label } from "~/model/label";
8989
import { defaultSortMode, sortModes } from "~/model/sort-modes";
9090

src/pages/clothing/view.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Created Date: 2025-09-08 15:39:55
66
* Author: 3urobeat
77
*
8-
* Last Modified: 2026-03-24 19:07:46
8+
* Last Modified: 2026-03-27 19:03:05
99
* Modified By: 3urobeat
1010
*
1111
* Copyright (c) 2025 - 2026 3urobeat <https://github.com/3urobeat>
@@ -156,10 +156,10 @@
156156
import { PhCheck, PhImageBroken, PhPencil, PhPlus, PhTrash, PhUploadSimple } from "@phosphor-icons/vue";
157157
import TitleBarBasic from "~/components/titleBarBasic.vue";
158158
import FileUpload from "~/components/fileUpload.vue";
159-
import type { Clothing } from "~/model/clothing";
159+
import type { Clothing } from "~/model/item";
160160
import { getNewLastLabelOrderIndex, sortLabelsList, type Label } from "~/model/label";
161161
import { getLabelsOfCategory, type Category } from "~/model/label-category";
162-
import { CategorySpecialityMap } from "~/model/label-category-speciality";
162+
import { CategorySpecialityMap } from "~/model/label-category";
163163
164164
165165
// Get global cache from app.vue

0 commit comments

Comments
 (0)