diff --git a/handlers/dev/masterkelainan.handlers.go b/handlers/dev/masterkelainan.handlers.go
index c174ad2..84574c5 100644
--- a/handlers/dev/masterkelainan.handlers.go
+++ b/handlers/dev/masterkelainan.handlers.go
@@ -28,6 +28,7 @@ type MasterKelainanService interface {
EditKelainan(id string, name string) (models.Kelainan, error)
DeleteKelainan(id string) (models.Kelainan, error)
GetListMasterKelainanDetail(id string, searchdetail string, currentPage int, rowPerPage int) ([]models.KelainanDetail, int, error)
+ AddKelainanDetail(name string, nameclassification string, selectedid string) (models.KelainanDetail, error)
}
func NewMasterKelainanHandler(us MasterKelainanService) *MasterKelainanHandler {
@@ -54,6 +55,8 @@ func (lh *MasterKelainanHandler) HandlerShowMasterKelainan(c echo.Context) error
tableDetailID := utils.GenerateRandomID("tablebodydetail")
paginationDetailID := utils.GenerateRandomID("paginationdetailid")
searchDetailID := utils.GenerateRandomID("searchdetailid")
+ dialogDetailAddID := utils.GenerateRandomID("dialogdetailaddid")
+ dialogDetailAddBodyID := utils.GenerateRandomID("dialogdetailaddbodyid")
// println("cek id param", id)
@@ -316,6 +319,54 @@ func (lh *MasterKelainanHandler) HandlerShowMasterKelainan(c echo.Context) error
"outerHTML", "", "",
)
+ // component modal add kelainan detail
+ dialogDetailAddBodyCmp := masterkelainan.BodyFormKelainanDetail(
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Kelainan",
+ Name: "kelainandetailid",
+ Placeholder: "Nama Kelainan",
+ Type: "hidden", ID: "kelainandetailid"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Kelainan",
+ Name: "kelainandetailname",
+ Placeholder: "Nama Kelainan",
+ Type: "text", ID: "kelainandetailinputname"},
+ models.SwitchclassPrm{
+ Label: "Dengan Klasifikasi",
+ Type: "checkbox",
+ Checked: "true ",
+ Name: "select",
+ ID: "switchname"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Klasifikasi",
+ Name: "classificationname",
+ Placeholder: "Nama Klasifikasi",
+ Type: "text", ID: "classificationinputname"},
+
+ dialogDetailAddBodyID, masterkelainan.JsHideModalDetail(""))
+ dialogDetailAddActionCmp := masterkelainan.ActionFormKelainanDetail(
+ "/dev/kelainandetail/closeaddform",
+ "#"+dialogDetailAddBodyID,
+ "outerHTML",
+ "#"+dialogDetailAddID)
+ dialogDetailAddCloseCmp := masterkelainan.BtnCloseFormKelainanDetail(
+ "/dev/kelainandetail/closeaddform",
+ "#"+dialogDetailAddBodyID,
+ "outerHTML",
+ "#"+dialogDetailAddID)
+ modaldetailaddcomponent := masterkelainan.KelainanDetailForm(models.KelainanDetailFormComponent{
+ IDComponent: "formkelainandetail",
+ Link: "/dev/kelainandetail/add",
+ HxTarget: "#" + dialogDetailAddBodyID,
+ HxSwap: "outerHTML",
+ HxInclude: "#selectedID, #tableDetailID, #paginationDetailID, #searchDetailID, #dialogDetailAddBodyID, #dialogDetailAddID, #selectedID #" + searchDetailID + ", #currpage" + paginationDetailID,
+ ModalID: dialogDetailAddID,
+ ModalTitle: "New - Kelainan",
+ DialogBody: dialogDetailAddBodyCmp,
+ DialogAction: dialogDetailAddActionCmp,
+ ButtonCLose: dialogDetailAddCloseCmp,
+ })
+
// content, css, js
content := masterkelainan.ContentMasterKelainan(
tableID, paginationID, searchID, dialogAddID, dialogAddBodyID,
@@ -326,6 +377,8 @@ func (lh *MasterKelainanHandler) HandlerShowMasterKelainan(c echo.Context) error
tableDetailID,
paginationDetailID,
searchDetailID,
+ dialogDetailAddID,
+ dialogDetailAddBodyID,
breadcrumbComponent,
contentKelainanComponent,
kelainanFilterComponent,
@@ -335,7 +388,8 @@ func (lh *MasterKelainanHandler) HandlerShowMasterKelainan(c echo.Context) error
modalDeleteFormComponent,
contentKelainanDetailCmp,
kelainanDetailFilterCmp,
- kelainanDetailPaginationCmp)
+ kelainanDetailPaginationCmp,
+ modaldetailaddcomponent)
css := masterkelainan.CssKelainan()
js := masterkelainan.JsMdKelainan()
@@ -1111,3 +1165,222 @@ func (lh *MasterKelainanHandler) HandlerShowMdKelainanDetailPagination(c echo.Co
return utils.ViewMulti(c, retval)
}
+
+func (lh *MasterKelainanHandler) HandlerAddKelainanDetail(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+ defer logger.Sync()
+
+ selectedID := c.FormValue("selectedID")
+ nameKelainanDetail := c.FormValue("kelainandetailname")
+ nameClassification := c.FormValue("classificationname")
+ // tableID := c.FormValue("tableID")
+ tableDetailID := c.FormValue("tableDetailID")
+ paginationDetailID := c.FormValue("paginationDetailID")
+ searchDetailID := c.FormValue("searchDetailID")
+ searchdetail := c.FormValue("searchdetail")
+ currPagePrmDetail := c.FormValue("currpage" + paginationDetailID)
+ dialogDetailAddBodyID := c.FormValue("dialogDetailAddBodyID")
+ dialogDetailAddID := c.FormValue("dialogDetailAddID")
+
+ currPage, err := strconv.Atoi(currPagePrmDetail)
+
+ if err != nil {
+ return err
+ }
+ logger.Info("ADD KELAINAN DETAIL",
+ zap.Any("nama", nameKelainanDetail),
+ zap.Any("nama klasifikasi", nameClassification),
+ zap.Any("tabelid", tableDetailID),
+ zap.Any("search", searchdetail),
+ zap.Any("currpage", currPage),
+ )
+
+ kelainanGrupID, _ := strconv.Atoi(selectedID)
+ // form validation
+ formValidation := ""
+ nameValidation := ""
+ kelainanGrupValidation := ""
+ if strings.TrimSpace(nameKelainanDetail) == "" {
+ formValidation = "Nama kelainan tidak boleh kosong"
+ nameValidation = "Nama kelainan tidak boleh kosong"
+ kelainanGrupValidation = ""
+ }
+ if strings.TrimSpace(selectedID) == "" || kelainanGrupID == 0 {
+ formValidation = "Pilih kelainan grup dulu"
+ nameValidation = ""
+ kelainanGrupValidation = "Pilih kelainan grup dulu"
+ }
+ if strings.TrimSpace(nameKelainanDetail) == "" && (strings.TrimSpace(selectedID) == "" || kelainanGrupID == 0) {
+ formValidation = "Nama kelainan dan Kelainan Grup tidak boleh kosong"
+ nameValidation = "Nama kelainan tidak boleh kosong"
+ kelainanGrupValidation = "Pilih kelainan grup dulu"
+ }
+ if formValidation != "" || nameValidation != "" || kelainanGrupValidation != "" {
+ newForm := masterkelainan.BodyFormKelainanDetail(
+ models.CustomTextFieldv2Prm{Label: "Nama Kelainan",
+ Name: "kelainandetailid",
+ Placeholder: "Nama Kelainan",
+ Type: "hidden",
+ ID: "kelainandetailid"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Kelainan",
+ Name: "kelainandetailname",
+ Placeholder: "Nama Kelainan",
+ Type: "text",
+ Value: nameKelainanDetail,
+ ID: "kelainandetailinputname",
+ ErrorMsg: nameValidation},
+ models.SwitchclassPrm{
+ Label: "Dengan Klasifikasi",
+ Type: "checkbox",
+ Checked: "true ",
+ Name: "select",
+ ID: "switchname"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Klasifikasi",
+ Name: "classificationname",
+ Placeholder: "Nama Klasifikasi",
+ Type: "text",
+ Value: nameClassification, ID: "classificationinputname"},
+ dialogDetailAddBodyID, masterkelainan.JsHideModalDetail(""))
+
+ return utils.ViewMulti(c, []templ.Component{
+ customtoastv2.CustomToastV2Show("Warning", formValidation, "warning"), newForm})
+ }
+
+ // add kelainan detail service
+ dataKelainanDetail, err := lh.MasterKelainanService.AddKelainanDetail(nameKelainanDetail, nameClassification, selectedID)
+
+ if err != nil {
+ logger.Info("Error",
+ zap.Any("Error", err),
+ zap.Any("nama", nameKelainanDetail),
+ zap.Any("nama klasifikasi", nameClassification),
+ zap.Any("selectedid", selectedID),
+ )
+
+ newForm := masterkelainan.BodyFormKelainanDetail(
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Kelainan",
+ Name: "kelainandetailid",
+ Placeholder: "Nama Kelainan",
+ Type: "hidden", ID: "kelainandetailid"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Kelainan",
+ Name: "kelainandetailname",
+ Placeholder: "Nama Kelainan",
+ Type: "text", ID: "kelainandetailinputname"},
+ models.SwitchclassPrm{
+ Label: "Dengan Klasifikasi",
+ Type: "checkbox",
+ Checked: "true ",
+ Name: "select",
+ ID: "switchname"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Klasifikasi",
+ Name: "classificationname",
+ Placeholder: "Nama Klasifikasi",
+ Type: "text", ID: "classificationinputname"},
+ dialogDetailAddBodyID, masterkelainan.JsHideModalDetail(""))
+ return utils.ViewMulti(c, []templ.Component{
+ customtoastv2.CustomToastV2Show("Error", err.Error(), "danger"), newForm})
+ }
+ logger.Info("ADD KELAINAN DETAIL",
+ zap.Any("return", dataKelainanDetail),
+ zap.Any("name", nameKelainanDetail),
+ zap.Any("name klasifikasi", nameClassification),
+ zap.Any("selectedid", selectedID),
+ )
+
+ // get data table current page
+ dataKelainanDetailList, totalpage, err := lh.MasterKelainanService.GetListMasterKelainanDetail(selectedID, searchdetail, currPage, 5)
+ if err != nil {
+ defer logger.Sync()
+ logger.Info("ERROR GET KELAINAN DETAIL",
+ zap.Any("error", err),
+ )
+ }
+
+ // new add form
+ newForm := masterkelainan.BodyFormKelainanDetail(
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Kelainan",
+ Name: "kelainandetailid",
+ Placeholder: "Nama Kelainan",
+ Type: "hidden", ID: "kelainandetailid"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Kelainan",
+ Name: "kelainandetailname",
+ Placeholder: "Nama Kelainan",
+ Type: "text",
+ Value: "",
+ ID: "kelainandetailinputname"},
+ models.SwitchclassPrm{
+ Label: "Dengan Klasifikasi",
+ Type: "checkbox",
+ Checked: "true ",
+ Name: "select",
+ ID: "switchname"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Klasifikasi",
+ Name: "classificationname",
+ Placeholder: "Nama Klasifikasi",
+ Type: "text",
+ Value: "",
+ ID: "classificationinputname"},
+ dialogDetailAddBodyID, masterkelainan.JsHideModalDetail("#"+dialogDetailAddID))
+
+ // new table listing
+ contentKelainanDetailComponent := masterkelainan.TableKelainanDetail(
+ dataKelainanDetailList, tableDetailID,
+ )
+
+ // new pagination
+ kelainanDetailPaginationCmp := pagination.PaginationV2(totalpage,
+ currPage,
+ "/dev/kelainandetailpagination",
+ paginationDetailID,
+ "#tableDetailID, #searchDetailID, #"+searchDetailID+", #paginationDetailID",
+ "#"+paginationDetailID, "outerHTML", "", "true")
+
+ toastSuccess := customtoastv2.CustomToastV2Show("Success", "Success add kelainan "+nameKelainanDetail, "success")
+
+ retVal := []templ.Component{toastSuccess, contentKelainanDetailComponent, kelainanDetailPaginationCmp, newForm}
+
+ return utils.ViewMulti(c, retVal)
+}
+
+func (lh *MasterKelainanHandler) HandlerCloseFormAddDetail(c echo.Context) error {
+ dialogDetailAddBodyID := c.FormValue("dialogDetailAddBodyID")
+
+ logger, _ := zap.NewProduction()
+ defer logger.Sync()
+ logger.Info("CEK dialogDetailAddBodyID CLOSE",
+ zap.Any("dialogDetailAddBodyID", dialogDetailAddBodyID),
+ )
+
+ newForm := masterkelainan.BodyFormKelainanDetail(
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Kelainan",
+ Name: "kelainandetailid",
+ Placeholder: "Nama Kelainan",
+ Type: "hidden", ID: "kelainandetailid"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Kelainan",
+ Name: "kelainandetailname",
+ Placeholder: "Nama Kelainan",
+ Type: "text", ID: "kelainandetailinputname"},
+ models.SwitchclassPrm{
+ Label: "Dengan Klasifikasi",
+ Type: "checkbox",
+ Checked: "true ",
+ Name: "select",
+ ID: "switchname"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Klasifikasi",
+ Name: "classificationname",
+ Placeholder: "Nama Klasifikasi",
+ Type: "text", ID: "classificationinputname"},
+ dialogDetailAddBodyID, masterkelainan.JsHideModalDetail(""))
+ return utils.View(c, newForm)
+}
diff --git a/handlers/routes.go b/handlers/routes.go
index 27d89e5..20d17eb 100644
--- a/handlers/routes.go
+++ b/handlers/routes.go
@@ -229,4 +229,6 @@ func SetupRoutesDev(app *echo.Echo, appStore db.AppStore) {
dev.GET("/kelainan/selected", devKLhandlers.HandlerShowMasterKelainanDetail)
dev.GET("/searchkelainandetail", devKLhandlers.HandlerShowMdKelainanDetailSearch)
dev.GET("/kelainandetailpagination", devKLhandlers.HandlerShowMdKelainanDetailPagination)
+ dev.POST("/kelainandetail/closeaddform", devKLhandlers.HandlerCloseFormAddDetail)
+ dev.POST("/kelainandetail/add", devKLhandlers.HandlerAddKelainanDetail)
}
diff --git a/models/kelainan.models.go b/models/kelainan.models.go
index b9b2b71..408f72d 100644
--- a/models/kelainan.models.go
+++ b/models/kelainan.models.go
@@ -59,3 +59,27 @@ type CustomTextFieldSelected struct {
ErrorMsg string `default:""`
ID string
}
+
+type KelainanDetailFormComponent struct {
+ IDComponent string
+ Link string
+ HxTarget string
+ HxSwap string
+ HxInclude string
+ ModalID string
+ ModalTitle string
+ InputName CustomTextFieldv2Prm
+ InputClassification CustomTextFieldv2Prm
+ InputID CustomTextFieldv2Prm
+ DialogBody templ.Component
+ DialogAction templ.Component
+ ButtonCLose templ.Component
+}
+
+type SwitchclassPrm struct {
+ Label string `default:"label"`
+ Type string `default:"type"`
+ Checked string `default:"Checked"`
+ Name string `default:"name"`
+ ID string
+}
diff --git a/services/dev/masterkelainan.services.go b/services/dev/masterkelainan.services.go
index 90b73eb..dc2bb34 100644
--- a/services/dev/masterkelainan.services.go
+++ b/services/dev/masterkelainan.services.go
@@ -314,3 +314,46 @@ func (su *ServicesMasterKelainan) GetListMasterKelainanDetail(id string, searchd
return KelainanDetailList, totalPage, nil
}
+
+func (su *ServicesMasterKelainan) GetKelainanDetailByID(id string) (models.KelainanDetail, error) {
+ logger, _ := zap.NewProduction()
+
+ var data models.KelainanDetail
+ err := dbx.Handlex.Get(&data, `SELECT * FROM mcu_kelainan
+ WHERE Mcu_KelainanID = ?`, id)
+
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error get data by id",
+ zap.String("ID", id),
+ )
+ return data, fmt.Errorf("QUERY_FAILED")
+ }
+ return data, nil
+}
+
+func (su *ServicesMasterKelainan) AddKelainanDetail(name string, nameclassification string, selectedid string) (models.KelainanDetail, error) {
+ logger, _ := zap.NewProduction()
+ var data models.KelainanDetail
+
+ qry := `INSERT INTO mcu_kelainan(
+ Mcu_KelainanName,
+ Mcu_KelainanClasification,
+ Mcu_KelainanMcu_KelainanGroupID,
+ Mcu_KelainanCreated,
+ Mcu_KelainanLastUpdated) VALUES(?,?,?,NOW(),NOW())`
+ rst := dbx.Handlex.MustExec(qry, name, nameclassification, selectedid)
+ _, err := rst.LastInsertId()
+
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error Insert Kelainan Detail",
+ zap.String("name", name),
+ zap.String("nameclasification", nameclassification),
+ zap.Any("selectedid", selectedid),
+ )
+ return data, fmt.Errorf("QUERY_FAILED")
+ }
+
+ return data, nil
+}
diff --git a/views/dev/masterkelainan/masterkelainan.templ b/views/dev/masterkelainan/masterkelainan.templ
index 1b4251e..a8c5eb0 100644
--- a/views/dev/masterkelainan/masterkelainan.templ
+++ b/views/dev/masterkelainan/masterkelainan.templ
@@ -19,6 +19,8 @@ templ ContentMasterKelainan(
tableDetailID string,
paginationDetailID string,
searchDetailID string,
+ dialogDetailAddID string,
+ dialogDetailAddBodyID string,
breadcrumb templ.Component,
tablecontent templ.Component,
filterComponent templ.Component,
@@ -29,6 +31,7 @@ templ ContentMasterKelainan(
tabledetailcontent templ.Component,
filterDetailComponent templ.Component,
paginationDetailComponent templ.Component,
+ modalDetailAddForm templ.Component,
) {
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableID",
@@ -84,6 +87,14 @@ templ ContentMasterKelainan(
Name: "selectedID",
Type: "hidden",
Value: "0"})
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDetailAddID",
+ Name: "dialogDetailAddID",
+ Type: "hidden",
+ Value: dialogDetailAddID})
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDetailAddBodyID",
+ Name: "dialogDetailAddBodyID",
+ Type: "hidden",
+ Value: dialogDetailAddBodyID})
@breadcrumb
@@ -131,6 +142,7 @@ templ ContentMasterKelainan(
type="button"
class="btn btn-primary"
data-toggle="modal"
+ data-target={ "#" + dialogDetailAddID }
>Add New
@@ -139,11 +151,13 @@ templ ContentMasterKelainan(
type="button"
class="btn btn-primary btn-block"
data-toggle="modal"
+ data-target={ "#" + dialogDetailAddID }
>Add New
@tabledetailcontent
@paginationDetailComponent
+ @modalDetailAddForm
diff --git a/views/dev/masterkelainan/masterkelainan_templ.go b/views/dev/masterkelainan/masterkelainan_templ.go
index d4887b1..ae99188 100644
--- a/views/dev/masterkelainan/masterkelainan_templ.go
+++ b/views/dev/masterkelainan/masterkelainan_templ.go
@@ -29,6 +29,8 @@ func ContentMasterKelainan(
tableDetailID string,
paginationDetailID string,
searchDetailID string,
+ dialogDetailAddID string,
+ dialogDetailAddBodyID string,
breadcrumb templ.Component,
tablecontent templ.Component,
filterComponent templ.Component,
@@ -39,6 +41,7 @@ func ContentMasterKelainan(
tabledetailcontent templ.Component,
filterDetailComponent templ.Component,
paginationDetailComponent templ.Component,
+ modalDetailAddForm 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)
@@ -148,6 +151,20 @@ func ContentMasterKelainan(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDetailAddID",
+ Name: "dialogDetailAddID",
+ Type: "hidden",
+ Value: dialogDetailAddID}).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDetailAddBodyID",
+ Name: "dialogDetailAddBodyID",
+ Type: "hidden",
+ Value: dialogDetailAddBodyID}).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
@@ -171,7 +188,7 @@ func ContentMasterKelainan(
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs("#" + dialogAddID)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\masterkelainan\masterkelainan.templ`, Line: 104, Col: 39}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\masterkelainan\masterkelainan.templ`, Line: 115, Col: 39}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
@@ -184,7 +201,7 @@ func ContentMasterKelainan(
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs("#" + dialogAddID)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\masterkelainan\masterkelainan.templ`, Line: 113, Col: 38}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\masterkelainan\masterkelainan.templ`, Line: 124, Col: 38}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
@@ -222,7 +239,33 @@ func ContentMasterKelainan(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -234,6 +277,10 @@ func ContentMasterKelainan(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
+ templ_7745c5c3_Err = modalDetailAddForm.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
@@ -253,9 +300,9 @@ func CssKelainan() templ.Component {
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
+ templ_7745c5c3_Var6 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var6 == nil {
+ templ_7745c5c3_Var6 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
@@ -277,9 +324,9 @@ func JsMdKelainan() templ.Component {
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
+ templ_7745c5c3_Var7 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var7 == nil {
+ templ_7745c5c3_Var7 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
if !templ_7745c5c3_IsBuffer {
@@ -304,12 +351,12 @@ func ShowKelainan(
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var6 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var6 == nil {
- templ_7745c5c3_Var6 = templ.NopComponent
+ templ_7745c5c3_Var8 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var8 == nil {
+ templ_7745c5c3_Var8 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Var7 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Var9 := 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()
@@ -324,7 +371,7 @@ func ShowKelainan(
}
return templ_7745c5c3_Err
})
- templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile).Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer)
+ templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile).Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/views/dev/masterkelainan/mdkelainandetailformmodal.templ b/views/dev/masterkelainan/mdkelainandetailformmodal.templ
new file mode 100644
index 0000000..17c03a4
--- /dev/null
+++ b/views/dev/masterkelainan/mdkelainandetailformmodal.templ
@@ -0,0 +1,145 @@
+package masterkelainan
+
+import (
+ "cpone/models"
+ "cpone/component/modal"
+ "cpone/component/customtextfield"
+)
+
+templ KelainanDetailForm(data models.KelainanDetailFormComponent) {
+
+
+
+}
+
+script HandleFormDetailBeforeRequest() {
+ // 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 HandleFormDetailAfterRequest() {
+ // console.log("handle enable btn add");
+
+ const boxes = document.querySelectorAll('.btnaddact');
+
+ for (let i = 0; i < boxes.length; i++) {
+ boxes[i].removeAttribute('disabled');
+
+ }
+}
+
+templ BodyFormKelainanDetail(inputId models.CustomTextFieldv2Prm,
+ inputName models.CustomTextFieldv2Prm,
+ inputSwitch models.SwitchclassPrm,
+ inputClassification models.CustomTextFieldv2Prm,
+ componentID string,
+ hxOnLoad templ.ComponentScript) {
+
+ @customtextfield.CustomTextFieldv2(
+ inputId)
+ @customtextfield.CustomTextFieldv2(
+ inputName)
+ @MainSwitch(inputSwitch)
+
+ @customtextfield.CustomTextFieldv2(
+ inputClassification)
+
+
+}
+
+templ MainSwitch(inp models.SwitchclassPrm) {
+
+
+
+
+
+
+}
+
+script toggleClassification(idswitch string) {
+ var checkbox = document.getElementById(idswitch);
+ // console.log(checkbox)
+ var classificationField = document.getElementById("classificationField");
+ var classificationInput = document.getElementById("classificationname");
+ // console.log(classificationField)
+ if (checkbox.checked) {
+ classificationField.style.display = "block";
+ } else {
+ classificationField.style.display = "none";
+ classificationInput.value = "";
+ }
+}
+
+script JsHideModalDetail(modalID string) {
+ $(modalID).modal('hide')
+}
+
+script JsShowModalDetail(modalID string) {
+ $(modalID).modal('show')
+}
+
+templ ActionFormKelainanDetail(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
+
+
+
+
+}
+
+templ BtnCloseFormKelainanDetail(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
+
+}
diff --git a/views/dev/masterkelainan/mdkelainandetailformmodal_templ.go b/views/dev/masterkelainan/mdkelainandetailformmodal_templ.go
new file mode 100644
index 0000000..b767591
--- /dev/null
+++ b/views/dev/masterkelainan/mdkelainandetailformmodal_templ.go
@@ -0,0 +1,561 @@
+// Code generated by templ - DO NOT EDIT.
+
+// templ: version: v0.2.663
+package masterkelainan
+
+//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/models"
+)
+
+func KelainanDetailForm(data models.KelainanDetailFormComponent) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var1 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var1 == nil {
+ templ_7745c5c3_Var1 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, HandleFormDetailBeforeRequest(), HandleFormDetailAfterRequest())
+ 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 HandleFormDetailBeforeRequest() templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_HandleFormDetailBeforeRequest_6266`,
+ Function: `function __templ_HandleFormDetailBeforeRequest_6266(){// 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_HandleFormDetailBeforeRequest_6266`),
+ CallInline: templ.SafeScriptInline(`__templ_HandleFormDetailBeforeRequest_6266`),
+ }
+}
+
+func HandleFormDetailAfterRequest() templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_HandleFormDetailAfterRequest_4cc7`,
+ Function: `function __templ_HandleFormDetailAfterRequest_4cc7(){// 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_HandleFormDetailAfterRequest_4cc7`),
+ CallInline: templ.SafeScriptInline(`__templ_HandleFormDetailAfterRequest_4cc7`),
+ }
+}
+
+func BodyFormKelainanDetail(inputId models.CustomTextFieldv2Prm,
+ inputName models.CustomTextFieldv2Prm,
+ inputSwitch models.SwitchclassPrm,
+ inputClassification models.CustomTextFieldv2Prm,
+ 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_Var9 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var9 == nil {
+ templ_7745c5c3_Var9 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, hxOnLoad)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(
+ inputId).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(
+ inputName).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = MainSwitch(inputSwitch).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 = customtextfield.CustomTextFieldv2(
+ inputClassification).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 MainSwitch(inp models.SwitchclassPrm) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var12 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var12 == nil {
+ templ_7745c5c3_Var12 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func toggleClassification(idswitch string) templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_toggleClassification_069f`,
+ Function: `function __templ_toggleClassification_069f(idswitch){var checkbox = document.getElementById(idswitch);
+ // console.log(checkbox)
+ var classificationField = document.getElementById("classificationField");
+ var classificationInput = document.getElementById("classificationname");
+ // console.log(classificationField)
+ if (checkbox.checked) {
+ classificationField.style.display = "block";
+ } else {
+ classificationField.style.display = "none";
+ classificationInput.value = "";
+ }
+}`,
+ Call: templ.SafeScript(`__templ_toggleClassification_069f`, idswitch),
+ CallInline: templ.SafeScriptInline(`__templ_toggleClassification_069f`, idswitch),
+ }
+}
+
+func JsHideModalDetail(modalID string) templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_JsHideModalDetail_da6c`,
+ Function: `function __templ_JsHideModalDetail_da6c(modalID){$(modalID).modal('hide')
+}`,
+ Call: templ.SafeScript(`__templ_JsHideModalDetail_da6c`, modalID),
+ CallInline: templ.SafeScriptInline(`__templ_JsHideModalDetail_da6c`, modalID),
+ }
+}
+
+func JsShowModalDetail(modalID string) templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_JsShowModalDetail_3147`,
+ Function: `function __templ_JsShowModalDetail_3147(modalID){$(modalID).modal('show')
+}`,
+ Call: templ.SafeScript(`__templ_JsShowModalDetail_3147`, modalID),
+ CallInline: templ.SafeScriptInline(`__templ_JsShowModalDetail_3147`, modalID),
+ }
+}
+
+func ActionFormKelainanDetail(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_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
+ }
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, JsHideModalDetail(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 BtnCloseFormKelainanDetail(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_Var24 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var24 == nil {
+ templ_7745c5c3_Var24 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, JsHideModalDetail(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
+ })
+}