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>
<input
type="search"
value={field.fm?.data?.[name]}
placeholder={field.field.label}
onBlur={() => {
clearTimeout(internal.search_timeout);

View File

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

View File

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