diff --git a/src/lib/components/composable/use-dictionary-form.svelte.js b/src/lib/components/composable/use-dictionary-form.svelte.js
new file mode 100644
index 0000000..e5b8f7e
--- /dev/null
+++ b/src/lib/components/composable/use-dictionary-form.svelte.js
@@ -0,0 +1,12 @@
+export function useDictionaryForm(formState) {
+ let uploadErrors = $state({});
+ let isChecking = $state({});
+
+ let hasErrors = $derived(
+ Object.values(formState.errors).some(value => value !== null)
+ );
+
+ return {
+ get hasErrors() { return hasErrors },
+ }
+}
\ No newline at end of file
diff --git a/src/lib/components/dictionary/location/config/location-config.js b/src/lib/components/dictionary/location/config/location-config.js
index 20d0a4f..9891e94 100644
--- a/src/lib/components/dictionary/location/config/location-config.js
+++ b/src/lib/components/dictionary/location/config/location-config.js
@@ -22,6 +22,45 @@ export const searchFields = [
];
export const detailSections = [
+ {
+ class: "grid grid-cols-2 gap-4 items-center",
+ fields: [
+ { key: "SiteID", label: "Site" },
+ { key: "Parent", label: "Parent" },
+ { key: "LocCode", label: "Location Code" },
+ { key: "LocFull", label: "Location Name" },
+ { key: "LocType", label: "Location Type" },
+ { key: "Description", label: "Description" },
+ ]
+ },
+ {
+ title: "",
+ class: "grid grid-cols-1 md:grid-cols-2 gap-4",
+ groups: [
+ {
+ class: "space-y-3",
+ fields: [
+ { key: "Province", label: "Province" },
+ { key: "City", label: "City" },
+ { key: "PostCode", label: "ZIP" },
+ ]
+ },
+ {
+ class: "space-y-3",
+ fields: [
+ { key: "Street1", label: "Street 1" },
+ { key: "Street2", label: "Street 2" },
+ ]
+ }
+ ]
+ },
+ {
+ class: "grid grid-cols-2 gap-4 items-center",
+ fields: [
+ { key: "GeoLocationSystem", label: "Geo Location System" },
+ { key: "GeoLocationData", label: "Geo Location Data" },
+ ]
+ },
];
export function locationActions(masterDetail) {
diff --git a/src/lib/components/dictionary/location/config/location-form-config.js b/src/lib/components/dictionary/location/config/location-form-config.js
index 098afca..dd7c624 100644
--- a/src/lib/components/dictionary/location/config/location-form-config.js
+++ b/src/lib/components/dictionary/location/config/location-form-config.js
@@ -2,7 +2,10 @@ import { API } from "$lib/config/api";
import EraserIcon from "@lucide/svelte/icons/eraser";
import { z } from "zod";
-export const locationSchema = z.object({});
+export const locationSchema = z.object({
+ LocCode: z.string().min(1, "Required"),
+ LocFull: z.string().min(1, "Required"),
+});
export const locationInitialForm = {
LocationID: '',
@@ -23,8 +26,7 @@ export const locationInitialForm = {
export const locationDefaultErrors = {
LocCode: "Required",
- LocName: "Required",
- LocType: "Required",
+ LocFull: "Required",
};
export const locationFormFields = [
@@ -37,7 +39,7 @@ export const locationFormFields = [
{
key: "SiteID",
label: "Site ID",
- required: true,
+ required: false,
type: "select",
optionsEndpoint: `${API.BASE_URL}${API.SITE}`,
},
@@ -48,21 +50,26 @@ export const locationFormFields = [
type: "text",
validateOn: ["input"]
},
+ ]
+ },
+ {
+ type: "row",
+ columns: [
{
key: "LocType",
label: "Location Type",
- required: true,
+ required: false,
type: "text",
- validateOn: ["input"]
},
{
key: "LocFull",
label: "Location Name",
- required: false,
+ required: true,
type: "text",
+ validateOn: ["input"]
}
]
- }
+ },
]
},
{
@@ -78,25 +85,26 @@ export const locationFormFields = [
type: "select",
optionsEndpoint: `${API.BASE_URL}${API.PROVINCE}`,
},
- {
- key: "City",
- label: "City",
- required: false,
- type: "select",
- optionsEndpoint: `${API.BASE_URL}${API.CITY}`,
- },
- {
- key: "ZIP",
- label: "ZIP",
- required: false,
- type: "text",
- },
{
key: "Street1",
label: "Street 1",
required: false,
type: "text",
},
+ ]
+ },
+ {
+ type: "row",
+ columns: [
+ {
+ key: "City",
+ label: "City",
+ required: false,
+ type: "select",
+ optionsEndpoint: `${API.BASE_URL}${API.CITY}`,
+ dependsOn: "Province",
+ endpointParamKey: "Parent"
+ },
{
key: "Street2",
label: "Street 2",
@@ -105,7 +113,17 @@ export const locationFormFields = [
}
]
},
-
+ {
+ type: "row",
+ columns: [
+ {
+ key: "ZIP",
+ label: "ZIP",
+ required: false,
+ type: "text",
+ },
+ ]
+ },
]
},
{
diff --git a/src/lib/components/dictionary/location/page/create-page.svelte b/src/lib/components/dictionary/location/page/create-page.svelte
index e69de29..c7c5dc8 100644
--- a/src/lib/components/dictionary/location/page/create-page.svelte
+++ b/src/lib/components/dictionary/location/page/create-page.svelte
@@ -0,0 +1,64 @@
+
+
+