fix toogle

This commit is contained in:
rizky 2024-09-04 00:44:20 -07:00
parent e9254ece60
commit cec4fefeaf
3 changed files with 28 additions and 26 deletions

View File

@ -85,6 +85,7 @@ export const FilterField: FC<{
</div> </div>
<input <input
type="search" type="search"
value={field.fm?.data?.[name]}
placeholder={field.field.label} placeholder={field.field.label}
onBlur={() => { onBlur={() => {
clearTimeout(internal.search_timeout); clearTimeout(internal.search_timeout);

View File

@ -38,15 +38,17 @@ export const FieldToggle: FC<{
: local.value.indexOf(value) > 0 : local.value.indexOf(value) > 0
? true ? true
: false; : false;
return ( return (
<> <>
<div className={cx("c-flex c-items-center c-justify-start c-w-full")}> <div className={cx("c-flex c-items-center c-justify-start c-w-full")}>
<label className="c-flex c-items-center c-cursor-pointer" onClick={(e) => { <label
if(local.ref){ className="c-flex c-items-center c-cursor-pointer"
local.ref.click(); onClick={(e) => {
} if(local.ref){
}}> local.ref.click();
}
}}
>
<div className="c-mr-3 c-text-gray-700 c-font-medium"> <div className="c-mr-3 c-text-gray-700 c-font-medium">
{get(local, "list[0].label")} {get(local, "list[0].label")}
</div> </div>
@ -69,25 +71,20 @@ export const FieldToggle: FC<{
checked={checked} checked={checked}
className="c-sr-only" className="c-sr-only"
onChange={(e) => { onChange={(e) => {
console.log("HHHH")
const check = e.target.checked; const check = e.target.checked;
if (check) { const find = local.list.findIndex((item) => {
arg.opt_set_value({ if (typeof item.value === "boolean") {
fm, return value ? item.value === true : item.value === false;
name: field.name, }
selected: [local.list[0]?.value], return item.value === value;
options: local.list, });
type: field.type, arg.opt_set_value({
}); fm,
} else { name: field.name,
arg.opt_set_value({ selected: [local.list[find ? 0 : 1]?.value],
fm, options: local.list,
name: field.name, type: field.type,
selected: [local.list[1]?.value], });
options: local.list,
type: field.type,
});
}
}} }}
/> />
<div className="dot-wrap c-block c-bg-gray-600 c-w-8 c-h-5 c-rounded-full"></div> <div className="dot-wrap c-block c-bg-gray-600 c-w-8 c-h-5 c-rounded-full"></div>

View File

@ -202,7 +202,7 @@ export const TableList: FC<TableListProp> = ({
const key = Object.keys(where.OR[0])[0]; const key = Object.keys(where.OR[0])[0];
if (key && where.OR[0][key]) { if (key && where.OR[0][key]) {
let filtering = where.OR[0][key].contains; let filtering = where.OR[0][key].contains;
if (typeof local.filtering === "string") { if (typeof local.filtering === "string" && filtering) {
filtering = filtering.slice(1, -1); filtering = filtering.slice(1, -1);
} else { } else {
filtering = ""; filtering = "";
@ -556,7 +556,11 @@ export const TableList: FC<TableListProp> = ({
} }
} }
let data = Array.isArray(local.data) ? local.data : []; let data = Array.isArray(local.data) ? local.data : [];
if (typeof local.data === "string") console.error(local.data);
if (typeof local.data === "string") {
console.error(local.data);
local.data = []
}
if (isEditor) { if (isEditor) {
if (data.length > 0) { if (data.length > 0) {