Problem/Motivation
Currently, the "Customize" feature for the webform submission list is maintained via global state. Some users may benefit from the ability to personalize which webform elements are visible in the list.
Proposed resolution
I think that we should examine and discuss how the current customize feature may be used by organizations. For example, some organizations may have a specific configuration that their submission viewers are not normally able to change. Perhaps the users that are analyzing submissions are not trained on how to use the customize feature, or do not wish to take on the responsibility of maintaining their own list views. A direct shift from global state to individualized user settings may be disruptive to this use case.
Remaining tasks
- Document how the feature was originally intended to be used.
- TBD?
User interface changes
Depending on the changes, the permissions controlling the "Customize" button may be affected.
API changes
Webform::(get|set|delete|has)UserData methods add
Data model changes
N/A
User Acceptance Test
- Confirm existing 'Customize' results is working as expected
/admin/structure/webform/manage/contact/results/submissions - Enable 'Allow users to customize the submission results table'
/admin/structure/webform/manage/contact/settings/submissions - Confirm 'Customize' button changed to 'Customize my table'
/admin/structure/webform/manage/contact/results/submissions - Click 'Customize my table'
/admin/structure/webform/manage/contact/results/submissions - Confirm 'Customize my table' allows table to be customized for the current user
/admin/structure/webform/manage/contact/results/submissions/custom/user - Confirm 'Customize default table' button on 'Customize my table' form allows defaults to be defined
/admin/structure/webform/manage/contact/results/submissions/custom - Confirm 'Customize default table' and 'Customize my table' reset works as expected
/admin/structure/webform/manage/contact/results/submissions/custom - Confirm 'Allow users to customize the submission results table' can be toggled on/off via the 'Customize' form
/admin/structure/webform/manage/contact/results/submissions/custom - Confirm 'Allow users to customize the submission results table' can be enabled for all webforms
/admin/structure/webform/config/submissions
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | 3108433-27.patch | 66.57 KB | jrockowitz |
| #33 | 3108433-33.patch | 66.56 KB | jrockowitz |
| #33 | interdiff-3108433-29-33.txt | 3.36 KB | jrockowitz |
| #29 | 3108433-29.patch | 65.65 KB | jrockowitz |
| #29 | Screen Shot 2020-03-03 at 4.39.35 PM.png | 205.35 KB | jrockowitz |
Comments
Comment #2
luke.leberAdded proof of concept patch that seems to allow customization on a per-user basis.
I'm not entirely convinced that using
\Drupal::stateis appropriate for this kind of thing after introducing this much granularity. While is was perfect for storing the global state, it almost seems like the wrong tool for storing per-user information.Comment #3
luke.leberCopying the patch from slack seems to have corrupted it. Trying again...
Comment #4
jrockowitz commentedThis would have to be configurable setting and use UserData. My gut says we need to allow admins to set the default results columns and then provide a setting to allow individual users to further customize the result columns.
A few notes...
Comment #5
luke.leberWhat are your thoughts on making an (abstract?) base class form to be able to recycle most of the form build? Using two forms could also allow for a cleaner separation of persistence logic. It should also let the existing form remain intact for BC reasons.
I'm also wondering if the new form should have its own link on the results page such that there could be a "Set Defaults" and/or a "Customize" (bikeshed needed) button that appears depending on the user's permission. This could allow more logic to be nicely separated, especially when a user has permission to edit the webform default as well as their own personal results lists.
This week is going to be busy, but I should have more time next weekend to get at least part of a rough working patch put together.
Comment #6
jrockowitz commentedBaseForm could be a good approach. I think you could also pass an $operation parameter to WebformResultsCustomForm::form. I recommend approaching this patch in small incremental steps and to make sure not to break WebformSubmissionListBuilderTest.
Comment #7
luke.leberAdded configuration related changes.
Comment #8
luke.leberOuch. Added webform settings update call to update hook.
Comment #9
luke.leberPassing config changes.
Comment #10
nancydruI don't see a per-user option as being terribly useful, but I really would like to see it not select every single form field to show. My forms have literally hundreds of fields, so the view gets enormous. I would rather see an opt-in for form fields (as opposed to module fields) instead of an opt-out.
Comment #11
luke.leberI think this is more of an "enterprisey" feature that is useful when more than one individual is involved in site management, and none of whom should be able to administer webform settings.
Our particular use case involves different types of stakeholders that all care about different data. For example, marketing associates want to see campaign related information (who clicked what, where did they come from, etc...) whereas others want to see other subsets.
Having multiple parties attempting to view data all at once can be disorienting (especially if someone else changes the view while you are using it). Having enough permission to customize the results also currently carries more implications.
Comment #12
luke.leberComment #13
jrockowitz commentedWe also need to add some test coverage either via \Drupal\Tests\webform\Functional\WebformSubmissionListBuilderTest or a brand new Test.
Comment #14
jrockowitz commentedThe attached patch just contains the 'results_customize' configured to be a global or webform specific behavior.
How the customized results data is stored right now is a little confusing and I want to see if there is an opportunity to fix this.
I do want to restore the below code once we have customized user results.
Comment #16
jrockowitz commentedApproach
On the Results table/page
In the 'Customize table' form
Notes
Comment #23
jrockowitz commentedThe attached patch is a preview of the new feature. The patch still needs some more test coverage.
Comment #27
jrockowitz commentedThis patch has test coverage and is ready to be reviewed.
Comment #29
jrockowitz commentedMost organization webforms have only one "owner", which means the one "owner" can customize the results without any problems.
Allowing users to customize the submission results table addresses the situation where a webform has multiple owners who required a customized results table. The existing functionality should be default behavior and allowing users to customize the submission results table can be enabled directly in the 'Customize table' modal.
Comment #30
jrockowitz commentedComment #31
luke.leberHey Jacob,
I was able to take a pass through the changes (sans tests -- I'll try to run through those tomorrow night). Overall, it's a work of art. I have just a couple pieces of feedback.
1) The
\Drupal\webform\Form\WebformResultsCustomFormform seems to continuously render a 'Customize my table' link for users that have access to customize their personal table, but not set the defaults. Perhaps this could be a fix:2) The
\Drupal\webform\WebformSubmissionStorage::getCustomSettingmethod could potentially allow user-specific customizations to be used even if the webform configuration forbids it.To POC this, add a user customization to a form that's different than the default, then disallow user customizations. Refresh the page and see that the user customized settings are still used.
Comment #33
jrockowitz commentedThanks for the code review. I applied your suggestions to the patch.
Comment #34
luke.leberI'm a little confused by some of the
WebformSubmissionListBuilderCustomizeTesttest. If I'm not mistaken, the test seems to be broken -- or at least not working like I'd expect it to.Running through the steps manually in my browser, I can confirm that a webform set with 'results_customize' should only show the 'Customize my table' link on the submission table and not the 'Customize' link. I'm not sure where the test is finding a 'Customize' link on that page.
* AH! It looks like
\Behat\Mink\Element\Element::findAllcan fall back to doing partial matches. Why the link was found now makes sense.Comment #35
jrockowitz commentedI will tweak the test to be more specific.
Comment #37
jrockowitz commentedInstead of
$this->assertLink('Customize');I decided to use$this->assertRaw('>Customize<');.Comment #38
jrockowitz commentedComment #40
jrockowitz commented