diff --git a/handlers/dev/md.nonlabtemplate.handlers.go b/handlers/dev/md.nonlabtemplate.handlers.go index 386cfd8..4fdee8c 100644 --- a/handlers/dev/md.nonlabtemplate.handlers.go +++ b/handlers/dev/md.nonlabtemplate.handlers.go @@ -124,29 +124,69 @@ func (nlt *MDNonlabTemplateHandler) HandleShowNonlabTemplateScreen(c echo.Contex dev_mdnonlabtemplateview.AfterRequestContent(), ) - // dialog delete - dialogDeleteCmp := dev_mdnonlabtemplateview.BodyFormMDNonlabTemplate( - dialogDeleteBodyID, + // dialog add + dialogAddBody := dev_mdnonlabtemplateview.BodyFormMDNonlabTemplate( + dialogAddBodyID, models.CustomTextFieldv2Prm{ - Label: "ID Nonlab Template", - Name: "nonlabtemplateid", - Placeholder: "ID Nonlab Template", - Type: "hidden", - ID: "nonlabtemplateinputid", + Name: "nonlabtemplateid", + ID: "nonlabtemplateinputid", + Type: "hidden", + Value: dialogAddBodyID, }, models.CustomTextFieldv2Prm{ - Label: "Name Nonlab Template", - Name: "nonlabtemplatename", - Placeholder: "Nama Nonlab Template", - Type: "text", - ID: "nonlabtemplateinputname", + Label: "Nama Template", + Name: "nonlabtemplatename", + ID: "nonlabtemplateinputname", + Type: "text", }, models.CustomCheckboxv1Prm{ - Name: "nonlabtemplateflag", - ID: "nonlabtemplateinputname", Text: "Template Fisik", + Name: "nonlabtemplatefisik", + ID: "nonlabtemplateinputname", Value: "N", }, + dev_mdnonlabtemplateview.BtnSimpanNama( + "/dev/md/nonlabtemplate/simpanama", + "#"+dialogAddBodyID, + "outerHTML", + "#"+dialogAddID, + "#tableID, #paginationID, #searchID, #dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #"+searchID+", #currpage"+paginationID, + ), + dev_mdnonlabtemplateview.JSShowModal(""), + ) + dialogAddBtn := dev_mdnonlabtemplateview.ActionFormMDNonlabTmplt( + "/dev/md/nonlabtemplate/closeaddform", + "#"+dialogAddBodyID, + "outerHTML", + "#"+dialogAddID, + ) + dialogAddCls := dev_mdnonlabtemplateview.BtnCloseFormMDNonlabTmplt( + "/dev/md/nonlabtemplate/closeaddform", + "#"+dialogAddBodyID, + "innerHTML", + "#"+dialogAddID, + ) + + modalAddFormComponent := dev_mdnonlabtemplateview.MDNonlabTmpltForm(models.MDNonlabTemplateForm{ + IDComponent: "test1", + Link: "/dev/md/nonlabtemplate/add", + HxTarget: "#" + dialogAddBodyID, + HxSwap: "outerHTML", + HxInclude: "#tableID, #paginationID, #searchID, #dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #" + searchID + ", #currpage" + paginationID, + ModalID: dialogAddID, + ModalTitle: "New - Nonlab Template", + DialogBody: dialogAddBody, + DialogAction: dialogAddBtn, + ButtonClose: dialogAddCls, + }) + + // dialog delete + dialogDeleteCmp := dev_mdnonlabtemplateview.DeleteKonfirmasiBody( + models.CustomTextFieldv2Prm{Name: "nonlabtemplateid", Type: "hidden", Value: "0"}, + dialogDeleteBodyID, + "Apakah anda yakin menghapus non lab template berikut ?", + []string{"NAME"}, + []string{""}, dev_mdnonlabtemplateview.JSHideModal(""), ) @@ -172,7 +212,7 @@ func (nlt *MDNonlabTemplateHandler) HandleShowNonlabTemplateScreen(c echo.Contex HxSwap: "outerHTML", HxInclude: "#tableID, #paginationID, #searchID, #dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #" + searchID + ", #currpage" + paginationID, ModalID: dialogDeleteID, - ModalTitle: "Delete - Non Lab Template", + ModalTitle: "Delete - Nonlab Template", DialogBody: dialogDeleteCmp, DialogAction: modalActionDeleteComp, ButtonClose: btnCloseModalDelete, @@ -193,6 +233,7 @@ func (nlt *MDNonlabTemplateHandler) HandleShowNonlabTemplateScreen(c echo.Contex tableFilter, tableComp, tablePagination, + modalAddFormComponent, modalDeleteFormComponent, ) @@ -438,3 +479,88 @@ func (nlt *MDNonlabTemplateHandler) HandleDelete(c echo.Context) error { return utils.ViewMulti(c, retVal) } + +func (nlt *MDNonlabTemplateHandler) HandleCloseFormAdd(c echo.Context) error { + logger, _ := zap.NewProduction() + defer logger.Sync() + + dialogAddBodyID := c.FormValue("dialogAddBodyID") + dialogAddID := c.FormValue("dialogAddID") + searchID := c.FormValue("searchID") + paginationID := c.FormValue("paginationID") + + dialogAddBody := dev_mdnonlabtemplateview.BodyFormMDNonlabTemplate( + dialogAddBodyID, + models.CustomTextFieldv2Prm{ + Name: "nonlabtemplateid", + ID: "nonlabtemplateinputid", + Type: "hidden", + }, + models.CustomTextFieldv2Prm{ + Label: "Nama Template", + Name: "nonlabtemplatename", + ID: "nonlabtemplateinputname", + Type: "text", + }, + models.CustomCheckboxv1Prm{ + Text: "Template Fisik", + Name: "nonlabtemplatefisik", + ID: "nonlabtemplateinputname", + Value: "N", + }, + dev_mdnonlabtemplateview.BtnSimpanNama( + "/dev/md/nonlabtemplate/simpanama", + "#"+dialogAddBodyID, + "outerHTML", + "#"+dialogAddID, + "#tableID, #paginationID, #searchID, #dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #"+searchID+", #currpage"+paginationID, + ), + dev_mdnonlabtemplateview.JSHideModal("#"+dialogAddID), + ) + return utils.View(c, dialogAddBody) +} + +func (nlt *MDNonlabTemplateHandler) HandleSimpanNama(c echo.Context) error { + logger, _ := zap.NewProduction() + dialogAddBodyID := c.FormValue("dialogAddBodyID") + dialogAddID := c.FormValue("dialogAddID") + searchID := c.FormValue("searchID") + paginationID := c.FormValue("paginationID") + logger.Info("Test Button") + + fisik := c.FormValue("nonlabtemplatefisik") + name := c.FormValue("nonlabtemplatename") + id := c.FormValue("nonlabtemplateid") + logger.Info("Component ID", zap.Any("ID", id)) + + dialogAddBody := dev_mdnonlabtemplateview.BodyFormMDNonlabTemplate( + dialogAddBodyID, + models.CustomTextFieldv2Prm{ + Name: "nonlabtemplateid", + ID: "nonlabtemplateinputid", + Type: "hidden", + }, + models.CustomTextFieldv2Prm{ + Label: "Nama Template", + Name: "nonlabtemplatename", + ID: "nonlabtemplateinputname", + Type: "text", + Value: name, + }, + models.CustomCheckboxv1Prm{ + Text: "Template Fisik", + Name: "nonlabtemplatefisik", + ID: "nonlabtemplateinputname", + Value: fisik, + }, + dev_mdnonlabtemplateview.BtnSimpanNama( + "/dev/md/nonlabtemplate/simpanama", + "#"+dialogAddBodyID, + "outerHTML", + "#"+dialogAddID, + "#tableID, #paginationID, #searchID, #dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #"+searchID+", #currpage"+paginationID, + ), + dev_mdnonlabtemplateview.JSShowModal(""), + ) + return utils.View(c, dialogAddBody) +} diff --git a/handlers/routes.go b/handlers/routes.go index 07f1c02..8620177 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -287,6 +287,8 @@ func SetupRoutesDev(app *echo.Echo, appStore db.AppStore) { dev.GET("/md/nonlabtemplate/opendelete", devMDNonlabTemplateHandlers.HandleOpenFormDelete) dev.POST("/md/nonlabtemplate/closedeleteform", devMDNonlabTemplateHandlers.HandleCloseFormDelete) dev.POST("/md/nonlabtemplate/delete", devMDNonlabTemplateHandlers.HandleDelete) + dev.POST("/md/nonlabtemplate/simpanama", devMDNonlabTemplateHandlers.HandleSimpanNama) + dev.POST("/md/nonlabtemplate/closeaddform", devMDNonlabTemplateHandlers.HandleCloseFormAdd) // masterdata nat unit devMdNatUnitServices := dev_services.NewMdNatUnitServices(appStore) diff --git a/views/dev/mdnonlabtemplate/mdnonlabtemplate.templ b/views/dev/mdnonlabtemplate/mdnonlabtemplate.templ index b4d8453..f4f6ebb 100644 --- a/views/dev/mdnonlabtemplate/mdnonlabtemplate.templ +++ b/views/dev/mdnonlabtemplate/mdnonlabtemplate.templ @@ -18,7 +18,7 @@ templ MdNonlabTemplateScreen( filtercomponent templ.Component, tablecontent templ.Component, paginationtable templ.Component, - // modalAddForm templ.Component, + modalAddForm templ.Component, // modalEditForm templ.Component, modalDeleteForm templ.Component, ) { @@ -97,7 +97,7 @@ templ MdNonlabTemplateScreen(
- // @modalAddForm + @modalAddForm // @modalEditForm @modalDeleteForm diff --git a/views/dev/mdnonlabtemplate/mdnonlabtemplate_templ.go b/views/dev/mdnonlabtemplate/mdnonlabtemplate_templ.go index cb49a66..23ed9a0 100644 --- a/views/dev/mdnonlabtemplate/mdnonlabtemplate_templ.go +++ b/views/dev/mdnonlabtemplate/mdnonlabtemplate_templ.go @@ -28,7 +28,7 @@ func MdNonlabTemplateScreen( filtercomponent templ.Component, tablecontent templ.Component, paginationtable templ.Component, - // modalAddForm templ.Component, + modalAddForm templ.Component, // modalEditForm templ.Component, modalDeleteForm templ.Component, ) templ.Component { @@ -165,6 +165,10 @@ func MdNonlabTemplateScreen( if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } + templ_7745c5c3_Err = modalAddForm.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } templ_7745c5c3_Err = modalDeleteForm.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err diff --git a/views/dev/mdnonlabtemplate/mdnonlabtmptmodal.templ b/views/dev/mdnonlabtemplate/mdnonlabtmptmodal.templ index 5681aeb..f72f252 100644 --- a/views/dev/mdnonlabtemplate/mdnonlabtmptmodal.templ +++ b/views/dev/mdnonlabtemplate/mdnonlabtmptmodal.templ @@ -18,7 +18,7 @@ templ MDNonlabTmpltForm(data models.MDNonlabTemplateForm) { hx-on::before-request={ HandleFormBeforeRequest() } hx-on::after-request={ HandleFormAfterRequest() } > - @modalcomponent.Modal(data.ModalID, + @modalcomponent.ModalXL(data.ModalID, data.ModalTitle, data.DialogBody, data.DialogAction, @@ -57,17 +57,25 @@ templ BodyFormMDNonlabTemplate( inputID models.CustomTextFieldv2Prm, inputName models.CustomTextFieldv2Prm, inputFlag models.CustomCheckboxv1Prm, + btnSimpan templ.Component, hxOnLoad templ.ComponentScript, ) {
@customtextfield.CustomTextFieldv2(inputID) - @customtextfield.CustomTextFieldv2(inputName) - @customcheckbox.MainCustomCheckboxInput(inputFlag) +
+
+ @customtextfield.CustomTextFieldv2(inputName) +
+
+ @customcheckbox.MainCustomCheckboxInput(inputFlag) +
+
+ @btnSimpan
} @@ -126,4 +134,18 @@ templ BtnCloseFormMDNonlabTmplt(LinkClose string, targetClose string, hxSwapClos > +} + +templ BtnSimpanNama(Link string, target string, hxSwap string, modalID string, hxInclude string) { + } \ No newline at end of file diff --git a/views/dev/mdnonlabtemplate/mdnonlabtmptmodal_templ.go b/views/dev/mdnonlabtemplate/mdnonlabtmptmodal_templ.go index 8e7e554..414deb9 100644 --- a/views/dev/mdnonlabtemplate/mdnonlabtmptmodal_templ.go +++ b/views/dev/mdnonlabtemplate/mdnonlabtmptmodal_templ.go @@ -123,7 +123,7 @@ func MDNonlabTmpltForm(data models.MDNonlabTemplateForm) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = modalcomponent.Modal(data.ModalID, + templ_7745c5c3_Err = modalcomponent.ModalXL(data.ModalID, data.ModalTitle, data.DialogBody, data.DialogAction, @@ -184,6 +184,7 @@ func BodyFormMDNonlabTemplate( inputID models.CustomTextFieldv2Prm, inputName models.CustomTextFieldv2Prm, inputFlag models.CustomCheckboxv1Prm, + btnSimpan templ.Component, hxOnLoad templ.ComponentScript, ) templ.Component { return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { @@ -209,7 +210,7 @@ func BodyFormMDNonlabTemplate( var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(componentID) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 62, Col: 25} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 63, Col: 25} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -232,15 +233,31 @@ func BodyFormMDNonlabTemplate( 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(inputName).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 + } templ_7745c5c3_Err = customcheckbox.MainCustomCheckboxInput(inputFlag).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = btnSimpan.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 } @@ -317,7 +334,7 @@ func ActionFormMDNonlabTmplt(LinkClose string, targetClose string, hxSwapClose s var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(LinkClose) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 95, Col: 31} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 103, Col: 31} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { @@ -330,7 +347,7 @@ func ActionFormMDNonlabTmplt(LinkClose string, targetClose string, hxSwapClose s var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(targetClose) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 96, Col: 35} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 104, Col: 35} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { @@ -343,7 +360,7 @@ func ActionFormMDNonlabTmplt(LinkClose string, targetClose string, hxSwapClose s var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(hxSwapClose) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 97, Col: 33} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 105, Col: 33} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { @@ -384,7 +401,7 @@ func BtnCloseFormMDNonlabTmplt(LinkClose string, targetClose string, hxSwapClose var templ_7745c5c3_Var18 string templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(LinkClose) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 118, Col: 27} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 126, Col: 27} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { @@ -397,7 +414,7 @@ func BtnCloseFormMDNonlabTmplt(LinkClose string, targetClose string, hxSwapClose var templ_7745c5c3_Var19 string templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(targetClose) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 119, Col: 31} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 127, Col: 31} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { @@ -410,7 +427,7 @@ func BtnCloseFormMDNonlabTmplt(LinkClose string, targetClose string, hxSwapClose var templ_7745c5c3_Var20 string templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(hxSwapClose) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 120, Col: 29} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnonlabtemplate\mdnonlabtmptmodal.templ`, Line: 128, Col: 29} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) if templ_7745c5c3_Err != nil { @@ -435,3 +452,79 @@ func BtnCloseFormMDNonlabTmplt(LinkClose string, targetClose string, hxSwapClose return templ_7745c5c3_Err }) } + +func BtnSimpanNama(Link string, target string, hxSwap string, modalID string, hxInclude 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_Var22 := templ.GetChildren(ctx) + if templ_7745c5c3_Var22 == nil { + templ_7745c5c3_Var22 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, 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 + }) +}