add feature edit
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
"cpone/services"
|
||||
"cpone/utils"
|
||||
dev_mdnatunitview "cpone/views/dev/mdnatunit"
|
||||
dev_mdusergroupview "cpone/views/dev/mdusergroup"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -25,6 +24,8 @@ 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)
|
||||
GetMdNatUnitByID(id string) (models.NatUnit, error)
|
||||
EditMdNatUnit(id string, code string, name string) (models.NatUnit, error)
|
||||
}
|
||||
|
||||
func NeWMdNatUnitHandler(nu MdNatUnitServices) *MdNatUnitHandler {
|
||||
@@ -45,6 +46,8 @@ func (nh *MdNatUnitHandler) HandleShowMdNatUnitScreen(c echo.Context) error {
|
||||
searchID := utils.GenerateRandomID("searchid")
|
||||
dialogAddID := utils.GenerateRandomID("dialogaddID")
|
||||
dialogAddBodyID := utils.GenerateRandomID("dialogaddbodyID")
|
||||
dialogEditID := utils.GenerateRandomID("dialogEditID")
|
||||
dialogEditBodyID := utils.GenerateRandomID("dialogEditbodyID")
|
||||
dataMenu, err := services.GetMenu()
|
||||
fmt.Println(dataMenu)
|
||||
fmt.Println(err)
|
||||
@@ -108,9 +111,13 @@ func (nh *MdNatUnitHandler) HandleShowMdNatUnitScreen(c echo.Context) error {
|
||||
|
||||
tableComponent := dev_mdnatunitview.TableNatUnit(dataNatUnit,
|
||||
tableID,
|
||||
"/dev/md/natunit/openedit",
|
||||
"#"+dialogEditBodyID,
|
||||
"outerHTML",
|
||||
"#dialogEditBodyID, #dialogEditID",
|
||||
)
|
||||
|
||||
//filter user group component
|
||||
//filter nat unit component
|
||||
natUnitFilterComponent := customtextfieldsearch.MainCustomTextFieldSearchV3(searchID,
|
||||
"search",
|
||||
"Cari Kode/Nama",
|
||||
@@ -183,6 +190,55 @@ func (nh *MdNatUnitHandler) HandleShowMdNatUnitScreen(c echo.Context) error {
|
||||
},
|
||||
)
|
||||
|
||||
// modal edit form
|
||||
dialogEditBodyCmp := 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"},
|
||||
dialogEditBodyID, dev_mdnatunitview.JsHideModal(""),
|
||||
)
|
||||
|
||||
modalActionEditCmp := dev_mdnatunitview.ActionFormNatUnit(
|
||||
"/dev/md/natunit/closeeditform",
|
||||
"#"+dialogEditBodyID,
|
||||
"outerHTML",
|
||||
"#"+dialogEditID,
|
||||
)
|
||||
|
||||
btnCloseModalEdit := dev_mdnatunitview.BtnCloseFormNatUnit(
|
||||
"/dev/md/natunit/closeeditform",
|
||||
"#"+dialogEditBodyID,
|
||||
"outerHTML",
|
||||
"#"+dialogEditID,
|
||||
)
|
||||
|
||||
modalEditFormComponent := dev_mdnatunitview.NatUnitForm(
|
||||
models.NatUnitFormComponent{
|
||||
IDComponent: "formnatunit",
|
||||
Link: "dev/md/natunit/edit",
|
||||
HxTarget: "#" + dialogEditBodyID,
|
||||
HxSwap: "outerHTML",
|
||||
HxInclude: "#tableID, #paginationID, #searchID, #dialogEditBodyID, #dialogEditID, #" + searchID + ", #currpage" + paginationID,
|
||||
ModalID: dialogEditID,
|
||||
ModalTitle: "New - Unit",
|
||||
DialogBody: dialogEditBodyCmp,
|
||||
DialogAction: modalActionEditCmp,
|
||||
ButtonCLose: btnCloseModalEdit,
|
||||
},
|
||||
)
|
||||
|
||||
// content, css, js
|
||||
content := dev_mdnatunitview.MdNatUnitScreen(
|
||||
tableID,
|
||||
@@ -190,11 +246,14 @@ func (nh *MdNatUnitHandler) HandleShowMdNatUnitScreen(c echo.Context) error {
|
||||
searchID,
|
||||
dialogAddID,
|
||||
dialogAddBodyID,
|
||||
dialogEditID,
|
||||
dialogEditBodyID,
|
||||
breadcrumbComponent,
|
||||
tableComponent,
|
||||
natUnitFilterComponent,
|
||||
natUnitPaginationComponent,
|
||||
modalAddFormComponent,
|
||||
modalEditFormComponent,
|
||||
)
|
||||
css := dev_mdnatunitview.CssMdNatUnit()
|
||||
js := dev_mdnatunitview.JsMdNatUnit()
|
||||
@@ -217,6 +276,7 @@ func (nh *MdNatUnitHandler) HandleFilterMdNatUnit(c echo.Context) error {
|
||||
searchID := c.QueryParam("searchID")
|
||||
tableID := c.QueryParam("tableID")
|
||||
paginationID := c.QueryParam("paginationID")
|
||||
dialogEditBodyID := c.QueryParam("dialogEditBodyID")
|
||||
var retval []templ.Component
|
||||
logger, _ := zap.NewProduction()
|
||||
|
||||
@@ -230,7 +290,11 @@ func (nh *MdNatUnitHandler) HandleFilterMdNatUnit(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
tableComponent := dev_mdnatunitview.TableNatUnit(dataNatUnit,
|
||||
tableID)
|
||||
tableID,
|
||||
"/dev/md/natunit/openedit",
|
||||
"#"+dialogEditBodyID,
|
||||
"outerHTML",
|
||||
"#dialogEditBodyID, #dialogEditID")
|
||||
natUnitPaginationComponent := pagination.PaginationV3(
|
||||
totalpage,
|
||||
1,
|
||||
@@ -253,6 +317,7 @@ func (nh *MdNatUnitHandler) HandlerChangePageMdNatUnit(c echo.Context) error {
|
||||
tableID := c.QueryParam("tableID")
|
||||
searchID := c.QueryParam("searchID")
|
||||
paginationID := c.QueryParam("paginationID")
|
||||
dialogEditBodyID := c.QueryParam("dialogEditBodyID")
|
||||
|
||||
var retval []templ.Component
|
||||
logger, _ := zap.NewProduction()
|
||||
@@ -276,7 +341,12 @@ func (nh *MdNatUnitHandler) HandlerChangePageMdNatUnit(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
tableComponent := dev_mdnatunitview.TableNatUnit(dataNatUnit,
|
||||
tableID)
|
||||
tableID,
|
||||
"/dev/md/natunit/openedit",
|
||||
"#"+dialogEditBodyID,
|
||||
"outerHTML",
|
||||
"#dialogEditBodyID, #dialogEditID",
|
||||
)
|
||||
natUnitPaginationComponent := pagination.PaginationV3(
|
||||
totalpage,
|
||||
page,
|
||||
@@ -311,7 +381,7 @@ func (nh *MdNatUnitHandler) HandlerCloseFormAdd(c echo.Context) error {
|
||||
Name: "natunitid",
|
||||
Placeholder: "Kode Unit",
|
||||
Type: "hidden", ID: "natunitinputid"},
|
||||
dialogAddBodyID, dev_mdusergroupview.JsHideModal(""))
|
||||
dialogAddBodyID, dev_mdnatunitview.JsHideModal(""))
|
||||
return utils.View(c, newForm)
|
||||
}
|
||||
|
||||
@@ -329,6 +399,7 @@ func (nh *MdNatUnitHandler) HandlerAddNatUnit(c echo.Context) error {
|
||||
currPagePrm := c.FormValue("currpage" + paginationID)
|
||||
dialogAddBodyID := c.FormValue("dialogAddBodyID")
|
||||
dialogAddID := c.FormValue("dialogAddID")
|
||||
dialogEditBodyID := c.FormValue("dialogEditBodyID")
|
||||
|
||||
currPage, err := strconv.Atoi(currPagePrm)
|
||||
if err != nil {
|
||||
@@ -441,6 +512,10 @@ func (nh *MdNatUnitHandler) HandlerAddNatUnit(c echo.Context) error {
|
||||
tableComponent := dev_mdnatunitview.TableNatUnit(
|
||||
dataNatUnitList,
|
||||
tableID,
|
||||
"/dev/md/natunit/openedit",
|
||||
"#"+dialogEditBodyID,
|
||||
"outerHTML",
|
||||
"#dialogEditBodyID, #dialogEditID",
|
||||
)
|
||||
|
||||
// pagination component
|
||||
@@ -484,3 +559,255 @@ func (nh *MdNatUnitHandler) HandlerAddNatUnit(c echo.Context) error {
|
||||
newForm,
|
||||
})
|
||||
}
|
||||
|
||||
func (nh *MdNatUnitHandler) HandlerOpenEditForm(c echo.Context) error {
|
||||
id := c.QueryParam("id")
|
||||
dialogEditID := c.QueryParam("dialogEditID")
|
||||
dialogEditBodyID := c.QueryParam("dialogEditBodyID")
|
||||
|
||||
dataNatUnit, err := nh.MdNatUnitServices.GetMdNatUnitByID(id)
|
||||
if err != nil {
|
||||
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"},
|
||||
dialogEditBodyID, dev_mdnatunitview.JsHideModal(""))
|
||||
return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Error", "Get unit error", "danger"), newForm})
|
||||
}
|
||||
newForm := dev_mdnatunitview.BodyFormNatUnit(
|
||||
models.CustomTextFieldv2Prm{
|
||||
Label: "Kode Unit",
|
||||
Name: "natunitcode",
|
||||
Placeholder: "Kode Unit",
|
||||
Value: dataNatUnit.Nat_UnitCode,
|
||||
Type: "text",
|
||||
ID: "natunitinputname"},
|
||||
models.CustomTextFieldv2Prm{
|
||||
Label: "Kode Unit",
|
||||
Name: "natunitname",
|
||||
Placeholder: "Kode Unit",
|
||||
Value: dataNatUnit.Nat_UnitName,
|
||||
Type: "text",
|
||||
ID: "natunitinputname"},
|
||||
models.CustomTextFieldv2Prm{
|
||||
Label: "Kode Unit",
|
||||
Name: "natunitid",
|
||||
Placeholder: "Kode Unit",
|
||||
Value: strconv.Itoa(dataNatUnit.Nat_UnitID),
|
||||
Type: "hidden",
|
||||
ID: "natunitinputid"},
|
||||
|
||||
dialogEditBodyID, dev_mdnatunitview.JsShowModal("#"+dialogEditID))
|
||||
|
||||
return utils.View(c, newForm)
|
||||
}
|
||||
|
||||
func (nh *MdNatUnitHandler) HandlerCloseFormEdit(c echo.Context) error {
|
||||
dialogEditBodyID := c.FormValue("dialogEditBodyID")
|
||||
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"},
|
||||
dialogEditBodyID, dev_mdnatunitview.JsHideModal(""))
|
||||
return utils.View(c, newForm)
|
||||
}
|
||||
|
||||
func (nh *MdNatUnitHandler) HandlerEditNatUnit(c echo.Context) error {
|
||||
logger, _ := zap.NewProduction()
|
||||
defer logger.Sync()
|
||||
|
||||
// prm form addnatunit
|
||||
code := c.FormValue("natunitcode")
|
||||
name := c.FormValue("natunitname")
|
||||
id := c.FormValue("natunitid")
|
||||
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")
|
||||
dialogEditID := c.FormValue("dialogEditID")
|
||||
dialogEditBodyID := c.FormValue("dialogEditBodyID")
|
||||
// dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID")
|
||||
|
||||
currPage, err := strconv.Atoi(currPagePrm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger.Info("ADD NAT 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"},
|
||||
dialogEditBodyID, dev_mdnatunitview.JsHideModal(""))
|
||||
return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Warning", formValidation, "warning"), newForm})
|
||||
}
|
||||
|
||||
// edit nat unit service
|
||||
dataNatUnit, err := nh.MdNatUnitServices.EditMdNatUnit(id, 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"},
|
||||
dialogEditBodyID, dev_mdnatunitview.JsHideModal(""))
|
||||
return utils.ViewMulti(c, []templ.Component{
|
||||
customtoastv2.CustomToastV2Show("Error", err.Error(), "danger"), newForm})
|
||||
}
|
||||
|
||||
logger.Info("ADD NAT 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 NAT UNIT",
|
||||
zap.Any("error", err),
|
||||
)
|
||||
fmt.Println(dataNatUnit)
|
||||
return err
|
||||
}
|
||||
|
||||
// table component
|
||||
tableComponent := dev_mdnatunitview.TableNatUnit(
|
||||
dataNatUnitList,
|
||||
tableID,
|
||||
"/dev/md/natunit/openedit",
|
||||
"#"+dialogEditBodyID,
|
||||
"outerHTML",
|
||||
"#dialogEditBodyID, #dialogEditID",
|
||||
)
|
||||
|
||||
// pagination component
|
||||
natUnitPaginationComponent := pagination.PaginationV3(
|
||||
totalPage,
|
||||
currPage,
|
||||
"/dev/md/natunit/changepage",
|
||||
paginationID,
|
||||
"#tableID, #searchID, #"+searchID+", #paginationID, #dialogEditBodyID, #dialogEditID",
|
||||
"#"+paginationID,
|
||||
"outerHTML", "", "true",
|
||||
dev_mdnatunitview.BeforeRequestContent(),
|
||||
dev_mdnatunitview.AfterRequestContent(),
|
||||
)
|
||||
|
||||
var retVal []templ.Component
|
||||
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"},
|
||||
dialogEditBodyID, dev_mdnatunitview.JsHideModal("#"+dialogEditID))
|
||||
toastSuccess := customtoastv2.CustomToastV2Show("Success", "Berhasil edit Unit "+name, "success")
|
||||
retVal = append(retVal, toastSuccess)
|
||||
retVal = append(retVal, tableComponent)
|
||||
retVal = append(retVal, natUnitPaginationComponent)
|
||||
retVal = append(retVal, newForm)
|
||||
return utils.ViewMulti(c, retVal)
|
||||
}
|
||||
|
||||
@@ -255,4 +255,7 @@ func SetupRoutesDev(app *echo.Echo, appStore db.AppStore) {
|
||||
dev.GET("/md/natunit/changepage", devMdNatUnitHandlers.HandlerChangePageMdNatUnit)
|
||||
dev.POST("/md/natunit/closeaddform", devMdNatUnitHandlers.HandlerCloseFormAdd)
|
||||
dev.POST("/md/natunit/add", devMdNatUnitHandlers.HandlerAddNatUnit)
|
||||
dev.GET("/md/natunit/openedit", devMdNatUnitHandlers.HandlerOpenEditForm)
|
||||
dev.POST("/md/natunit/closeeditform", devMdNatUnitHandlers.HandlerCloseFormEdit)
|
||||
dev.POST("/md/natunit/edit", devMdNatUnitHandlers.HandlerEditNatUnit)
|
||||
}
|
||||
|
||||
@@ -178,3 +178,57 @@ func (nu *MdNatUnitServices) AddMdNatUnit(code string, name string) (models.NatU
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (nu *MdNatUnitServices) EditMdNatUnit(id string, 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' AND Nat_UnitID <> ?`
|
||||
err := dbx.Handlex.Select(&datacek, qryCek, code, id)
|
||||
|
||||
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 := `UPDATE nat_unit
|
||||
SET Nat_UnitCode = ?,
|
||||
Nat_UnitName = ?,
|
||||
Nat_UnitLastUpdated = NOW()
|
||||
WHERE Nat_UnitID = ?`
|
||||
rst := dbx.Handlex.MustExec(qry, code, name, id)
|
||||
_, err = rst.RowsAffected()
|
||||
if err != nil {
|
||||
defer logger.Sync()
|
||||
logger.Error("Error Update natunit",
|
||||
zap.String("code", code),
|
||||
zap.String("name", name),
|
||||
)
|
||||
return data, fmt.Errorf("QUERY_FAILED")
|
||||
}
|
||||
|
||||
data, err = nu.GetMdNatUnitByID(id)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -12,11 +12,14 @@ templ MdNatUnitScreen(
|
||||
searchID string,
|
||||
dialogAddID string,
|
||||
dialogAddBodyID string,
|
||||
dialogEditID string,
|
||||
dialogEditBodyID string,
|
||||
breadcrumb templ.Component,
|
||||
tablecontent templ.Component,
|
||||
filterComponent templ.Component,
|
||||
paginationComponent templ.Component,
|
||||
modalAddForm templ.Component) {
|
||||
modalAddForm templ.Component,
|
||||
modalEditForm templ.Component) {
|
||||
<div class="container-fluid">
|
||||
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableID",
|
||||
Name: "tableID",
|
||||
@@ -38,6 +41,14 @@ templ MdNatUnitScreen(
|
||||
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})
|
||||
<div class="row align-items-center mb-10">
|
||||
<div class="col-md-10 col-sm-12 p-0 ">
|
||||
@breadcrumb
|
||||
@@ -67,6 +78,7 @@ templ MdNatUnitScreen(
|
||||
@tablecontent
|
||||
@paginationComponent
|
||||
@modalAddForm
|
||||
@modalEditForm
|
||||
<div id="loading-child" class=" rounded bg-transparent">
|
||||
// <div class="spinner spinner-lg spinner-primary"></div>
|
||||
<div id="loading-spinner" class="spinner-border text-primary d-none" style="width: 3rem; height: 3rem;" role="status">
|
||||
|
||||
@@ -22,11 +22,14 @@ func MdNatUnitScreen(
|
||||
searchID string,
|
||||
dialogAddID string,
|
||||
dialogAddBodyID string,
|
||||
dialogEditID string,
|
||||
dialogEditBodyID string,
|
||||
breadcrumb templ.Component,
|
||||
tablecontent templ.Component,
|
||||
filterComponent templ.Component,
|
||||
paginationComponent templ.Component,
|
||||
modalAddForm templ.Component) templ.Component {
|
||||
modalAddForm templ.Component,
|
||||
modalEditForm 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 {
|
||||
@@ -78,6 +81,20 @@ func MdNatUnitScreen(
|
||||
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 = templ_7745c5c3_Buffer.WriteString("<div class=\"row align-items-center mb-10\"><div class=\"col-md-10 col-sm-12 p-0 \">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
@@ -93,7 +110,7 @@ func MdNatUnitScreen(
|
||||
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\mdnatunit\mdnatunit.templ`, Line: 52, Col: 37}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunit.templ`, Line: 63, Col: 37}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -106,7 +123,7 @@ func MdNatUnitScreen(
|
||||
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\mdnatunit\mdnatunit.templ`, Line: 61, Col: 36}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunit.templ`, Line: 72, Col: 36}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -136,6 +153,10 @@ func MdNatUnitScreen(
|
||||
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 = templ_7745c5c3_Buffer.WriteString("<div id=\"loading-child\" class=\" rounded bg-transparent\"><div id=\"loading-spinner\" class=\"spinner-border text-primary d-none\" style=\"width: 3rem; height: 3rem;\" role=\"status\"><span class=\"sr-only\">Loading...</span></div></div></div><div id=\"loadingcontent\"></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
|
||||
@@ -3,19 +3,34 @@ package dev_mdnatunitview
|
||||
import (
|
||||
"cpone/component/table"
|
||||
"cpone/models"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
templ TableNatUnit(data []models.NatUnit,
|
||||
tableID string,
|
||||
hxGetEdit string,
|
||||
hxTargetEdit string,
|
||||
hxSwapEdit string,
|
||||
hxIncludeEdit string,
|
||||
) {
|
||||
<div id={ tableID } hx-swap-oob="true">
|
||||
@tablecomponent.TableV3([]string{"KODE", "UNIT", "AKSI"},
|
||||
[]string{"40%", "40%", "20%"},
|
||||
RowNatUnit(data))
|
||||
RowNatUnit(data,
|
||||
hxGetEdit,
|
||||
hxTargetEdit,
|
||||
hxSwapEdit,
|
||||
hxIncludeEdit,
|
||||
))
|
||||
</div>
|
||||
}
|
||||
|
||||
templ RowNatUnit(data []models.NatUnit) {
|
||||
templ RowNatUnit(data []models.NatUnit,
|
||||
hxGetEdit string,
|
||||
hxTargetEdit string,
|
||||
hxSwapEdit string,
|
||||
hxIncludeEdit string,
|
||||
) {
|
||||
if len(data) == 0 {
|
||||
<tr>
|
||||
<td colspan="3" class="text-center">Data Tidak Ditemukan</td>
|
||||
@@ -26,8 +41,63 @@ templ RowNatUnit(data []models.NatUnit) {
|
||||
<td>{ v.Nat_UnitCode }</td>
|
||||
<td>{ v.Nat_UnitName }</td>
|
||||
<td>
|
||||
Action
|
||||
@TableAction(v.Nat_UnitID,
|
||||
hxGetEdit,
|
||||
hxTargetEdit,
|
||||
hxSwapEdit,
|
||||
hxIncludeEdit,
|
||||
)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
|
||||
templ TableAction(
|
||||
id int,
|
||||
hxGetEdit string,
|
||||
hxTargetEdit string,
|
||||
hxSwapEdit string,
|
||||
hxIncludeEdit string,
|
||||
) {
|
||||
<div class="row px-5 d-flex justify-content-around">
|
||||
<a
|
||||
type="button"
|
||||
class="btnactionug col-12 col-sm-12 col-md-12 col-lg-5 col-xl-5 col-xxl-5 btn btn-light-tosca mb-2 btn-sm"
|
||||
hx-get={ hxGetEdit + "?id=" + strconv.Itoa(id) }
|
||||
hx-target={ hxTargetEdit }
|
||||
hx-swap={ hxSwapEdit }
|
||||
hx-include={ hxIncludeEdit }
|
||||
hx-indicator={ "#spnredt" + strconv.Itoa(id) }
|
||||
hx-on::before-request={ HandleBeforeRequestRow(strconv.Itoa(id)) }
|
||||
hx-on::after-request={ HandleAfterRequestRow(strconv.Itoa(id)) }
|
||||
>
|
||||
<span id={ "spnredt" + strconv.Itoa(id) } class="htmx-indicator spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
Edit
|
||||
</a>
|
||||
<a
|
||||
type="button"
|
||||
class=" btnactionug col-12 col-sm-12 col-md-12 col-lg-5 col-xl-5 col-xxl-5 btn btn-light-danger mb-2 btn-sm"
|
||||
>
|
||||
<span id={ "spnrdel" + strconv.Itoa(id) } class="htmx-indicator spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
Hapus
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
|
||||
script HandleBeforeRequestRow(id string) {
|
||||
var cusid_ele = document.getElementsByClassName('btnactionug');
|
||||
for (var i = 0; i < cusid_ele.length; ++i) {
|
||||
var item = cusid_ele[i];
|
||||
item.classList.add('disabled');
|
||||
}
|
||||
// console.log(id)
|
||||
}
|
||||
|
||||
script HandleAfterRequestRow(id string) {
|
||||
var cusid_ele = document.getElementsByClassName('btnactionug');
|
||||
for (var i = 0; i < cusid_ele.length; ++i) {
|
||||
var item = cusid_ele[i];
|
||||
item.classList.remove('disabled');
|
||||
}
|
||||
// console.log(id)
|
||||
}
|
||||
|
||||
@@ -13,10 +13,15 @@ import "bytes"
|
||||
import (
|
||||
"cpone/component/table"
|
||||
"cpone/models"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func TableNatUnit(data []models.NatUnit,
|
||||
tableID string,
|
||||
hxGetEdit string,
|
||||
hxTargetEdit string,
|
||||
hxSwapEdit string,
|
||||
hxIncludeEdit 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)
|
||||
@@ -37,7 +42,7 @@ func TableNatUnit(data []models.NatUnit,
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(tableID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 11, Col: 18}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 16, Col: 18}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -49,7 +54,12 @@ func TableNatUnit(data []models.NatUnit,
|
||||
}
|
||||
templ_7745c5c3_Err = tablecomponent.TableV3([]string{"KODE", "UNIT", "AKSI"},
|
||||
[]string{"40%", "40%", "20%"},
|
||||
RowNatUnit(data)).Render(ctx, templ_7745c5c3_Buffer)
|
||||
RowNatUnit(data,
|
||||
hxGetEdit,
|
||||
hxTargetEdit,
|
||||
hxSwapEdit,
|
||||
hxIncludeEdit,
|
||||
)).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -64,7 +74,12 @@ func TableNatUnit(data []models.NatUnit,
|
||||
})
|
||||
}
|
||||
|
||||
func RowNatUnit(data []models.NatUnit) templ.Component {
|
||||
func RowNatUnit(data []models.NatUnit,
|
||||
hxGetEdit string,
|
||||
hxTargetEdit string,
|
||||
hxSwapEdit string,
|
||||
hxIncludeEdit 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 {
|
||||
@@ -91,7 +106,7 @@ func RowNatUnit(data []models.NatUnit) templ.Component {
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(v.Nat_UnitCode)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 26, Col: 23}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 41, Col: 23}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -104,13 +119,26 @@ func RowNatUnit(data []models.NatUnit) templ.Component {
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(v.Nat_UnitName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 27, Col: 23}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 42, Col: 23}
|
||||
}
|
||||
_, 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("</td><td>Action\r</td></tr>")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = TableAction(v.Nat_UnitID,
|
||||
hxGetEdit,
|
||||
hxTargetEdit,
|
||||
hxSwapEdit,
|
||||
hxIncludeEdit,
|
||||
).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td></tr>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -121,3 +149,180 @@ func RowNatUnit(data []models.NatUnit) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func TableAction(
|
||||
id int,
|
||||
hxGetEdit string,
|
||||
hxTargetEdit string,
|
||||
hxSwapEdit string,
|
||||
hxIncludeEdit 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_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("<div class=\"row px-5 d-flex justify-content-around\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, HandleBeforeRequestRow(strconv.Itoa(id)), HandleAfterRequestRow(strconv.Itoa(id)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<a type=\"button\" class=\"btnactionug col-12 col-sm-12 col-md-12 col-lg-5 col-xl-5 col-xxl-5 btn btn-light-tosca mb-2 btn-sm\" hx-get=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(hxGetEdit + "?id=" + strconv.Itoa(id))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 66, Col: 49}
|
||||
}
|
||||
_, 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("\" hx-target=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(hxTargetEdit)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 67, Col: 27}
|
||||
}
|
||||
_, 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("\" hx-swap=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(hxSwapEdit)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 68, Col: 23}
|
||||
}
|
||||
_, 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("\" hx-include=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(hxIncludeEdit)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 69, Col: 29}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-indicator=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs("#spnredt" + strconv.Itoa(id))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 70, Col: 47}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-on::before-request=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 templ.ComponentScript = HandleBeforeRequestRow(strconv.Itoa(id))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12.Call)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-on::after-request=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var13 templ.ComponentScript = HandleAfterRequestRow(strconv.Itoa(id))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var13.Call)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><span id=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs("spnredt" + strconv.Itoa(id))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 74, Col: 42}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"htmx-indicator spinner-border spinner-border-sm\" role=\"status\" aria-hidden=\"true\"></span> Edit\r</a> <a type=\"button\" class=\" btnactionug col-12 col-sm-12 col-md-12 col-lg-5 col-xl-5 col-xxl-5 btn btn-light-danger mb-2 btn-sm\"><span id=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var15 string
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs("spnrdel" + strconv.Itoa(id))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdnatunit\mdnatunittable.templ`, Line: 81, Col: 42}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"htmx-indicator spinner-border spinner-border-sm\" role=\"status\" aria-hidden=\"true\"></span> Hapus\r</a></div>")
|
||||
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 HandleBeforeRequestRow(id string) templ.ComponentScript {
|
||||
return templ.ComponentScript{
|
||||
Name: `__templ_HandleBeforeRequestRow_9a4e`,
|
||||
Function: `function __templ_HandleBeforeRequestRow_9a4e(id){var cusid_ele = document.getElementsByClassName('btnactionug');
|
||||
for (var i = 0; i < cusid_ele.length; ++i) {
|
||||
var item = cusid_ele[i];
|
||||
item.classList.add('disabled');
|
||||
}
|
||||
// console.log(id)
|
||||
}`,
|
||||
Call: templ.SafeScript(`__templ_HandleBeforeRequestRow_9a4e`, id),
|
||||
CallInline: templ.SafeScriptInline(`__templ_HandleBeforeRequestRow_9a4e`, id),
|
||||
}
|
||||
}
|
||||
|
||||
func HandleAfterRequestRow(id string) templ.ComponentScript {
|
||||
return templ.ComponentScript{
|
||||
Name: `__templ_HandleAfterRequestRow_9e81`,
|
||||
Function: `function __templ_HandleAfterRequestRow_9e81(id){var cusid_ele = document.getElementsByClassName('btnactionug');
|
||||
for (var i = 0; i < cusid_ele.length; ++i) {
|
||||
var item = cusid_ele[i];
|
||||
item.classList.remove('disabled');
|
||||
}
|
||||
// console.log(id)
|
||||
}`,
|
||||
Call: templ.SafeScript(`__templ_HandleAfterRequestRow_9e81`, id),
|
||||
CallInline: templ.SafeScriptInline(`__templ_HandleAfterRequestRow_9e81`, id),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user