tsgrp / ActiveWizard

OpenContent Dynamic Forms and Workflow
http://www.tsgrp.com/products/opencontentforms/
4 stars 0 forks source link

Table view - Does not work when questions are reordered #123

Closed gsteimer closed 9 years ago

gsteimer commented 9 years ago

See the screencam below - the table gets really messed up when you have questions ordered in the admin that are not in a contiguous ID order. In the admin, the order of the questions can be changed at any time:

image

In the screencap below, the first question was added last to the page (and was reordered in the admin to be first on the page).

reordered-table-questions

Thanks to @dgrumieaux for helping figure out that it was the ID order that was the issue...

dgrumieaux commented 9 years ago

We'll want to add logic to the PageSetInstanceProvider#transform method to ensure the question/input ids are a contiguous block (ie 2-5, 4-7). This should solve this issue.

mikeblum commented 9 years ago

For my own reference: as we parse each question, iterate and assign a fresh id. question ids from page set definitions are unreliable.

mikeblum commented 9 years ago

What's the name of the form with the ordering error? I think i have a fix.

dgrumieaux commented 9 years ago

Don't forget to account for unaligned questions before/after @mblum

On Tue, Nov 25, 2014 at 4:01 PM, Michael Blum notifications@github.com wrote:

What's the name of the form with the ordering error? I think i have a fix.

— Reply to this email directly or view it on GitHub https://github.com/tsgrp/ActiveWizard/issues/123#issuecomment-64478873.

gsteimer commented 9 years ago

On wizard_d67, it was the Equipment Request form. But I updated it to be in the correct order so I could do my screencam. All you should have to do to test is go into the wizard admin and reorder the questions on a page with a table group.

mikeblum commented 9 years ago

See issue #129

mikeblum commented 9 years ago

Number mask breaks calculations, Next step is to implement the masks, but the ids have fixed this particular ticket. closing..

r11232 | mblum | 2014-11-26 10:17:18 -0600 (Wed, 26 Nov 2014) | 2 lines

Fixed question ids falling out of sync when re-ordered in the AW Admin: Table view - Does not work when questions are reordered #123

gsteimer commented 9 years ago

@mikeblum - do not close until this has been merged to trunk. Any commits to your branch do not need to be logged here.

mikeblum commented 9 years ago

Issue appears to be with how we're cloning a row. We expected the ids to be in sequential order but this is the result of cloning in2, in0, in1:

this.pluck('_id'): Array[7]
0: "in2"
1: "in1"
2: "in0"
3: "in3"
4: "in4"
5: "in5"
6: "in6"

When cloning a row we should loop through the last row (row we're cloning). Get each id, add the offset of the grouped question length (i this case 3), and push that onto the list of items in the new row to get the desired outcome:

in2, in0, in1, in3, in6, in4, in5 etc

mikeblum commented 9 years ago

Revision: 11279 Author: mblum Date: 2014-12-03 09:54:45.835237 mergiung in html5 active wizard bugfixes

M /trunk/code/test/tests/modules/wizard/services/pagesetinstanceproviderSpec.js M /trunk/code/app/modules/wizard/services/formatservice.js M /trunk/code/app/modules/wizard/formfields/aspects.js M /trunk/code/app/modules/common/typeahead.js M /trunk/code M /trunk/code/app/templates/wizard/tablequestion.html M /trunk/code/app/modules/wizard/services/validationservice.js M /trunk/code/app/modules/wizard/views/questionview.js M /trunk/code/test/tests/modules/wizard/wizard/questioncollectionSpec.js M /trunk/code/app/modules/wizard/views/controltypes.js M /trunk/code/app/templates/wizard/table.html M /trunk/code/app/modules/wizard/models/questioncollection.js M /trunk/code/test/tests/modules/wizard/formfields/requireableAspectSpec.js M /trunk/code/test/tests/modules/wizard/formfields/aspectsSpec.js M /trunk/code/app/modules/wizard/services/formulaservice.js M /trunk/code/app/modules/wizard/services/pagesetinstanceprovider.js M /trunk/code/app M /trunk/code/app/modules/wizard/wizardflex.js M /trunk/code/assets/css/styles/hpi.styl

gsteimer commented 9 years ago

This is still a problem. I added a new page in the Kitchen SInk form on Edge1 that shows this failing:

table-add-row-fail

From talking to @mikeblum the problem is that the code does not take into account that there can be holes in the input ID numbers. When the wizard admin gives a new answer (or question or page, etc) a new ID, it simply looks at the existing answers and gets the largest one and then increments by one. That means that if you delete questions in the middle, those IDs are never reused (unless all answers with higher IDs are also deleted). In the case of the new Kitchen Sink page, the IDs are in the following order: IN2, IN5, IN4.

In the old version of the Active Form's repeating pages, we used a dot syntax for generated questions and answers. This way, there's no way that IDs can clash. For example:

in2    |  in5    |  in4
in2.0  |  in5.0  |  in4.0
in2.1  |  in5.1  |  in4.1

From talking to @mikeblum, we probably don't want to use the dot syntax this time since Javascript tries to round 3.0 to 3 when converting from string to number. Something like an underscore or something else would be preferable.

Also (I'm assuming it does this now, but just in case), answer IDs will also need to be updated when a row is duplicated. So if in2 is a selectbox with 10 answers, we'll have the same ID issue with option IDs. In2 could have 10 options with IDs in any order and with missing values. Something like op1, op4, op2, op7, op8, op11, etc.

@dgrumieaux

gsteimer commented 9 years ago

Just to be clear, repeating pages in the old ActiveForm module used the dot syntax for answers as well...

mikeblum commented 9 years ago

Once more with feeling:

Revision: 11311 Author: mblum Date: Monday, December 08, 2014 12:42:28 PM Message:

merging in wizard-bugfixes branch to fix: https://github.com/tsgrp/ActiveWizard/issues/138, https://github.com/tsgrp/ActiveWizard/issues/121

Modified : /trunk/code Modified : /trunk/code/app Modified : /trunk/code/app/modules/common/typeahead.js Modified : /trunk/code/app/modules/wizard/models/pagesetinstance.js Modified : /trunk/code/app/modules/wizard/models/questioncollection.js Modified : /trunk/code/app/modules/wizard/services/validationservice.js Modified : /trunk/code/project/wizard-dctm/app/configs/config-project.js Modified : /trunk/code/test/tests Modified : /trunk/code/test/tests/modules/wizard/wizard/questioncollectionSpec.js