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

Option for editing of undefined non-required fields (bug with tables of objects) #980

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Krivich
Copy link
Contributor

@Krivich Krivich commented May 4, 2021

As developer I want to let user edit (set, update) optional fields if future even if inital value was empty.

Reproduce:

  1. User creates new object A.
  2. User sets only mandatory fields and keep optional fields blank.
  3. User saves object.
  4. User decided to set optional filed of A. He starts editing orbject A
    Current behavior:
  5. Json-editor is not displaying editor for optional filed beacuse it is not initial object creation and optional field value is undefined.
    Expected behaviour:
  6. Json-editor displayes editor with empty value for optional field.
Q A
Is bugfix?
New feature? ✔️
Is backward-compatible? ✔️
Tests pass? ✔️
Fixed issues comma-separated list of tickets # fixed by the PR, if any
Updated README/docs?
Added CHANGELOG entry?

As developer I want to let user edit (set, update) optional fields if future even if inital value was empty. 

Reproduce:
1) User creates new object A.
2) User sets only mandatory fields and keep optional fields blank.
3) User saves object.
4) User decided to set optional filed of A. He starts editing orbject A
Current behavior:
 5) Json-editor is not displaying editor for optional filed beacuse it is not initial object creation and optional field value is undefined.
Expected behaviour:
 6) Json-editor displayes editor with empty value for optional field.
@Krivich
Copy link
Contributor Author

Krivich commented May 4, 2021

The live example: my object reprecents a day of the library schedule:

class ScheduleDto {

    id: number;

    dayCode: DayCode;

    startTime?: string;

    endTime?: string;

    breakStartTime?: string;

    breakEndTime?: string;

}

Initially library is closed on Monday, so all fields except DayCode are undefined. But what if user want to change schedule and set startTime and endTime for Modnay? Without extra option user will see just dayCode editor and no one more editors.

@schmunk42
Copy link
Collaborator

Could you add an example and/or screenshot, I don't quite understand.

@Krivich
Copy link
Contributor Author

Krivich commented May 4, 2021

image

The reason of missing fields in the firest image is that server returned the next array: [{dayCode: "MO"}, {dayCode: "TU"}, {dayCode: "WE"}, {dayCode: "TH"}, {dayCode: "FR"}, {dayCode: "SA"},…] so this code

     } else if (!initial && !this.isRequiredObject(editor)) {
    this.removeObjectProperty(i)

just removed extra editors. But it is not what I'd want.

@germanbisurgi
Copy link
Collaborator

Did you tried show_opt_in option?

@Krivich
Copy link
Contributor Author

Krivich commented May 4, 2021

Yes, I've tried to apply it for field, object and array - no effect.

    "schedule": {
        "type": "array",
        "format": "tabs-top",
        "title": "РЕЖИМ РАБОТЫ\t",
        "maxItems": 8,
        "uniqueItems": true,
        "items": {
            "type": "object",
            "title": "Режим",
            // TODO: how to display enum's title but not value?
            "headerTemplate": "{{ self.dayCode }}",
            "required": [
                "dayCode"
            ],
            "options": {
                **"show_opt_in": true**
            },
            "properties": {
                "id": {
                    "type": "number",
                    "title": "ID",
                    "options": {
                        "hidden": true
                    },
                    "default": ""
                },
                "dayCode": {
                    "type": "string",
                    "title": "День",
                    "options": {
                        "disable": true
                    },
                    "enumSource": [
                        {
                            "source": [
                                {
                                    "value": "MO",
                                    "title": "Понедельник"
                                },
                                {
                                    "value": "TU",
                                    "title": "Втоник"
                                },
                                {
                                    "value": "WE",
                                    "title": "Среда"
                                },
                                {
                                    "value": "TH",
                                    "title": "Четверг"
                                },
                                {
                                    "value": "FR",
                                    "title": "Пятница"
                                },
                                {
                                    "value": "SA",
                                    "title": "Суббота"
                                },
                                {
                                    "value": "SU",
                                    "title": "Воскресенье"
                                },
                                {
                                    "value": "HD",
                                    "title": "Гос. Праздник"
                                }
                            ],
                            "title": "{{item.title}}",
                            "value": "{{item.value}}"
                        }
                    ]
                },
                "startTime": {
                    "type": "string",
                    "title": "Открытие",
                    "options": {
                        "infoText": "Пример 9:00",
                        "inputAttributes": {
                            "placeholder": "9:00"
                        },
                        **"show_opt_in": true**
                    }
                },

@schmunk42
Copy link
Collaborator

@Krivich Please post a usable schema or even better a link.

@Krivich
Copy link
Contributor Author

Krivich commented May 4, 2021

@schmunk42 may I send schema to your email in profile? The project is not yet released so I'd want to limit access for a while

@germanbisurgi
Copy link
Collaborator

germanbisurgi commented May 4, 2021

The show_opt_in is a global option. You have to set it when instantiating the JSONEditor in the options object. Not in the schema.

@Krivich
Copy link
Contributor Author

Krivich commented May 4, 2021

https://json-editor.github.io/json-editor/?data=N4Ig9gDgLglmB2BnEAuUMDGCA2MBGqIAZglAIYDuApomALZUCsIANOHgFZUZQD62ZAJ5gArlELwwAJzplsrEIgwALKrNSgogiFUJkpUoQpIyy4lCHJ5EAWiiQFsKNl0XABCCBUEEBoIIAwQQDggAARugAgggIgggHgggEQggNQgAYD4IIDEIIC4IIBYIJHBAYBIINGAKCDBgOQgPgA64myyAB4AklBqyCgAHGwi8DAAjiJU1bWoUFIdbDA1dHWa2q7sXDyOgy6EboCsIIBsIIAcIIA8IAqqZAAmVFIAKmoQAjWEwMABiFTYRAB0W0IAwmA7AQC+rwpSVO0wX1uoAG0QPdBE8diAALpsSCwBAjRTKMAUXgw3gweA9PpUV5sCBSSC7WA0DQgGD/NCWMYSER0PC7abOcaVAAiChhcCQJOUZJ2GJQvQ6OOBVCIZBE2HMIBAQpBYNcox0hEQvXRAHMGbMLDl5oBeEEAMiBs6Ac+FbGCIMh4TUC7FsKjwGkAZVEUgwrgBoFoIhdbtAADc5B1CABZADyGvGcUAfCA6+aAFhB5oBuED1OuWgC4QaUsP0B8Z7ACq4cImUAQiDRtMZrPYQMWADqAFECxZAIQggAEQOOABhByyB/ZWcwAJBsgfLzIuAJhB5s3AMwgne7VZAADEAEoDuKAeRAiynAGIgHZxFdnDoAggPG4BhEEAjCCnyNF7eZrvZwgO/NsJyakCZSOAQRBU6337q9fNp3eFi9qyT4zOMgDIIB+NzxM2baAOwgsYpumrxQpYYGnMAgxqDcz7Yh8bAzuMZxYXQNyEe80oQkKyr6FAewwAwJJaIqFjKlIaoDuERZfoA0iBFss/7QkacIkuiJAHOUkpxM2azjgEACcKAAAxKQo6IQGI+5QCqeBiMSFJHGQrqItgOxSIQikqRmCJIii0Bony1rvLa8BbPRjEUsx4xsRxoGMoQgDoIG2vH8YJ4DCZyFJiWAElSTJqxyQATAAzCgjDyWp8AaVAWk6Xp8KGcZYCmfSFgpWlGXOSAEBmDUUh8iAAB6RRFFswBKSwiWvCgLVtV1AAk1l4F8ZAANYOuQUh0Qx8qUixigqvA6p+S+4SnnGAQ6m2gDiIG2CaRoasKReg8DiVQkmENJsnNgEACMAAsylKQEywJssASAPwgx7viWmXZbl7G6TUBUCEVJXmRYD1PdKQo1dpuwNQAFM1rXtZ13W9cAA0AJQAPxDSNo21q57mzV5SqLctaH+RYa0bZGqbRrtKZheyIlRadMXnXF113YwT0vW9n3fb9AxZZp2mA/lJKFVQJlmYQt381ZVVw3VSMo21HVdT1qM4/j7xVYgiLIrs+JSHUpLwHVRlHY4qgeSAeBgGAUBsWQED3TDQA

[
{
"dayCode": "MO"
},
{
"dayCode": "TU"
},
{
"dayCode": "WE"
},
{
"dayCode": "TH"
},
{
"dayCode": "FR"
},
{
"dayCode": "SA"
}
]

@Krivich
Copy link
Contributor Author

Krivich commented May 4, 2021

The show_opt_in is a global option. You have to set it when instantiating the JSONEditor in the options object. Not in the schema.

I've also tried this, without any luck. Thanks.

@schmunk42
Copy link
Collaborator

The fields are readonly, is that the problem?

@Krivich
Copy link
Contributor Author

Krivich commented May 4, 2021

Sorry, not clear why they are readonly. Did I use any market for that?

@schmunk42
Copy link
Collaborator

We need some tests for the use-cases first.

Test-PRs welcome (only tests with @optional in name) is fine.

@germanbisurgi
Copy link
Collaborator

This is the corrected schema:

{
  "type": "array",
  "format": "tabs-top",
  "title": "РЕЖИМ РАБОТЫ ПУНКТА ВЫДАЧИ\t",
  "maxItems": 8,
  "uniqueItems": true,
  "items": {
    "type": "object",
    "title": "Режим",
    "headerTemplate": "{{ self.dayCode }}",
    "required": [
      "dayCode"
    ],
    "properties": {
      "id": {
        "type": "number",
        "title": "ID",
        "options": {
          "hidden": true
        },
        "default": ""
      },
      "dayCode": {
        "type": "string",
        "title": "День",
        "options": {
          "disable": true
        },
        "enumSource": [
          {
            "source": [
              {
                "value": "MO",
                "title": "Понедельник"
              },
              {
                "value": "TU",
                "title": "Втоник"
              },
              {
                "value": "WE",
                "title": "Среда"
              },
              {
                "value": "TH",
                "title": "Четверг"
              },
              {
                "value": "FR",
                "title": "Пятница"
              },
              {
                "value": "SA",
                "title": "Суббота"
              },
              {
                "value": "SU",
                "title": "Воскресенье"
              },
              {
                "value": "HD",
                "title": "Гос. Праздник"
              }
            ],
            "title": "{{item.title}}",
            "value": "{{item.value}}"
          }
        ]
      },
      "startTime": {
        "type": "string",
        "title": "Открытие",
        "options": {
          "infoText": "Пример 9:00",
          "inputAttributes": {
            "placeholder": "9:00"
          }
        }
      },
      "endTime": {
        "type": "string",
        "title": "Закрытие",
        "options": {
          "infoText": "Пример 23:59",
          "inputAttributes": {
            "placeholder": "23:59"
          }
        },
        "pattern": "^\\d{0,2}:\\d{2}$"
      },
      "breakStartTime": {
        "type": "string",
        "title": "Обед начало",
        "options": {
          "infoText": "Пример 14:00 или пусто",
          "inputAttributes": {
            "placeholder": "14:00"
          }
        },
        "pattern": "(^\\d{0,2}:\\d{2}$)?"
      },
      "breakEndTime": {
        "type": "string",
        "title": "Обед окончание",
        "options": {
          "infoText": "Пример 15:00 или пусто",
          "inputAttributes": {
            "placeholder": "15:00"
          }
        },
        "pattern": "(^\\d{0,2}:\\d{2}$)?"
      }
    }
  }
}

In the current latest release there is a bug that leaves the optional editors disabled. I fixed this bug already but a release is necessary.

@Krivich : you could try this schema with the master version of json-editor

@Krivich
Copy link
Contributor Author

Krivich commented May 4, 2021

@Krivich : you could try this schema with the master version of json-editor

I appreciate if you hint how to do that. Currently json-editor is loaded by npm inside docker build like:

   "@json-editor/json-editor": "~2.5.3",

Is there any option to make it get version associated with master?

@Krivich
Copy link
Contributor Author

Krivich commented May 4, 2021

I've referenced the latest master version in my npm this way:

"@json-editor/json-editor": "git+https://github.com/json-editor/json-editor.git#7aae084",

If I add "show_opt_in": true on the object declaration level - I see my blank editors but they are disabled by some reason:

{
        "type": "array",
        "format": "tabs-top",
        "title": "РЕЖИМ РАБОТЫ ПУНКТА ВЫДАЧИ\t",
        "maxItems": 8,
        "uniqueItems": true,
        "items": {
            "type": "object",
            "title": "Режим",
            "headerTemplate": "{{ self.dayCode }}",
            "required": [
                "dayCode"
            ],
            "options": {
                "show_opt_in": true
            },
            "properties": {
                "id": {
                    "type": "number",
                    "title": "ID",
                    "options": {
                        "hidden": true
                    },
                    "default": ""
                },
                "dayCode": {
                    "type": "string",
                    "title": "День",
                    "options": {
                        "disable": true
                    },
                    "enumSource": [
                        {
                            "source": [
                                {
                                    "value": "MO",
                                    "title": "Понедельник"
                                },
                                {
                                    "value": "TU",
                                    "title": "Втоник"
                                },
                                {
                                    "value": "WE",
                                    "title": "Среда"
                                },
                                {
                                    "value": "TH",
                                    "title": "Четверг"
                                },
                                {
                                    "value": "FR",
                                    "title": "Пятница"
                                },
                                {
                                    "value": "SA",
                                    "title": "Суббота"
                                },
                                {
                                    "value": "SU",
                                    "title": "Воскресенье"
                                },
                                {
                                    "value": "HD",
                                    "title": "Гос. Праздник"
                                }
                            ],
                            "title": "{{item.title}}",
                            "value": "{{item.value}}"
                        }
                    ]
                },
                "startTime": {
                    "type": "string",
                    "title": "Открытие",
                    "options": {
                        "infoText": "Пример 9:00",
                        "inputAttributes": {
                            "placeholder": "9:00"
                        }
                    }
                },
                "endTime": {
                    "type": "string",
                    "title": "Закрытие",
                    "options": {
                        "infoText": "Пример 23:59",
                        "inputAttributes": {
                            "placeholder": "23:59"
                        }
                    },
                    "pattern": "^\\d{0,2}:\\d{2}$"
                },
                "breakStartTime": {
                    "type": "string",
                    "title": "Обед начало",
                    "options": {
                        "infoText": "Пример 14:00 или пусто",
                        "inputAttributes": {
                            "placeholder": "14:00"
                        }
                    },
                    "pattern": "(^\\d{0,2}:\\d{2}$)?"
                },
                "breakEndTime": {
                    "type": "string",
                    "title": "Обед окончание",
                    "options": {
                        "infoText": "Пример 15:00 или пусто",
                        "inputAttributes": {
                            "placeholder": "15:00"
                        }
                    },
                    "pattern": "(^\\d{0,2}:\\d{2}$)?"
                }
            }
        }
    } 

image

@Krivich
Copy link
Contributor Author

Krivich commented May 4, 2021

This code is resposible for disabled editors if I show them by show_opt_in option. Is it really expected behaviour?

  deactivateNonRequiredProperties () {
    /* the show_opt_in editor option is for backward compatibility */
    if (this.jsoneditor.options.show_opt_in || this.options.show_opt_in) {
      Object.entries(this.editors).forEach(([key, editor]) => {
        if (!this.isRequiredObject(editor)) {
          this.editors[key].deactivate()
        }
      })
    }
  }

@germanbisurgi
Copy link
Collaborator

i meant like this:

const editor = new JSONEditor(element, {
show_opt_in: true,
theme: 'bootstrap4'
});

  • use the corrected schema
  • use master branch build not the release

@Krivich
Copy link
Contributor Author

Krivich commented May 5, 2021

@germanbisurgi, the side-effect is checkbox near every optional field:
image

@schmunk42
Copy link
Collaborator

@germanbisurgi, the side-effect is checkbox near every optional field:

Yeah, I noticed that also.
We need tests for it.

@germanbisurgi
Copy link
Collaborator

The additional checkboxes is an expected behaviour. That is how the json-editor allows you to opt_in properties

@Krivich
Copy link
Contributor Author

Krivich commented May 5, 2021

Interesting observation: editors of empty optional filed of the childern object of the root object are displayed, all missing editors are in the object which bound to the root over the array. In other words object->object->editor behaviour is not the same like object->array->object->editor which could tell about a bug but I didn't find the root cause. It means that instead of my MR we might need to make object inside array works the same like without parent array.

@Krivich Why is there no data-schemapath?

I'm not familiar with the test library so just trying to implement some realistic but experiencing lack of knowledges. Sorry.
I took this syntax from the array_test.js:
I.seeElement('[name="root[0][property]"]');

@germanbisurgi
Copy link
Collaborator

germanbisurgi commented May 5, 2021

I think is working fine (object->array->object->editor)

Bildschirmfoto 2021-05-05 um 11 51 14

@Krivich
Copy link
Contributor Author

Krivich commented May 5, 2021

I think is working fine (object->array->object->editor)

UPDATED: sorry you are right. The field in the root is displayed becaue of empty string. Below is demostration.

https://json-editor.github.io/json-editor/?data=N4Ig9gDgLglmB2BnEAuUMDGCA2MBGqIAZglAIYDuApomALZUCsIANOHgFZUZQD62ZAJ5gArlELwwAJzplsrEIgwALKrNShYUbFUIBhehDLxBCqIIi6U7LjwWRYCZGhAATGIjJ4dvLNgEQiFZQUiJUAL5sEFKQVFKwNBogMK5J5pYSInR4cWYw2lYgAJIAIvbQcEhJyimuVPCoIWGRblREZCLY4tYgLWBERJhWmhaFYJzc4mxaOoQA8gNDCnhkiJh6ZFBUAObSggAq+bPWBnR0CApSVACOIjBXqSgA2iDwZAwgALpRMZbxMIkXG8Pi50oVECEYPBtnkCvpDMZBAACYG6Nh0KEAGXq2ygylQABZ0WQAB7Y6F41AANgJLUwCAAqlJ5KDRoQIVIoTDpkdCpiwLskQyAEqYhQY+Dk3H4lAARgATMSyTjKSh5YwqWwSDJNoQRMzeuEWkpVK5OsMQGDCGQpFIhAptbJupavIgALRQSCw44gADKKioZtmSqKWzozgAHGwRPAYLcqKG1M4mlQ2Pkk2k2dZxrYppbeYQSva2KoyHUpPs1BABFtCMBgEigtgiAA6VxCAx1FszKhIo2XG53B6oF7twSd3TfcAVJxJdyebxUXxgfxkQLBUKpkBYOhGOwoFMtaKxf6A9CPEYZazwLI5KTewqlcqOKouGquOoNA+blp1dqdZ1ejYMcJ0zK9FEhaEH0IQAUEEAVhBAF4QQAZEAUeosl9UQpAwKwnlAWh9WwkdQAANzkMJCAAWTmaDrAohAxyAkiyMKfYGRokB9mUMJEAY8Ipx7OtgHTOhu15fs2FI7ByOsethJbSTmnCXpPmNch4kOEFL3BSDuXzOFrDmSwGjYBxKmcdB4BISsSWdQB8EEAARBAA4QQAeEDg+ykQAThQAAGbyFChCAxAAQSgSE8DEM8QGrMhsOUFdy0ILzfMNI1UuNOKKF4OIYikZxkngLY7R4SozFUEEQDwMAwCgDk1wJAdbnuQNeDwQReD/DoulQdpsCCYCPGitqrkah5eBwUwUB6vrFAysboF4KFurkabJF4Mt3BfOReGPP4EmcKatzIDhSSW3qt3nLwfEDfJeA4WgvxTfqFx8PwAiCU7pouxdtt+OI9saTcnsupcbTtNr1o+86PGBtbbSEXgrmkBLJuWqHnpBuG2rqHRaxRs62HqGHQfhrAIAmg62GJtqsAKmJet4T0IEhoHvqp9qqBxkH/ARsAKGTQG3Gh1nMfZzn+FWPgYgoAHFKAA

{
  "id": "",
  "office": {
    "name": "My Company",
    "iconUrl": ""
  },
  "schedule": [
    {
      "dayCode": "MO"
    }
  ]
}

image

@Krivich
Copy link
Contributor Author

Krivich commented May 5, 2021

The easy way to fix side-efect of show_opt_in: true with checkbox - hide them with CSS:

.json-editor-opt-in {
    display: none;
}

But it brings the next problem - fields which was empty are disabled and without checkbox it is impossible to enable them. So it seems that my proposal in MR solves the problem cleaner - editors are visible and enabled.

Please tell me what I need to do to satisfy MR merge criterias?

@germanbisurgi
Copy link
Collaborator

Optional "empty" properties is one the reasons why json-editor uses checkboxes.

@Krivich
Copy link
Contributor Author

Krivich commented May 5, 2021

I might upderstand you incorrectly. Json-editor will automaically remove from json output optional properties which has empty value. It means that if I suppose that user may want to set optional filed later - I can safely show him all editors and json-editor will output this field only if user has set the value. What is the reason to make user check checkox to start editing empty optional field in this scenario?

@germanbisurgi
Copy link
Collaborator

Not quite. It could be that you want to have a property that is empty, but that also has to appear in the output. How do you determine if is active or not? The answer is, you do not base it state based on its value but something else, like a checkbox.

@Krivich
Copy link
Contributor Author

Krivich commented May 5, 2021

Sounds like very exotic case. I'd remove this field from json output untill user touch the field. If touched - output empty string. If initial value is empty string - output empty string. To let remove such "empty" value - I'd show "clear" button. It is just a raw idea. The current UX where I have to show checkbox near all optional fileds if I want to let user edit optional field later is very "heavy", I'm not really sure that non-technical user will like such UI.

What do you think about my MR? Is there any chance to merge it? At least is it a good alternative, 100% non-breakin and 100% backward compatible.

@Krivich
Copy link
Contributor Author

Krivich commented May 6, 2021

@schmunk42, @germanbisurgi what should I do to help to accept my pull-request?

@schmunk42
Copy link
Collaborator

@germanbisurgi you took a closer look, can we merge this?

@Krivich
Copy link
Contributor Author

Krivich commented May 8, 2021

This PR will also improve consistancy of json-editor because table format of array allows editing of optional fields any time, but tabs formt - not.

@germanbisurgi
Copy link
Collaborator

Sorry, I would not merge this.

@Krivich
Copy link
Contributor Author

Krivich commented May 8, 2021

What should I improve to make it acceptable?

@germanbisurgi
Copy link
Collaborator

If it don't change the behaviour of show_opt_in directly it' ok for me. In particular the empty fields should not be activated automatically unless it was told to do so with an extra option setting. If you can expand your teste to prove this we can merge the PR .

@Krivich
Copy link
Contributor Author

Krivich commented May 10, 2021

Done.

  1. Existing tests for show_opt_in are not broken => it don't change the behaviour of show_opt_in directly
  2. Test for show-non-required-editors=false is not broken => the empty fields are not activated automatically unless it was told to do so with an extra option
  3. Test for show-non-required-editors=true is not broken => if user wants to see editors for empty optional feilds - he can do it with extra option show-non-required-editors

Please let me know if anything else is required from my side.

@germanbisurgi
Copy link
Collaborator

Perfect :)

@schmunk42: what do you think?

@schmunk42
Copy link
Collaborator

While the PR looks good, just a README entry about the new option would is missing, I still do not fully understand it.

Actually showing non required editors should be the default, unless display_required_only would be set.

So why do we need a new option?

@Krivich
Copy link
Contributor Author

Krivich commented May 11, 2021

Let me prepare a short demo for you.

@Krivich
Copy link
Contributor Author

Krivich commented May 11, 2021

  1. Open editor https://json-editor.github.io/json-editor/?data=N4Ig9gDgLglmB2BnEAuUMDGCA2MBGqIAZglAIYDuApomALZUCsIANOHgFZUZQD62ZAJ5gArlELwwAJzplsrEIgwALKrNSgogiFUJkpUoQthRsulCAAy+Q1MEACCtIDWAEyGJ7S11VcizCiQyZOIW5HgBbLIAHgCSUGrIKAAcbCLwMACOIlTxiahQUjlsMAl0SZra5uxcPMalARYAIkZsqmQ+UgAqahACCYTAwF5U2EQAdO6CAMJgPvYAvgsKUlTZMKuuqADaIFOzPiAAumyQsAgVispgFLyS8Lyr65u8vqXSSYU5C2wQUpBUKSwGgaEAwLZoEBaHQSER0PCA+qmaqxJoKM5wJCg5TgnzwApFKg/PZUIhkfyhEAgYn7ObmSowiyIQoweAAcyRjRALUE6OgmMurhgiDIEXMXyJbCo8DhAGVRFIMOZtqBaCJFcrQAA3OQ5QgAWQA8pzqvqEFNqSxtbrql0AKomwhdHKIC0/a3YPUWADqAFFHT7fPAaG6TlCGtUhqU1OMTGYlgodZ7I8Bo3RxknvssFkdicz9FAujAGKDodVmVJWRy2HHqoadPjTvyLqDWSQetFKb7omQ6H0qPYAJwoAAMI4UrIgYgAglAWXgxCDIX0yErrthOoRh2PqUspfBXEWS5Cy4QK1WAyBptgwIhdE3zljIW2wB2uz2+2Z7ABGZKj8clPAU5QLO86LpcK5rmAG6IhYv7/ruSx7lcNyvAYHyEKyCSGDwmLGKox4gHgYBgFAFZkBAAAsu5AA

  2. Specify value

[  
  {
    "dayCode": "MO"
  },
  {
    "dayCode": "TU"
  },
  {
    "dayCode": "WE"
  }
]
  1. Replace array format to "tabs-top" -- comare result with the previous.

As you can see table representation lets edit values any time. It means that If you want to change work hours for Monday - no problems, just input new values. Unfortunately table layout is not mobile-friendly. Once you migrate to tabs-top format which is much more mobile-friendly - you are loosing opportunity to edit work hours anytime you want. The only existing workaround for now - turn on show_opt_in for editor and put up with checkboxes everywhere...

@germanbisurgi
Copy link
Collaborator

germanbisurgi commented May 11, 2021

Oh, maybe i know where the problem lays but i need some time to test it. I will update this post asap.

Edit:

  • there is a bug with the table editor (specifically objects in tables): It sets all properties defined in the schema also when some properties are explicitly set. Also ignores some options like "display_required_only" and "show_opt_in". That is why i would not merge the PR.

  • @Krivich with your changes you have what you desired until you change the value of some editor in the array. Then the value its refreshed and more properties are added to it automatically. I think that will not help your goal and what you really want is the "show_opt_in" option but with a different UI (checkboxes). A PR for a more user friendly alternative UI would be great.

@germanbisurgi germanbisurgi changed the title Option for editing of undefined non-required fields Option for editing of undefined non-required fields (bug with tables of objects) May 12, 2021
@schmunk42
Copy link
Collaborator

I think I understand now :)

It's indeed not intuitive, but just how json-schema works.

Acutally I think showing empty fields should be accomplished just by using required_by_default or required.
Would you agree to that?

But I also noticed that this does not show the fields, when data is loaded without the corresponding keys.
Shouldn't just hat be fixed?


We had such issues before, looks trivial first, but get compley. That's why I am still a bit hesitant to merge.

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

Successfully merging this pull request may close these issues.

None yet

3 participants