Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting showNot to false with MaterialConfig changes the styles to vanilla widgets #373

Closed
slim-hmidi opened this issue Mar 17, 2021 · 4 comments

Comments

@slim-hmidi
Copy link

slim-hmidi commented Mar 17, 2021

I tried tot hide the Not conjunctions and leave only the And and OR conjunctions.
I set the showNot: false the styles changed from material ui components to vanilla widgets.
I create a reproduction on codesandbox.
uncomment the line 68-70 then the config changes from Material-UI to Vanilla widgets.

EDIT:

I think the issue is due to the config/material/index.js:

const settings = {
  ...BasicConfig.settings,

  renderField: (props) => <MaterialFieldSelect {...props} />,
  renderOperator: (props) => <MaterialFieldSelect {...props} />,
  renderFunc: (props) => <MaterialFieldSelect {...props} />,
  renderConjs: (props) => <MaterialConjs {...props} />,
  renderButton: (props) => <MaterialButton {...props} />,
  renderButtonGroup: (props) => <MaterialButtonGroup {...props} />,
  renderValueSources: (props) => <MaterialValueSources {...props} />,
  renderProvider: (props) => <MaterialProvider {...props} />,
  renderConfirm: MaterialConfirm,
  useConfirm: MaterialUseConfirm,
};

it takes the BasicConfig as settings;

const settings = {
  ...defaultSettings,

  formatField: (field, parts, label2, fieldDefinition, config, isForDisplay) => {
    if (isForDisplay)
      return label2;
    else
      return field;
  },
  sqlFormatReverse: (q, operator, reversedOp, operatorDefinition, revOperatorDefinition) => {
    if (q == undefined) return undefined;
    return "NOT(" + q + ")";
  },
  formatReverse: (q, operator, reversedOp, operatorDefinition, revOperatorDefinition, isForDisplay) => {
    if (q == undefined) return undefined;
    if (isForDisplay)
      return "NOT(" + q + ")";
    else
      return "!(" + q + ")";
  },
  canCompareFieldWithField: (leftField, leftFieldConfig, rightField, rightFieldConfig) => {
    //for type == 'select'/'multiselect' you can check listValues
    return true;
  },

  // enable compare fields
  valueSourcesInfo: {
    value: {
      label: "Value"
    },
    field: {
      label: "Field",
      widget: "field",
    },
    func: {
      label: "Function",
      widget: "func",
    }
  },
  customFieldSelectProps: {
    showSearch: true
  },
};

Which calls the default settings and erase the MaterialConfig by the Vanilla Config, that's why the issue was risen.

@ukrbublik
Copy link
Owner

Try this:

  settings: {
    ...InitialConfig.settings,
    showNot: false
  }

It's correct way to ovrride config over InitialConfig

PS. Probably you've chnaged your sandbox code since creatiion this issue.

I see TypeError can't convert undefined to object in your current sandbox.
Reason for this - need to add widgets to config.types.boolean

    boolean: {
      defaultOperator: "equal",
      widgets: {}
    }

Better approach:

    boolean: {
      ...InitialConfig.types.boolean,
      defaultOperator: "equal",
    }

@slim-hmidi
Copy link
Author

I tried

settings: {
    ...InitialConfig.settings,
    showNot: false
  }

but does not fix the issue

@ukrbublik
Copy link
Owner

Can you please post updated sandbox with issue?
I've forked yours with fixes I mentioned above and seems like it has no issue.
What version of lib are you using?

@ukrbublik
Copy link
Owner

Closing issue after no fedback. If you still see issue please reopen and provide more info to reproduce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants