diff --git a/src/lib/components/app-sidebar.svelte b/src/lib/components/app-sidebar.svelte index 7e0d397..33b8fc0 100644 --- a/src/lib/components/app-sidebar.svelte +++ b/src/lib/components/app-sidebar.svelte @@ -109,6 +109,10 @@ title: "Workstation", url: "/workstation", }, + { + title: "Instrument", + url: "/instrument", + }, ], }, { diff --git a/src/lib/components/dictionary/instrument/api/instrument-api.js b/src/lib/components/dictionary/instrument/api/instrument-api.js new file mode 100644 index 0000000..86656a9 --- /dev/null +++ b/src/lib/components/dictionary/instrument/api/instrument-api.js @@ -0,0 +1,18 @@ +import { API } from '$lib/config/api.js'; +import { getById, searchWithParams, create, update } from '$lib/api/api-client'; + +export async function getInstruments(searchQuery) { + return await searchWithParams(API.INSTRUMENT, searchQuery) +} + +export async function getInstrument(searchQuery) { + return await getById(API.INSTRUMENT, searchQuery) +} + +export async function createInstrument(newInstrumentForm) { + return await create(API.INSTRUMENT, newInstrumentForm) +} + +export async function editInstrument(editInstrumentForm, id) { + return await update(API.INSTRUMENT, editInstrumentForm, id) +} \ No newline at end of file diff --git a/src/lib/components/dictionary/instrument/config/instrument-config.js b/src/lib/components/dictionary/instrument/config/instrument-config.js new file mode 100644 index 0000000..b55fd04 --- /dev/null +++ b/src/lib/components/dictionary/instrument/config/instrument-config.js @@ -0,0 +1,61 @@ +import PlusIcon from "@lucide/svelte/icons/plus"; +import Settings2Icon from "@lucide/svelte/icons/settings-2"; +import PencilIcon from "@lucide/svelte/icons/pencil"; +import RefreshIcon from "@lucide/svelte/icons/refresh-cw"; + +export const searchFields = [ + { + key: "InstrumentName", + label: "Instrument Name", + type: "text", + }, +]; + +export const detailSections = [ + { + title: "", + class: "grid grid-cols-1 gap-4", + groups: [ + { + class: "space-y-3", + fields: [ + { key: "IEID", label: "Internal Equipment ID" }, + { key: "InstrumentID", label: "Instrument ID" }, + { key: "InstrumentName", label: "Instrument Name" }, + { key: "WorkstationID", label: "Workstation" }, + { key: "EquipmentRole", label: "Equipment Role" }, + { key: "isEnable", label: "Enable" }, + ] + }, + ] + }, +]; + +export function instrumentActions(masterDetail, handlers) { + return [ + { + Icon: RefreshIcon, + label: 'Refresh Data', + onClick: handlers.refresh, + }, + { + Icon: PlusIcon, + label: 'Add Instrument', + onClick: () => masterDetail.enterCreate(), + }, + { + Icon: Settings2Icon, + label: 'Search Parameters', + }, + ]; +} + +export function viewActions(handlers){ + return [ + { + Icon: PencilIcon, + label: 'Edit Instrument', + onClick: handlers.editInstrument, + }, + ] +} \ No newline at end of file diff --git a/src/lib/components/dictionary/instrument/config/instrument-form-config.js b/src/lib/components/dictionary/instrument/config/instrument-form-config.js new file mode 100644 index 0000000..7f8c9ce --- /dev/null +++ b/src/lib/components/dictionary/instrument/config/instrument-form-config.js @@ -0,0 +1,67 @@ +import { API } from "$lib/config/api"; +import EraserIcon from "@lucide/svelte/icons/eraser"; +import { z } from "zod"; + +export const instrumentSchema = z.object({ + +}); + +export const instrumentInitialForm = { + EID: '', + IEID: '', + DepartmentID: '', + InstrumentID: '', + InstrumentName: '', + WorkstationID: '', + isEnable: '', + EquipmentRole: '', +}; + +export const instrumentDefaultErrors = { +}; + +export const instrumentFormFields = [ + { + title: "Basic Information", + rows: [ + { + type: "row", + columns: [ + { + key: "EID", + label: "Equipment ID", + required: false, + type: "text", + }, + { + key: "IEID", + label: "Internal Equipment ID", + required: false, + type: "text", + }, + ] + }, + { + type: "row", + columns: [ + { + key: "DepartmentID", + label: "Department ID", + required: false, + type: "textarea", + }, + ] + } + ] + }, +]; + +export function getInstrumentFormActions(handlers) { + return [ + { + Icon: EraserIcon, + label: 'Clear Form', + onClick: handlers.clearForm, + }, + ]; +} \ No newline at end of file diff --git a/src/lib/components/dictionary/instrument/page/create-page.svelte b/src/lib/components/dictionary/instrument/page/create-page.svelte new file mode 100644 index 0000000..4649907 --- /dev/null +++ b/src/lib/components/dictionary/instrument/page/create-page.svelte @@ -0,0 +1 @@ +cr \ No newline at end of file diff --git a/src/lib/components/dictionary/instrument/page/edit-page.svelte b/src/lib/components/dictionary/instrument/page/edit-page.svelte new file mode 100644 index 0000000..9a58f89 --- /dev/null +++ b/src/lib/components/dictionary/instrument/page/edit-page.svelte @@ -0,0 +1 @@ +ed \ No newline at end of file diff --git a/src/lib/components/dictionary/instrument/page/master-page.svelte b/src/lib/components/dictionary/instrument/page/master-page.svelte new file mode 100644 index 0000000..f19f4cd --- /dev/null +++ b/src/lib/components/dictionary/instrument/page/master-page.svelte @@ -0,0 +1,74 @@ + + +{#snippet searchParamSnippet(close)} + search.handleSearch(close)} onReset={search.handleReset} isLoading={search.isLoading} + selectOptions={search.selectOptions} loadingOptions={search.loadingOptions} fetchOptions={search.fetchOptions} + /> +{/snippet} + +
props.masterDetail.isFormMode && props.masterDetail.exitForm()} + onkeydown={(e) => e.key === 'Enter' && props.masterDetail.isFormMode && props.masterDetail.exitForm()} + class={` + ${props.masterDetail.isMobile ? "w-full" : props.masterDetail.isFormMode ? "w-[3%] cursor-pointer" : "w-[35%]"} + transition-all duration-300 flex flex-col items-center p-2 h-full overflow-y-auto + `} +> +
+ {#if props.masterDetail.isFormMode} + + +
+ {#each "INSTRUMENT".split("") as c} + {c} + {/each} +
+
+ {/if} + + {#if !props.masterDetail.isFormMode} +
e.stopPropagation()} onkeydown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + e.stopPropagation(); + } + }}> + +
+ {#if search.searchData.length > 0} + + {:else} +
+ +
+ {/if} +
+
+ {/if} +
+
\ No newline at end of file diff --git a/src/lib/components/dictionary/instrument/page/view-page.svelte b/src/lib/components/dictionary/instrument/page/view-page.svelte new file mode 100644 index 0000000..aac9662 --- /dev/null +++ b/src/lib/components/dictionary/instrument/page/view-page.svelte @@ -0,0 +1,97 @@ + + +{#snippet Fieldset({ value, label, isUTCDate = false })} +
+
+ {label} +
+
+ {#if isUTCDate} + {formatUTCDate(value)} + {:else} + {value ?? "-"} + {/if} +
+
+{/snippet} + +{#if masterDetail.isLoadingDetail} +
+ +
+{:else if masterDetail.selectedItem} +
+ +
+ {#each detailSections as section} +
+ {#if section.groups} +
+ {#each section.groups as group} +
+
+ {#each group.fields as field} + {@render Fieldset({ + label: field.label, + value: getFieldValue(field), + isUTCDate: field.isUTCDate + })} + {/each} +
+
+ {/each} +
+ {:else} +
+ {#each section.fields as field} + {@render Fieldset({ + label: field.label, + value: getFieldValue(field), + isUTCDate: field.isUTCDate + })} + {/each} +
+ {/if} +
+ {/each} +
+
+{:else} + +{/if} \ No newline at end of file diff --git a/src/lib/components/dictionary/instrument/table/instrument-columns.js b/src/lib/components/dictionary/instrument/table/instrument-columns.js new file mode 100644 index 0000000..e33e269 --- /dev/null +++ b/src/lib/components/dictionary/instrument/table/instrument-columns.js @@ -0,0 +1,10 @@ +export const instrumentColumns = [ + { + accessorKey: "InstrumentName", + header: "Instrument Name", + }, + { + accessorKey: "DepartmentName", + header: "Department", + }, +]; \ No newline at end of file diff --git a/src/lib/config/api.js b/src/lib/config/api.js index b2fe7f9..8f33a93 100644 --- a/src/lib/config/api.js +++ b/src/lib/config/api.js @@ -29,4 +29,5 @@ export const API = { TESTMAP: '/api/test/testmap', EQUIPMENT: '/api/equipmentlist', ORDERTEST: '/api/ordertest', + INSTRUMENT: '/api/equipmentlist', }; diff --git a/src/routes/+layout.server.js b/src/routes/+layout.server.js index 5c56f4c..d04bfcc 100644 --- a/src/routes/+layout.server.js +++ b/src/routes/+layout.server.js @@ -42,6 +42,9 @@ export async function load({ url }) { '/dictionary/testmap': { title: 'Test Map' }, + '/dictionary/instrument': { + title: 'Instrument' + }, '/order/ordertest': { title: 'Order Test' }, diff --git a/src/routes/dictionary/instrument/+page.svelte b/src/routes/dictionary/instrument/+page.svelte new file mode 100644 index 0000000..ed0f14e --- /dev/null +++ b/src/routes/dictionary/instrument/+page.svelte @@ -0,0 +1,52 @@ + + +
+ {#if masterDetail.showMaster} + + {/if} + + {#if masterDetail.showDetail} +
+ {#if masterDetail.mode === "view"} + + {:else if masterDetail.mode === "create"} + + {:else if masterDetail.mode === "edit"} + + {/if} +
+ {/if} +
\ No newline at end of file