Problem/Motivation
Using of Entity Browser is not so smooth. Any action in browser makes full reload of entity browser and that makes reset of form. For example: when view with filtering and paging of entities is used, after adding one entity in list of selected entities, previous defined filter is reset and paging too. Additionally when view with checkboxes (or some other way of selection) is used, there is one additional not needed step in selection process (click checkbox -> click select entities -> click use selected entities) - and first click can be automated to automatically add entity in list of selected entities.
Proposed resolution
Adding/removing of entities in selection display for multi step display, should be made over Ajax requests, where only relevant part of entity browser form will be loaded or removed (without full reload, without losing filtering, paging, etc.)
Remaining tasks
- provide add functionality for multistep display that will load entities over Ajax request
- provide remove functionality for multistep display that will remove element from page and update selection in form
*Edit* Usability example
Comment | File | Size | Author |
---|---|---|---|
#55 | interdiff_2822009_55_53.txt | 671 bytes | mtodor |
#55 | 2822009_55.patch | 87.41 KB | mtodor |
#53 | 2822009_53.patch | 87.37 KB | slashrsm |
#48 | interdiff_2822009_48_46.txt | 8.29 KB | mtodor |
#48 | 2822009_48.patch | 87.42 KB | mtodor |
Comments
Comment #2
mtodor CreditAttribution: mtodor at Thunder commentedComment #3
mtodor CreditAttribution: mtodor at Thunder commentedHere is initial work. It's still work in progress, but it would be nice if someone can take a look and give some feedback.
I have also added example in example module, so that's easier to check it.
Note
In order for functionality to work one core patch is required: #2699489: FormBuilder $ajax_form_request check does not check which AJAX form is being requested
Next things on my list are:
Comment #4
mtodor CreditAttribution: mtodor at Thunder commentedHere is new patch. It contains further work:
I have also added ticket for Upload Widget (in this case DropZoneJS widget), to support "auto_select" functionality. More or less, just drop files and they will be added to multistep selection display (rejected files ignored, valid automatically uploaded, entities created and added in list of selected entities for multistep selection display) - ticket: #2823670: Improved MultiStep selection display (DropZone Widget).
Comment #5
mtodor CreditAttribution: mtodor at Thunder commentedI have created pull request on github - because I think it's easier to review it there and collaborate when it comes to review, feedback, comments etc.
Pull request is here: https://github.com/drupal-media/entity_browser/pull/153
Comment #6
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedChecked the pull request. Approach generally looks OK to me. Left one comment, but nothing major.
Still needs a proper review and testing (let's continue doing that on the pull request from #5).
Comment #9
mtodor CreditAttribution: mtodor at Thunder commentedMade adjustments from comments provided on github pull request. (except moving functionality provided in view widget example into view widget).
Pushing patch here for checking are tests running and easier usage in packaging tools.
Comment #12
mtodor CreditAttribution: mtodor at Thunder commentedIssue with displayed action buttons for multistep display should be solved (now they appear only when there is some selection in multistep display).
I have moved functionality provided in example into view widget, now view widget can work out of the box. (as @samuel.mortenson has suggested)
Comment #13
mtodor CreditAttribution: mtodor at Thunder commentedComment #14
mtodor CreditAttribution: mtodor at Thunder commentedComment #15
mtodor CreditAttribution: mtodor at Thunder commentedThere was issue with Hide/Show button -> because click behavior was registered on every ajax request, now it should work properly.
Comment #16
esolitosI love the idea! Haven't got the chance to test the patch so i will not put in RTBC, but the code overall seems ok.
Comment #17
chr.fritschI rebased the pull-request and re-rolled the patch to make them work with current HEAD again
Comment #18
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedFinally managed to look at this patch. I was able to do general approach review and it looks great.
We would need someone to do a proper frontend review (I don't feel competent enough in this area). I will try to find some time in next few days to properly test this and make an in-depth review.
Great work @mtodor!!
Comment #19
mtodor CreditAttribution: mtodor at Thunder commentedComment #20
samuel.mortensonUsing this feels pretty good!
Some front-end notes:
The patch required a small re-roll so I'm not uploading the (broken) interdiff.
Comment #21
mtodor CreditAttribution: mtodor at Thunder commented@samuel.mortenson thank you for feedback.
I have checked with example provided in example module and I'm not getting problems you have listed here. It would be nice, if you can provide information about environment you have used or create module with only configuration, so that I can reproduce it.
I have rebased pull request and here is new patch based on that.
Comment #22
mtodor CreditAttribution: mtodor at Thunder commentedComment #23
samuel.mortenson@mtodor #21.1 Agreed - the issue's title threw me off but if the scope is just auto selection, then we can work on this issue elsewhere.
For #21.2 and #21.3, here are full replication steps:
I see no JS errors, but if it helps I'm on Mac OSX running Chrome 54.0.2840.98 (64-bit). Here's another GIF of what I'm seeing.
A few other notes when reviewing the patch again:
This code won't work for Views that aren't using the "Table" display, like File Browser.
Can we make the "input" selector more specific here?
Can we indicate that a View result has been selected somehow, maybe by adding a class to the View row? The checkboxes are hidden now, so as a user there is no longer a way to visually indicate that a row has been selected. It's worth noting that File Browser and the browser provided by Lightning Media both highlight Views rows on click, or based on the checkbox state.
Comment #24
samuel.mortensonComment #25
mtodor CreditAttribution: mtodor at Thunder commented@samuel.mortenson I can't reproduce it. What Drupal version are you using? Do you have some additional modules installed? I'm using Drupal 8.2.3 and only EB module and examples.
I'll take a look what can be done regarding #23.1 and #23.2.
When it comes to #23.3, since it's possible to select same entity multiple times, marking entities looses purpose, because you can't demark it (any new click will just add entity in selection).
In Thunder we have mix, when we use "multi_step_display" we are not marking selected entities in view (because they are displayed in selection display anyway). When we use "no_display", then we are marking selected entities in view.
Comment #26
samuel.mortenson@mtodor I'm using 8.2.x HEAD, no additional modules beyond what the Standard profile provides.
Comment #27
samuel.mortensonThat makes sense, I take that point back then. If I want specific styling in File Browser I can implement it myself :-)
Comment #28
mtodor CreditAttribution: mtodor at Thunder commented@samuel.mortenson I wasn't able to reproduce with Drupal 8.2.x HEAD. But problem occurred for chr.fritsch and looks like it's caused by Twig debug mode. Twig adds additional wrapping div with HTML comments and that's why after element is removed, wrapping div with comments stays. Can you check is that problem in your case too? Because you mentioned in #20.2 that element is additionally wrapped with div, and that should not happen.
Comment #29
samuel.mortenson@mtodor I can confirm that I have Twig debugging on, but I think the CSS rules should work even in that case. I have Twig debugging on for most of my local development and don't want to have to turn it off to use Entity Browser.
I've actually looked into this before, you can see my the issue where they added the wrapping div and my comment here: https://www.drupal.org/node/736066#comment-11747543 In my opinion wrapping AJAX responses in a div when there is only one Node.ELEMENT_NODE element is a bug.
Comment #30
mtodor CreditAttribution: mtodor at Thunder commentedComment #31
mtodor CreditAttribution: mtodor at Thunder commentedI have adjusted Ajax response. HTML comments are removed from single tag HTML (only base comments, inner comments will stay). Other solution is to make custom JS commands, but that complicates code and functionality, only to support twig debugging mode.
Css selectors in JS are adjusted so that it can work with all view types (table, html, grid and unformatted). I have pushed commit to PR on github and here is patch + interdiff.
Comment #32
pixelmord CreditAttribution: pixelmord at Wunder for Hubert Burda Media commentedComment #33
samuel.mortenson@mtodor Awesome! I just looked over my review in #20 and #23 and I think that everything I brought up has been addressed. trimSingleHtmlTag() seems a bit complicated but I understand the motivation behind writing it.
Looking over the patch again, I don't see test coverage for the code being added here. It appears that the only change to tests is to disable auto_select so that existing tests continue to work. We'll definitely need Javascript test coverage given the complexity of this feature.
Comment #34
mtodor CreditAttribution: mtodor at Thunder commented@samuel.mortenson I wanted to get functionality first with feedback and review before adding tests. To keep smaller code base. But it looks like, we have quite stable feature here and functionality is satisfying. So, next logical step will be adding tests (for that I have also waited for #2764889: Entity Browser widget loses selected images in inline entity form with all tests provided there). We already have tests in Thunder for this functionality and it should not be difficult to port it here.
Comment #35
mtodor CreditAttribution: mtodor at Thunder commentedComment #36
mtodor CreditAttribution: mtodor at Thunder commentedHere are tests!
Ajax commands test are one method, but there are 4 parts of it. What is covered here is following:
It's also tested with Selenium and PhantomJS.
Comment #37
Bojhan CreditAttribution: Bojhan as a volunteer commentedWhat feedback do you want in terms of usability review?
Comment #38
mtodor CreditAttribution: mtodor at Thunder commented@Bojhan Someone on IRC (I think it was @slashrsm) asked to make UX review. I'm not sure what are exactly key points for review. I have made 2 gifs (without improvements and with improvements added by this ticket).
Few improvements introduced with this issue:
Without patch:
With patch:
Comment #39
chr.fritschI rerolled the patch, based on the latest EntityBrowser changes. Couldn't provide an interdiff, because it was broken.
Comment #40
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedThanks! This looks great. We are almost there. Few nitpiks and a bit of clean-up in the area of the "auto_select" configuration variable on widgets:
Missing newline.
Would be nice to check all widgets and not just the current one.
Would also be nice if we would validate this on config form too. Can be a follow-up (let's create an issue).
This is already added on the base class. Why add it here too?
This should not be disabled if widget doesn't support it. Is shouldn't be added at all. One of the consequences of this is that we need to add schema definition for this value even to widgets that don't need it at all. This is not desired.
Could this go on the base class? Might be useful for other tests too.
Comment #41
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedComment #42
naveenvalechaWe are adding the new key to the schema? Do we need update hook/default values would work? if default values will work could you add a test for that?
similarly as above new key in schema.
Nitpick: :)
Comment #43
mtodor CreditAttribution: mtodor at Thunder commentedI have made few modifications listed in previous comments:
Comment #40:
WidgetBase::getForm()
. If we move option from base into widget that supports auto submit functionality, then it will not be clean from code where it's used and where it's set. I can do that, but it will be more messy. And also I would like to see Update widget to use auto select functionality too.Comment #42:
So I need feedback regarding #40.4 and #42.1.
Comment #44
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commented#40-3: That is a mistake. Feel free to add the parent call and remove submit_text from Upload.
#40-4: I am not saying that config should be moved away from WidgetBase. I am just saying it should not be added for the widgets that do not support it (condition in
defaultConfiguration()
and on other relevant places).#42.1: We don't need to do any updates in my opinion.
defaultConfiguration()
should handle that.Comment #45
mtodor CreditAttribution: mtodor at Thunder commentedHere are changes related to #40.3 and #40.4.
Comment #46
mtodor CreditAttribution: mtodor at Thunder commentedAdjusted code for #40.4 -> now everything stays in base widget class, but with additional checking if widget supports auto select.
Comment #47
mtodor CreditAttribution: mtodor at Thunder commentedRenamed annotation names -> from camelCase to snake_case.
Comment #48
mtodor CreditAttribution: mtodor at Thunder commentedPatch at #47 is not complete -> here is new upload.
Comment #53
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedReroll of #48.
Comment #55
mtodor CreditAttribution: mtodor at Thunder commentedHere is adjustment for tests.
Comment #57
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedCommitted! Thank you all. It is a great improvement to the module!
Comment #58
samuel.mortensonGreat job everyone, I'm glad this got in even with all the core Media work being done. I'll be updating File Browser to add full support for this soon. :-D
Comment #60
Tom M Fallon CreditAttribution: Tom M Fallon at mtc. commented