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

Dynamic Schema issues in array #101

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

Conversation

nagarajanchinnasamy
Copy link
Contributor

When using dependsOn between properties of an object placed in an array, encountered various issues. Please use the examples provided in examples folder to test scenarios below:

Issue 1:

When an item is added by clicking Add Item button, received Uncaught Type Error: element.equals is not a function exception.

01_elementequals

Issue 2:

After fixing issue-1, using the following steps:

  1. Add an item
  2. Remove the item
  3. Add the item again

received Uncaught TypeError: cannot read property 'type' of undefined exception

02_addlevel1item_delete_againadd

Issue 3:

After fixing issue-2, using the following steps (in example2.html):

  1. Add Level-1 Item
  2. Add Level-2 Item
  3. Select "OPTION-2" in drop-down

received Uncaught TypeError: cannot read property '$ref' of undefined exception.

03_addlevel2item_selectoption-2

Issue 4:

After fixing issue-3, noticed that, dependency change is effective only in the last item of the array. Other items do not react to change in the drop-down value. This I feel something to do with depencyMap. But could not figure out a solution for this. Need help. Thanks.

@@ -177,6 +177,7 @@ if (typeof brutusin === "undefined") {
} else if (s.media) {
input = document.createElement("input");
input.type = "file";
appendChild(input, option, s);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addition of this line is unintended. I will remove this line from my version and resubmit the pull request.

} else if (s.format === "date") {
input.type = "date";
} else if (s.format === "time") {
input.type = "time";
} else if (s.format === "email") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deletion of above 4 lines unintended. Will add these in my version and re-submit the pull request.

@@ -204,7 +205,7 @@ if (typeof brutusin === "undefined") {
}
}
if (s.enum.length === 1)
input.selectedIndex = 0;
input.selectedIndex = 1;
Copy link
Contributor Author

@nagarajanchinnasamy nagarajanchinnasamy Sep 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must be:
input.selectedIndex = 0;

Will change and re-submit

if (value === true || value !== false && s.default) {
input.checked = true;
if (value === true) {
input.checked = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in above 2 lines are unintended. Will revert and re-submit

@@ -1311,7 +1307,7 @@ if (typeof brutusin === "undefined") {

function cleanSchemaMap(schemaId) {
for (var prop in schemaMap) {
if (prop.startsWith(schemaId)) {
if (prop.startsWith(schemaId)) { // 02_AddLevel1Item_Delete_AgainAdd.png
delete schemaMap[prop];
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly, in the origin itself, the code differs between src and dist!!!

src has this fix... but dist doesn't have the fix.

@KiSchulte
Copy link

@nagarajanchinnasamy Thank you this pull request fixed all my open issues.
@idelvall +1 for merging this pull request

@machinaeXphilip
Copy link

thank you! fixed issues i had as well with dynamically build arrays with distinct fieldnames
hope this can be merged soon into @idelvall 's master !

@ma-hack
Copy link

ma-hack commented Jan 22, 2019

thank you very much for the implementation!

With the getData method, the generated elements are not displayed. The error occurs when the first element had an addition and the next element makes a schema change.

image

Than getData has the result:
data: {"speciesList":[{"species":"dog"},{"species":"human"}]}

With only one Entry the result is:
data: {"speciesList":[{"species":"dog","subspecies":"bulldog"}]}

How did you fix the problem? Does it happen to you too?

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

Successfully merging this pull request may close these issues.

4 participants