diff --git a/handlers/routes.go b/handlers/routes.go index 1a5c6a8..a4d90be 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -263,21 +263,6 @@ func SetupRoutesDev(app *echo.Echo, appStore db.AppStore) { dev.POST("/md/usergroupv2/closedeleteform", devMdUserGroupHandlers.HandleCloseFormDelete) dev.POST("/md/usergroupv2/delete", devMdUserGroupHandlers.HandleDeleteUserGroup) - // group result - devGRServices := dev_services.NewServicesGroupResult(appStore) - devGRhandlers := dev_handlers.NewGroupResultHandler(devGRServices) - dev.GET("/groupresult", devGRhandlers.HandlerShowGroupResultV1) - dev.GET("/searchgroupresultv1", devGRhandlers.HandlerShowGroupResultSearchV1) - dev.GET("/groupresultv1pagination", devGRhandlers.HandlerShowGroupResultPaginationV1) - dev.POST("/groupresulthandlecloseform", devGRhandlers.HandleCloseForm) - dev.POST("/groupresulthandlecloseformedit", devGRhandlers.HandleCloseFormEdit) - dev.GET("/groupresultshoweditform", devGRhandlers.HandleEditForm) - dev.GET("/groupresultshowdeleteform", devGRhandlers.HandleDeleteForm) - // dev.GET("/groupresultshowdeleteform", devGRhandlers.HandleDeleteForm) - // form add - dev.POST("/groupresult/add", devGRhandlers.AddGroupResult) - dev.POST("/groupresult/edit", devGRhandlers.EditGroupResult) - dev.POST("/groupresult/delete", devGRhandlers.DeleteGroupResult) // md sample station devMDSampleStationServices := dev_services.NewMDSampleStationServices(appStore) devMDSampleStationHandlers := dev_handlers.NewMDSampleStationHandler(devMDSampleStationServices) diff --git a/models/samplestation.models.go b/models/samplestation.models.go index 9b4238f..ef1d089 100644 --- a/models/samplestation.models.go +++ b/models/samplestation.models.go @@ -1,5 +1,7 @@ package models +import "github.com/a-h/templ" + type MDSampleStation struct { T_SampleStationID int `db:"T_SampleStationID"` T_SampleStationCode string `db:"T_SampleStationCode"` @@ -8,3 +10,33 @@ type MDSampleStation struct { T_SampleStationIsNonLab string `db:"T_SampleStationIsNonLab"` T_SampleStationIsActive string `db:"T_SampleStationIsActive"` } + +type MDSampleStationForm struct { + IDComponent string + Link string + HxTarget string + HxSwap string + HxInclude string + ModalID string + ModalTitle string + InputID CustomTextFieldv2Prm + InputCode CustomTextFieldv2Prm + InputName CustomTextFieldv2Prm + InputGroup CustomDropdownv1Prm + DialogBody templ.Component + DialogAction templ.Component + ButtonClose templ.Component +} + +type MDSampleStationConfirmation struct { + IDComponent string + Link string + HxTarget string + HxSwap string + HxInclude string + ModalID string + ModalTitle string + DialogBody templ.Component + DialogAction templ.Component + ButtonClose templ.Component +} diff --git a/views/dev/mdsamplestation/mdsamplestationmodal.templ b/views/dev/mdsamplestation/mdsamplestationmodal.templ new file mode 100644 index 0000000..1b4dc60 --- /dev/null +++ b/views/dev/mdsamplestation/mdsamplestationmodal.templ @@ -0,0 +1,179 @@ +package dev_mdsamplestationview + +import "cpone/models" +import "cpone/component/modal" +import "cpone/component/customtextfield" +import "cpone/component/customdropdown" + +templ MDSampleStationForm(data models.MDSampleStationForm) { +
+
+ @modalcomponent.Modal(data.ModalID, + data.ModalTitle, + data.DialogBody, + data.DialogAction, + data.ButtonClose, + ) +
+
+} + +script HandleFormBeforeRequest() { + const btnActCancel = document.querySelectorAll('.btnactcancel'); + const btnActSaveData = document.querySelectorAll('.btnactsavedata'); + + for (let i = 0; i < btnActCancel.length; i++) { + btnActCancel[i].setAttribute('disabled', 'true'); + } + for (let i = 0; i < btnActSaveData.length; i++) { + btnActSaveData[i].setAttribute('disabled', 'true'); + } +} + +script HandleFormAfterRequest() { + const btnActCancel = document.querySelectorAll('.btnactcancel'); + const btnActSaveData = document.querySelectorAll('.btnactsavedata'); + + for (let i = 0; i < btnActCancel.length; i++) { + btnActCancel[i].setAttribute('disabled'); + } + for (let i = 0; i < document.length; i++) { + btnActSaveData[i].setAttribute('disabled'); + } +} + +templ BodyFormMDSampleStation( + componentID string, + inputID models.CustomTextFieldv2Prm, + inputName models.CustomTextFieldv2Prm, + inputCode models.CustomTextFieldv2Prm, + inputGroup models.CustomDropdownv1Prm, + hxOnLoad templ.ComponentScript, +) { +
+ @customtextfield.CustomTextFieldv2(inputID) + @customtextfield.CustomTextFieldv2(inputCode) + @customtextfield.CustomTextFieldv2(inputName) + @customdropdown.MainCustomDropdownV1(inputGroup) +
+} + +script JSHideModal(modalID string) { + $(modalID).modal('hide') +} + +script JSShowModal(modalID string) { + $(modalID).modal('show') + const btnActCancel = document.querySelectorAll('.btnactcancel'); + const btnActSaveData = document.querySelectorAll('.btnactsavedata'); + + for (let i = 0; i < btnActCancel.length; i++) { + btnActCancel[i].removeAttribute('disabled'); + } + for (let i = 0; i < btnActSaveData.length; i++) { + btnActSaveData[i].removeAttribute('disabled'); + } +} + +templ ActionFormMDSampleStation(LinkClose string, targetClose string, hxSwapClose string, modalID string) { +
+ + +
+} + +templ BtnCloseFormMDSampleStation(LinkClose string, targetClose string, hxSwapClose string, modalID string) { + +} + +templ DeleteConfirmationBody( + inputID models.CustomTextFieldv2Prm, + componentID string, + message string, + dataHeader []string, + dataText []string, + hxOnLoad templ.ComponentScript, +) { +
+

{ message }

+
+
+
+ for _, v := range dataHeader { +
{ v }
+ } +
+
+ for _, v := range dataText { +
{ v }
+ } +
+
+
+ @customtextfield.CustomTextFieldv2(inputID) +
+} + +templ ActionFormMDSampleStationDelete(LinkClose string, targetClose string, hxSwapClose string, modalID string) { +
+ + +
+} \ No newline at end of file diff --git a/views/dev/mdsamplestation/mdsamplestationmodal_templ.go b/views/dev/mdsamplestation/mdsamplestationmodal_templ.go new file mode 100644 index 0000000..c258f74 --- /dev/null +++ b/views/dev/mdsamplestation/mdsamplestationmodal_templ.go @@ -0,0 +1,646 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package dev_mdsamplestationview + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +import "cpone/models" +import "cpone/component/modal" +import "cpone/component/customtextfield" +import "cpone/component/customdropdown" + +func MDSampleStationForm(data models.MDSampleStationForm) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, HandleFormBeforeRequest(), HandleFormAfterRequest()) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = modalcomponent.Modal(data.ModalID, + data.ModalTitle, + data.DialogBody, + data.DialogAction, + data.ButtonClose, + ).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func HandleFormBeforeRequest() templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_HandleFormBeforeRequest_7bdf`, + Function: `function __templ_HandleFormBeforeRequest_7bdf(){const btnActCancel = document.querySelectorAll('.btnactcancel'); + const btnActSaveData = document.querySelectorAll('.btnactsavedata'); + + for (let i = 0; i < btnActCancel.length; i++) { + btnActCancel[i].setAttribute('disabled', 'true'); + } + for (let i = 0; i < btnActSaveData.length; i++) { + btnActSaveData[i].setAttribute('disabled', 'true'); + } +}`, + Call: templ.SafeScript(`__templ_HandleFormBeforeRequest_7bdf`), + CallInline: templ.SafeScriptInline(`__templ_HandleFormBeforeRequest_7bdf`), + } +} + +func HandleFormAfterRequest() templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_HandleFormAfterRequest_cce9`, + Function: `function __templ_HandleFormAfterRequest_cce9(){const btnActCancel = document.querySelectorAll('.btnactcancel'); + const btnActSaveData = document.querySelectorAll('.btnactsavedata'); + + for (let i = 0; i < btnActCancel.length; i++) { + btnActCancel[i].setAttribute('disabled'); + } + for (let i = 0; i < document.length; i++) { + btnActSaveData[i].setAttribute('disabled'); + } +}`, + Call: templ.SafeScript(`__templ_HandleFormAfterRequest_cce9`), + CallInline: templ.SafeScriptInline(`__templ_HandleFormAfterRequest_cce9`), + } +} + +func BodyFormMDSampleStation( + componentID string, + inputID models.CustomTextFieldv2Prm, + inputName models.CustomTextFieldv2Prm, + inputCode models.CustomTextFieldv2Prm, + inputGroup models.CustomDropdownv1Prm, + hxOnLoad templ.ComponentScript, +) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var9 := templ.GetChildren(ctx) + if templ_7745c5c3_Var9 == nil { + templ_7745c5c3_Var9 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, hxOnLoad) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(inputID).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(inputCode).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(inputName).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customdropdown.MainCustomDropdownV1(inputGroup).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func JSHideModal(modalID string) templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_JSHideModal_4530`, + Function: `function __templ_JSHideModal_4530(modalID){$(modalID).modal('hide') +}`, + Call: templ.SafeScript(`__templ_JSHideModal_4530`, modalID), + CallInline: templ.SafeScriptInline(`__templ_JSHideModal_4530`, modalID), + } +} + +func JSShowModal(modalID string) templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_JSShowModal_658d`, + Function: `function __templ_JSShowModal_658d(modalID){$(modalID).modal('show') + const btnActCancel = document.querySelectorAll('.btnactcancel'); + const btnActSaveData = document.querySelectorAll('.btnactsavedata'); + + for (let i = 0; i < btnActCancel.length; i++) { + btnActCancel[i].removeAttribute('disabled'); + } + for (let i = 0; i < btnActSaveData.length; i++) { + btnActSaveData[i].removeAttribute('disabled'); + } +}`, + Call: templ.SafeScript(`__templ_JSShowModal_658d`, modalID), + CallInline: templ.SafeScriptInline(`__templ_JSShowModal_658d`, modalID), + } +} + +func ActionFormMDSampleStation(LinkClose string, targetClose string, hxSwapClose string, modalID string) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var12 := templ.GetChildren(ctx) + if templ_7745c5c3_Var12 == nil { + templ_7745c5c3_Var12 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, JSHideModal(modalID)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func BtnCloseFormMDSampleStation(LinkClose string, targetClose string, hxSwapClose string, modalID string) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var17 := templ.GetChildren(ctx) + if templ_7745c5c3_Var17 == nil { + templ_7745c5c3_Var17 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, JSHideModal(modalID)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func DeleteConfirmationBody( + inputID models.CustomTextFieldv2Prm, + componentID string, + message string, + dataHeader []string, + dataText []string, + hxOnLoad templ.ComponentScript, +) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var22 := templ.GetChildren(ctx) + if templ_7745c5c3_Var22 == nil { + templ_7745c5c3_Var22 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, hxOnLoad) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var25 string + templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(message) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdsamplestation\mdsamplestationmodal.templ`, Line: 137, Col: 20} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + for _, v := range dataHeader { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var26 string + templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(v) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdsamplestation\mdsamplestationmodal.templ`, Line: 142, Col: 86} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + for _, v := range dataText { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var27 string + templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(v) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdsamplestation\mdsamplestationmodal.templ`, Line: 147, Col: 67} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(inputID).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func ActionFormMDSampleStationDelete(LinkClose string, targetClose string, hxSwapClose string, modalID string) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var28 := templ.GetChildren(ctx) + if templ_7745c5c3_Var28 == nil { + templ_7745c5c3_Var28 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, JSHideModal(modalID)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +}