sciapp / sampledb

Sample and Measurement Metadata Database
https://scientific-it-systems.iffgit.fz-juelich.de/SampleDB/
MIT License
21 stars 10 forks source link

Conditional required not working in special case #44

Closed NilsWeber98 closed 1 year ago

NilsWeber98 commented 1 year ago

Hej,

I found a special situation where the conditional properties are not working like expected (at least for me).

The following minimal json action works as expected. The required test field is only required if the condition is fulfilled. But in a special case the requirements are not fulfilled and I am not able to save the object.

{
  "title": "",
  "type": "object",
  "properties": {
    "name": {
      "title": "Name",
      "type": "text"
    },
    "text": {
      "title": "Text",
      "type": "text",
      "choices": [
        "Option1",
        "Option2"
      ],
      "default": "Option1"
    },
    "test": {
      "title": "test",
      "type": "quantity",
      "units": "1",
      "conditions": [
        {
          "type": "choice_equals",
          "property_name": "text",
          "choice": "Option1"
        }
      ]
    }
  },
  "required": [
    "name",
    "text",
    "test"
  ],
  "propertyOrder": [
    "name",
    "text",
    "test"
  ]
}

The mentioned special case: If I leave the required field empty and try to save, SampleDB throws an hint as expected.

image

If I now change to the other option (because I forgot to change that), the required field is not shown anymore but it is still required. I am not able to save the following:

image

Maybe it seems a little bit constructed, but I was stuck for some minutes today without knowing why I am not able to save the object.

FlorianRhiem commented 1 year ago

Does this occur when creating the object? If so, it might be due to a bug I fixed a few hours ago. Please try using the current development version and let me know if the issue is fixed with that.

NilsWeber98 commented 1 year ago

Yes, I was still working at version https://github.com/sciapp/sampledb/commit/04dff4bc0feae2bb41f606ea8bf2241a45c79d99 . It is fixed in the new version.