step 9 : add notif saran mcu, perbaikan utils hx include

This commit is contained in:
sindhu
2024-05-22 09:24:18 +07:00
parent 79d736884e
commit 445d238426
6 changed files with 239 additions and 108 deletions

View File

@@ -1,24 +1,52 @@
package utils
import "cpone/models"
import (
"cpone/models"
"strings"
)
func GetIdSurveyMcu(id string) string {
return id
}
func ConcatHxIncludeSurveyMcu(data []models.ItemSurveyMcu) string {
var stringx string
// func ConcatHxIncludeSurveyMcu(data []models.ItemSurveyMcu) string {
// var stringx string
if len(data) > 0 {
for i, v := range data {
if i > 0 {
stringx += ", "
// if len(data) > 0 {
// for i, v := range data {
// if i > 0 {
// stringx += ", "
// }
// stringx += "[name='radio-" + v.IDItemSurvey + "'], [name='default-radio-" + v.IDItemSurvey + "'], [name='id-radio']"
// }
// }
// stringx += ",[name='saranMcu']"
// return stringx
// }
func ConcatHxIncludeSurveyMcu(dataSurveyMcu []models.SurveyMcu) string {
var elements []string
if len(dataSurveyMcu) > 0 {
for _, x := range dataSurveyMcu {
// radio button
if len(x.DataListItemSurveyMcu) > 0 {
for _, v := range x.DataListItemSurveyMcu {
elements = append(elements, "[name='radio-"+v.IDItemSurvey+"']", "[name='default-radio-"+v.IDItemSurvey+"']", "[name='id-radio']")
}
}
// saran
if len(x.DataListItemSurveyMcuSaran) > 0 {
for _, v := range x.DataListItemSurveyMcuSaran {
elements = append(elements, "[name='saranmcu-"+v.IDItemSurveyMcuSaran+"']", "[name='default-saranmcu-"+v.IDItemSurveyMcuSaran+"']", "[name='id-saran']")
}
}
stringx += "[name='radio-" + v.IDItemSurvey + "'], [name='default-radio-" + v.IDItemSurvey + "'], [name='id-radio']"
}
}
stringx += ",[name='saranMcu']"
return stringx
// Gabungkan semua elemen dengan koma
return strings.Join(elements, ", ")
}