Procházet zdrojové kódy

add .replaceAll(":", ".$.")

visuddhinanda před 2 roky
rodič
revize
f127cab6d8
1 změnil soubory, kde provedl 6 přidání a 2 odebrání
  1. 6 2
      dashboard/src/components/dict/SelectCase.tsx

+ 6 - 2
dashboard/src/components/dict/SelectCase.tsx

@@ -18,6 +18,7 @@ const SelectCaseWidget = ({ value, onCaseChange }: IWidget) => {
   useEffect(() => {
     const arrValue = value
       ?.replaceAll("#", "$")
+      .replaceAll(":", ".$.")
       .split("$")
       .map((item) => item.replaceAll(".", ""));
     setCurrValue(arrValue);
@@ -327,8 +328,11 @@ const SelectCaseWidget = ({ value, onCaseChange }: IWidget) => {
       value={currValue}
       options={options}
       placeholder="Please select case"
-      onChange={(value: (string | number)[]) => {
+      onChange={(value?: (string | number)[]) => {
         console.log("case changed", value);
+        if (typeof value === "undefined") {
+          return;
+        }
         let newValue: (string | number)[];
         if (
           value.length > 1 &&
@@ -341,7 +345,7 @@ const SelectCaseWidget = ({ value, onCaseChange }: IWidget) => {
         setCurrValue(newValue);
         if (typeof onCaseChange !== "undefined") {
           let output = newValue.map((item) => `.${item}.`).join("$");
-          output = output.replace(".$.base", ":base");
+          output = output.replace(".$.base", ":base").replace(".$.ind", ":ind");
           if (output.indexOf("$") > 0) {
             output =
               output.substring(0, output.indexOf("$")) +