Ivan Galakhov před 4 roky
rodič
revize
0397044ba7

+ 6 - 1
dashboard/src/components/values-form/ValuesForm.tsx

@@ -7,6 +7,7 @@ import {
   ShowIf,
   ShowIfOr,
   ShowIfAnd,
+  ShowIfNot,
 } from "shared/types";
 import { Context } from "shared/Context";
 
@@ -310,7 +311,7 @@ export default class ValuesForm extends Component<PropsType, StateType> {
     });
   };
 
-  evalShowIf = (vals: ShowIf) => {
+  evalShowIf: (vals: ShowIf) => boolean = (vals: ShowIf) => {
     if (!vals) {
       return false;
     }
@@ -335,6 +336,10 @@ export default class ValuesForm extends Component<PropsType, StateType> {
       }
       return true;
     }
+    if ((vals as ShowIfNot).not) {
+      vals = vals as ShowIfNot;
+      return !this.evalShowIf(vals.not);
+    }
 
     return false;
   };

+ 5 - 1
dashboard/src/shared/types.tsx

@@ -112,7 +112,11 @@ export interface ShowIfOr {
   or: ShowIf[];
 }
 
-export type ShowIf = string | ShowIfAnd | ShowIfOr;
+export interface ShowIfNot {
+  not: ShowIf;
+}
+
+export type ShowIf = string | ShowIfAnd | ShowIfOr | ShowIfNot;
 
 export interface Section {
   name?: string;