diff --git a/handlers/dev/md.natunit.handlers.go b/handlers/dev/md.natunit.handlers.go
index fc2491b..443e756 100644
--- a/handlers/dev/md.natunit.handlers.go
+++ b/handlers/dev/md.natunit.handlers.go
@@ -6,12 +6,15 @@ import (
navbarmenu "cpone/component/navbar"
"cpone/component/pagination"
sidebaruserprofile "cpone/component/sidebar_user_profile"
+ customtoastv2 "cpone/component/toastbootstrap"
"cpone/models"
"cpone/services"
"cpone/utils"
dev_mdnatunitview "cpone/views/dev/mdnatunit"
+ dev_mdusergroupview "cpone/views/dev/mdusergroup"
"fmt"
"strconv"
+ "strings"
"github.com/a-h/templ"
"github.com/labstack/echo/v4"
@@ -21,6 +24,7 @@ import (
type MdNatUnitServices interface {
GetListMdNatUnit(search string, currentPage int, rowPerPage int) ([]models.NatUnit, int, error)
GetMdNatUnitBreadCrumb(title string) (models.BreadCrumbV1, error)
+ AddMdNatUnit(code string, name string) (models.NatUnit, error)
}
func NeWMdNatUnitHandler(nu MdNatUnitServices) *MdNatUnitHandler {
@@ -39,6 +43,8 @@ func (nh *MdNatUnitHandler) HandleShowMdNatUnitScreen(c echo.Context) error {
tableID := utils.GenerateRandomID("tablebody")
paginationID := utils.GenerateRandomID("paginationid")
searchID := utils.GenerateRandomID("searchid")
+ dialogAddID := utils.GenerateRandomID("dialogaddID")
+ dialogAddBodyID := utils.GenerateRandomID("dialogaddbodyID")
dataMenu, err := services.GetMenu()
fmt.Println(dataMenu)
fmt.Println(err)
@@ -128,15 +134,67 @@ func (nh *MdNatUnitHandler) HandleShowMdNatUnitScreen(c echo.Context) error {
dev_mdnatunitview.AfterRequestContent(),
)
+ // modal add form
+ dialogAddBodyCmp := dev_mdnatunitview.BodyFormNatUnit(
+ models.CustomTextFieldv2Prm{
+ Label: "Kode Unit",
+ Name: "natunitcode",
+ Placeholder: "Kode Unit",
+ Type: "text", ID: "natunitinputname"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Unit",
+ Name: "natunitname",
+ Placeholder: "Nama Unit",
+ Type: "text", ID: "natunitinputname"},
+ models.CustomTextFieldv2Prm{
+ Label: "Kode Unit",
+ Name: "natunitid",
+ Placeholder: "Kode Unit",
+ Type: "hidden", ID: "natunitinputid"},
+ dialogAddBodyID, dev_mdnatunitview.JsHideModal(""),
+ )
+
+ modalActionAddCmp := dev_mdnatunitview.ActionFormNatUnit(
+ "/dev/md/natunit/closeaddform",
+ "#"+dialogAddBodyID,
+ "outerHTML",
+ "#"+dialogAddID,
+ )
+
+ btnCloseModalAdd := dev_mdnatunitview.BtnCloseFormNatUnit(
+ "/dev/md/natunit/closeaddform",
+ "#"+dialogAddBodyID,
+ "outerHTML",
+ "#"+dialogAddID,
+ )
+
+ modalAddFormComponent := dev_mdnatunitview.NatUnitForm(
+ models.NatUnitFormComponent{
+ IDComponent: "formnatunit",
+ Link: "/dev/md/natunit/add",
+ HxTarget: "#" + dialogAddBodyID,
+ HxSwap: "outerHTML",
+ HxInclude: "#tableID, #paginationID, #searchID, #dialogAddBodyID, #dialogAddID, #" + searchID + ", #currpage" + paginationID,
+ ModalID: dialogAddID,
+ ModalTitle: "New - Unit",
+ DialogBody: dialogAddBodyCmp,
+ DialogAction: modalActionAddCmp,
+ ButtonCLose: btnCloseModalAdd,
+ },
+ )
+
// content, css, js
content := dev_mdnatunitview.MdNatUnitScreen(
tableID,
paginationID,
searchID,
+ dialogAddID,
+ dialogAddBodyID,
breadcrumbComponent,
tableComponent,
natUnitFilterComponent,
natUnitPaginationComponent,
+ modalAddFormComponent,
)
css := dev_mdnatunitview.CssMdNatUnit()
js := dev_mdnatunitview.JsMdNatUnit()
@@ -234,3 +292,195 @@ func (nh *MdNatUnitHandler) HandlerChangePageMdNatUnit(c echo.Context) error {
retval = append(retval, natUnitPaginationComponent)
return utils.ViewMulti(c, retval)
}
+
+func (nh *MdNatUnitHandler) HandlerCloseFormAdd(c echo.Context) error {
+ dialogAddBodyID := c.FormValue("dialogAddBodyID")
+ newForm := dev_mdnatunitview.BodyFormNatUnit(
+ models.CustomTextFieldv2Prm{
+ Label: "Kode Unit",
+ Name: "natunitcode",
+ Placeholder: "Kode Unit",
+ Type: "text", ID: "natunitinputname"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Unit",
+ Name: "natunitname",
+ Placeholder: "Nama Unit",
+ Type: "text", ID: "natunitinputname"},
+ models.CustomTextFieldv2Prm{
+ Label: "Kode Unit",
+ Name: "natunitid",
+ Placeholder: "Kode Unit",
+ Type: "hidden", ID: "natunitinputid"},
+ dialogAddBodyID, dev_mdusergroupview.JsHideModal(""))
+ return utils.View(c, newForm)
+}
+
+func (nh *MdNatUnitHandler) HandlerAddNatUnit(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+ defer logger.Sync()
+
+ // prm form addnatunit
+ code := c.FormValue("natunitcode")
+ name := c.FormValue("natunitname")
+ tableID := c.FormValue("tableID")
+ paginationID := c.FormValue("paginationID")
+ searchID := c.FormValue("searchID")
+ search := c.FormValue("search")
+ currPagePrm := c.FormValue("currpage" + paginationID)
+ dialogAddBodyID := c.FormValue("dialogAddBodyID")
+ dialogAddID := c.FormValue("dialogAddID")
+
+ currPage, err := strconv.Atoi(currPagePrm)
+ if err != nil {
+ return err
+ }
+ logger.Info("ADD UNIT PARAM",
+ zap.Any("code", code),
+ zap.Any("nama", name),
+ zap.Any("tableid", tableID),
+ zap.Any("search", search),
+ zap.Any("currpage", currPage),
+ )
+
+ formValidation := ""
+ codeValidation := ""
+ nameValidation := ""
+ if strings.TrimSpace(code) == "" {
+ formValidation = "Code unit tidak boleh kosong"
+ codeValidation = "Code unit tidak boleh kosong"
+ nameValidation = ""
+ }
+ if strings.TrimSpace(name) == "" {
+ formValidation = "Nama unit tidak boleh kosong"
+ codeValidation = ""
+ nameValidation = "Nama unit tidak boleh kosong"
+ }
+ if strings.TrimSpace(code) == "" && strings.TrimSpace(name) == "" {
+ formValidation = "Code dan nama unit tidak boleh kosong"
+ codeValidation = "Code unit tidak boleh kosong"
+ nameValidation = "Nama unit tidak boleh kosong"
+
+ }
+
+ if formValidation != "" || codeValidation != "" || nameValidation != "" {
+ newForm := dev_mdnatunitview.BodyFormNatUnit(
+ models.CustomTextFieldv2Prm{
+ Label: "Kode Unit",
+ Name: "natunitcode",
+ Placeholder: "Kode Unit",
+ ErrorMsg: codeValidation,
+ Value: code,
+ Type: "text"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Unit",
+ Name: "natunitname",
+ Placeholder: "Nama Unit",
+ ErrorMsg: nameValidation,
+ Value: name,
+ Type: "text"},
+ models.CustomTextFieldv2Prm{
+ Label: "Kode Unit",
+ Name: "natunitid",
+ Placeholder: "Kode Unit",
+ Type: "hidden", ID: "natunitinputid"},
+ dialogAddBodyID, dev_mdnatunitview.JsHideModal(""))
+ return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Warning", formValidation, "warning"), newForm})
+ }
+
+ // add nat unit service
+ dataNatUnit, err := nh.MdNatUnitServices.AddMdNatUnit(code, name)
+ if err != nil {
+ logger.Info("Error",
+ zap.Any("Error", err),
+ zap.Any("code", code),
+ zap.Any("name", name),
+ )
+ newForm := dev_mdnatunitview.BodyFormNatUnit(
+ models.CustomTextFieldv2Prm{
+ Label: "Kode Unit",
+ Name: "natunitcode",
+ Placeholder: "Kode Unit",
+ ErrorMsg: codeValidation,
+ Value: code,
+ Type: "text"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Unit",
+ Name: "natunitname",
+ Placeholder: "Nama Unit",
+ ErrorMsg: nameValidation,
+ Value: name,
+ Type: "text"},
+ models.CustomTextFieldv2Prm{
+ Label: "Kode Unit",
+ Name: "natunitid",
+ Placeholder: "Kode Unit",
+ Type: "hidden", ID: "natunitinputid"},
+ dialogAddBodyID, dev_mdnatunitview.JsHideModal(""))
+ return utils.ViewMulti(c, []templ.Component{
+ customtoastv2.CustomToastV2Show("Error", err.Error(), "danger"),
+ newForm})
+ }
+ logger.Info("ADD UNIT",
+ zap.Any("return", dataNatUnit),
+ zap.Any("code", code),
+ zap.Any("name", name),
+ )
+
+ // get list nat unit for table
+ dataNatUnitList, totalPage, err := nh.MdNatUnitServices.GetListMdNatUnit(search, currPage, 5)
+ if err != nil {
+ defer logger.Sync()
+ logger.Info("ERROR GET UNIT",
+ zap.Any("error", err),
+ )
+ fmt.Println(dataNatUnit)
+ return err
+ }
+
+ // table component
+ tableComponent := dev_mdnatunitview.TableNatUnit(
+ dataNatUnitList,
+ tableID,
+ )
+
+ // pagination component
+ natUnitPaginationComponent := pagination.PaginationV3(
+ totalPage,
+ currPage,
+ "/dev/md/natunit/changepage",
+ paginationID,
+ "#tableID, #searchID, #"+searchID+", #paginationID",
+ "#"+paginationID,
+ "outerHTML", "", "true",
+ dev_mdnatunitview.BeforeRequestContent(),
+ dev_mdnatunitview.AfterRequestContent(),
+ )
+
+ newForm := dev_mdnatunitview.BodyFormNatUnit(
+ models.CustomTextFieldv2Prm{
+ Label: "Kode Unit",
+ Name: "natunitcode",
+ Placeholder: "Kode Unit",
+ ErrorMsg: codeValidation,
+ Type: "text"},
+ models.CustomTextFieldv2Prm{
+ Label: "Nama Unit",
+ Name: "natunitname",
+ Placeholder: "Nama Unit",
+ ErrorMsg: nameValidation,
+ Type: "text"},
+ models.CustomTextFieldv2Prm{
+ Label: "Kode Unit",
+ Name: "natunitid",
+ Placeholder: "Kode Unit",
+ Type: "hidden", ID: "natunitinputid"},
+ dialogAddBodyID, dev_mdnatunitview.JsHideModal("#"+dialogAddID))
+ toastSuccess := customtoastv2.CustomToastV2Show("Success", "Berhasil insert unit "+name, "success")
+
+ return utils.ViewMulti(c, []templ.Component{
+ toastSuccess,
+ tableComponent,
+ natUnitPaginationComponent,
+ newForm,
+ })
+}
diff --git a/handlers/routes.go b/handlers/routes.go
index 54d5ed4..4c2c317 100644
--- a/handlers/routes.go
+++ b/handlers/routes.go
@@ -253,4 +253,6 @@ func SetupRoutesDev(app *echo.Echo, appStore db.AppStore) {
dev.GET("/md/natunit", devMdNatUnitHandlers.HandleShowMdNatUnitScreen)
dev.GET("/md/natunit/filter", devMdNatUnitHandlers.HandleFilterMdNatUnit)
dev.GET("/md/natunit/changepage", devMdNatUnitHandlers.HandlerChangePageMdNatUnit)
+ dev.POST("/md/natunit/closeaddform", devMdNatUnitHandlers.HandlerCloseFormAdd)
+ dev.POST("/md/natunit/add", devMdNatUnitHandlers.HandlerAddNatUnit)
}
diff --git a/models/natunit.models.go b/models/natunit.models.go
index f5cf236..2f5301f 100644
--- a/models/natunit.models.go
+++ b/models/natunit.models.go
@@ -1,5 +1,7 @@
package models
+import "github.com/a-h/templ"
+
type NatUnit struct {
Nomor string `db:"nomor"`
Nat_UnitID int `db:"Nat_UnitID"`
@@ -9,3 +11,19 @@ type NatUnit struct {
Nat_UnitLastUpdated string `db:"Nat_UnitLastUpdated"`
Nat_UnitIsActive string `db:"Nat_UnitIsActive"`
}
+
+type NatUnitFormComponent struct {
+ IDComponent string
+ Link string
+ HxTarget string
+ HxSwap string
+ HxInclude string
+ ModalID string
+ ModalTitle string
+ InputName CustomTextFieldv2Prm
+ InputCode CustomTextFieldv2Prm
+ InputID CustomTextFieldv2Prm
+ DialogBody templ.Component
+ DialogAction templ.Component
+ ButtonCLose templ.Component
+}
diff --git a/services/dev/md.natunit.services.go b/services/dev/md.natunit.services.go
index 43f024c..cde45fb 100644
--- a/services/dev/md.natunit.services.go
+++ b/services/dev/md.natunit.services.go
@@ -6,7 +6,10 @@ import (
dbx "cpone/package/database"
"fmt"
"math"
+ "strconv"
"strings"
+
+ "go.uber.org/zap"
)
func NewMdNatUnitServices(uStore db.AppStore) *MdNatUnitServices {
@@ -104,3 +107,74 @@ func (nu *MdNatUnitServices) GetMdNatUnitBreadCrumb(title string) (models.BreadC
return ret, nil
}
+
+func (nu *MdNatUnitServices) GetMdNatUnitByID(id string) (models.NatUnit, error) {
+ logger, _ := zap.NewProduction()
+
+ var data models.NatUnit
+ err := dbx.Handlex.Get(&data, `SELECT * FROM nat_unit
+ WHERE Nat_UnitID = ?`, id)
+
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error get data unit by id",
+ zap.String("ID", id),
+ zap.Error(err),
+ )
+ return data, fmt.Errorf("QUERY_FAILED")
+ }
+ return data, nil
+}
+
+func (nu *MdNatUnitServices) AddMdNatUnit(code string, name string) (models.NatUnit, error) {
+ logger, _ := zap.NewProduction()
+ var data models.NatUnit
+ var datacek []models.NatUnit
+
+ qryCek := `SELECT Nat_UnitCode FROM nat_unit
+ WHERE Nat_UnitCode = ? AND Nat_UnitIsActive = 'Y'`
+ err := dbx.Handlex.Select(&datacek, qryCek, code)
+
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error cek data by code",
+ zap.String("code", code),
+ 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("code", code),
+ )
+ return data, fmt.Errorf("code sudah dipakai")
+ }
+
+ qry := `INSERT INTO nat_unit
+ (Nat_UnitCode,
+ Nat_UnitName) VALUES(?,?)`
+ rst := dbx.Handlex.MustExec(qry, code, name)
+ insertedID, err := rst.LastInsertId()
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error Insert natunit",
+ zap.String("code", code),
+ zap.String("name", name),
+ )
+ return data, fmt.Errorf("QUERY_FAILED")
+ }
+
+ s := strconv.Itoa(int(insertedID))
+ data, err = nu.GetMdNatUnitByID(s)
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error get natunit by id",
+ zap.String("code", code),
+ zap.String("name", name),
+ )
+ return data, fmt.Errorf("QUERY_FAILED")
+ }
+ return data, nil
+}
diff --git a/views/dev/mdnatunit/mdnatunit.templ b/views/dev/mdnatunit/mdnatunit.templ
index 65a768b..332d399 100644
--- a/views/dev/mdnatunit/mdnatunit.templ
+++ b/views/dev/mdnatunit/mdnatunit.templ
@@ -10,10 +10,13 @@ templ MdNatUnitScreen(
tableID string,
paginationID string,
searchID string,
+ dialogAddID string,
+ dialogAddBodyID string,
breadcrumb templ.Component,
tablecontent templ.Component,
filterComponent templ.Component,
- paginationComponent templ.Component) {
+ paginationComponent templ.Component,
+ modalAddForm templ.Component) {
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableID",
Name: "tableID",
@@ -27,6 +30,14 @@ templ MdNatUnitScreen(
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})
@breadcrumb
@@ -38,6 +49,7 @@ templ MdNatUnitScreen(
type="button"
class="btn btn-primary"
data-toggle="modal"
+ data-target={ "#" + dialogAddID }
>Add New
@@ -46,6 +58,7 @@ templ MdNatUnitScreen(
type="button"
class="btn btn-primary btn-block"
data-toggle="modal"
+ data-target={ "#" + dialogAddID }
>Add New
@@ -53,6 +66,7 @@ templ MdNatUnitScreen(
@tablecontent
@paginationComponent
+ @modalAddForm
//
diff --git a/views/dev/mdnatunit/mdnatunit_templ.go b/views/dev/mdnatunit/mdnatunit_templ.go
index 532d8e2..16c114c 100644
--- a/views/dev/mdnatunit/mdnatunit_templ.go
+++ b/views/dev/mdnatunit/mdnatunit_templ.go
@@ -20,10 +20,13 @@ func MdNatUnitScreen(
tableID string,
paginationID string,
searchID string,
+ dialogAddID string,
+ dialogAddBodyID string,
breadcrumb templ.Component,
tablecontent templ.Component,
filterComponent templ.Component,
- paginationComponent templ.Component) templ.Component {
+ paginationComponent templ.Component,
+ modalAddForm 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 {
@@ -61,6 +64,20 @@ func MdNatUnitScreen(
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 = templ_7745c5c3_Buffer.WriteString("
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
@@ -69,7 +86,33 @@ func MdNatUnitScreen(
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
}
@@ -89,6 +132,10 @@ func MdNatUnitScreen(
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 = templ_7745c5c3_Buffer.WriteString("
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
@@ -108,9 +155,9 @@ func CssMdNatUnit() templ.Component {
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
+ 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("")
@@ -132,9 +179,9 @@ func JsMdNatUnit() templ.Component {
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
+ 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("")
@@ -193,12 +240,12 @@ func ShowMdNatUnitScreen(title string, cmp templ.Component, css 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_Var5 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Var7 := 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()
@@ -213,7 +260,7 @@ func ShowMdNatUnitScreen(title string, cmp templ.Component, css templ.Component,
}
return templ_7745c5c3_Err
})
- templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile).Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer)
+ templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile).Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/views/dev/mdnatunit/mdnatunitformmodal.templ b/views/dev/mdnatunit/mdnatunitformmodal.templ
new file mode 100644
index 0000000..2422185
--- /dev/null
+++ b/views/dev/mdnatunit/mdnatunitformmodal.templ
@@ -0,0 +1,134 @@
+package dev_mdnatunitview
+
+import "cpone/models"
+import "cpone/component/modal"
+import "cpone/component/customtextfield"
+
+templ NatUnitForm(data models.NatUnitFormComponent) {
+
+
+
+}
+
+script HandleFormBeforeRequest() {
+ console.log("handle disable btn add");
+ const btnActCancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+ for (let i = 0; i < btnActCancel.length; i++) {
+ btnActCancel[i].setAttribute('disabled', 'true');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].setAttribute('disabled', 'true');
+
+ }
+}
+
+script HandleFormAfterRequest() {
+ console.log("handle enable btn add");
+
+ const btnactcancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+
+ for (let i = 0; i < btnactcancel.length; i++) {
+ btnactcancel[i].removeAttribute('disabled');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].removeAttribute('disabled');
+
+ }
+}
+
+templ BodyFormNatUnit(inputId models.CustomTextFieldv2Prm,
+ inputCode models.CustomTextFieldv2Prm,
+ inputName models.CustomTextFieldv2Prm,
+ componentID string,
+ hxOnLoad templ.ComponentScript) {
+
+ @customtextfield.CustomTextFieldv2(
+ inputId)
+ @customtextfield.CustomTextFieldv2(
+ inputCode)
+ @customtextfield.CustomTextFieldv2(
+ inputName)
+
+}
+
+script JsHideModal(modalID string) {
+ $(modalID).modal('hide')
+}
+
+script JsShowModal(modalID string) {
+ $(modalID).modal('show')
+ const btnactcancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+
+ for (let i = 0; i < btnactcancel.length; i++) {
+ btnactcancel[i].removeAttribute('disabled');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].removeAttribute('disabled');
+
+ }
+}
+
+templ ActionFormNatUnit(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
+
+
+
+
+}
+
+templ BtnCloseFormNatUnit(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
+
+}
diff --git a/views/dev/mdnatunit/mdnatunitformmodal_templ.go b/views/dev/mdnatunit/mdnatunitformmodal_templ.go
new file mode 100644
index 0000000..03ba642
--- /dev/null
+++ b/views/dev/mdnatunit/mdnatunitformmodal_templ.go
@@ -0,0 +1,447 @@
+// Code generated by templ - DO NOT EDIT.
+
+// templ: version: v0.2.663
+package dev_mdnatunitview
+
+//lint:file-ignore SA4006 This context is only used if a nested component is present.
+
+import "github.com/a-h/templ"
+import "context"
+import "io"
+import "bytes"
+
+import "cpone/models"
+import "cpone/component/modal"
+import "cpone/component/customtextfield"
+
+func NatUnitForm(data models.NatUnitFormComponent) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var1 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var1 == nil {
+ templ_7745c5c3_Var1 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, HandleFormBeforeRequest(), HandleFormAfterRequest())
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ 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_2922`,
+ Function: `function __templ_HandleFormBeforeRequest_2922(){console.log("handle disable btn add");
+ const btnActCancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+ for (let i = 0; i < btnActCancel.length; i++) {
+ btnActCancel[i].setAttribute('disabled', 'true');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].setAttribute('disabled', 'true');
+
+ }
+}`,
+ Call: templ.SafeScript(`__templ_HandleFormBeforeRequest_2922`),
+ CallInline: templ.SafeScriptInline(`__templ_HandleFormBeforeRequest_2922`),
+ }
+}
+
+func HandleFormAfterRequest() templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_HandleFormAfterRequest_956b`,
+ Function: `function __templ_HandleFormAfterRequest_956b(){console.log("handle enable btn add");
+
+ const btnactcancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+
+ for (let i = 0; i < btnactcancel.length; i++) {
+ btnactcancel[i].removeAttribute('disabled');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].removeAttribute('disabled');
+
+ }
+}`,
+ Call: templ.SafeScript(`__templ_HandleFormAfterRequest_956b`),
+ CallInline: templ.SafeScriptInline(`__templ_HandleFormAfterRequest_956b`),
+ }
+}
+
+func BodyFormNatUnit(inputId models.CustomTextFieldv2Prm,
+ inputCode models.CustomTextFieldv2Prm,
+ inputName 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(
+ inputCode).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(
+ inputName).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func JsHideModal(modalID string) templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_JsHideModal_da6c`,
+ Function: `function __templ_JsHideModal_da6c(modalID){$(modalID).modal('hide')
+}`,
+ Call: templ.SafeScript(`__templ_JsHideModal_da6c`, modalID),
+ CallInline: templ.SafeScriptInline(`__templ_JsHideModal_da6c`, modalID),
+ }
+}
+
+func JsShowModal(modalID string) templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_JsShowModal_b74d`,
+ Function: `function __templ_JsShowModal_b74d(modalID){$(modalID).modal('show')
+ const btnactcancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+
+ for (let i = 0; i < btnactcancel.length; i++) {
+ btnactcancel[i].removeAttribute('disabled');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].removeAttribute('disabled');
+
+ }
+}`,
+ Call: templ.SafeScript(`__templ_JsShowModal_b74d`, modalID),
+ CallInline: templ.SafeScriptInline(`__templ_JsShowModal_b74d`, modalID),
+ }
+}
+
+func ActionFormNatUnit(LinkClose string, targetClose string, hxSwapClose string, modalID string) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var12 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var12 == nil {
+ templ_7745c5c3_Var12 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, JsHideModal(modalID))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func BtnCloseFormNatUnit(LinkClose string, targetClose string, hxSwapClose string, modalID string) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var17 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var17 == nil {
+ templ_7745c5c3_Var17 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, JsHideModal(modalID))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}