diff --git a/component/customcheckbox/customcheckboxv1.templ b/component/customcheckbox/customcheckboxv1.templ new file mode 100644 index 0000000..cac9ce4 --- /dev/null +++ b/component/customcheckbox/customcheckboxv1.templ @@ -0,0 +1,25 @@ +package customcheckbox + +import "cpone/models" + +templ MainCustomCheckboxInput(inp models.CustomCheckboxv1Prm) { +
+
+ +
+ +
+
+
+ { inp.ErrorMsg } +
+
+} diff --git a/component/customcheckbox/customcheckboxv1_templ.go b/component/customcheckbox/customcheckboxv1_templ.go new file mode 100644 index 0000000..7c154a4 --- /dev/null +++ b/component/customcheckbox/customcheckboxv1_templ.go @@ -0,0 +1,143 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package customcheckbox + +//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" + +func MainCustomCheckboxInput(inp models.CustomCheckboxv1Prm) 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 + } + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(inp.ErrorMsg) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\customcheckbox\customcheckboxv1.templ`, Line: 22, Col: 17} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + 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 + }) +} diff --git a/component/customdropdown/customdropdown.templ b/component/customdropdown/customdropdown.templ new file mode 100644 index 0000000..49b3b31 --- /dev/null +++ b/component/customdropdown/customdropdown.templ @@ -0,0 +1,61 @@ +package customdropdown; + +import "cpone/models" + +templ MainCustomDropdown(inp models.CustomDropdownv1Prm, listItem templ.Component) { +
+ +
+ { inp.ErrorMsg } +
+
+} + +templ MainCustomDropdownInput(inp models.CustomDropdownv1Prm, listItem templ.Component) { +
+ +
+ { inp.ErrorMsg } +
+
+} + +templ MainCustomDropdownV1(name string, id string, hxTarget string, hxGet string, hxIndicator string, hxTrigger string, hxInclude string, listItem templ.Component) { +
+ +
+} diff --git a/component/customdropdown/customdropdown_templ.go b/component/customdropdown/customdropdown_templ.go new file mode 100644 index 0000000..3430837 --- /dev/null +++ b/component/customdropdown/customdropdown_templ.go @@ -0,0 +1,343 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package customdropdown + +//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" + +func MainCustomDropdown(inp models.CustomDropdownv1Prm, listItem templ.Component) 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 + } + var templ_7745c5c3_Var9 string + templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(inp.ErrorMsg) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\customdropdown\customdropdown.templ`, Line: 22, Col: 17} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) + 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 MainCustomDropdownInput(inp models.CustomDropdownv1Prm, listItem templ.Component) 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_Var10 := templ.GetChildren(ctx) + if templ_7745c5c3_Var10 == nil { + templ_7745c5c3_Var10 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var13 string + templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(inp.ErrorMsg) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\customdropdown\customdropdown.templ`, Line: 39, Col: 17} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) + 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 MainCustomDropdownV1(name string, id string, hxTarget string, hxGet string, hxIndicator string, hxTrigger string, hxInclude string, listItem templ.Component) 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_Var14 := templ.GetChildren(ctx) + if templ_7745c5c3_Var14 == nil { + templ_7745c5c3_Var14 = 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 + }) +} diff --git a/handlers/dev/groupresult.handlers.go b/handlers/dev/groupresult.handlers.go new file mode 100644 index 0000000..19475ab --- /dev/null +++ b/handlers/dev/groupresult.handlers.go @@ -0,0 +1,1378 @@ +package dev_handlers + +import ( + breadcrumbadmin "cpone/component/breadcrumbadmin" + customtextfieldsearch "cpone/component/customtextfieldsearch" + navbarmenu "cpone/component/navbar" + "cpone/component/pagination" + sidebaruserprofile "cpone/component/sidebar_user_profile" + customtoastv2 "cpone/component/toastbootstrap" + "cpone/models" + globalservices "cpone/services" + "cpone/utils" + groupresult "cpone/views/dev/groupresult" + mastermenuusergroup "cpone/views/dev/mastermenuusergroup" + "fmt" + "strconv" + "strings" + + "github.com/a-h/templ" + "github.com/labstack/echo/v4" + "go.uber.org/zap" +) + +type GroupResultService interface { + GetGroupResultByIDV1(id string) (models.GroupResult, error) + GetListBreadCrumb(title string) (models.BreadCrumbV1, error) + EditGroupResult(id string, groupresultname string, groupresultflagpertest string, groupresultflagnonlab string, groupresultresumemcu string) (models.GroupResult, error) + DeleteGroupResult(id string) (models.GroupResult, error) + GetListGroupResult(search string, currentPage int, rowPerPage int) ([]models.GroupResult, int, error) + GetGroupResultResumeMcu() ([]models.GroupResultResumeMcu, error) + AddGroupResult(groupresultname string, groupresultflagpertest string, groupresultflagnonlab string, groupresultresumemcu string) (models.GroupResult, error) +} + +func NewGroupResultHandler(us GroupResultService) *GroupResultHandler { + return &GroupResultHandler{ + GroupResultService: us, + } +} + +type GroupResultHandler struct { + GroupResultService GroupResultService +} + +// PAGINATION +func (lh *GroupResultHandler) HandlerShowGroupResultPaginationV1(c echo.Context) error { + logger, _ := zap.NewProduction() + + search := c.QueryParam("search") + pageparam := c.QueryParam("page") + tableID := c.QueryParam("tableID") + searchID := c.QueryParam("searchID") + + paginationID := c.QueryParam("paginationID") + dialogEditBodyID := c.QueryParam("dialogEditBodyID") + // dialogEditID := c.QueryParam("dialogEditID") + dialogDeleteBodyID := c.QueryParam("dialogDeleteBodyID") + // dialogDeleteID := c.QueryParam("dialogDeleteID") + page, err := strconv.Atoi(pageparam) + if err != nil { + defer logger.Sync() + logger.Info("ERROR CONVERT PAGE PARAM", + zap.Any("page", page), + zap.Any("error ", err), + ) + return err + } + + dataGroupResult, totalpage, err := lh.GroupResultService.GetListGroupResult(search, page, 5) + if err != nil { + defer logger.Sync() + logger.Info("ERROR GET USER GROUP", + zap.Any("error", err), + ) + fmt.Println(dataGroupResult) + return err + } + + contentUserGroupComponent := groupresult.TableGroupResult( + dataGroupResult, tableID, "/dev/groupresultshoweditform", + "#"+dialogEditBodyID, + "outerHTML", + "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "/dev/groupresultshowdeleteform", + "#"+dialogDeleteBodyID, + "outerHTML", + "#dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #dialogEditID") + + userGroupResultPaginationComponent := pagination.PaginationV2(totalpage, + page, + "/dev/groupresultv1pagination", + paginationID, + // "#tableID, #searchID, #"+searchID+", #dropdownID, #"+dropdownID+", #paginationID, #dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID, [name='search'], [name='usergroup']", + "#tableID, #searchID, #"+searchID+", #paginationID, #dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "#"+paginationID, "outerHTML", "", "") + + retval := []templ.Component{contentUserGroupComponent, userGroupResultPaginationComponent} + + return utils.ViewMulti(c, retval) +} + +// HANDLE CLOSE BUTTON +func (lh *GroupResultHandler) HandleCloseForm(c echo.Context) error { + // #dialogAddBodyID, #dialogAddID + + logger, _ := zap.NewProduction() + defer logger.Sync() + + // listItem + dataResultMcu, err := lh.GroupResultService.GetGroupResultResumeMcu() + fmt.Println(dataResultMcu) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultMcu) + return err + } + // Component Dropdown MCU + listItemResultMcuComponent := groupresult.ItemDropdown(dataResultMcu, 0) + + dialogAddBodyID := c.FormValue("dialogAddBodyID") + form := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponent, + dialogAddBodyID, groupresult.HandleJSModalAddGR("")) + return utils.View(c, form) +} + +// CLOSE FORM EDIT +func (lh *GroupResultHandler) HandleCloseFormEdit(c echo.Context) error { + logger, _ := zap.NewProduction() + defer logger.Sync() + + // listItem + dataResultMcu, err := lh.GroupResultService.GetGroupResultResumeMcu() + fmt.Println(dataResultMcu) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultMcu) + return err + } + // Component Dropdown MCU + listItemResultMcuComponent := groupresult.ItemDropdown(dataResultMcu, 0) + + dialogEditBodyID := c.FormValue("dialogEditBodyID") + form := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponent, + dialogEditBodyID, groupresult.HandleJSModalAddGR("")) + return utils.View(c, form) +} + +// LISTING FUNCTION INITIAL +func (lh *GroupResultHandler) HandlerShowGroupResultV1(c echo.Context) error { + + logger, _ := zap.NewProduction() + //get sidebarmenu + + dataMenu, err := globalservices.GetMenu() + fmt.Println(dataMenu) + fmt.Println(err) + if err != nil { + fmt.Println(dataMenu) + return err + } + + //get user login + dataUser, err := globalservices.GetUserLogin() + fmt.Println(dataUser) + fmt.Println(err) + if err != nil { + fmt.Println(dataUser) + return err + } + + // dropdownUserGroupInitial := + + dataGroupResult, totalpage, err := lh.GroupResultService.GetListGroupResult("", 1, 5) + if err != nil { + defer logger.Sync() + logger.Info("ERROR GET USER GROUP", + zap.Any("error", err), + ) + fmt.Println(dataGroupResult) + return err + } + + // si := mastermenuusergroup.ListMasterUserGroupInitial(dataGroupResult) + + defer logger.Sync() + logger.Info("LOAD USER GROUP DEV", + zap.Any("data", dataGroupResult), + ) + + tableID := utils.GenerateRandomID("tablebody") + paginationID := utils.GenerateRandomID("paginationid") + searchID := utils.GenerateRandomID("searchid") + dialogAddID := utils.GenerateRandomID("dialogaddID") + dialogAddBodyID := utils.GenerateRandomID("dialogaddbodyID") + dialogEditID := utils.GenerateRandomID("dialogEditID") + dialogEditBodyID := utils.GenerateRandomID("dialogEditbodyID") + dialogdeleteID := utils.GenerateRandomID("dialogdeleteID") + dialogdeleteBodyID := utils.GenerateRandomID("dialogdeletebodyID") + + paramTitleBreadcrumbConvert := "Master Group Result" + + dataBreadCrumb, err := lh.GroupResultService.GetListBreadCrumb(paramTitleBreadcrumbConvert) + fmt.Println(dataBreadCrumb) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataBreadCrumb) + return err + } + + defer logger.Sync() + logger.Info("LOAD BREADCRUMB DEV", + zap.Any("data", dataBreadCrumb), + ) + + // navbar menu + navbarmenuComponent := navbarmenu.NavbarMenu(dataMenu) + + // navbar user + navbaruserComponent := navbarmenu.Navbar(dataUser) + + // sidebar + sidebaruserprofileComponent := sidebaruserprofile.Navbaruserprofile(dataUser) + + // listItem + dataResultMcu, err := lh.GroupResultService.GetGroupResultResumeMcu() + fmt.Println(dataResultMcu) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultMcu) + return err + } + + defer logger.Sync() + logger.Info("LOAD BREADCRUMB DEV", + zap.Any("data", dataBreadCrumb), + ) + + // Component Dropdown MCU + listItemResultMcuComponent := groupresult.ItemDropdown(dataResultMcu, 0) + + //Component modal add usergroup + // modaladdcomponent := groupresult.EmptyDiv1() + modaladdcomponent := groupresult.GroupResultForm(models.GroupResultFormComponent{ + IDComponent: "formgroupresult", + Link: "/dev/groupresult/add", + HxTarget: "#" + dialogAddBodyID, + HxSwap: "outerHTML", + HxInclude: "#tableID, #paginationID, #searchID, #dialogAddBodyID, #dialogAddID, #dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #dialogEditID, #" + searchID + ", #currpage" + paginationID, + ModalID: dialogAddID, + ModalTitle: "New-Group Result", + DialogBody: groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + Value: "N", + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + Value: "N", + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponent, + dialogAddBodyID, groupresult.HandleJSModalAddGR("")), + DialogAction: groupresult.DialogNewActionV1("/dev/groupresulthandlecloseform", "#"+dialogAddBodyID, "outerHTML", "#"+dialogAddID), + ButtonCLose: groupresult.BtnCloseNewV1("/dev/groupresulthandlecloseform", "#"+dialogAddBodyID, "outerHTML", "#"+dialogAddID), + }) + + //Component modal edit usergroup + // modalEditcomponent := groupresult.EmptyDiv1() + //Component modal edit usergroup + modalEditcomponent := groupresult.GroupResultForm(models.GroupResultFormComponent{ + IDComponent: "formgroupresultedit", + Link: "/dev/groupresult/edit", + HxTarget: "#" + dialogEditBodyID, + HxSwap: "outerHTML", + // HxInclude: "#tableID, #paginationID, #searchID, #dialogEditBodyID, #dialogEditID, #" + searchID + ", #currpage" + paginationID, + HxInclude: "#tableID, #paginationID, #searchID, #dialogEditBodyID, #dialogEditID, #" + searchID + ", #currpage" + paginationID + ", #dialogDeleteBodyID, #dialogDeleteID", + ModalID: dialogEditID, + ModalTitle: "Edit-Group Result", + DialogBody: groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + Value: "N", + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + Value: "N", + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponent, + dialogEditBodyID, groupresult.HandleJSModalAddGR("")), + DialogAction: groupresult.DialogNewActionV1("/dev/groupresulthandlecloseformedit", "#"+dialogEditBodyID, "outerHTML", "#"+dialogEditID), + ButtonCLose: groupresult.BtnCloseNewV1("/dev/groupresulthandlecloseformedit", "#"+dialogEditBodyID, "outerHTML", "#"+dialogEditID), + }) + + //Component modal delete usergroup + // modalDeletecomponent := groupresult.EmptyDiv1() + //Component modal delete usergroup + modalDeletecomponent := groupresult.GroupResultForm(models.GroupResultFormComponent{ + IDComponent: "formgroupresultdelete", + Link: "/dev/groupresult/delete", + HxTarget: "#" + dialogdeleteBodyID, + HxSwap: "outerHTML", + // HxInclude: "#tableID, #paginationID, #searchID, #dialogDeleteBodyID, #dialogDeleteID, #" + searchID + ", #currpage" + paginationID, + HxInclude: "#tableID, #paginationID, #searchID, #dialogDeleteBodyID, #dialogDeleteID, #" + searchID + ", #currpage" + paginationID + ", #dialogEditBodyID, #dialogEditID", + ModalID: dialogdeleteID, + ModalTitle: "Delete-User Group", + DialogBody: groupresult.DeleteConfirmationBody( + models.CustomTextFieldv2Prm{Type: "hidden", Value: "0", Name: "groupresultid"}, + dialogdeleteBodyID, "Apakah anda yakin menghapus user group berikut ?", + []string{"GROUP RESULT NAME", "RESULT FLAG PER TEST", "RESULT FLAG NON LAB", "RESULT RESUME MCU"}, + []string{"", "", "", ""}, + groupresult.HandleJSModalAddGR(""), + ), + DialogAction: groupresult.DialogNewActionV1("/dev/usergrouphandlecloseformdelete", "#"+dialogdeleteBodyID, "outerHTML", "#"+dialogdeleteID), + ButtonCLose: groupresult.BtnCloseNewV1("/dev/usergrouphandlecloseformdelete", "#"+dialogdeleteBodyID, "outerHTML", "#"+dialogdeleteID), + }) + + //table listing user group component + contentUserGroupComponent := groupresult.TableGroupResult( + dataGroupResult, tableID, + "/dev/groupresultshoweditform", + "#"+dialogEditBodyID, + "outerHTML", + "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "/dev/groupresultshowdeleteform", + "#"+dialogdeleteBodyID, + "outerHTML", + "#dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #dialogEditID") + + //filter user search component + // customtextfieldsearch.MainCustomTextFieldSearchV1("#"+contentIDSearch, "q", "Cari Nama Staff / Email", "text", "/dev/searchgroupresultv1?"+link, "input changed delay:500ms, search", "#"+contentID, "#indicator", "", contentIDHtmxExtension, "[name='usergroup']") + + userFilterComp := customtextfieldsearch.MainCustomTextFieldSearchV2( + searchID, + "search", + "Cari Group Result Name / Result Resume Mcu", + "text", + "/dev/searchgroupresultv1", + "input changed delay:500ms, search", + "#"+paginationID, "", "", "outerHTML", + "#tableID, #paginationID, #searchID, #dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID") + + // pagination usergroup component + userGroupResultPaginationComponent := pagination.PaginationV2( + totalpage, + 1, + "/dev/groupresultv1pagination", + paginationID, + "#tableID, #searchID, #"+searchID+", #paginationID, #dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "#"+paginationID, + "outerHTML", "", "", + ) + + //Show user group screen + si := groupresult.ShowGroupResultV1x( + "Group Result", + groupresult.ContentGroupResultV1( + tableID, + paginationID, + searchID, + dialogAddID, + dialogAddBodyID, + dialogEditID, + dialogEditBodyID, + dialogdeleteID, + dialogdeleteBodyID, + breadcrumbadmin.MainBreadcrumbAdminV1(dataBreadCrumb), + contentUserGroupComponent, + userFilterComp, + userGroupResultPaginationComponent, + modaladdcomponent, + modalEditcomponent, + modalDeletecomponent, + ), + + groupresult.CssMasterGroupResultV1x(), + groupresult.JSkuGroupResultV1(), + navbarmenuComponent, + navbaruserComponent, + sidebaruserprofileComponent, + ) + + return utils.View(c, si) +} + +// PROSES ADD DATA +func (lh *GroupResultHandler) AddGroupResult(c echo.Context) error { + logger, _ := zap.NewProduction() + defer logger.Sync() + + //prm form addusergroup + + // DARI FORM ADD NYA + groupresultname := c.FormValue("groupresultname") + groupresultflagpertest := c.FormValue("groupresultflagpertest") + groupresultflagnonlab := c.FormValue("groupresultflagnonlab") + groupresultresumemcu := c.FormValue("groupresultresumemcu") + + // setting flag test dan flagnonlab + var flagPerTest string = "N" + var flagNonLab string = "N" + // var mcuResumeSelectedValue int = 0 + + // OTHER + tableID := c.FormValue("tableID") + paginationID := c.FormValue("paginationID") + + // groupresultid := c.FormValue("groupresultid") + searchID := c.FormValue("searchID") + search := c.FormValue("search") + currPagePrm := c.FormValue("currpage" + paginationID) + // #dialogAddBodyID, #dialogAddID + dialogAddBodyID := c.FormValue("dialogAddBodyID") + dialogAddID := c.FormValue("dialogAddID") + dialogEditBodyID := c.FormValue("dialogEditBodyID") + // dialogEditID := c.FormValue("dialogEditID") + dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID") + // dialogDeleteID := c.FormValue("dialogDeleteID") + + currPage, err := strconv.Atoi(currPagePrm) + + if err != nil { + return err + } + logger.Info("ADD USER GROUP PARAM", + zap.Any("groupresultname", groupresultname), + zap.Any("groupresultflagpertest", groupresultflagpertest), + zap.Any("groupresultflagnonlab", groupresultflagnonlab), + zap.Any("groupresultresumemcu", groupresultresumemcu), + zap.Any("tableid", tableID), + zap.Any("search", search), + zap.Any("currpage", currPage), + ) + + // listItem + dataResultMcu, err := lh.GroupResultService.GetGroupResultResumeMcu() + fmt.Println(dataResultMcu) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultMcu) + return err + } + // Component Dropdown MCU + listItemResultMcuComponent := groupresult.ItemDropdown(dataResultMcu, 0) + + // check dropdown result mcu + var idSelectedGroupResultResumeMcu int + idSelectedGroupResultResumeMcu, err = strconv.Atoi(groupresultresumemcu) + if err != nil { + // Tangani kesalahan konversi + fmt.Println("Error converting string to int:", err) + // return + test := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponent, + dialogAddBodyID, groupresult.HandleJSModalAddGR(""), + ) + coba := utils.ViewMulti(c, []templ.Component{ + customtoastv2.CustomToastV2Show("Error", "Error converting string to int", "error"), + test}) + return coba + } + + var groupresultresumemcuNew string + for _, x := range dataResultMcu { + if x.ID == idSelectedGroupResultResumeMcu { + groupresultresumemcuNew = x.Text + // mcuResumeSelectedValue = x.ID + } + } + + // check group result flag per test + if groupresultflagpertest == "on" { + flagPerTest = "Y" + } + + // check group result flag non lab + if groupresultflagnonlab == "on" { + flagNonLab = "Y" + } + + //Form Validation + if strings.TrimSpace(groupresultname) == "" { + // Component Dropdown MCU + listItemResultMcuComponent := groupresult.ItemDropdown(dataResultMcu, idSelectedGroupResultResumeMcu) + test := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Value: groupresultname, + ErrorMsg: "Group Result Name Kosong", + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + Value: groupresultflagpertest, + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + Value: groupresultflagnonlab, + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponent, + dialogAddBodyID, groupresult.HandleJSModalAddGR(""), + ) + coba := utils.ViewMulti(c, []templ.Component{ + customtoastv2.CustomToastV2Show("Warning", "Group Result Name Kosong", "warning"), + test}) + return coba + + } + + //Add user group service + dataGroupResultAdd, err := lh.GroupResultService.AddGroupResult(groupresultname, flagPerTest, flagNonLab, groupresultresumemcuNew) + + if err != nil { + logger.Info("Error", + zap.Any("Error", err), + zap.Any("groupresultname", groupresultname), + zap.Any("groupresultflagpertest", groupresultflagpertest), + zap.Any("groupresultflagnonlab", groupresultflagnonlab), + zap.Any("groupresultresumemcu", groupresultresumemcu), + ) + + test := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Value: groupresultname, + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + Value: groupresultflagpertest, + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + Value: groupresultflagnonlab, + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponent, + dialogAddBodyID, groupresult.HandleJSModalAddGR("")) + coba := utils.ViewMulti(c, []templ.Component{ + customtoastv2.CustomToastV2Show("Error", err.Error(), "danger"), + test}) + return coba + } + logger.Info("ADD USER GROUP", + zap.Any("return", dataGroupResultAdd), + zap.Any("groupresultname", groupresultname), + zap.Any("groupresultflagpertest", groupresultflagpertest), + zap.Any("groupresultflagnonlab", groupresultflagnonlab), + zap.Any("groupresultresumemcu", groupresultresumemcu), + ) + + //Get data table current page + dataGroupResultList, totalpage, err := lh.GroupResultService.GetListGroupResult(search, currPage, 5) + if err != nil { + defer logger.Sync() + logger.Info("ERROR GET USER GROUP", + zap.Any("error", err), + ) + return err + } + + //New add form + newForm := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponent, + dialogAddBodyID, groupresult.HandleJSModalAddGR("#"+dialogAddID)) + + //new table listing + contentUserGroupComponent := groupresult.TableGroupResult( + dataGroupResultList, tableID, + "/dev/usergroupshoweditform", + "#"+dialogEditBodyID, + "outerHTML", + "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "/dev/groupresultshowdeleteform", + "#"+dialogDeleteBodyID, + "outerHTML", + "#dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #dialogEditID") + + //new pagination + userGroupPaginationComponent := pagination.PaginationV2(totalpage, + 1, + "/dev/groupresultv1pagination", + paginationID, + "#tableID, #searchID, #"+searchID+", #paginationID, #dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "#"+paginationID, "outerHTML", "", "true") + + toastSuccess := customtoastv2.CustomToastV2Show("Success", "Success add group result "+groupresultname, "success") + + retval := []templ.Component{toastSuccess, contentUserGroupComponent, userGroupPaginationComponent, newForm} + + return utils.ViewMulti(c, retval) +} + +// SEARCH PROSES +func (lh *GroupResultHandler) HandlerShowGroupResultSearchV1(c echo.Context) error { + search := c.QueryParam("search") + searchID := c.QueryParam("searchID") + tableID := c.QueryParam("tableID") + paginationID := c.QueryParam("paginationID") + dialogEditBodyID := c.QueryParam("dialogEditBodyID") + // dialogEditID := c.QueryParam("dialogEditID") + dialogDeleteBodyID := c.QueryParam("dialogDeleteBodyID") + // dialogDeleteID := c.QueryParam("dialogDeleteID") + + logger, _ := zap.NewProduction() + + dataGroupResult, totalpage, err := lh.GroupResultService.GetListGroupResult(search, 1, 5) + if err != nil { + defer logger.Sync() + logger.Info("ERROR GET USER GROUP", + zap.Any("error", err), + ) + fmt.Println(dataGroupResult) + return err + } + + // totalPages := int(math.Ceil(float64(len(dataUserGroupFiltered)) / float64(rowPerPage))) + + contentUserGroupComponent := groupresult.TableGroupResult( + dataGroupResult, tableID, "/dev/usergroupshoweditform", + "#"+dialogEditBodyID, + "outerHTML", + "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "/dev/groupresultshowdeleteform", + "#"+dialogDeleteBodyID, + "outerHTML", + "#dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #dialogEditID") + + userGroupResultPaginationComponent := pagination.PaginationV2(totalpage, + 1, + "/dev/groupresultv1pagination", + paginationID, + "#tableID, #searchID, #"+searchID+", #paginationID, #dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "#"+paginationID, + "outerHTML", + "", + "", + ) + + // swapTable := + // mastermenuusergroup.SwapTableUserGroup(userGroupResultPaginationComponent, contentUserGroupComponent) + retval := []templ.Component{contentUserGroupComponent, userGroupResultPaginationComponent} + + return utils.ViewMulti(c, retval) + // return utils.View(c, si) +} + +// FORM EDIT SHOW +func (lh *GroupResultHandler) HandleEditForm(c echo.Context) error { + println("Masuk change edit form") + + logger, _ := zap.NewProduction() + defer logger.Sync() + + id := c.QueryParam("id") + dialogEditID := c.QueryParam("dialogEditID") + dialogEditBodyID := c.QueryParam("dialogEditBodyID") + + // listItem + dataResultMcu, err := lh.GroupResultService.GetGroupResultResumeMcu() + fmt.Println(dataResultMcu) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultMcu) + return err + } + // Component Dropdown MCU default + listItemResultMcuComponent := groupresult.ItemDropdown(dataResultMcu, 0) + + // get data by id + dataGroupList, err := lh.GroupResultService.GetGroupResultByIDV1(id) + if err != nil { + test := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponent, + dialogEditBodyID, groupresult.HandleJSModalAddGRShow("#"+dialogEditID)) + coba := utils.ViewMulti(c, []templ.Component{ + customtoastv2.CustomToastV2Show("Error", err.Error(), "danger"), + test}) + return coba + + } + + // Component Dropdown MCU + var idSelectedGroupResultResumeMcu int = 0 + for _, x := range dataResultMcu { + if x.Text == dataGroupList.Group_ResultResumeMcu { + idSelectedGroupResultResumeMcu = x.ID + } + } + + listItemResultMcuComponentPopulate := groupresult.ItemDropdown(dataResultMcu, idSelectedGroupResultResumeMcu) + form := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + Value: strconv.Itoa(dataGroupList.Group_ResultID), + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Type: "text", ID: "groupresultname", + Value: dataGroupList.Group_ResultName, + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + Value: dataGroupList.Group_ResultFlagPerTest, + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + Value: dataGroupList.Group_ResultFlagNonLab, + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponentPopulate, + dialogEditBodyID, groupresult.HandleJSModalAddGRShow("#"+dialogEditID)) + coba := utils.ViewMulti(c, []templ.Component{form}) + return coba + +} + +// PROSES EDIT DATA +func (lh *GroupResultHandler) EditGroupResult(c echo.Context) error { + + logger, _ := zap.NewProduction() + defer logger.Sync() + + // DARI FORM ADD NYA + groupresultname := c.FormValue("groupresultname") + groupresultflagpertest := c.FormValue("groupresultflagpertest") + groupresultflagnonlab := c.FormValue("groupresultflagnonlab") + groupresultresumemcu := c.FormValue("groupresultresumemcu") + + // setting flag test dan flagnonlab + var flagPerTest string = "N" + var flagNonLab string = "N" + + id := c.FormValue("groupresultid") + tableID := c.FormValue("tableID") + paginationID := c.FormValue("paginationID") + searchID := c.FormValue("searchID") + search := c.FormValue("search") + dialogEditBodyID := c.FormValue("dialogEditBodyID") + dialogEditID := c.FormValue("dialogEditID") + dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID") + currPagePrm := c.FormValue("currpage" + paginationID) + + currPage, err := strconv.Atoi(currPagePrm) + + if err != nil { + return err + } + logger.Info("Edit USER GROUP PARAM", + zap.Any("id", id), + zap.Any("groupresultname", groupresultname), + zap.Any("groupresultflagpertest", groupresultflagpertest), + zap.Any("groupresultflagnonlab", groupresultflagnonlab), + zap.Any("groupresultresumemcu", groupresultresumemcu), + zap.Any("tableid", tableID), + zap.Any("search", search), + zap.Any("currpage", currPage), + ) + + // listItem + dataResultMcu, err := lh.GroupResultService.GetGroupResultResumeMcu() + fmt.Println(dataResultMcu) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultMcu) + return err + } + + // Component Dropdown MCU + listItemResultMcuComponentInitial := groupresult.ItemDropdown(dataResultMcu, 0) + + // check dropdown result mcu + var idSelectedGroupResultResumeMcu int + idSelectedGroupResultResumeMcu, err = strconv.Atoi(groupresultresumemcu) + if err != nil { + // Tangani kesalahan konversi + fmt.Println("Error converting string to int:", err) + // return + test := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponentInitial, + dialogEditBodyID, groupresult.HandleJSModalAddGR(""), + ) + coba := utils.ViewMulti(c, []templ.Component{ + customtoastv2.CustomToastV2Show("Error", "Error converting string to int", "error"), + test}) + return coba + } + + var groupresultresumemcuNew string + for _, x := range dataResultMcu { + if x.ID == idSelectedGroupResultResumeMcu { + groupresultresumemcuNew = x.Text + } + } + + // check group result flag per test + if groupresultflagpertest == "on" { + flagPerTest = "Y" + } + + // check group result flag non lab + if groupresultflagnonlab == "on" { + flagNonLab = "Y" + } + + if strings.TrimSpace(groupresultname) == "" { + listItemResultMcuComponent := groupresult.ItemDropdown(dataResultMcu, idSelectedGroupResultResumeMcu) + test := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + Value: id, + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + ErrorMsg: "Group Result Name Kosong", + Value: groupresultname, + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + Value: groupresultflagpertest, + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + Value: groupresultflagnonlab, + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponent, + dialogEditBodyID, groupresult.HandleJSModalAddGR("")) + coba := utils.ViewMulti(c, []templ.Component{ + customtoastv2.CustomToastV2Show("Warning", "Code and name cannot empty", "warning"), + test}) + return coba + } + + dataUserGroup, err := lh.GroupResultService.EditGroupResult(id, groupresultname, flagPerTest, flagNonLab, groupresultresumemcuNew) + + if err != nil { + listItemResultMcuComponent := groupresult.ItemDropdown(dataResultMcu, idSelectedGroupResultResumeMcu) + logger.Info("Error", + zap.Any("Error", err), + zap.Any("groupresultname", groupresultname), + zap.Any("groupresultflagpertest", groupresultflagpertest), + zap.Any("groupresultflagnonlab", groupresultflagnonlab), + zap.Any("groupresultresumemcu", groupresultresumemcu), + ) + + test := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + Value: id, + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Value: groupresultname, + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + Value: groupresultflagpertest, + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + Value: groupresultflagnonlab, + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponent, + dialogEditBodyID, groupresult.HandleJSModalAddGR("")) + coba := utils.ViewMulti(c, []templ.Component{ + customtoastv2.CustomToastV2Show("Error", err.Error(), "danger"), + test}) + return coba + } + logger.Info("ADD USER GROUP", + zap.Any("return", dataUserGroup), + zap.Any("groupresultname", groupresultname), + zap.Any("groupresultflagpertest", groupresultflagpertest), + zap.Any("groupresultflagnonlab", groupresultflagnonlab), + zap.Any("groupresultresumemcu", groupresultresumemcu), + ) + dataGroupList, totalpage, err := lh.GroupResultService.GetListGroupResult(search, currPage, 5) + if err != nil { + defer logger.Sync() + logger.Info("ERROR GET GROUP RESULT", + zap.Any("error", err), + ) + return err + } + + newForm := groupresult.DialogNewBodyV1( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }, + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Type: "text", ID: "groupresultname"}, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + }, + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + }, + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItemResultMcuComponentInitial, + dialogEditBodyID, groupresult.HandleJSModalAddGR("#"+dialogEditID)) + + contentUserGroupComponent := groupresult.TableGroupResult( + dataGroupList, tableID, "/dev/groupresultshoweditform", + "#"+dialogEditBodyID, + "outerHTML", + "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "/dev/groupresultshowdeleteform", + "#"+dialogDeleteBodyID, + "outerHTML", + "#dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #dialogEditID") + + userGroupPaginationComponent := pagination.PaginationV2(totalpage, + currPage, + "/dev/groupresultv1pagination", + paginationID, + "#tableID, #searchID, #"+searchID+", #paginationID, #dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "#"+paginationID, "outerHTML", "", "true") + + toastSuccess := customtoastv2.CustomToastV2Show("Success", "Success edit Group Result Name : "+groupresultname, "success") + retval := []templ.Component{toastSuccess, contentUserGroupComponent, userGroupPaginationComponent, newForm} + // time.Sleep(20 * time.Second) + return utils.ViewMulti(c, retval) +} + +// FORM DELETE SHOW +func (lh *GroupResultHandler) HandleDeleteForm(c echo.Context) error { + id := c.QueryParam("id") + dialogDeleteID := c.QueryParam("dialogDeleteID") + dialogDeleteBodyID := c.QueryParam("dialogDeleteBodyID") + + dataGroupList, err := lh.GroupResultService.GetGroupResultByIDV1(id) + if err != nil { + // test := mastermenuusergrouptryandy.DialogNewBody(code, name, "", "Name cannot empty") + test := groupresult.DeleteConfirmationBody( + models.CustomTextFieldv2Prm{Type: "hidden", Value: "0", Name: "groupresultid"}, + dialogDeleteBodyID, "Apakah anda yakin menghapus user group berikut ?", + []string{"GROUP RESULT NAME", "RESULT FLAG PER TEST", "RESULT FLAG NON LAB", "RESULT RESUME MCU"}, + []string{"", "", "", ""}, + groupresult.HandleJSModalAddGR(""), + ) + coba := utils.ViewMulti(c, []templ.Component{ + customtoastv2.CustomToastV2Show("Error", err.Error(), "danger"), + test}) + return coba + } + + form := groupresult.DeleteConfirmationBody( + models.CustomTextFieldv2Prm{Type: "hidden", Value: strconv.Itoa(dataGroupList.Group_ResultID), Name: "groupresultid"}, + dialogDeleteBodyID, "Apakah anda yakin menghapus user group berikut ?", + []string{"GROUP RESULT NAME", "RESULT FLAG PER TEST", "RESULT FLAG NON LAB", "RESULT RESUME MCU"}, + []string{dataGroupList.Group_ResultName, dataGroupList.Group_ResultFlagPerTest, dataGroupList.Group_ResultFlagNonLab, dataGroupList.Group_ResultResumeMcu}, + groupresult.HandleJSModalAddGRShow("#"+dialogDeleteID), + ) + coba := utils.ViewMulti(c, []templ.Component{form}) + return coba +} + +// CLOSE FORM DELETE +func (lh *GroupResultHandler) HandleCloseFormDelete(c echo.Context) error { + dialogDeleteID := c.FormValue("dialogDeleteID") + dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID") + form := groupresult.DeleteConfirmationBody( + models.CustomTextFieldv2Prm{Type: "hidden", Value: "0", Name: "groupresultid"}, + dialogDeleteBodyID, "Apakah anda yakin menghapus user group berikut ?", + []string{"GROUP RESULT NAME", "RESULT FLAG PER TEST", "RESULT FLAG NON LAB", "RESULT RESUME MCU"}, + []string{"", "", "", ""}, + groupresult.HandleJSModalAddGR("#"+dialogDeleteID)) + return utils.View(c, form) +} + +// PROSES DELETE +func (lh *GroupResultHandler) DeleteGroupResult(c echo.Context) error { + + logger, _ := zap.NewProduction() + defer logger.Sync() + + id := c.FormValue("groupresultid") + tableID := c.FormValue("tableID") + paginationID := c.FormValue("paginationID") + searchID := c.FormValue("searchID") + search := c.FormValue("search") + currPagePrm := c.FormValue("currpage" + paginationID) + dialogDeleteID := c.FormValue("dialogDeleteID") + dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID") + // dialogEditID := c.FormValue("dialogEditID") + dialogEditBodyID := c.FormValue("dialogEditBodyID") + + currPage, err := strconv.Atoi(currPagePrm) + + if err != nil { + return err + } + + dataGrupResult, err := lh.GroupResultService.DeleteGroupResult(id) + + if err != nil { + logger.Info("Error", + zap.Any("Error", err), + zap.Any("prm", id), + ) + return err + } + logger.Info("DELETE USER GROUP handler", + zap.Any("return", dataGrupResult), + zap.Any("prm", id), + ) + dataGroupList, totalpage, err := lh.GroupResultService.GetListGroupResult(search, currPage, 5) + if err != nil { + defer logger.Sync() + logger.Info("ERROR GET USER GROUP", + zap.Any("error", err), + ) + return err + } + newForm := mastermenuusergroup.DeleteConfirmationBody( + models.CustomTextFieldv2Prm{Type: "hidden", Value: "0", Name: "usergroupid"}, + dialogDeleteBodyID, "Apakah anda yakin menghapus user group berikut ?", + []string{"Kode", "User Group"}, + []string{"", ""}, + mastermenuusergroup.HandleJSModalAddUG("#"+dialogDeleteID), + ) + if len(dataGroupList) == 0 && totalpage > 1 { + currPage = currPage - 1 + dataGroupList, _, err = lh.GroupResultService.GetListGroupResult(search, currPage, 5) + if err != nil { + defer logger.Sync() + logger.Info("ERROR GET GROUP RESULT", + zap.Any("error", err), + ) + return err + } + } + contentUserGroupComponent := groupresult.TableGroupResult( + dataGroupList, tableID, + "/dev/groupresultshoweditform", + "#"+dialogEditBodyID, + "outerHTML", + "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "/dev/groupresultshowdeleteform", + "#"+dialogDeleteBodyID, + "outerHTML", + "#dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #dialogEditID") + + groupResultPaginationComponent := pagination.PaginationV2(totalpage, + currPage, + "/dev/groupresultv1pagination", + paginationID, + "#tableID, #searchID, #"+searchID+", #paginationID, #dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "#"+paginationID, "outerHTML", "", "true") + + toastSuccess := customtoastv2.CustomToastV2Show("Success", "Success delete group result ", "success") + retval := []templ.Component{toastSuccess, contentUserGroupComponent, groupResultPaginationComponent, newForm} + // time.Sleep(20 * time.Second) + return utils.ViewMulti(c, retval) +} diff --git a/handlers/routes.go b/handlers/routes.go index 84520a4..8989bd5 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -247,4 +247,19 @@ 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) } diff --git a/models/customcheckbox.models.go b/models/customcheckbox.models.go new file mode 100644 index 0000000..ba456db --- /dev/null +++ b/models/customcheckbox.models.go @@ -0,0 +1,18 @@ +package models + +// name string, id string, hxTarget string, hxGet string, hxIndicator string, hxTrigger string, hxInclude string, + +type CustomCheckboxv1Prm struct { + HxTarget string `default:"hxTarget"` + HxGet string `default:"hxGet"` + HxIndicator string `default:"hxIndicator"` + HxInclude string `default:"hxInclude"` + HxTrigger string `default:"hxTrigger"` + Label string `default:"Label"` + Name string `default:"name"` + Text string `default:"text"` + // Type string `default:"text"` + Value string `default:""` + ErrorMsg string `default:""` + ID string +} diff --git a/models/customdropdown.models.go b/models/customdropdown.models.go new file mode 100644 index 0000000..7bc3001 --- /dev/null +++ b/models/customdropdown.models.go @@ -0,0 +1,18 @@ +package models + +// name string, id string, hxTarget string, hxGet string, hxIndicator string, hxTrigger string, hxInclude string, + +type CustomDropdownv1Prm struct { + HxTarget string `default:"hxTarget"` + HxGet string `default:"hxGet"` + HxIndicator string `default:"hxIndicator"` + HxInclude string `default:"hxInclude"` + HxTrigger string `default:"hxTrigger"` + Label string `default:"Label"` + Name string `default:"name"` + // Placeholder string `default:"Placeholder"` + // Type string `default:"text"` + // Value string `default:""` + ErrorMsg string `default:""` + ID string +} diff --git a/models/groupresult.models.go b/models/groupresult.models.go new file mode 100644 index 0000000..fc6146d --- /dev/null +++ b/models/groupresult.models.go @@ -0,0 +1,38 @@ +package models + +import "github.com/a-h/templ" + +type GroupResultResumeMcu struct { + Text string `default:"text"` + ID int `default:"id"` +} + +type GroupResult struct { + Nomor string `db:"nomor"` + Group_ResultID int `db:"Group_ResultID"` + Group_ResultName string `db:"Group_ResultName"` + Group_ResultFlagPerTest string `db:"Group_ResultFlagPerTest"` + Group_ResultFlagNonLab string `db:"Group_ResultFlagNonLab"` + Group_ResultResumeMcu string `db:"Group_ResultResumeMcu"` + Group_ResultIsActive string `db:"Group_ResultIsActive"` +} + +// form component +type GroupResultFormComponent struct { + IDComponent string + Link string + HxTarget string + HxSwap string + HxInclude string + ModalID string + ModalTitle string + InputGroupResultName CustomTextFieldv2Prm + InputGroupResult CustomTextFieldv2Prm + CheckboxGroupResultFlagPerTest CustomCheckboxv1Prm + CheckboxGroupResultFlagNonLab CustomCheckboxv1Prm + InputID CustomTextFieldv2Prm + DropdownGroupResultResumeMcu CustomDropdownv1Prm + DialogBody templ.Component + DialogAction templ.Component + ButtonCLose templ.Component +} diff --git a/services/dev/groupresult.services.go b/services/dev/groupresult.services.go new file mode 100644 index 0000000..51b5ae1 --- /dev/null +++ b/services/dev/groupresult.services.go @@ -0,0 +1,878 @@ +package dev_services + +import ( + "cpone/db" + "cpone/models" + "fmt" + "math" + "strconv" + "strings" + + dbx "cpone/package/database" + + "go.uber.org/zap" +) + +func NewServicesGroupResult(uStore db.AppStore) *ServicesGroupResult { + + return &ServicesGroupResult{ + GroupResultStore: uStore, + } +} + +type ServicesGroupResult struct { + GroupResultStore db.AppStore +} + +func (su *ServicesGroupResult) GetMasterMenus() ([]MasterMenu, error) { + + // dummyBreadcrumb := []Breadcrumb{ + // { + // Name: "Dashboard", + // Url: "/client/dashboard", + // }, + // { + // Name: "Front Office", + // Url: "/client/usermanagement", + // }, + // } + + dummyMenu := []MasterMenu{ + // 1. Dashboard + { + ID: "1", + ParentMenuID: "0", + ParentMenuName: "Dashboard", + ParentUrl: "/client/md/dashboard", + ParentIcon: "", + Children: []ChildrenMenu{ + { + ChildrenParentID: "1", + ChildrenMenuID: "1", + ChildrenMenuName: "Master User", + ChildrenMenuURL: "/client/md/user", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "Y", + // }, + // }, + }, + }, + }, + + // 2. Front Office + { + ID: "2", + ParentMenuID: "1", + ParentMenuName: "Front Office", + ParentUrl: "#", + ParentIcon: "", + Children: []ChildrenMenu{ + { + ChildrenParentID: "1", + ChildrenMenuID: "1", + ChildrenMenuName: "Registrasi", + ChildrenMenuURL: "/fo/registrasi", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User", + // IsActive: "Y", + // }, + // }, + }, + }, + }, + + // 3. Station + { + ID: "3", + ParentMenuID: "2", + ParentMenuName: "Station", + ParentUrl: "#", + ParentIcon: "", + Children: []ChildrenMenu{ + { + ChildrenParentID: "2", + ChildrenMenuID: "1", + ChildrenMenuName: "Sample Station", + ChildrenMenuURL: "/station/sample", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User", + // IsActive: "Y", + // }, + // }, + }, + }, + }, + + // 4. Management MCU + { + ID: "4", + ParentMenuID: "3", + ParentMenuName: "Management MCU", + ParentUrl: "#", + ParentIcon: "", + Children: []ChildrenMenu{ + { + ChildrenParentID: "3", + ChildrenMenuID: "1", + ChildrenMenuName: "Setup MCU", + ChildrenMenuURL: "/mcu/setup", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User", + // IsActive: "Y", + // }, + // }, + }, + { + ChildrenParentID: "3", + ChildrenMenuID: "2", + ChildrenMenuName: "Pre-Registrasi", + ChildrenMenuURL: "/mcu/preregister", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User", + // IsActive: "Y", + // }, + // }, + }, + }, + }, + + // 5. Master Data + { + ID: "5", + ParentMenuID: "4", + ParentMenuName: "Master Data", + ParentUrl: "#", + ParentIcon: "", + Children: []ChildrenMenu{ + // * Master User + { + ChildrenParentID: "4", + ChildrenMenuID: "1", + ChildrenMenuName: "Master User", + ChildrenMenuURL: "/client/md/user", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User", + // IsActive: "Y", + // }, + // }, + }, + + // * Master User Group + { + ChildrenParentID: "4", + ChildrenMenuID: "2", + ChildrenMenuName: "Master User Group", + ChildrenMenuURL: "/client/md/usergroup", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Master Corporate + { + ChildrenParentID: "4", + ChildrenMenuID: "3", + ChildrenMenuName: "Corporate", + ChildrenMenuURL: "/client/md/corp", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Test + { + ChildrenParentID: "4", + ChildrenMenuID: "4", + ChildrenMenuName: "Test", + ChildrenMenuURL: "/client/md/test", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Bahan + { + ChildrenParentID: "4", + ChildrenMenuID: "5", + ChildrenMenuName: "Bahan", + ChildrenMenuURL: "/client/md/bahan", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Sample Type + { + ChildrenParentID: "4", + ChildrenMenuID: "6", + ChildrenMenuName: "Sample Type", + ChildrenMenuURL: "/client/sample/type", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Sample Station + { + ChildrenParentID: "4", + ChildrenMenuID: "7", + ChildrenMenuName: "Sample Station", + ChildrenMenuURL: "/station/sample", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Result Non Lab + { + ChildrenParentID: "4", + ChildrenMenuID: "8", + ChildrenMenuName: "Result Non Lab", + ChildrenMenuURL: "/client/md/resultnonlab", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Template Fisik + { + ChildrenParentID: "4", + ChildrenMenuID: "9", + ChildrenMenuName: "Template Fisik", + ChildrenMenuURL: "/client/md/template-fisik", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Pasien + { + ChildrenParentID: "4", + ChildrenMenuID: "10", + ChildrenMenuName: "Pasien", + ChildrenMenuURL: "/client/md/pasien", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Dokter + { + ChildrenParentID: "4", + ChildrenMenuID: "11", + ChildrenMenuName: "Dokter", + ChildrenMenuURL: "/client/md/dokter", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Paket + { + ChildrenParentID: "4", + ChildrenMenuID: "12", + ChildrenMenuName: "Paket", + ChildrenMenuURL: "/client/md/paket", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Harga Single + { + ChildrenParentID: "4", + ChildrenMenuID: "13", + ChildrenMenuName: "Harga Single", + ChildrenMenuURL: "/client/md/hargasingle", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + }, + }, + } + + return dummyMenu, nil +} + +func (ug *ServicesGroupResult) GetUserGroup() ([]models.UserGroup, error) { + data := []models.UserGroup{ + {UserGroupID: 1, UserGroupKode: "A", UserGroupName: "UG1"}, + {UserGroupID: 2, UserGroupKode: "B", UserGroupName: "UG2"}, + {UserGroupID: 3, UserGroupKode: "C", UserGroupName: "UG3"}, + } + return data, nil +} + +func (su *ServicesGroupResult) GetListBreadCrumb(title string) (models.BreadCrumbV1, error) { + var ret models.BreadCrumbV1 + + dummyBreadcrumb := []models.BreadCrumbV1{ + { + Title: "Master User Group", + Item: []models.ItemBreadCrumbV1{ + { + Item: "Dashboard", + Url: "/dev/dashboard", + }, + { + Item: "Master", + Url: "/dev/master", + }, + { + Item: "User Group", + Url: "", + }, + }, + }, + + { + Title: "Master User", + Item: []models.ItemBreadCrumbV1{ + { + Item: "Dashboard", + Url: "/dev/dashboard", + }, + { + Item: "Master", + Url: "/dev/master", + }, + { + Item: "User", + Url: "", + }, + }, + }, + + { + Title: "Master Group Result", + Item: []models.ItemBreadCrumbV1{ + { + Item: "Dashboard", + Url: "/dev/dashboard", + }, + { + Item: "Master", + Url: "/dev/master", + }, + { + Item: "Group Result", + Url: "", + }, + }, + }, + } + + for _, breadcrumb := range dummyBreadcrumb { + // if utils.Contains(breadcrumb.Title, title) { + // ret = breadcrumb + // return ret, nil + // } + if breadcrumb.Title == title { + ret = breadcrumb + return ret, nil + } + } + + return ret, nil +} + +// (LAB, NONLAB, FISIK, DOCTOR) +// hardcore group result resume mcu +func (ug *ServicesGroupResult) GetGroupResultResumeMcu() ([]models.GroupResultResumeMcu, error) { + data := []models.GroupResultResumeMcu{ + { + ID: 1, + Text: "LAB", + }, + { + ID: 2, + Text: "NONLAB", + }, + { + ID: 3, + Text: "FISIK", + }, + { + ID: 4, + Text: "DOCTOR", + }, + } + return data, nil +} + +// versi 2 +func (su *ServicesGroupResult) GetListGroupResult(search string, currentPage int, rowPerPage int) ([]models.GroupResult, int, error) { + var groupresultList []models.GroupResult + + logger, _ := zap.NewProduction() + defer logger.Sync() + + var totalData int + offset := (currentPage - 1) * rowPerPage + + prm := "%" + strings.TrimSpace(search) + "%" + querytotal := ` + SELECT COUNT(*) + FROM group_result + WHERE Group_ResultIsActive = 'Y' + AND (Group_ResultName LIKE ? OR Group_ResultResumeMcu LIKE ?) + ` + + logger.Info("QUERY SEARCH INITIAL TOTAL COUNT", + zap.String("query search", querytotal), + ) + + if err := dbx.Handlex.Get(&totalData, querytotal, prm, prm); err != nil { + return nil, 0, fmt.Errorf("error querying database: %v", err) + } + + query := ` + SELECT + ROW_NUMBER() OVER () AS nomor, + Group_ResultID, + IFNULL(Group_ResultName, '') AS Group_ResultName, + IFNULL(Group_ResultFlagPerTest, '') AS Group_ResultFlagPerTest, + IFNULL(Group_ResultFlagNonLab, '') AS Group_ResultFlagNonLab, + IFNULL(Group_ResultResumeMcu, '') AS Group_ResultResumeMcu, + Group_ResultIsActive + FROM group_result + WHERE Group_ResultIsActive = 'Y' + AND (Group_ResultName LIKE ? OR Group_ResultResumeMcu LIKE ?) + ORDER BY Group_ResultID ASC + LIMIT ? OFFSET ? + ` + + logger.Info("QUERY SEARCH INITIAL", + zap.String("query search", query), + ) + + if err := dbx.Handlex.Select(&groupresultList, query, prm, prm, rowPerPage, offset); err != nil { + return nil, 0, fmt.Errorf("error querying database: %v", err) + } + + totalPage := int(math.Ceil(float64(totalData) / float64(rowPerPage))) + + return groupresultList, totalPage, nil +} + +// GET BY ID +func (ug *ServicesGroupResult) GetGroupResultByIDV1(id string) (models.GroupResult, error) { + logger, _ := zap.NewProduction() + + var data models.GroupResult + err := dbx.Handlex.Get(&data, `SELECT + Group_ResultID, + Group_ResultName, + CASE + WHEN Group_ResultFlagPerTest = 'Y' THEN 'on' + ELSE Group_ResultFlagPerTest + END AS Group_ResultFlagPerTest, + CASE + WHEN Group_ResultFlagNonLab = 'Y' THEN 'on' + ELSE Group_ResultFlagNonLab + END AS Group_ResultFlagNonLab, + Group_ResultResumeMcu, + Group_ResultIsActive + FROM group_result + WHERE Group_ResultID = ?`, id) + + if err != nil { + defer logger.Sync() + logger.Error("Error get data gr by id vs", + zap.String("ID", id), + zap.Error(err), + ) + return data, fmt.Errorf("QUERY_FAILED") + } + return data, nil +} + +// ADD DATA +func (ug *ServicesGroupResult) AddGroupResult(groupresultname string, groupresultflagpertest string, groupresultflagnonlab string, groupresultresumemcu string) (models.GroupResult, error) { + logger, _ := zap.NewProduction() + var data models.GroupResult + var datacek []models.GroupResult + // var groupresultflagpertestConvert string = "" + // var groupresultflagnonlabConvert string = "" + // var groupresultresumemcuConvert string = "" + + prm := "%" + strings.TrimSpace(groupresultname) + "%" + qryCek := `SELECT Group_ResultName FROM group_result WHERE Group_ResultName LIKE ? AND Group_ResultIsActive = 'Y'` + err := dbx.Handlex.Select(&datacek, qryCek, prm) + + if err != nil { + defer logger.Sync() + logger.Error("Error cek data by groupresultname", + zap.String("groupresultname", groupresultname), + zap.Any("datacek", datacek), + ) + return data, fmt.Errorf("QUERY_FAILED") + } + if len(datacek) > 0 { + defer logger.Sync() + logger.Error("Group Result Name already taken by another data", + zap.String("groupresultname", groupresultname), + ) + return data, fmt.Errorf("group result name sudah dipakai") + } + qry := `INSERT INTO group_result + ( + Group_ResultName, + Group_ResultFlagPerTest, + Group_ResultFlagNonLab, + Group_ResultResumeMcu + ) + VALUES ( + ?, + ?, + ?, + ? + );` + // time.Sleep(5 * time.Second) + rst := dbx.Handlex.MustExec(qry, groupresultname, groupresultflagpertest, groupresultflagnonlab, groupresultresumemcu) + insertedID, err := rst.LastInsertId() + if err != nil { + defer logger.Sync() + logger.Error("Error Insert group result", + zap.Any("groupresultname", groupresultname), + zap.Any("groupresultflagpertest", groupresultflagpertest), + zap.Any("groupresultflagnonlab", groupresultflagnonlab), + zap.Any("groupresultresumemcu", groupresultresumemcu), + ) + return data, fmt.Errorf("QUERY_FAILED") + } + s := strconv.Itoa(int(insertedID)) + data, err = ug.GetGroupResultByIDV1(s) + if err != nil { + defer logger.Sync() + logger.Error("Error get usergroup by id", + zap.Any("groupresultname", groupresultname), + zap.Any("groupresultflagpertest", groupresultflagpertest), + zap.Any("groupresultflagnonlab", groupresultflagnonlab), + zap.Any("groupresultresumemcu", groupresultresumemcu), + ) + return data, fmt.Errorf("QUERY_FAILED") + } + return data, nil +} + +// EDIT DATA +func (ug *ServicesGroupResult) EditGroupResult(id string, groupresultname string, groupresultflagpertest string, groupresultflagnonlab string, groupresultresumemcu string) (models.GroupResult, error) { + logger, _ := zap.NewProduction() + var data models.GroupResult + var datacek []models.GroupResult + + prm := "%" + strings.TrimSpace(groupresultname) + "%" + qryCek := `SELECT Group_ResultName FROM group_result WHERE Group_ResultName LIKE ? AND Group_ResultIsActive = 'Y' AND Group_ResultID <> ?` + err := dbx.Handlex.Select(&datacek, qryCek, prm, id) + + if err != nil { + defer logger.Sync() + logger.Error("Error cek data by code", + zap.String("groupresultname", groupresultname), + zap.Any("datacek", datacek), + ) + return data, fmt.Errorf("QUERY_FAILED") + } + if len(datacek) > 0 { + defer logger.Sync() + logger.Error("Code already taken by another data", + zap.String("groupresultname", groupresultname), + ) + return data, fmt.Errorf("group result name sudah dipakai") + } + + qry := `UPDATE group_result + SET Group_ResultName = ?, + Group_ResultFlagPerTest = ?, + Group_ResultFlagNonLab = ?, + Group_ResultResumeMcu = ? + WHERE Group_ResultID = ?` + // time.Sleep(5 * time.Second) + rst := dbx.Handlex.MustExec(qry, groupresultname, groupresultflagpertest, groupresultflagnonlab, groupresultresumemcu, id) + _, err = rst.RowsAffected() + if err != nil { + defer logger.Sync() + logger.Error("Error Update group result", + zap.Any("groupresultname", groupresultname), + zap.Any("groupresultflagpertest", groupresultflagpertest), + zap.Any("groupresultflagnonlab", groupresultflagnonlab), + zap.Any("groupresultresumemcu", groupresultresumemcu), + ) + return data, fmt.Errorf("QUERY_FAILED") + } + + data, err = ug.GetGroupResultByIDV1(id) + if err != nil { + defer logger.Sync() + logger.Error("Error get group result by id", + zap.Any("groupresultname", groupresultname), + zap.Any("groupresultflagpertest", groupresultflagpertest), + zap.Any("groupresultflagnonlab", groupresultflagnonlab), + zap.Any("groupresultresumemcu", groupresultresumemcu), + ) + return data, fmt.Errorf("QUERY_FAILED") + } + return data, nil +} + +// DELETE DATA +func (ug *ServicesGroupResult) DeleteGroupResult(id string) (models.GroupResult, error) { + logger, _ := zap.NewProduction() + var data models.GroupResult + qry := `UPDATE group_result + SET Group_ResultIsActive = 'N' + WHERE Group_ResultID = ?;` + // time.Sleep(5 * time.Second) + rst := dbx.Handlex.MustExec(qry, id) + _, err := rst.RowsAffected() + if err != nil { + defer logger.Sync() + logger.Error("Error delete group result", + zap.String("id", id), + ) + return data, fmt.Errorf("QUERY_FAILED") + } + + data, err = ug.GetGroupResultByIDV1(id) + if err != nil { + defer logger.Sync() + logger.Error("Error get group result by id", + zap.String("id", id), + ) + return data, fmt.Errorf("QUERY_FAILED") + } + return data, nil +} diff --git a/views/dev/groupresult/groupresult.templ b/views/dev/groupresult/groupresult.templ new file mode 100644 index 0000000..0d014c3 --- /dev/null +++ b/views/dev/groupresult/groupresult.templ @@ -0,0 +1,388 @@ +package groupresult + +import ( + "cpone/layout" + "cpone/models" + "cpone/component/modal" + "strconv" + "cpone/component/table" + "cpone/component/customtextfield" +) + +// "cpone/component/sidebar_user_profile" +templ ContentGroupResultV1( + tableID string, + paginationID string, + searchID string, + dialogAddID string, + dialogAddBodyID string, + dialogEditID string, + dialogEditBodyID string, + dialogDeleteID string, + dialogDeleteBodyID string, + breadcrumb templ.Component, + tablecontent templ.Component, + filter templ.Component, + paginationGroupResult templ.Component, + modaladdform templ.Component, + modalEditform templ.Component, + modalDeleteform templ.Component, +) { +
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableID", + Name: "tableID", + Type: "hidden", + Value: tableID}) + @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "paginationID", + Name: "paginationID", + Type: "hidden", + Value: paginationID}) + @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "searchID", + Name: "searchID", + Type: "hidden", + Value: searchID}) + @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddID", + Name: "dialogAddID", + Type: "hidden", + Value: dialogAddID}) + @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddBodyID", + Name: "dialogAddBodyID", + Type: "hidden", + Value: dialogAddBodyID}) + @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditID", + Name: "dialogEditID", + Type: "hidden", + Value: dialogEditID}) + @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditBodyID", + Name: "dialogEditBodyID", + Type: "hidden", + Value: dialogEditBodyID}) + @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteID", + Name: "dialogDeleteID", + Type: "hidden", + Value: dialogDeleteID}) + @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteBodyID", + Name: "dialogDeleteBodyID", + Type: "hidden", + Value: dialogDeleteBodyID}) +
+
+ @breadcrumb +
+
+ //
+
+ +
+
+
+ +
+
+ @filter + // table content + @tablecontent + @paginationGroupResult +
+
+ +
+
+ // hx-on::after-request="showtoast()" + // hx-on::reponse-error="cobaerror()" + // hx-on::send-error="cobaerror()" + @modaladdform + @modalEditform + @modalDeleteform + // @modalcomponent.Modal("dialogEdit", "Edit - User Group", DialogEditBody("", ""), DialogEditAction(), BtnCloseNew()) + @JSkuGroupResultV1() +
+} + +templ TableRowGroupResultV1(data []models.GroupResult, + hxGetEdit string, + hxTargetEdit string, + hxSwapEdit string, + hxIncludeEdit string, + hxGetDelete string, + hxTargetDelete string, + hxSwapDelete string, + hxIncludeDelete string) { + if len(data) == 0 { + + Data Tidak Ditemukan + + } + for _, v := range data { + + { v.Group_ResultName } + { v.Group_ResultFlagPerTest } + { v.Group_ResultFlagNonLab } + { v.Group_ResultResumeMcu } + + @TableAction(v.Group_ResultID, hxGetEdit, hxTargetEdit, hxSwapEdit, hxIncludeEdit, hxGetDelete, hxTargetDelete, hxSwapDelete, hxIncludeDelete) + + + } +} + +templ TableAction( + id int, + hxGetEdit string, + hxTargetEdit string, + hxSwapEdit string, + hxIncludeEdit string, + hxGetDelete string, + hxTargetDelete string, + hxSwapDelete string, + hxIncludeDelete string, +) { +
+ + +
+} + +templ DialogDeleteGroupResultActionV1() { +
+ + +
+} + +templ BtnCloseDeleteGroupResultV1() { + +} + +templ JSkuGroupResultV1() { + +} + +templ CssMasterGroupResultV1x() { + + + + +} + +// for item dropdown +templ ItemDropdown(dataDropdown []models.GroupResultResumeMcu, selectedId int) { + if len(dataDropdown) == 0 { + + } else { + for _, v := range dataDropdown { + if (selectedId == v.ID) { + + } else { + + } + } + } +} + +// for empty div +templ EmptyDiv1() { +
+} + +templ ShowGroupResultV1x(title string, cmp templ.Component, css templ.Component, js templ.Component, + navbarmenu templ.Component, + navbaruser templ.Component, + userprofile templ.Component) { + @layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile) { + @cmp + } +} + +// table +templ TableGroupResult(data []models.GroupResult, tableID string, + hxGetEdit string, + hxTargetEdit string, + hxSwapEdit string, + hxIncludeEdit string, + hxGetDelete string, + hxTargetDelete string, + hxSwapDelete string, + hxIncludeDelete string) { +
+ @tablecomponent.TableV3([]string{"GROUP RESULT NAME", "RESULT FLAG PER TEST", "RESULT FLAG NON LAB", "RESULT RESUME MCU", "AKSI"}, + []string{"20%", "20%", "20%", "20%", "20%"}, + TableRowGroupResultV1(data, hxGetEdit, hxTargetEdit, hxSwapEdit, hxIncludeEdit, hxGetDelete, hxTargetDelete, hxSwapDelete, hxIncludeDelete)) +
+} + +templ SwapTableGroupResult(pagination templ.Component, table templ.Component) { + @pagination + @table +} + +templ GroupResultForm(data models.GroupResultFormComponent) { +
+
+ @modalcomponent.Modal(data.ModalID, + data.ModalTitle, + data.DialogBody, + data.DialogAction, + data.ButtonCLose) +
+
+} + +script HandleFormBeforeRequest() { + console.log("handle disable btn add"); + const boxes = document.querySelectorAll('.btnaddact'); + + for (let i = 0; i < boxes.length; i++) { + boxes[i].setAttribute('disabled', 'true'); + + } +} + +script HandleFormAfterRequest() { + console.log("handle enable btn add"); + + const boxes = document.querySelectorAll('.btnaddact'); + + for (let i = 0; i < boxes.length; i++) { + boxes[i].removeAttribute('disabled'); + + } +} + +templ DeleteConfirmationBody(inputId models.CustomTextFieldv2Prm, + componentID string, + message string, + datHeader []string, + dataText []string, + hxOnLoad templ.ComponentScript) { +
+

{ message }

+
+
+
+ for _, v := range datHeader { +
{ v }
+ } +
+
+ for _, v := range dataText { +
+ { v } +
+ } +
+
+
+ @customtextfield.CustomTextFieldv2(inputId) +
+} diff --git a/views/dev/groupresult/groupresult_templ.go b/views/dev/groupresult/groupresult_templ.go new file mode 100644 index 0000000..aa56db3 --- /dev/null +++ b/views/dev/groupresult/groupresult_templ.go @@ -0,0 +1,1059 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package groupresult + +//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/component/customtextfield" + "cpone/component/modal" + "cpone/component/table" + "cpone/layout" + "cpone/models" + "strconv" +) + +// "cpone/component/sidebar_user_profile" +func ContentGroupResultV1( + tableID string, + paginationID string, + searchID string, + dialogAddID string, + dialogAddBodyID string, + dialogEditID string, + dialogEditBodyID string, + dialogDeleteID string, + dialogDeleteBodyID string, + breadcrumb templ.Component, + tablecontent templ.Component, + filter templ.Component, + paginationGroupResult templ.Component, + modaladdform templ.Component, + modalEditform templ.Component, + modalDeleteform templ.Component, +) 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 = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableID", + Name: "tableID", + Type: "hidden", + Value: tableID}).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "paginationID", + Name: "paginationID", + Type: "hidden", + Value: paginationID}).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "searchID", + Name: "searchID", + Type: "hidden", + Value: searchID}).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddID", + Name: "dialogAddID", + Type: "hidden", + Value: dialogAddID}).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddBodyID", + Name: "dialogAddBodyID", + Type: "hidden", + Value: dialogAddBodyID}).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditID", + Name: "dialogEditID", + Type: "hidden", + Value: dialogEditID}).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditBodyID", + Name: "dialogEditBodyID", + Type: "hidden", + Value: dialogEditBodyID}).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteID", + Name: "dialogDeleteID", + Type: "hidden", + Value: dialogDeleteID}).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteBodyID", + Name: "dialogDeleteBodyID", + Type: "hidden", + Value: dialogDeleteBodyID}).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 = breadcrumb.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 = filter.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = tablecontent.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = paginationGroupResult.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 = modaladdform.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = modalEditform.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 + } + templ_7745c5c3_Err = JSkuGroupResultV1().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 TableRowGroupResultV1(data []models.GroupResult, + hxGetEdit string, + hxTargetEdit string, + hxSwapEdit string, + hxIncludeEdit string, + hxGetDelete string, + hxTargetDelete string, + hxSwapDelete string, + hxIncludeDelete 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_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + if len(data) == 0 { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Data Tidak Ditemukan") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + for _, v := range data { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(v.Group_ResultName) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\groupresult\groupresult.templ`, Line: 128, Col: 27} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + 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_Var6 string + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(v.Group_ResultFlagPerTest) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\groupresult\groupresult.templ`, Line: 129, Col: 34} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) + 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_Var7 string + templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(v.Group_ResultFlagNonLab) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\groupresult\groupresult.templ`, Line: 130, Col: 33} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) + 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_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(v.Group_ResultResumeMcu) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\groupresult\groupresult.templ`, Line: 131, Col: 32} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + 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 = TableAction(v.Group_ResultID, hxGetEdit, hxTargetEdit, hxSwapEdit, hxIncludeEdit, hxGetDelete, hxTargetDelete, hxSwapDelete, hxIncludeDelete).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 TableAction( + id int, + hxGetEdit string, + hxTargetEdit string, + hxSwapEdit string, + hxIncludeEdit string, + hxGetDelete string, + hxTargetDelete string, + hxSwapDelete string, + hxIncludeDelete 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_Var9 := templ.GetChildren(ctx) + if templ_7745c5c3_Var9 == nil { + templ_7745c5c3_Var9 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Edit\r Hapus\r
") + 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 DialogDeleteGroupResultActionV1() 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_Var18 := templ.GetChildren(ctx) + if templ_7745c5c3_Var18 == nil { + templ_7745c5c3_Var18 = 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 + }) +} + +func BtnCloseDeleteGroupResultV1() 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_Var19 := templ.GetChildren(ctx) + if templ_7745c5c3_Var19 == nil { + templ_7745c5c3_Var19 = 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 + }) +} + +func JSkuGroupResultV1() 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_Var20 := templ.GetChildren(ctx) + if templ_7745c5c3_Var20 == nil { + templ_7745c5c3_Var20 = 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 + }) +} + +func CssMasterGroupResultV1x() 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_Var21 := templ.GetChildren(ctx) + if templ_7745c5c3_Var21 == nil { + templ_7745c5c3_Var21 = 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 + }) +} + +// for item dropdown +func ItemDropdown(dataDropdown []models.GroupResultResumeMcu, selectedId int) 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) + if len(dataDropdown) == 0 { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + for _, v := range dataDropdown { + if selectedId == v.ID { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + _, 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 + }) +} + +// for empty div +func EmptyDiv1() 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_Var27 := templ.GetChildren(ctx) + if templ_7745c5c3_Var27 == nil { + templ_7745c5c3_Var27 = 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 + }) +} + +func ShowGroupResultV1x(title string, cmp templ.Component, css templ.Component, js templ.Component, + navbarmenu templ.Component, + navbaruser templ.Component, + userprofile templ.Component) 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_Var29 := 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) + } + templ_7745c5c3_Err = cmp.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer) + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile).Render(templ.WithChildren(ctx, templ_7745c5c3_Var29), templ_7745c5c3_Buffer) + 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 + }) +} + +// table +func TableGroupResult(data []models.GroupResult, tableID string, + hxGetEdit string, + hxTargetEdit string, + hxSwapEdit string, + hxIncludeEdit string, + hxGetDelete string, + hxTargetDelete string, + hxSwapDelete string, + hxIncludeDelete 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_Var30 := templ.GetChildren(ctx) + if templ_7745c5c3_Var30 == nil { + templ_7745c5c3_Var30 = 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 = tablecomponent.TableV3([]string{"GROUP RESULT NAME", "RESULT FLAG PER TEST", "RESULT FLAG NON LAB", "RESULT RESUME MCU", "AKSI"}, + []string{"20%", "20%", "20%", "20%", "20%"}, + TableRowGroupResultV1(data, hxGetEdit, hxTargetEdit, hxSwapEdit, hxIncludeEdit, hxGetDelete, hxTargetDelete, hxSwapDelete, hxIncludeDelete)).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 SwapTableGroupResult(pagination templ.Component, table templ.Component) 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_Var32 := templ.GetChildren(ctx) + if templ_7745c5c3_Var32 == nil { + templ_7745c5c3_Var32 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = pagination.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = table.Render(ctx, templ_7745c5c3_Buffer) + 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 GroupResultForm(data models.GroupResultFormComponent) 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_Var33 := templ.GetChildren(ctx) + if templ_7745c5c3_Var33 == nil { + templ_7745c5c3_Var33 = 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_1e3f`, + Function: `function __templ_HandleFormBeforeRequest_1e3f(){console.log("handle disable btn add"); + const boxes = document.querySelectorAll('.btnaddact'); + + for (let i = 0; i < boxes.length; i++) { + boxes[i].setAttribute('disabled', 'true'); + + } +}`, + Call: templ.SafeScript(`__templ_HandleFormBeforeRequest_1e3f`), + CallInline: templ.SafeScriptInline(`__templ_HandleFormBeforeRequest_1e3f`), + } +} + +func HandleFormAfterRequest() templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_HandleFormAfterRequest_ee07`, + Function: `function __templ_HandleFormAfterRequest_ee07(){console.log("handle enable btn add"); + + const boxes = document.querySelectorAll('.btnaddact'); + + for (let i = 0; i < boxes.length; i++) { + boxes[i].removeAttribute('disabled'); + + } +}`, + Call: templ.SafeScript(`__templ_HandleFormAfterRequest_ee07`), + CallInline: templ.SafeScriptInline(`__templ_HandleFormAfterRequest_ee07`), + } +} + +func DeleteConfirmationBody(inputId models.CustomTextFieldv2Prm, + componentID string, + message string, + datHeader []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_Var41 := templ.GetChildren(ctx) + if templ_7745c5c3_Var41 == nil { + templ_7745c5c3_Var41 = 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_Var44 string + templ_7745c5c3_Var44, templ_7745c5c3_Err = templ.JoinStringErrs(message) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\groupresult\groupresult.templ`, Line: 369, Col: 14} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var44)) + 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 datHeader { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var45 string + templ_7745c5c3_Var45, templ_7745c5c3_Err = templ.JoinStringErrs(v) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\groupresult\groupresult.templ`, Line: 374, Col: 68} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var45)) + 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_Var46 string + templ_7745c5c3_Var46, templ_7745c5c3_Err = templ.JoinStringErrs(v) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\groupresult\groupresult.templ`, Line: 380, Col: 10} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var46)) + 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 + }) +} diff --git a/views/dev/groupresult/modaladdgroupresult.templ b/views/dev/groupresult/modaladdgroupresult.templ new file mode 100644 index 0000000..7813986 --- /dev/null +++ b/views/dev/groupresult/modaladdgroupresult.templ @@ -0,0 +1,111 @@ +package groupresult + +import ( + "cpone/models" + "cpone/component/customtextfield" + "cpone/component/customcheckbox" + "cpone/component/customdropdown" +) + +templ DialogNewBodyV1(inputId models.CustomTextFieldv2Prm, + inputGrName models.CustomTextFieldv2Prm, + checkboxGrFlagPerTest models.CustomCheckboxv1Prm, + checkboxGrFlagNonLab models.CustomCheckboxv1Prm, + dropdownGrResumeMcu models.CustomDropdownv1Prm, + listItem templ.Component, + componentID string, + hxOnLoad templ.ComponentScript) { +
+ @customtextfield.CustomTextFieldv2( + inputId) + @customtextfield.CustomTextFieldv2( + inputGrName) + @customcheckbox.MainCustomCheckboxInput( + checkboxGrFlagPerTest) + @customcheckbox.MainCustomCheckboxInput( + checkboxGrFlagNonLab) + @customdropdown.MainCustomDropdownInput( + dropdownGrResumeMcu, + listItem) +
+ +} + +script HandleJSModalAddGR(modalID string) { + $(modalID).modal('hide'); +} + +script HandleJSModalAddGRShow(modalID string) { + $(modalID).modal('show') +} + +templ DialogNewActionV1(LinkClose string, targetClose string, hxSwapClose string, modalID string) { +
+ + +
+} + +templ DialogNewAction() { +
+ + +
+} + +templ BtnCloseNew() { + +} + +templ BtnCloseNewV1(LinkClose string, targetClose string, hxSwapClose string, modalID string) { + +} diff --git a/views/dev/groupresult/modaladdgroupresult_templ.go b/views/dev/groupresult/modaladdgroupresult_templ.go new file mode 100644 index 0000000..84565a8 --- /dev/null +++ b/views/dev/groupresult/modaladdgroupresult_templ.go @@ -0,0 +1,329 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package groupresult + +//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/component/customcheckbox" + "cpone/component/customdropdown" + "cpone/component/customtextfield" + "cpone/models" +) + +func DialogNewBodyV1(inputId models.CustomTextFieldv2Prm, + inputGrName models.CustomTextFieldv2Prm, + checkboxGrFlagPerTest models.CustomCheckboxv1Prm, + checkboxGrFlagNonLab models.CustomCheckboxv1Prm, + dropdownGrResumeMcu models.CustomDropdownv1Prm, + listItem templ.Component, + componentID 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_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = 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( + inputGrName).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customcheckbox.MainCustomCheckboxInput( + checkboxGrFlagPerTest).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customcheckbox.MainCustomCheckboxInput( + checkboxGrFlagNonLab).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customdropdown.MainCustomDropdownInput( + dropdownGrResumeMcu, + listItem).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 HandleJSModalAddGR(modalID string) templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_HandleJSModalAddGR_a6af`, + Function: `function __templ_HandleJSModalAddGR_a6af(modalID){$(modalID).modal('hide'); +}`, + Call: templ.SafeScript(`__templ_HandleJSModalAddGR_a6af`, modalID), + CallInline: templ.SafeScriptInline(`__templ_HandleJSModalAddGR_a6af`, modalID), + } +} + +func HandleJSModalAddGRShow(modalID string) templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_HandleJSModalAddGRShow_3147`, + Function: `function __templ_HandleJSModalAddGRShow_3147(modalID){$(modalID).modal('show') +}`, + Call: templ.SafeScript(`__templ_HandleJSModalAddGRShow_3147`, modalID), + CallInline: templ.SafeScriptInline(`__templ_HandleJSModalAddGRShow_3147`, modalID), + } +} + +func DialogNewActionV1(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_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = 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, HandleJSModalAddGR(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 DialogNewAction() 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_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 BtnCloseNew() 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_Var10 := templ.GetChildren(ctx) + if templ_7745c5c3_Var10 == nil { + templ_7745c5c3_Var10 = 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 + }) +} + +func BtnCloseNewV1(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_Var11 := templ.GetChildren(ctx) + if templ_7745c5c3_Var11 == nil { + templ_7745c5c3_Var11 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, HandleJSModalAddGR(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 + }) +} diff --git a/views/dev/groupresult/modaleditgroupresult.templ b/views/dev/groupresult/modaleditgroupresult.templ new file mode 100644 index 0000000..1eb3635 --- /dev/null +++ b/views/dev/groupresult/modaleditgroupresult.templ @@ -0,0 +1,101 @@ +package groupresult + +import ( + "cpone/models" + "cpone/component/customtextfield" + "cpone/component/customcheckbox" + "cpone/component/customdropdown" +) + +templ DialogEditForm(groupresultname string, groupresultflagpertest string, groupresultflagnonlab string, listItem templ.Component) { + @customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }) + @customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Value: groupresultname, + Type: "text", ID: "groupresultname"}) + @customcheckbox.MainCustomCheckboxInput( + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + Value: groupresultflagpertest, + }) + @customcheckbox.MainCustomCheckboxInput( + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + Value: groupresultflagnonlab, + }) + @customdropdown.MainCustomDropdownInput( + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItem) +} + +templ DialogEditBody(groupresultname string, groupresultflagpertest string, groupresultflagnonlab string, listItem templ.Component) { +
+ @DialogEditForm(groupresultname, groupresultflagpertest, groupresultflagnonlab, listItem) +
+
+ //
+ //
+ //
+
+} + +templ LoadingSpinner() { +
+
+
+
+
+} + +templ DialogEditAction() { +
+ + +
+} + +templ BtnCloseEdit() { + +} diff --git a/views/dev/groupresult/modaleditgroupresult_templ.go b/views/dev/groupresult/modaleditgroupresult_templ.go new file mode 100644 index 0000000..9dececd --- /dev/null +++ b/views/dev/groupresult/modaleditgroupresult_templ.go @@ -0,0 +1,193 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package groupresult + +//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/component/customcheckbox" + "cpone/component/customdropdown" + "cpone/component/customtextfield" + "cpone/models" +) + +func DialogEditForm(groupresultname string, groupresultflagpertest string, groupresultflagnonlab string, listItem templ.Component) 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 = customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Group Result name", + Name: "groupresultid", + Placeholder: "Group Result name", + Type: "hidden", + ID: "groupresultid", + }).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Group Result Name", + Name: "groupresultname", + Placeholder: "Group Result Name", + Value: groupresultname, + Type: "text", ID: "groupresultname"}).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customcheckbox.MainCustomCheckboxInput( + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Per Test (Dicentang Maka Ya)", + Name: "groupresultflagpertest", + ID: "groupresultflagpertest", + Value: groupresultflagpertest, + }).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customcheckbox.MainCustomCheckboxInput( + models.CustomCheckboxv1Prm{ + Label: "Group Result Flag Non Lab (Dicentang Maka Ya)", + Name: "groupresultflagnonlab", + ID: "groupresultflagnonlab", + Value: groupresultflagnonlab, + }).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customdropdown.MainCustomDropdownInput( + models.CustomDropdownv1Prm{ + Label: "Group Result Resume MCU", + Name: "groupresultresumemcu", + ID: "groupresultresumemcu", + }, + listItem).Render(ctx, templ_7745c5c3_Buffer) + 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 DialogEditBody(groupresultname string, groupresultflagpertest string, groupresultflagnonlab string, listItem templ.Component) 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_Var2 := templ.GetChildren(ctx) + if templ_7745c5c3_Var2 == nil { + templ_7745c5c3_Var2 = 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 = DialogEditForm(groupresultname, groupresultflagpertest, groupresultflagnonlab, listItem).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 LoadingSpinner() 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_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = 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 + }) +} + +func DialogEditAction() 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_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = 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 + }) +} + +func BtnCloseEdit() 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_Var5 := templ.GetChildren(ctx) + if templ_7745c5c3_Var5 == nil { + templ_7745c5c3_Var5 = 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 + }) +}