This commit is contained in:
Sas Andy
2024-05-29 11:04:41 +07:00
parent e227d59a39
commit 23f8fd513d
9 changed files with 1910 additions and 252 deletions

View File

@@ -5,11 +5,13 @@ 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_mdbahanview "cpone/views/dev/mdbahan"
"strconv"
"strings"
"github.com/a-h/templ"
"github.com/labstack/echo/v4"
@@ -23,7 +25,11 @@ type MdBahanServices interface {
currentPage int,
rowPerPage int) ([]models.Bahan, int, error)
GetMdBahanBreadCrumb(title string) (models.BreadCrumbV1, error)
GetListSampleStation() ([]models.TmpSampleStation, error)
GetListSampleStation(isFilter bool) ([]models.TmpSampleStation, error)
AddMdBahan(code string, name string, stationid string) (bool, error)
EditMdBahan(id string, code string, name string, stationid string) (bool, error)
GetMdBahanByID(id string) (models.Bahan, error)
DeleteMdBahan(id string) (bool, error)
}
func NewMdBahanHandler(us MdBahanServices) *MdBahanHandler {
@@ -41,6 +47,13 @@ func (lh *MdBahanHandler) HandleShowMdBahanScreen(c echo.Context) error {
dataMenu, err := services.GetMenu()
paginationID := utils.GenerateRandomID("paginationID")
modalAddID := utils.GenerateRandomID("modalAdd")
modalAddBodyID := utils.GenerateRandomID("modalAddbody")
modalEditID := utils.GenerateRandomID("modalEdit")
modalEditBodyID := utils.GenerateRandomID("modalEditbody")
modalDeleteID := utils.GenerateRandomID("modalDelete")
modalDeleteBodyID := utils.GenerateRandomID("modalDeletebody")
tableBahanID := utils.GenerateRandomID("BahanID")
if err != nil {
defer logger.Sync()
@@ -80,36 +93,47 @@ func (lh *MdBahanHandler) HandleShowMdBahanScreen(c echo.Context) error {
// sidebar
sidebaruserprofileComponent := sidebaruserprofile.Navbaruserprofile(dataUser)
bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan("", "1", 1, 5)
bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan("", "0", 1, 5)
defer logger.Sync()
logger.Info("GET DATA BAHAN",
zap.Any("data", bahanList),
zap.Any("err", err),
zap.Any("totalPage", totalPage),
)
stationList, err := lh.MdBahanServices.GetListSampleStation()
stationListFilter, err := lh.MdBahanServices.GetListSampleStation(true)
defer logger.Sync()
logger.Info("GET DATA BAHAN",
zap.Any("data", bahanList),
logger.Info("GET STATION LIST Filter",
zap.Any("err", err),
)
stationList, err := lh.MdBahanServices.GetListSampleStation(false)
defer logger.Sync()
logger.Info("GET STATION LIST ",
zap.Any("err", err),
zap.Any("totalPage", totalPage),
)
//Bahan Table
tableBahanID := utils.GenerateRandomID("BahanID")
// #dialogDeleteBodyID, #dialogDeleteID
mdBahanTable := dev_mdbahanview.TableBahan(
bahanList,
tableBahanID, "getedt", "trgtEdit", "swpEdit", "imcldEdit", "getDlt", "trgtDlt", "swpDlt", "imcldDlt")
tableBahanID,
"/dev/md/bahan/openedit",
"#"+modalEditBodyID,
"outerHTML",
"#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
"/dev/md/bahan/opendelete",
"#"+modalDeleteBodyID,
"outerHTML",
"#dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #dialogEditID")
//FIlter table
mdBahanFilter := dev_mdbahanview.MdBahanFilter(
"/dev/md/bahan/filter",
"input changed delay:500ms",
"#filter-name, #filter-station, #tableID, #paginationID",
"#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
"outerHTML",
"#"+paginationID,
stationList,
stationList[0].T_SampleStationID,
stationListFilter,
stationListFilter[0].T_SampleStationID,
dev_mdbahanview.BeforeRequestContent(),
dev_mdbahanview.AfterRequestContent(),
)
@@ -120,7 +144,7 @@ func (lh *MdBahanHandler) HandleShowMdBahanScreen(c echo.Context) error {
totalPage, 1,
"/dev/md/bahan/pagination",
paginationID,
"#filter-name, #filter-station, #tableID, #paginationID, #currpage"+paginationID,
"#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
"#"+paginationID,
"outerHTML",
"",
@@ -128,8 +152,112 @@ func (lh *MdBahanHandler) HandleShowMdBahanScreen(c echo.Context) error {
dev_mdbahanview.BeforeRequestContent(),
dev_mdbahanview.AfterRequestContent(),
)
//Form Add
modalAddBody := dev_mdbahanview.BodyFormBahan(
"",
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
},
modalAddBodyID,
dev_mdbahanview.JsShowModal(""),
)
modalAddAction := dev_mdbahanview.ActionFormBahan("/dev/md/bahan/closeaddform", "#"+modalAddBodyID, "outerHTML", "#"+modalAddID)
modalAddBtnCls := dev_mdbahanview.BtnCloseFormBahan("/dev/md/bahan/closeaddform", "#"+modalAddBodyID, "outerHTML", "#"+modalAddID)
modalAddBahan := dev_mdbahanview.BahanForm(models.BahanFormComponent{
IDComponent: "",
Link: "/dev/md/bahan/add",
HxTarget: "#" + modalAddBodyID,
HxSwap: "outerHTML",
HxInclude: "#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage" + paginationID,
ModalID: modalAddID,
ModalTitle: "New-Bahan",
DialogBody: modalAddBody,
DialogAction: modalAddAction,
ButtonCLose: modalAddBtnCls,
})
mdBahanScreen := dev_mdbahanview.MdBahanScreen(tableBahanID, paginationID, breadcrumbComponent, mdBahanTable, mdBahanFilter, mdbahanPagination)
//Form Edit
modalEditBody := dev_mdbahanview.BodyFormBahan(
"",
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
},
modalEditBodyID,
dev_mdbahanview.JsShowModal(""),
)
modalEditAction := dev_mdbahanview.ActionFormBahan("/dev/md/bahan/closeeditform", "#"+modalEditBodyID, "outerHTML", "#"+modalEditID)
modalEditBtnCls := dev_mdbahanview.BtnCloseFormBahan("/dev/md/bahan/closeeditform", "#"+modalEditBodyID, "outerHTML", "#"+modalEditID)
modalEditBahan := dev_mdbahanview.BahanForm(models.BahanFormComponent{
IDComponent: "",
Link: "/dev/md/bahan/edit",
HxTarget: "#" + modalEditBodyID,
HxSwap: "outerHTML",
HxInclude: "#filter-name, #filter-station, #tableID, #paginationID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage" + paginationID,
ModalID: modalEditID,
ModalTitle: "Edit-Bahan",
DialogBody: modalEditBody,
DialogAction: modalEditAction,
ButtonCLose: modalEditBtnCls,
})
//Form Delete
modalDeleteBody := dev_mdbahanview.DeleteConfirmationBody(
"",
modalDeleteBodyID,
"Apakah anda yakin menghapus bahan berikut ?",
[]string{"Kode", "Nama Bahan", "Sample Station"},
[]string{"", "", ""}, dev_mdbahanview.JsShowModal(""))
modalDeleteAction := dev_mdbahanview.ActionFormBahanDelete("/dev/md/bahan/closedeleteform", "#"+modalDeleteBodyID, "outerHTML", "#"+modalDeleteID)
modalDeleteBtnCls := dev_mdbahanview.BtnCloseFormBahan("/dev/md/bahan/closedeleteform", "#"+modalDeleteBodyID, "outerHTML", "#"+modalDeleteID)
modalDeleteBahan := dev_mdbahanview.BahanForm(models.BahanFormComponent{
IDComponent: "",
Link: "/dev/md/bahan/delete",
HxTarget: "#" + modalDeleteBodyID,
HxSwap: "outerHTML",
HxInclude: "#filter-name, #filter-station, #tableID, #paginationID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage" + paginationID,
ModalID: modalDeleteID,
ModalTitle: "Delete-Bahan",
DialogBody: modalDeleteBody,
DialogAction: modalDeleteAction,
ButtonCLose: modalDeleteBtnCls,
})
mdBahanScreen := dev_mdbahanview.MdBahanScreen(
tableBahanID,
paginationID,
modalAddID,
modalAddBodyID,
modalEditID,
modalEditBodyID,
modalDeleteID,
modalDeleteBodyID,
breadcrumbComponent,
mdBahanTable,
mdBahanFilter,
mdbahanPagination,
modalAddBahan,
modalEditBahan,
modalDeleteBahan)
cssMdBahan := dev_mdbahanview.CssMdUserGroup()
jsMdBahan := dev_mdbahanview.JsMdBahan()
@@ -149,6 +277,8 @@ func (lh *MdBahanHandler) HandleFilterMdBahan(c echo.Context) error {
var retval []templ.Component
filtername := c.QueryParam("filtername")
filterstation := c.QueryParam("filterstation")
dialogEditBodyID := c.QueryParam("dialogEditBodyID")
dialogDeleteBodyID := c.QueryParam("dialogDeleteBodyID")
tableID := c.QueryParam("tableID")
paginationID := c.QueryParam("paginationID")
bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan(filtername, filterstation, 1, 5)
@@ -162,14 +292,22 @@ func (lh *MdBahanHandler) HandleFilterMdBahan(c echo.Context) error {
mdBahanTable := dev_mdbahanview.TableBahan(
bahanList,
tableID, "getedt", "trgtEdit", "swpEdit", "imcldEdit", "getDlt", "trgtDlt", "swpDlt", "imcldDlt")
tableID,
"/dev/md/bahan/openedit",
"#"+dialogEditBodyID,
"outerHTML",
"#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
"/dev/md/bahan/opendelete",
"#"+dialogDeleteBodyID,
"outerHTML",
"#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID")
//Pagination
mdbahanPagination := pagination.PaginationV3(
totalPage, 1,
"/dev/md/bahan/pagination",
paginationID,
"#filter-name, #filter-station, #tableID, #paginationID, #currpage"+paginationID,
"#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
"#"+paginationID,
"outerHTML",
"",
@@ -189,6 +327,8 @@ func (lh *MdBahanHandler) HandlePaginationMdBahan(c echo.Context) error {
filtername := c.QueryParam("filtername")
filterstation := c.QueryParam("filterstation")
tableID := c.QueryParam("tableID")
dialogEditBodyID := c.QueryParam("dialogEditBodyID")
dialogDeleteBodyID := c.QueryParam("dialogDeleteBodyID")
paginationID := c.QueryParam("paginationID")
page, err := strconv.Atoi(pageparam)
if err != nil {
@@ -210,14 +350,22 @@ func (lh *MdBahanHandler) HandlePaginationMdBahan(c echo.Context) error {
mdBahanTable := dev_mdbahanview.TableBahan(
bahanList,
tableID, "getedt", "trgtEdit", "swpEdit", "imcldEdit", "getDlt", "trgtDlt", "swpDlt", "imcldDlt")
tableID,
"/dev/md/bahan/openedit",
"#"+dialogEditBodyID,
"outerHTML",
"#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
"/dev/md/bahan/opendelete",
"#"+dialogDeleteBodyID,
"outerHTML",
"#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID")
//Pagination
mdbahanPagination := pagination.PaginationV3(
totalPage, page,
"/dev/md/bahan/pagination",
paginationID,
"#filter-name, #filter-station, #tableID, #paginationID, #currpage"+paginationID,
"#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
"#"+paginationID,
"outerHTML",
"",
@@ -229,3 +377,578 @@ func (lh *MdBahanHandler) HandlePaginationMdBahan(c echo.Context) error {
retval = append(retval, mdbahanPagination)
return utils.ViewMulti(c, retval)
}
func (lh *MdBahanHandler) HandleCloseFormAddMdBahan(c echo.Context) error {
logger, _ := zap.NewProduction()
stationList, err := lh.MdBahanServices.GetListSampleStation(false)
defer logger.Sync()
logger.Info("GET DATA STATIOn",
zap.Any("err", err),
)
dialogAddBodyID := c.FormValue("dialogAddBodyID")
dialogAddID := c.FormValue("dialogAddID")
modalAddBody := dev_mdbahanview.BodyFormBahan(
"",
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
},
dialogAddBodyID,
dev_mdbahanview.JsHideModal("#"+dialogAddID),
)
return utils.View(c, modalAddBody)
}
func (lh *MdBahanHandler) HandleAddMdBahan(c echo.Context) error {
logger, _ := zap.NewProduction()
code := c.FormValue("kodebahan")
name := c.FormValue("namabahan")
stationIDPrm := c.FormValue("stationid")
tableID := c.FormValue("tableID")
paginationID := c.FormValue("paginationID")
filtername := c.FormValue("filtername")
filterstation := c.FormValue("filterstation")
currPagePrm := c.FormValue("currpage" + paginationID)
dialogAddBodyID := c.FormValue("dialogAddBodyID")
// searchID := c.FormValue("searchID")
dialogAddID := c.FormValue("dialogAddID")
dialogEditBodyID := c.FormValue("dialogEditBodyID")
dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID")
currPage, err := strconv.Atoi(currPagePrm)
if err != nil {
return err
}
stationID, err := strconv.Atoi(stationIDPrm)
if err != nil {
return err
}
formValidation := ""
codeValidation := ""
nameValidation := ""
stationValidation := ""
if strings.TrimSpace(code) == "" {
formValidation = "Code bahan tidak boleh kosong"
codeValidation = "Code bahan tidak boleh kosong"
nameValidation = ""
stationValidation = ""
}
if strings.TrimSpace(name) == "" {
formValidation = "Nama bahan tidak boleh kosong"
codeValidation = ""
stationValidation = ""
nameValidation = "Nama bahan tidak boleh kosong"
}
if stationID == 0 {
formValidation = "Pilih salah satu station"
codeValidation = ""
nameValidation = ""
stationValidation = "Pilih salah satu station"
}
if strings.TrimSpace(code) == "" && strings.TrimSpace(name) == "" {
formValidation = "Code,nama, dan station bahan tidak boleh kosong"
codeValidation = "Code bahan tidak boleh kosong"
stationValidation = "Pilih salah satu station"
nameValidation = "Nama bahan tidak boleh kosong"
}
stationList, err := lh.MdBahanServices.GetListSampleStation(false)
defer logger.Sync()
logger.Info("GET DATA STATIOn",
zap.Any("err", err),
)
if formValidation != "" || codeValidation != "" || nameValidation != "" || stationValidation != "" {
newForm := dev_mdbahanview.BodyFormBahan(
"",
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Value: code,
ErrorMsg: codeValidation,
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
ErrorMsg: nameValidation,
Value: name,
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ErrorMsg: stationValidation,
ListItem: dev_mdbahanview.ListItemStation(stationList, stationID),
},
dialogAddBodyID,
dev_mdbahanview.JsShowModal(""),
)
return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Warning", formValidation, "warning"), newForm})
}
_, err = lh.MdBahanServices.AddMdBahan(code, name, stationIDPrm)
if err != nil {
newForm := dev_mdbahanview.BodyFormBahan(
"",
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Value: code,
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
Value: name,
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ListItem: dev_mdbahanview.ListItemStation(stationList, int(stationID)),
},
dialogAddBodyID,
dev_mdbahanview.JsShowModal(""),
)
return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Gagal", err.Error(), "danger"), newForm})
}
bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan(filtername, filterstation, currPage, 5)
defer logger.Sync()
logger.Info("GET DATA BAHAN",
zap.Any("data", bahanList),
zap.Any("err", err),
zap.Any("totalPage", totalPage),
)
//Bahan Table
mdBahanTable := dev_mdbahanview.TableBahan(
bahanList,
tableID,
"/dev/md/bahan/openedit",
"#"+dialogEditBodyID,
"outerHTML",
"#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
"/dev/md/bahan/opendelete",
"#"+dialogDeleteBodyID,
"outerHTML",
"#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID")
//Pagination
mdbahanPagination := pagination.PaginationV3(
totalPage, currPage,
"/dev/md/bahan/pagination",
paginationID,
"#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
"#"+paginationID,
"outerHTML",
"",
"true",
dev_mdbahanview.BeforeRequestContent(),
dev_mdbahanview.AfterRequestContent(),
)
//Form Add
modalAddBody := dev_mdbahanview.BodyFormBahan(
"",
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
},
dialogAddBodyID,
dev_mdbahanview.JsHideModal("#"+dialogAddID),
)
toastSuccess := customtoastv2.CustomToastV2Show("Success", "Success add bahan ", "success")
retval := []templ.Component{toastSuccess, mdBahanTable, mdbahanPagination, modalAddBody}
// time.Sleep(20 * time.Second)
return utils.ViewMulti(c, retval)
}
func (lh *MdBahanHandler) HandleOpenEditMdBahan(c echo.Context) error {
logger, _ := zap.NewProduction()
id := c.QueryParam("id")
dialogEditID := c.QueryParam("dialogEditID")
dialogEditBodyID := c.QueryParam("dialogEditBodyID")
stationList, err := lh.MdBahanServices.GetListSampleStation(false)
defer logger.Sync()
logger.Info("GET DATA STATION",
zap.Any("err", err),
)
dataBahan, err := lh.MdBahanServices.GetMdBahanByID(id)
if err != nil {
newForm := dev_mdbahanview.BodyFormBahan(
id,
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ListItem: dev_mdbahanview.ListItemStation(stationList, dataBahan.T_BahanT_SampleStationID),
},
dialogEditBodyID,
dev_mdbahanview.JsHideModal(""),
)
return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Error", "Get data bahan error", "danger"), newForm})
}
newForm := dev_mdbahanview.BodyFormBahan(
id,
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Value: dataBahan.T_BahanCode,
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
Value: dataBahan.T_BahanName,
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ListItem: dev_mdbahanview.ListItemStation(stationList, dataBahan.T_BahanT_SampleStationID),
},
dialogEditBodyID,
dev_mdbahanview.JsShowModal("#"+dialogEditID),
)
return utils.View(c, newForm)
}
func (lh *MdBahanHandler) HandleCloseFormEditMdBahan(c echo.Context) error {
logger, _ := zap.NewProduction()
stationList, err := lh.MdBahanServices.GetListSampleStation(false)
dialogEditID := c.FormValue("dialogEditID")
dialogEditBodyID := c.FormValue("dialogEditBodyID")
defer logger.Sync()
logger.Info("GET DATA STATION",
zap.Any("err", err),
zap.Any("dialogeditbodyid", dialogEditBodyID),
)
modalAddBody := dev_mdbahanview.BodyFormBahan(
"",
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
},
dialogEditBodyID,
dev_mdbahanview.JsHideModal("#"+dialogEditID),
)
return utils.View(c, modalAddBody)
}
func (lh *MdBahanHandler) HandleEditMdBahan(c echo.Context) error {
logger, _ := zap.NewProduction()
code := c.FormValue("kodebahan")
name := c.FormValue("namabahan")
id := c.FormValue("bahanid")
stationIDPrm := c.FormValue("stationid")
tableID := c.FormValue("tableID")
paginationID := c.FormValue("paginationID")
filtername := c.FormValue("filtername")
filterstation := c.FormValue("filterstation")
currPagePrm := c.FormValue("currpage" + paginationID)
// dialogAddBodyID := c.FormValue("dialogAddBodyID")
// searchID := c.FormValue("searchID")
dialogEditID := c.FormValue("dialogEditID")
dialogEditBodyID := c.FormValue("dialogEditBodyID")
dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID")
currPage, err := strconv.Atoi(currPagePrm)
if err != nil {
return err
}
stationID, err := strconv.Atoi(stationIDPrm)
if err != nil {
return err
}
formValidation := ""
codeValidation := ""
nameValidation := ""
stationValidation := ""
if strings.TrimSpace(code) == "" {
formValidation = "Code bahan tidak boleh kosong"
codeValidation = "Code bahan tidak boleh kosong"
nameValidation = ""
stationValidation = ""
}
if strings.TrimSpace(name) == "" {
formValidation = "Nama bahan tidak boleh kosong"
codeValidation = ""
stationValidation = ""
nameValidation = "Nama bahan tidak boleh kosong"
}
if stationID == 0 {
formValidation = "Pilih salah satu station"
codeValidation = ""
nameValidation = ""
stationValidation = "Pilih salah satu station"
}
if strings.TrimSpace(code) == "" && strings.TrimSpace(name) == "" {
formValidation = "Code,nama, dan station bahan tidak boleh kosong"
codeValidation = "Code bahan tidak boleh kosong"
stationValidation = "Pilih salah satu station"
nameValidation = "Nama bahan tidak boleh kosong"
}
stationList, err := lh.MdBahanServices.GetListSampleStation(false)
defer logger.Sync()
logger.Info("GET DATA STATIOn",
zap.Any("err", err),
)
if formValidation != "" || codeValidation != "" || nameValidation != "" || stationValidation != "" {
newForm := dev_mdbahanview.BodyFormBahan(
id,
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Value: code,
ErrorMsg: codeValidation,
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
ErrorMsg: nameValidation,
Value: name,
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ErrorMsg: stationValidation,
ListItem: dev_mdbahanview.ListItemStation(stationList, stationID),
},
dialogEditBodyID,
dev_mdbahanview.JsShowModal(""),
)
return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Warning", formValidation, "warning"), newForm})
}
_, err = lh.MdBahanServices.EditMdBahan(id, code, name, stationIDPrm)
if err != nil {
newForm := dev_mdbahanview.BodyFormBahan(
id,
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Value: code,
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
Value: name,
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ListItem: dev_mdbahanview.ListItemStation(stationList, int(stationID)),
},
dialogEditBodyID,
dev_mdbahanview.JsShowModal(""),
)
return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Gagal", err.Error(), "danger"), newForm})
}
bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan(filtername, filterstation, currPage, 5)
defer logger.Sync()
logger.Info("GET DATA BAHAN",
zap.Any("data", bahanList),
zap.Any("err", err),
zap.Any("totalPage", totalPage),
)
//Bahan Table
mdBahanTable := dev_mdbahanview.TableBahan(
bahanList,
tableID,
"/dev/md/bahan/openedit",
"#"+dialogEditBodyID,
"outerHTML",
"#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
"/dev/md/bahan/opendelete",
"#"+dialogDeleteBodyID,
"outerHTML",
"#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID")
//Pagination
mdbahanPagination := pagination.PaginationV3(
totalPage, currPage,
"/dev/md/bahan/pagination",
paginationID,
"#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
"#"+paginationID,
"outerHTML",
"",
"true",
dev_mdbahanview.BeforeRequestContent(),
dev_mdbahanview.AfterRequestContent(),
)
//Form Add
modalAddBody := dev_mdbahanview.BodyFormBahan(
"",
models.CustomTextFieldv2Prm{Label: "Kode Bahan",
Name: "kodebahan",
Placeholder: "Kode Bahan",
Type: "text"},
models.CustomTextFieldv2Prm{Label: "Nama Bahan",
Name: "namabahan",
Placeholder: "Nama Bahan",
Type: "text"},
models.CustomDropdownV2Prm{
Name: "stationid",
Label: "Sample Station",
ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
},
dialogEditBodyID,
dev_mdbahanview.JsHideModal("#"+dialogEditID),
)
toastSuccess := customtoastv2.CustomToastV2Show("Success", "Success edit bahan ", "success")
retval := []templ.Component{toastSuccess, mdBahanTable, mdbahanPagination, modalAddBody}
// time.Sleep(20 * time.Second)
return utils.ViewMulti(c, retval)
}
func (lh *MdBahanHandler) HandleOpenDeleteMdBahan(c echo.Context) error {
logger, _ := zap.NewProduction()
id := c.QueryParam("id")
dialogDeleteID := c.QueryParam("dialogDeleteID")
dialogDeleteBodyID := c.QueryParam("dialogDeleteBodyID")
dataBahan, err := lh.MdBahanServices.GetMdBahanByID(id)
if err != nil {
defer logger.Sync()
logger.Info("GET DATA BAHAN",
zap.Any("err", err),
)
newForm := dev_mdbahanview.DeleteConfirmationBody(
"",
dialogDeleteBodyID,
"Apakah anda yakin menghapus bahan berikut ?",
[]string{"Kode", "Nama Bahan", "Sample Station"},
[]string{"", "", ""}, dev_mdbahanview.JsShowModal(""))
return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Error", "Get data bahan error", "danger"), newForm})
}
newForm := dev_mdbahanview.DeleteConfirmationBody(
strconv.Itoa(dataBahan.T_BahanID),
dialogDeleteBodyID,
"Apakah anda yakin menghapus bahan berikut ?",
[]string{"Kode", "Nama Bahan", "Sample Station"},
[]string{dataBahan.T_BahanCode, dataBahan.T_BahanName, dataBahan.T_SampleStationName}, dev_mdbahanview.JsShowModal("#"+dialogDeleteID))
return utils.View(c, newForm)
}
func (lh *MdBahanHandler) HandleCloseDeleteMdBahan(c echo.Context) error {
dialogDeleteID := c.FormValue("dialogDeleteID")
dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID")
newForm := dev_mdbahanview.DeleteConfirmationBody(
"",
dialogDeleteBodyID,
"Apakah anda yakin menghapus bahan berikut ?",
[]string{"Kode", "Nama Bahan", "Sample Station"},
[]string{"", "", ""}, dev_mdbahanview.JsHideModal("#"+dialogDeleteID))
return utils.View(c, newForm)
}
func (lh *MdBahanHandler) HandleDeleteMdBahan(c echo.Context) error {
logger, _ := zap.NewProduction()
id := c.FormValue("bahanid")
tableID := c.FormValue("tableID")
paginationID := c.FormValue("paginationID")
filtername := c.FormValue("filtername")
filterstation := c.FormValue("filterstation")
currPagePrm := c.FormValue("currpage" + paginationID)
// dialogAddBodyID := c.FormValue("dialogAddBodyID")
// searchID := c.FormValue("searchID")
dialogDeleteID := c.FormValue("dialogDeleteID")
dialogEditBodyID := c.FormValue("dialogEditBodyID")
dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID")
currPage, err := strconv.Atoi(currPagePrm)
if err != nil {
return err
}
_, err = lh.MdBahanServices.DeleteMdBahan(id)
if err != nil {
defer logger.Sync()
logger.Info("ERR DELETE MD BAHAN",
zap.Any("err", err),
)
newForm := dev_mdbahanview.DeleteConfirmationBody(
"",
dialogDeleteBodyID,
"Apakah anda yakin menghapus bahan berikut ?",
[]string{"Kode", "Nama Bahan", "Sample Station"},
[]string{"", "", ""}, dev_mdbahanview.JsShowModal(""))
return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Error", "Get data bahan error", "danger"), newForm})
}
bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan(filtername, filterstation, currPage, 5)
defer logger.Sync()
logger.Info("GET DATA BAHAN",
zap.Any("data", bahanList),
zap.Any("err", err),
zap.Any("totalPage", totalPage),
)
//Bahan Table
mdBahanTable := dev_mdbahanview.TableBahan(
bahanList,
tableID,
"/dev/md/bahan/openedit",
"#"+dialogEditBodyID,
"outerHTML",
"#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
"/dev/md/bahan/opendelete",
"#"+dialogDeleteBodyID,
"outerHTML",
"#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID")
//Pagination
mdbahanPagination := pagination.PaginationV3(
totalPage, currPage,
"/dev/md/bahan/pagination",
paginationID,
"#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
"#"+paginationID,
"outerHTML",
"",
"true",
dev_mdbahanview.BeforeRequestContent(),
dev_mdbahanview.AfterRequestContent(),
)
toastSuccess := customtoastv2.CustomToastV2Show("Success", "Berhasil hapus bahan", "success")
newForm := dev_mdbahanview.DeleteConfirmationBody(
"",
dialogDeleteBodyID,
"Apakah anda yakin menghapus bahan berikut ?",
[]string{"Kode", "Nama Bahan", "Sample Station"},
[]string{"", "", ""}, dev_mdbahanview.JsHideModal("#"+dialogDeleteID))
return utils.ViewMulti(c, []templ.Component{toastSuccess, mdBahanTable, mdbahanPagination, newForm})
}

View File

@@ -297,5 +297,12 @@ func SetupRoutesDev(app *echo.Echo, appStore db.AppStore) {
dev.GET("/md/bahan", devMdBahanHandlers.HandleShowMdBahanScreen)
dev.GET("/md/bahan/filter", devMdBahanHandlers.HandleFilterMdBahan)
dev.GET("/md/bahan/pagination", devMdBahanHandlers.HandlePaginationMdBahan)
dev.POST("/md/bahan/add", devMdBahanHandlers.HandleAddMdBahan)
dev.POST("/md/bahan/closeaddform", devMdBahanHandlers.HandleCloseFormAddMdBahan)
dev.GET("/md/bahan/openedit", devMdBahanHandlers.HandleOpenEditMdBahan)
dev.POST("/md/bahan/closeeditform", devMdBahanHandlers.HandleCloseFormEditMdBahan)
dev.POST("/md/bahan/edit", devMdBahanHandlers.HandleEditMdBahan)
dev.GET("/md/bahan/opendelete", devMdBahanHandlers.HandleOpenDeleteMdBahan)
dev.POST("/md/bahan/closedeleteform", devMdBahanHandlers.HandleCloseDeleteMdBahan)
dev.POST("/md/bahan/delete", devMdBahanHandlers.HandleDeleteMdBahan)
}

View File

@@ -1,9 +1,11 @@
package models
import "github.com/a-h/templ"
type Bahan struct {
T_BahanID int `db:"T_BahanID"`
T_BahanT_SampleStationID string `db:"T_BahanT_SampleStationID"`
T_SampleStationID string `db:"T_SampleStationID"`
T_BahanT_SampleStationID int `db:"T_BahanT_SampleStationID"`
T_SampleStationID int `db:"T_SampleStationID"`
T_SampleStationName string `db:"T_SampleStationName"`
T_BahanCode string `db:"T_BahanCode"`
T_BahanName string `db:"T_BahanName"`
@@ -18,6 +20,19 @@ type Bahan struct {
}
type TmpSampleStation struct {
T_SampleStationID string `db:"T_SampleStationID"`
T_SampleStationID int `db:"T_SampleStationID"`
T_SampleStationName string `db:"T_SampleStationName"`
}
type BahanFormComponent struct {
IDComponent string
Link string
HxTarget string
HxSwap string
HxInclude string
ModalID string
ModalTitle string
DialogBody templ.Component
DialogAction templ.Component
ButtonCLose templ.Component
}

View File

@@ -1,5 +1,7 @@
package models
import "github.com/a-h/templ"
// name string, id string, hxTarget string, hxGet string, hxIndicator string, hxTrigger string, hxInclude string,
type CustomDropdownv1Prm struct {
@@ -16,3 +18,19 @@ type CustomDropdownv1Prm struct {
ErrorMsg string `default:""`
ID string
}
type CustomDropdownV2Prm struct {
HxTarget string `default:"hxTarget"`
HxGet string `default:"hxGet"`
HxIndicator string `default:"hxIndicator"`
HxInclude string `default:"hxInclude"`
HxTrigger string `default:"hxTrigger"`
HxSwap string `default:"HxSwap"`
Label string `default:"Label"`
Name string `default:"name"`
Placeholder string `default:"Placeholder"`
// Type string `default:"text"`
// Value string `default:""`
ErrorMsg string `default:""`
ID string
ListItem templ.Component
}

View File

@@ -7,6 +7,8 @@ import (
"fmt"
"math"
"strings"
"go.uber.org/zap"
)
func NewMdBahanServices(uStore db.AppStore) *MdBahanServices {
@@ -30,6 +32,11 @@ func (su *MdBahanServices) GetListMdBahan(
var totalData int
offset := (currentPage - 1) * rowPerPage
prm := "%" + strings.TrimSpace(search) + "%"
filterStation := ""
if stationID != "0" {
filterStation = "AND T_BahanT_SampleStationID = " + stationID
}
querytotal := `
SELECT COUNT(*) FROM
t_bahan
@@ -39,9 +46,9 @@ func (su *MdBahanServices) GetListMdBahan(
AND T_BahanIsActive = 'Y'
AND T_SampleStationIsActive = 'Y'
WHERE (T_BahanName LIKE ? OR T_BahanCode LIKE ? )
AND T_BahanT_SampleStationID = ?
`
if err := dbx.Handlex.Get(&totalData, querytotal, prm, prm, stationID); err != nil {
` + filterStation
if err := dbx.Handlex.Get(&totalData, querytotal, prm, prm); err != nil {
return nil, 0, fmt.Errorf("error querying database: %v", err)
}
query := `
@@ -55,11 +62,11 @@ func (su *MdBahanServices) GetListMdBahan(
AND T_BahanIsActive = 'Y'
AND T_SampleStationIsActive = 'Y'
WHERE (T_BahanName LIKE ? OR T_BahanCode LIKE ? )
AND T_BahanT_SampleStationID = ?
` + filterStation + `
LIMIT ? OFFSET ?
`
if err := dbx.Handlex.Select(&bahanList, query, prm, prm, stationID, rowPerPage, offset); err != nil {
if err := dbx.Handlex.Select(&bahanList, query, prm, prm, rowPerPage, offset); err != nil {
return nil, 0, fmt.Errorf("error querying database: %v", err)
}
totalPage := int(math.Ceil(float64(totalData) / float64(rowPerPage)))
@@ -90,7 +97,7 @@ func (su *MdBahanServices) GetMdBahanBreadCrumb(title string) (models.BreadCrumb
return ret, nil
}
func (su *MdBahanServices) GetListSampleStation() ([]models.TmpSampleStation, error) {
func (su *MdBahanServices) GetListSampleStation(isFilter bool) ([]models.TmpSampleStation, error) {
var stationList []models.TmpSampleStation
query := `
SELECT
@@ -104,6 +111,141 @@ func (su *MdBahanServices) GetListSampleStation() ([]models.TmpSampleStation, er
if err := dbx.Handlex.Select(&stationList, query); err != nil {
return nil, fmt.Errorf("error querying database: %v", err)
}
if isFilter {
stationList = append(
[]models.TmpSampleStation{{T_SampleStationID: 0, T_SampleStationName: "Semua"}}, stationList...)
}
return stationList, nil
}
func (su *MdBahanServices) AddMdBahan(code string, name string, stationid string) (bool, error) {
logger, _ := zap.NewProduction()
var datacek []models.Bahan
qryCek := `SELECT T_BahanCode FROM t_bahan WHERE T_BahanCode = ? AND T_BahanIsActive = '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 false, fmt.Errorf("query cek failed")
}
if len(datacek) > 0 {
defer logger.Sync()
logger.Error("Code already taken by another data",
zap.String("code", code),
)
return false, fmt.Errorf("code sudah dipakai")
}
query := `
INSERT INTO t_bahan(
T_BahanT_SampleStationID,
T_BahanCode,
T_BahanName,
T_BahanCreated,
T_BahanCreatedUserID)
VALUES(?,?,?, NOW(), 1)
`
rst := dbx.Handlex.MustExec(query, stationid, code, name)
_, err = rst.LastInsertId()
if err != nil {
defer logger.Sync()
logger.Error("Error Insert t bahan",
zap.Any("code", err),
)
return false, fmt.Errorf("insert data failed")
}
return true, nil
}
func (ug *MdBahanServices) GetMdBahanByID(id string) (models.Bahan, error) {
logger, _ := zap.NewProduction()
var data models.Bahan
err := dbx.Handlex.Get(&data,
`SELECT t_bahan.*,
T_SampleStationID,
T_SampleStationName
FROM t_bahan
JOIN
t_samplestation
ON T_BahanT_SampleStationID = T_SampleStationID
AND T_BahanIsActive = 'Y'
AND T_SampleStationIsActive = 'Y'
WHERE T_BahanID = ? `, id)
if err != nil {
defer logger.Sync()
logger.Error("Error get data bahan by id vs",
zap.String("ID", id),
zap.Error(err),
)
return data, fmt.Errorf("get bahan failed")
}
return data, nil
}
func (su *MdBahanServices) EditMdBahan(id string, code string, name string, stationid string) (bool, error) {
logger, _ := zap.NewProduction()
var datacek []models.Bahan
qryCek := `SELECT T_BahanCode FROM t_bahan WHERE T_BahanCode = ? AND T_BahanIsActive = 'Y' AND T_BahanID <> ?`
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 false, fmt.Errorf("query cek failed")
}
if len(datacek) > 0 {
defer logger.Sync()
logger.Error("Code already taken by another data",
zap.String("code", code),
)
return false, fmt.Errorf("code sudah dipakai")
}
query := `
UPDATE t_bahan SET
T_BahanCode = ?,
T_BahanName = ?,
T_BahanT_SampleStationID = ?
WHERE T_BahanID = ?
`
rst := dbx.Handlex.MustExec(query, code, name, stationid, id)
_, err = rst.LastInsertId()
if err != nil {
defer logger.Sync()
logger.Error("Error edit t bahan",
zap.Any("code", err),
)
return false, fmt.Errorf("edit data failed")
}
return true, nil
}
func (su *MdBahanServices) DeleteMdBahan(id string) (bool, error) {
logger, _ := zap.NewProduction()
query := `
UPDATE t_bahan
SET T_BahanIsActive = 'N',
T_BahanDeleted = NOW(),
T_BahanDeletedUserID = '1'
WHERE T_BahanID = ?
`
rst := dbx.Handlex.MustExec(query, id)
_, err := rst.LastInsertId()
if err != nil {
defer logger.Sync()
logger.Error("Error edit t bahan",
zap.Any("code", err),
)
return false, fmt.Errorf("edit data failed")
}
return true, nil
}

View File

@@ -3,16 +3,51 @@ package dev_mdbahanview
import "cpone/layout"
import "cpone/models"
import "cpone/component/customtextfield"
import "cpone/component/customdropdown"
import "strconv"
templ MdBahanScreen(
tableID string,
paginationID string,
dialogAddID string,
dialogAddBodyID string,
dialogEditID string,
dialogEditBodyID string,
dialogDeleteID string,
dialogDeleteBodyID string,
breadcrumb templ.Component,
tablecontent templ.Component,
filterComponent templ.Component,
pagination templ.Component,
dialogAddCmp templ.Component,
dialogEditCmp templ.Component,
dialogDeleteCmp templ.Component,
) {
<div class="container-fluid">
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddID",
Name: "dialogAddID",
Type: "hidden",
Value: dialogAddID})
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddBodyID",
Name: "dialogAddBodyID",
Type: "hidden",
Value: dialogAddBodyID})
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditID",
Name: "dialogEditID",
Type: "hidden",
Value: dialogEditID})
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditBodyID",
Name: "dialogEditBodyID",
Type: "hidden",
Value: dialogEditBodyID})
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteID",
Name: "dialogDeleteID",
Type: "hidden",
Value: dialogDeleteID})
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteBodyID",
Name: "dialogDeleteBodyID",
Type: "hidden",
Value: dialogDeleteBodyID})
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableID",
Name: "tableID",
Type: "hidden",
@@ -31,6 +66,8 @@ templ MdBahanScreen(
<button
type="button"
class="btn btn-primary"
data-toggle="modal"
data-target={ "#" + dialogAddID }
>Add New</button>
</div>
</div>
@@ -38,6 +75,8 @@ templ MdBahanScreen(
<button
type="button"
class="btn btn-primary btn-block"
data-toggle="modal"
data-target={ "#" + dialogAddID }
>Add New</button>
</div>
</div>
@@ -53,6 +92,9 @@ templ MdBahanScreen(
</div>
</div>
<div id="loadingcontent"></div>
@dialogAddCmp
@dialogEditCmp
@dialogDeleteCmp
</div>
}
@@ -61,27 +103,75 @@ templ CssMdUserGroup() {
templ JsMdBahan() {
<script>
function onLoadingStart() {
}
function onLoadingEnd() {
console.log('Loading ended');
}
document.addEventListener('htmx:afterSwap', function(event) {
// Reinitialize selectpicker after HTMX content swap
$('.selectpicker').selectpicker('refresh');
});
document.addEventListener('htmx:beforeRequest', function(event) {
var indicator = document.querySelector('#loadingcontent');
console.log("Before Request")
console.log(event.detail.xhr)
console.log(event.detail.elt)
if (indicator) {
onLoadingStart();
}
console.log(event.detail.target)
});
document.addEventListener('htmx:afterRequest', function(event) {
var indicator = document.querySelector('#loadingcontent');
if (indicator) {
onLoadingEnd();
}
console.log("After Request")
console.log(event.detail.xhr)
console.log(event.detail.target)
});
document.addEventListener('htmx:historyCacheError', function(event) {
console.log("Error History Cache Error")
console.log(event.detail.cause)
});
document.addEventListener('htmx:historyCacheMissError', function(event) {
console.log("Error History Cache Miss Error")
console.log(event.detail.xhr)
console.log(event.detail.path)
});
document.addEventListener('htmx:oobErrorNoTarget', function(event) {
console.log("Error OOB No Target")
console.log(event.detail.content)
});
document.addEventListener('htmx:onLoadError', function(event) {
console.log("Error On Load")
console.log(event.detail.xhr)
console.log(event.detail.elt)
console.log(event.detail.target)
console.log(event.detail.exception)
console.log(event.detail.requestConfig)
});
document.addEventListener('htmx:responseError', function(event) {
console.log("Error Response")
console.log(event.detail.xhr)
console.log(event.detail.elt)
console.log(event.detail.requestConfig)
});
document.addEventListener('htmx:sendError', function(event) {
console.log("Error Send Error")
console.log(event.detail.xhr)
console.log(event.detail.elt)
console.log(event.detail.requestConfig)
});
document.addEventListener('htmx:sseError', function(event) {
console.log("Error Sse ")
console.log(event.detail.xhr)
console.log(event.detail.error)
console.log(event.detail.source)
});
document.addEventListener('htmx:swapError', function(event) {
console.log("Error Swap Error")
console.log(event.detail.xhr)
console.log(event.detail.elt)
console.log("Target Swap: "+event.detail.target)
console.log(event.detail.requestConfig)
});
document.addEventListener('htmx:targetError', function(event) {
console.log("Error target")
console.log(event.detail.elt)
console.log("Target ID: "+event.detail.target)
});
</script>
}
@@ -115,7 +205,7 @@ templ MdBahanFilter(
hxSwap string,
hxTarget string,
dataStation []models.TmpSampleStation,
selectedIdStation string,
selectedIdStation int,
hxBeforeRequest templ.ComponentScript,
hxAfterRequest templ.ComponentScript,
) {
@@ -139,78 +229,32 @@ templ MdBahanFilter(
/>
</div>
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 mb-2">
<select
class="form-control form-control-lg bg-field btn-lg rounded-lg selectpicker"
data-live-search="true"
data-size="5"
id="filter-station"
autocomplete="off"
name="filterstation"
hx-trigger="change"
data-style="btn-field btn-lg rounded-lg"
data-container="form-control-lg"
data-live-search-placeholder="cari sample station"
hx-include={ hxInclude }
hx-get={ hxGet }
hx-swap={ hxSwap }
hx-target={ hxTarget }
hx-on::before-request={ hxBeforeRequest }
hx-on::after-request={ hxAfterRequest }
>
// hx-trigger={ hxTrigger }
for _, v := range dataStation {
if v.T_SampleStationID == selectedIdStation {
<option value={ v.T_SampleStationID }>{ v.T_SampleStationName }</option>
} else {
<option value={ v.T_SampleStationID }>{ v.T_SampleStationName }</option>
}
}
</select>
// <select
// class="form-control form-control-lg bg-field selectpicker"
// data-live-search="true"
// data-size="5"
// id="filter-station"
// autocomplete="off"
// hx-trigger={ hxTrigger }
// hx-include={ hxInclude }
// hx-get={ hxGet }
// hx-swap={ hxSwap }
// hx-target={ hxTarget }
// >
// for _, v := range dataStation {
// if v.T_SampleStationID == selectedIdStation {
// <option value={ v.T_SampleStationID }>{ v.T_SampleStationName }</option>
// } else {
// <option value={ v.T_SampleStationID }>{ v.T_SampleStationName }</option>
// }
// }
// </select>
// <select
// type="option"
// id="filter-station"
// name="filterstation"
// class="form-control bg-field border-0 h-auto py-6 px-6 rounded-lg selectpicker"
// data-live-search="true"
// data-size="5"
// >
// for _, v := range dataStation {
// if v.T_SampleStationID == selectedIdStation {
// <option value={ v.T_SampleStationID }>{ v.T_SampleStationName }</option>
// } else {
// <option value={ v.T_SampleStationID }>{ v.T_SampleStationName }</option>
// }
// }
// // <option>1</option>
// // <option>2</option>
// // <option>3</option>
// // <option>4</option>
// </select>
@customdropdown.CustomDropdownFilter("filter-station",
"filterstation",
hxInclude,
hxGet,
hxSwap,
hxTarget,
"change",
hxBeforeRequest,
hxAfterRequest, ListItemStation(dataStation, selectedIdStation))
</div>
</div>
</div>
}
templ ListItemStation(
dataStation []models.TmpSampleStation,
selectedIdStation int) {
for _, v := range dataStation {
if v.T_SampleStationID == selectedIdStation {
<option value={ strconv.Itoa(v.T_SampleStationID) } selected="selected">{ v.T_SampleStationName }</option>
} else {
<option value={ strconv.Itoa(v.T_SampleStationID) }>{ v.T_SampleStationName }</option>
}
}
}
templ ShowMdBahanScreen(title string, cmp templ.Component, css templ.Component, js templ.Component,
navbarmenu templ.Component,
navbaruser templ.Component,

View File

@@ -13,14 +13,25 @@ import "bytes"
import "cpone/layout"
import "cpone/models"
import "cpone/component/customtextfield"
import "cpone/component/customdropdown"
import "strconv"
func MdBahanScreen(
tableID string,
paginationID string,
dialogAddID string,
dialogAddBodyID string,
dialogEditID string,
dialogEditBodyID string,
dialogDeleteID string,
dialogDeleteBodyID string,
breadcrumb templ.Component,
tablecontent templ.Component,
filterComponent templ.Component,
pagination templ.Component,
dialogAddCmp templ.Component,
dialogEditCmp templ.Component,
dialogDeleteCmp 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)
@@ -38,6 +49,48 @@ func MdBahanScreen(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddID",
Name: "dialogAddID",
Type: "hidden",
Value: dialogAddID}).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddBodyID",
Name: "dialogAddBodyID",
Type: "hidden",
Value: dialogAddBodyID}).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditID",
Name: "dialogEditID",
Type: "hidden",
Value: dialogEditID}).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditBodyID",
Name: "dialogEditBodyID",
Type: "hidden",
Value: dialogEditBodyID}).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteID",
Name: "dialogDeleteID",
Type: "hidden",
Value: dialogDeleteID}).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteBodyID",
Name: "dialogDeleteBodyID",
Type: "hidden",
Value: dialogDeleteBodyID}).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableID",
Name: "tableID",
Type: "hidden",
@@ -60,7 +113,33 @@ func MdBahanScreen(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div class=\"col-md-2 d-none d-lg-block d-xl-block d-md-block d-sm-none\"><div class=\"d-flex justify-content-end\"><button type=\"button\" class=\"btn btn-primary\">Add New</button></div></div><div class=\"col-md-2 d-block d-lg-none d-xl-none d-md-none d-sm-block justify-content-center px-5\"><button type=\"button\" class=\"btn btn-primary btn-block\">Add New</button></div></div><div id=\"loading-parent\" class=\" rounded\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div class=\"col-md-2 d-none d-lg-block d-xl-block d-md-block d-sm-none\"><div class=\"d-flex justify-content-end\"><button type=\"button\" class=\"btn btn-primary\" data-toggle=\"modal\" data-target=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
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\mdbahan\mdbahan.templ`, Line: 70, Col: 37}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">Add New</button></div></div><div class=\"col-md-2 d-block d-lg-none d-xl-none d-md-none d-sm-block justify-content-center px-5\"><button type=\"button\" class=\"btn btn-primary btn-block\" data-toggle=\"modal\" data-target=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
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\mdbahan\mdbahan.templ`, Line: 79, Col: 36}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">Add New</button></div></div><div id=\"loading-parent\" class=\" rounded\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -76,7 +155,23 @@ func MdBahanScreen(
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>")
_, 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>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = dialogAddCmp.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = dialogEditCmp.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = dialogDeleteCmp.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -95,9 +190,9 @@ func CssMdUserGroup() 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)
if !templ_7745c5c3_IsBuffer {
@@ -115,12 +210,12 @@ func JsMdBahan() 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("<script>\r\n function onLoadingStart() {\r\n }\r\n\r\n function onLoadingEnd() {\r\n console.log('Loading ended');\r\n }\r\n\r\n document.addEventListener('htmx:beforeRequest', function(event) {\r\n var indicator = document.querySelector('#loadingcontent');\r\n\t\t\tconsole.log(event.detail.xhr)\r\n\t\t\tconsole.log(event.detail.elt)\r\n if (indicator) {\r\n onLoadingStart();\r\n }\r\n });\r\n\r\n document.addEventListener('htmx:afterRequest', function(event) {\r\n var indicator = document.querySelector('#loadingcontent');\r\n if (indicator) {\r\n onLoadingEnd();\r\n }\r\n });\r\n </script>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script>\r\n\t\tdocument.addEventListener('htmx:afterSwap', function(event) {\r\n\t\t\t// Reinitialize selectpicker after HTMX content swap\r\n\t\t\t$('.selectpicker').selectpicker('refresh');\r\n\t\t});\r\n \r\n document.addEventListener('htmx:beforeRequest', function(event) {\r\n console.log(\"Before Request\")\r\n\t\t\tconsole.log(event.detail.xhr)\r\n\t\t\tconsole.log(event.detail.target)\r\n \r\n });\r\n\r\n document.addEventListener('htmx:afterRequest', function(event) {\r\n console.log(\"After Request\")\r\n console.log(event.detail.xhr)\r\n\t\t\tconsole.log(event.detail.target)\r\n });\r\n document.addEventListener('htmx:historyCacheError', function(event) {\r\n console.log(\"Error History Cache Error\")\r\n console.log(event.detail.cause)\r\n\t\t\t\r\n });\r\n document.addEventListener('htmx:historyCacheMissError', function(event) {\r\n console.log(\"Error History Cache Miss Error\")\r\n console.log(event.detail.xhr)\r\n console.log(event.detail.path)\r\n\t\t\t\r\n });\r\n document.addEventListener('htmx:oobErrorNoTarget', function(event) {\r\n console.log(\"Error OOB No Target\")\r\n console.log(event.detail.content)\r\n });\r\n document.addEventListener('htmx:onLoadError', function(event) {\r\n console.log(\"Error On Load\")\r\n console.log(event.detail.xhr)\r\n console.log(event.detail.elt)\r\n console.log(event.detail.target)\r\n console.log(event.detail.exception)\r\n console.log(event.detail.requestConfig)\r\n });\r\n document.addEventListener('htmx:responseError', function(event) {\r\n console.log(\"Error Response\")\r\n console.log(event.detail.xhr)\r\n console.log(event.detail.elt)\r\n console.log(event.detail.requestConfig)\r\n });\r\n document.addEventListener('htmx:sendError', function(event) {\r\n console.log(\"Error Send Error\")\r\n console.log(event.detail.xhr)\r\n console.log(event.detail.elt)\r\n console.log(event.detail.requestConfig)\r\n });\r\n document.addEventListener('htmx:sseError', function(event) {\r\n console.log(\"Error Sse \")\r\n console.log(event.detail.xhr)\r\n console.log(event.detail.error)\r\n console.log(event.detail.source)\r\n });\r\n\t\tdocument.addEventListener('htmx:swapError', function(event) {\r\n console.log(\"Error Swap Error\")\r\n console.log(event.detail.xhr)\r\n console.log(event.detail.elt)\r\n console.log(\"Target Swap: \"+event.detail.target)\r\n console.log(event.detail.requestConfig)\r\n });\r\n\t\tdocument.addEventListener('htmx:targetError', function(event) {\r\n console.log(\"Error target\")\r\n console.log(event.detail.elt)\r\n console.log(\"Target ID: \"+event.detail.target)\r\n });\r\n </script>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -172,7 +267,7 @@ func MdBahanFilter(
hxSwap string,
hxTarget string,
dataStation []models.TmpSampleStation,
selectedIdStation string,
selectedIdStation int,
hxBeforeRequest templ.ComponentScript,
hxAfterRequest templ.ComponentScript,
) templ.Component {
@@ -183,9 +278,9 @@ func MdBahanFilter(
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("<div class=\"container p-0\"><div class=\"row\"><div class=\"col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 mb-2\">")
@@ -200,12 +295,12 @@ func MdBahanFilter(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(hxTarget)
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(hxTarget)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 132, Col: 25}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 222, Col: 25}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -213,12 +308,12 @@ func MdBahanFilter(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(hxTrigger)
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(hxTrigger)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 133, Col: 27}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 223, Col: 27}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -226,12 +321,12 @@ func MdBahanFilter(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(hxInclude)
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(hxInclude)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 134, Col: 27}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 224, Col: 27}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -239,12 +334,12 @@ func MdBahanFilter(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(hxGet)
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(hxGet)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 135, Col: 19}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 225, Col: 19}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -252,12 +347,12 @@ func MdBahanFilter(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(hxSwap)
var templ_7745c5c3_Var11 string
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(hxSwap)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 136, Col: 21}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 226, Col: 21}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -265,8 +360,8 @@ func MdBahanFilter(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var10 templ.ComponentScript = hxBeforeRequest
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10.Call)
var templ_7745c5c3_Var12 templ.ComponentScript = hxBeforeRequest
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12.Call)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -274,8 +369,8 @@ func MdBahanFilter(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var11 templ.ComponentScript = hxAfterRequest
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11.Call)
var templ_7745c5c3_Var13 templ.ComponentScript = hxAfterRequest
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var13.Call)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -283,109 +378,69 @@ func MdBahanFilter(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, hxBeforeRequest, hxAfterRequest)
templ_7745c5c3_Err = customdropdown.CustomDropdownFilter("filter-station",
"filterstation",
hxInclude,
hxGet,
hxSwap,
hxTarget,
"change",
hxBeforeRequest,
hxAfterRequest, ListItemStation(dataStation, selectedIdStation)).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<select class=\"form-control form-control-lg bg-field btn-lg rounded-lg selectpicker\" data-live-search=\"true\" data-size=\"5\" id=\"filter-station\" autocomplete=\"off\" name=\"filterstation\" hx-trigger=\"change\" data-style=\"btn-field btn-lg rounded-lg\" data-container=\"form-control-lg\" data-live-search-placeholder=\"cari sample station\" hx-include=\"")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(hxInclude)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 153, Col: 27}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
})
}
func ListItemStation(
dataStation []models.TmpSampleStation,
selectedIdStation int) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-get=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(hxGet)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 154, Col: 19}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-swap=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(hxSwap)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 155, Col: 21}
}
_, 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("\" hx-target=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(hxTarget)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 156, Col: 25}
}
_, 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("\" hx-on::before-request=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var16 templ.ComponentScript = hxBeforeRequest
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16.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_Var17 templ.ComponentScript = hxAfterRequest
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17.Call)
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
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var14 := templ.GetChildren(ctx)
if templ_7745c5c3_Var14 == nil {
templ_7745c5c3_Var14 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
for _, v := range dataStation {
if v.T_SampleStationID == selectedIdStation {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<option value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var18 string
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(v.T_SampleStationID)
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(v.T_SampleStationID))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 163, Col: 42}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 251, Col: 52}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
_, 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("\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" selected=\"selected\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var19 string
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(v.T_SampleStationName)
var templ_7745c5c3_Var16 string
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(v.T_SampleStationName)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 163, Col: 68}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 251, Col: 98}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -398,12 +453,12 @@ func MdBahanFilter(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var20 string
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(v.T_SampleStationID)
var templ_7745c5c3_Var17 string
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(v.T_SampleStationID))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 165, Col: 42}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 253, Col: 52}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -411,12 +466,12 @@ func MdBahanFilter(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var21 string
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(v.T_SampleStationName)
var templ_7745c5c3_Var18 string
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(v.T_SampleStationName)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 165, Col: 68}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahan.templ`, Line: 253, Col: 78}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -426,10 +481,6 @@ func MdBahanFilter(
}
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</select></div></div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
@@ -448,12 +499,12 @@ func ShowMdBahanScreen(title string, cmp templ.Component, css templ.Component, j
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var22 := templ.GetChildren(ctx)
if templ_7745c5c3_Var22 == nil {
templ_7745c5c3_Var22 = templ.NopComponent
templ_7745c5c3_Var19 := templ.GetChildren(ctx)
if templ_7745c5c3_Var19 == nil {
templ_7745c5c3_Var19 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var23 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Var20 := 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()
@@ -468,7 +519,7 @@ func ShowMdBahanScreen(title string, cmp templ.Component, css templ.Component, j
}
return templ_7745c5c3_Err
})
templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile).Render(templ.WithChildren(ctx, templ_7745c5c3_Var23), templ_7745c5c3_Buffer)
templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile).Render(templ.WithChildren(ctx, templ_7745c5c3_Var20), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@@ -1,8 +1,11 @@
package dev_mdbahanview
import "cpone/models"
import "cpone/component/modal"
import "cpone/component/customtextfield"
import "cpone/component/customdropdown"
templ UserGroupForm(data models.UserGroupFormComponent) {
templ BahanForm(data models.BahanFormComponent) {
<div class="">
<form
id={ data.IDComponent }
@@ -56,18 +59,19 @@ script HandleFormAfterRequest() {
}
}
templ BodyFormUserGroup(inputId models.CustomTextFieldv2Prm,
templ BodyFormBahan(inputId string,
inputCode models.CustomTextFieldv2Prm,
inputName models.CustomTextFieldv2Prm,
inputStation models.CustomDropdownV2Prm,
componentID string,
hxOnLoad templ.ComponentScript) {
<div id={ componentID } hx-on::load={ hxOnLoad }>
@customtextfield.CustomTextFieldv2(
inputId)
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{Name: "bahanid", ID: "bahanID", Type: "hidden", Value: inputId})
@customtextfield.CustomTextFieldv2(
inputCode)
@customtextfield.CustomTextFieldv2(
inputName)
@customdropdown.CustomDropdownForm(inputStation)
</div>
}
@@ -91,7 +95,7 @@ script JsShowModal(modalID string) {
}
}
templ ActionFormUserGroup(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
templ ActionFormBahan(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
<div>
<button
hx-on::after-request={ JsHideModal(modalID) }
@@ -116,7 +120,7 @@ templ ActionFormUserGroup(LinkClose string, targetClose string, hxSwapClose stri
</div>
}
templ BtnCloseFormUserGroup(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
templ BtnCloseFormBahan(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
<button
hx-post={ LinkClose }
hx-target={ targetClose }
@@ -131,7 +135,7 @@ templ BtnCloseFormUserGroup(LinkClose string, targetClose string, hxSwapClose st
</button>
}
templ DeleteConfirmationBody(inputId models.CustomTextFieldv2Prm,
templ DeleteConfirmationBody(inputId string,
componentID string,
message string,
datHeader []string,
@@ -155,11 +159,11 @@ templ DeleteConfirmationBody(inputId models.CustomTextFieldv2Prm,
</div>
</div>
</div>
@customtextfield.CustomTextFieldv2(inputId)
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{Name: "bahanid", ID: "bahanID", Type: "hidden", Value: inputId})
</div>
}
templ ActionFormUserGroupDelete(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
templ ActionFormBahanDelete(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
<div>
<button
hx-on::after-request={ JsHideModal(modalID) }

View File

@@ -0,0 +1,654 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.663
package dev_mdbahanview
//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"
import "cpone/component/customdropdown"
func BahanForm(data models.BahanFormComponent) 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("<div class=\"\">")
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("<form id=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(data.IDComponent)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 11, Col: 24}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-post=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(data.Link)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 12, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"form\" hx-target=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(data.HxTarget)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 14, Col: 28}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
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_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(data.HxSwap)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 15, Col: 24}
}
_, 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("\" hx-include=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(data.HxInclude)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 16, Col: 30}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-indicator=\".formloading\" hx-on::before-request=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 templ.ComponentScript = HandleFormBeforeRequest()
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var7.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_Var8 templ.ComponentScript = HandleFormAfterRequest()
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8.Call)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = modalcomponent.Modal(data.ModalID,
data.ModalTitle,
data.DialogBody,
data.DialogAction,
data.ButtonCLose).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</form></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 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 BodyFormBahan(inputId string,
inputCode models.CustomTextFieldv2Prm,
inputName models.CustomTextFieldv2Prm,
inputStation models.CustomDropdownV2Prm,
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("<div id=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(componentID)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 68, Col: 22}
}
_, 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-on::load=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var11 templ.ComponentScript = hxOnLoad
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11.Call)
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(models.CustomTextFieldv2Prm{Name: "bahanid", ID: "bahanID", Type: "hidden", Value: 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 = customdropdown.CustomDropdownForm(inputStation).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</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 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 ActionFormBahan(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("<div>")
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("<button hx-on::after-request=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var13 templ.ComponentScript = JsHideModal(modalID)
_, 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("\" hx-post=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(LinkClose)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 102, Col: 22}
}
_, 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("\" hx-target=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(targetClose)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 103, Col: 26}
}
_, 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("\" hx-swap=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var16 string
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(hxSwapClose)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 104, Col: 24}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-indicator=\".cancelloading\" type=\"button\" class=\"btn btn-outline-secondary font-weight-bolder rounded-lg mr-4 btnactcancel \" data-dismiss=\"modal\"><span class=\"htmx-indicator spinner-border spinner-border-sm cancelloading\" role=\"status\" aria-hidden=\"true\"></span> Batal\r</button> <button type=\"submit\" class=\"btn btn-primary btn-shadow font-weight-bold rounded-lg btnactsavedata\"><span class=\"htmx-indicator spinner-border spinner-border-sm formloading\" role=\"status\" aria-hidden=\"true\"></span> Simpan\r</button></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 BtnCloseFormBahan(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("<button hx-post=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var18 string
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(LinkClose)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 125, Col: 21}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
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_Var19 string
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(targetClose)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 126, Col: 25}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
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_Var20 string
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(hxSwapClose)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 127, Col: 23}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" type=\"button\" hx-on::after-request=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var21 templ.ComponentScript = JsHideModal(modalID)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var21.Call)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"close btnactcancel\" data-dismiss=\"modal\" aria-label=\"Close\"><i aria-hidden=\"true\" class=\"ki ki-close\"></i></button>")
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 DeleteConfirmationBody(inputId string,
componentID string,
message string,
datHeader []string,
dataText []string,
hxOnLoad templ.ComponentScript) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var22 := templ.GetChildren(ctx)
if templ_7745c5c3_Var22 == nil {
templ_7745c5c3_Var22 = 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("<div id=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var23 string
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(componentID)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 144, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-on::load=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var24 templ.ComponentScript = hxOnLoad
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var24.Call)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var25 string
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(message)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 145, Col: 14}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><div class=\"card rounded-lg\"><div class=\"card-body d-flex flex-row\"><div class=\"d-flex flex-column\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, v := range datHeader {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"mb-1 mt-1 text-disabled font-weight-bold mr-5\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var26 string
templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(v)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 150, Col: 68}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div class=\"d-flex flex-column \">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, v := range dataText {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"mb-1 mt-1 font-weight-bold\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var27 string
templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(v)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 156, Col: 10}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{Name: "bahanid", ID: "bahanID", Type: "hidden", Value: inputId}).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</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 ActionFormBahanDelete(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_Var28 := templ.GetChildren(ctx)
if templ_7745c5c3_Var28 == nil {
templ_7745c5c3_Var28 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div>")
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("<button hx-on::after-request=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var29 templ.ComponentScript = JsHideModal(modalID)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var29.Call)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-post=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var30 string
templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(LinkClose)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 170, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30))
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_Var31 string
templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(targetClose)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 171, Col: 26}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
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_Var32 string
templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(hxSwapClose)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 172, Col: 24}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-indicator=\".cancelloading\" type=\"button\" class=\"btn btn-outline-secondary font-weight-bolder rounded-lg mr-4 btnactcancel\" data-dismiss=\"modal\"><span class=\"htmx-indicator spinner-border spinner-border-sm cancelloading\" role=\"status\" aria-hidden=\"true\"></span> Batal\r</button> <button type=\"submit\" class=\"btn btn-primary btn-shadow font-weight-bold rounded-lg btnactsavedata\"><span class=\"htmx-indicator spinner-border spinner-border-sm formloading\" role=\"status\" aria-hidden=\"true\"></span> Yakin\r</button></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
})
}