Problem/Motivation

This issue is for discussing how we can improve the UI for EB configuration.

1. Currently if you edit an entity browser and want to just save settings in "General information" in order to save it you have to click next until you get to widgets with the finish button.
2. If there are plugins that have no configuration user still needs to go through their (empty) configuration pages.

Proposed resolution

1. Add Finish button on every page so a quick edit can be easier.
2. Skip steps if there is nothing to config.
3. Provide general help text on first config page. Describe meaning of individual plugins, how they fit together, ...

CommentFileSizeAuthor
#100 issue-2764875-81-reroll.patch70.66 KBoknate
#96 entity-browser-82-drop-wizard-2764875-96.patch70.66 KBoknate
#96 interdiff-92-96.txt6.79 KBoknate
#92 interdiff-83-92.txt6.52 KBoknate
#92 entity-browser-82-drop-wizard-2764875-92.patch68.48 KBoknate
#87 interdiff-73-84.txt16.04 KBoknate
#84 entity-browser-82-drop-wizard-2764875-83.patch70.99 KBoknate
#84 interdiff-82-83.txt797 bytesoknate
#83 unsaved_changes.png52.89 KBoknate
#82 entity-browser-82-drop-wizard-2764875-82.patch70.96 KBoknate
#82 interdiff-81-82.txt1.98 KBoknate
#81 interdiff-80-81.txt7.33 KBoknate
#81 entity-browser-82-drop-wizard-2764875-81.patch70.92 KBoknate
#80 entity-browser-82-drop-wizard-2764875-80.patch69.72 KBoknate
#80 interdiff-79-80.txt712 bytesoknate
#79 interdiff-78-79.txt1.1 KBoknate
#79 entity-browser-82-drop-wizard-2764875-79.patch69.84 KBoknate
#78 entity-browser-82-drop-wizard-2764875-78.patch69.84 KBoknate
#78 interdiff-73-78.txt8 KBoknate
#73 entity-browser-82-drop-wizard-2764875-73.patch72.2 KBoknate
#70 entity-browser-82-drop-wizard-2764875-70.patch115.43 KBoknate
#69 entity-browser-82-drop-wizard-2764875-69.patch116.32 KBoknate
#67 entity-browser-81-drop-wizard-2764875-67.patch115.56 KBoknate
#67 entity-browser-82-drop-wizard-2764875-67.patch115.55 KBoknate
#66 entity-browser-81-drop-wizard-2764875-66.patch114.36 KBoknate
#66 entity-browser-82-drop-wizard-2764875-66.patch114.35 KBoknate
#65 entity-browser-82-drop-wizard-2764875-65.patch112.58 KBoknate
#65 entity-browser-81-drop-wizard-2764875-65.patch112.58 KBoknate
#64 entity-browser-81-drop-wizard-2764875-64.patch105.27 KBoknate
#64 entity-browser-82-drop-wizard-2764875-64.patch105.27 KBoknate
#63 entity-browser-82-drop-wizard-2764875-63.patch104.86 KBoknate
#63 entity-browser-81-drop-wizard-2764875-63.patch104.86 KBoknate
#61 entity-browser-81-drop-wizard-2764875-61.patch76.31 KBoknate
#61 entity-browser-82-drop-wizard-2764875-61.patch76.3 KBoknate
#58 interdiff-redirect-to-widgets-on-creation.patch806 bytesoknate
#58 entity-browser-81-drop-wizard-2764875-59.patch75.95 KBoknate
#58 entity-browser-82-drop-wizard-2764875-58.patch75.94 KBoknate
#54 entity-browser-81-drop-wizard-2764875-54.patch75.94 KBoknate
#53 entity-browser-82-drop-wizard-2764875-53.patch75.93 KBoknate
#49 entity-browser-82-drop-wizard-2764875-49.patch82.84 KBoknate
#48 entity-browser-81-drop-wizard-2764875-48.patch82.84 KBoknate
#47 entity-browser-81-drop-wizard-2764875-47.patch82.85 KBoknate
#46 entity-browser-82-drop-wizard-2764875-46.patch76.46 KBoknate
#45 entity-browser-81-drop-wizard-2764875-45.patch75.92 KBoknate
#44 entity-browser-drop-wizard-2764875-44.patch75.92 KBoknate
#43 40-43-interdiff.txt1.46 KBoknate
#43 entity-browser-drop-wizard-2764875-43.patch75.84 KBoknate
#42 add_form_4.png179.38 KBoknate
#42 add_form_3.png166.87 KBoknate
#42 add_form_2.png167.31 KBoknate
#42 add_form_1.png239.7 KBoknate
#41 entity_browser_add_form_revised.mov6.93 MBoknate
#40 entity-browser-drop-wizard-2764875-40.patch75.47 KBoknate
#38 interdiff-32-38.txt6.78 KBoknate
#38 entity-browser-drop-wizard-2764875-38.patch75.47 KBoknate
#35 Screen Shot 2018-05-08 at 2.20.55 PM.png121.18 KBfrob
#32 entity-browser-drop-wizard-2764875-32.patch74.87 KBoknate
#31 combined-form-2.png193.78 KBoknate
#31 combined-form-1.png252.07 KBoknate
#30 entity-browser-drop-wizard-2764875-30.patch74.86 KBoknate
#28 entity-browser-drop-wizard-2764875-28.patch53.19 KBoknate
#27 entity-browser-drop-wizard-2764875-27.patch53.18 KBoknate
#26 entity-browser-drop-wizard-2764875-26.patch53.24 KBoknate
#25 hidden-tabs.png360.78 KBoknate
#25 hidden-operations.png59.65 KBoknate
#23 entity-browser-drop-wizard-2764875-23.patch53.24 KBoknate
#22 entity-browser-drop-wizard-2764875-22.patch47.62 KBoknate
#20 entity-browser-drop-wizard-2764875-20.patch47.61 KBoknate
#19 entity-browser-drop-wizard-2764875-19.patch46.42 KBoknate
#17 entity-browser-drop-wizard-2764875-17.patch47.57 KBoknate
#16 entity-browser-drop-wizard-2764875-16.patch47.63 KBoknate
#15 entity-browser-drop-wizard-2764875-15.patch47.63 KBoknate
#14 entity-browser-drop-wizard-2764875-14.patch47.63 KBoknate
#13 entity-browser-drop-wizard-2764875-13.patch41.1 KBoknate
#10 entity-browser-drop-wizard-2764875-10.patch36.4 KBoknate
#9 entity-browser-drop-wizard-2764875-9.patch27.69 KBoknate
#8 entity-browser-drop-wizard-2764875-8.patch29.98 KBoknate

Comments

Denchev created an issue. See original summary.

slashrsm’s picture

Issue summary: View changes
phenaproxima’s picture

Regarding point #2 -- absolutely agree. Can we do a thing where we check if the plugins are implementing ConfigurablePluginInterface, and skip their config steps if they aren't? I believe the CTools Wizard API specifically includes provisions to do this, although I don't know exactly how to leverage them.

One concern I have is that EB uses an awful lot of jargon-ey words, which can potentially confuse the hell out of users. I feel that a good start would be to provide a #description for every single form field in the core EB configuration UI. We should also leverage the #states system as much as possible to hide fields which are not absolutely necessary.

slashrsm’s picture

Issue summary: View changes
joachim’s picture

I would suggest:

- drop the wizard UI
- have several forms with 2nd-level tabs to navigate between them (or everything in one form)
- use entity operations to provide links directly to the different tabs

marcoscano’s picture

Issue tags: +D8Media, +Usability
eelkeblok’s picture

I was pointed here by @marcoscano after creating #2962064: Alternative to wizard-like configuration screen?. I second the suggestion to drop the wizard UI.

oknate’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
StatusFileSize
new29.98 KB

I've started working on this.

This patch drops the wizard UI, and adds 2nd-level tabs to navigate between them.

I wanted to post it as a work in progress. There's a major bug where it works fine, as far as I can tell, for editing, but I'm getting an error when I try to create a new entity browser.
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

I'll keep working on it, but if someone wants to try out what I have so far and see if they can figure out what the bug is, that'd be great.

Also to do: "use entity operations to provide links directly to the different tabs".

Also, I think hook_menu_local_tasks_alter to hide the local tasks that don't have any configuration settings would be great.

Also, we'll probably need to update the tests.

oknate’s picture

StatusFileSize
new27.69 KB

I have added an updated patch that fixes the bug on entity_browser creation.

Next up, we need to fix the tests.

oknate’s picture

I added entity operations links, so that on the list page you can jump right into a section.

esolitos’s picture

Really looking forward to this change!
Let us know when you feel that the patch is ready to be tested. :)

oknate’s picture

Please test it out. I don't want to mark ready for review until the tests are fixed, though.

oknate’s picture

StatusFileSize
new41.1 KB

Fixing tests.

oknate’s picture

StatusFileSize
new47.63 KB

This patch additionally removes dependency on CTools in the entity_browser module.

It looks like I didn't fix all the functional tests, I was just looking at the /src/tests folder, not the /tests folder.

oknate’s picture

StatusFileSize
new47.63 KB

I think some of tests were failing because I failed to capitalize "Routing" in namespace. Updating patch to run tests.

oknate’s picture

StatusFileSize
new47.63 KB

Updating patch again, capitalizing "routing" > "Routing" in service declaration.

oknate’s picture

StatusFileSize
new47.57 KB

Fixing errors in tests.

esolitos’s picture

Please test it out. I don't want to mark ready for review until the tests are fixed, though.

Alright I'll try it on a few sites this coming week.

oknate’s picture

StatusFileSize
new46.42 KB

Attempting to fix the last test error.

oknate’s picture

StatusFileSize
new47.61 KB

Fixing tests

oknate’s picture

Status: Active » Needs review

OK, Tests are fixed. Marking ready for review.

oknate’s picture

StatusFileSize
new47.62 KB

Testing the patch against the 8.x-1.x branch.

oknate’s picture

StatusFileSize
new53.24 KB

Here's an updated patch.

The operations and tabs for the subforms now are hidden if the plugin lacks a configuration form. I'm rebuilding the access to these routes (and hence the local tasks) when the entity browser is saved. I think this slows the form submit though, which is annoying. Using local task alter doesn't help speed it up either, also, the caching permission really only works if you have an access callback.

Status: Needs review » Needs work

The last submitted patch, 23: entity-browser-drop-wizard-2764875-23.patch, failed testing. View results

oknate’s picture

StatusFileSize
new59.65 KB
new360.78 KB

The tabs for subforms that lack configuration form don't display:
hidden tabs

The operations for subforms that lack configuration form don't display:
hidden operations

oknate’s picture

StatusFileSize
new53.24 KB

Rerolling for 8.x-2.x

oknate’s picture

StatusFileSize
new53.18 KB

Fixing a bug introduced in the last patch (typo on variable name in last builder).

oknate’s picture

StatusFileSize
new53.19 KB

Same bug fix as above, but for 8.x-1.x branch

oknate’s picture

Status: Needs work » Needs review
oknate’s picture

StatusFileSize
new74.86 KB

Here's a new version of a reconfigured backend ui. This time, instead of four tabs, I combine the first three tabs into one form and load the subform in. When you update a plugin, the plugin settings form changes. This seems even more user friendly than four sets of tabs. I left the last tab where you configure widgets as a separate tab, as it is much larger than the other subforms.

oknate’s picture

StatusFileSize
new252.07 KB
new193.78 KB

Here's a screenshot of the new ui in patch #30.

combined form

And here's a screenshot with one of the subforms expanded.

combined form two

oknate’s picture

StatusFileSize
new74.87 KB

Same as patch in #30 but against the 8.x-1.x branch.

frob’s picture

This isn't really a meta issue is it?

oknate’s picture

It's still open to discussion. It'd be great if someone took a look at my work and gave some feedback.

frob’s picture

StatusFileSize
new121.18 KB

I think you're on the right track, just replacing the wizard is a huge help. I like the wizard for creating new things, but they are a pain when it comes to editing existing things.

One change I would make is to the help text markup. Right now it is all just thrown into the fieldset. If we add some paragraphs and a definition list then the content would be more semantic and it would flow visually much better.

<p>
            Choose here how the browser(s) should be presented to the end user.</p><p> The available plugins are:</p>
    <dl><dt>iFrame:</dt> 
        <dd>Displays the entity browser in an iFrame container embedded into the main page.</dd>
        <dt>Modal:</dt>
        <dd> Displays the entity browser in a modal window.</dd>
        <dt>Standalone form:</dt>
        <dd> Displays the entity browser as a standalone form. Only intended for testing or very specific use cases.</dd></dl>

The screenshot is using the Material Admin Theme.

frob’s picture

That was testing 1.4.0 + patch.

frob’s picture

Status: Needs review » Needs work
oknate’s picture

Here's a new version of the patch against 8.x-1.x branch, with new description format based on feedback from frob.

oknate’s picture

Status: Needs work » Needs review
oknate’s picture

StatusFileSize
new75.47 KB

Same as patch 38 (including new description markup), but for the 8.x-2.x branch.

oknate’s picture

StatusFileSize
new6.93 MB

Here's an example of the add form.

oknate’s picture

StatusFileSize
new239.7 KB
new167.31 KB
new166.87 KB
new179.38 KB

Here are some screenshots of the entity browser add form (patch 38 and 40, vs 8.x-1.x and 8.x-2.x branches respectively). This is with Adminimal admin theme.

Here's the entity browser add form (also used for edit form):
add form 1

With the display plugin settings collapsible fieldset open (using a "details" render element):
add form 2

After switching the display plugin, the display plugin settings update via ajax:
add form 3

And again after switching display plugin settings to the standalone display plugin.
add form 4

The other plugins behave the same way, with collapsed "details" render elements that open when the plugin is switched (since that's when you'd presumable want to config it). This is also handy to get a sense of the options for each plugin.

Here's a summary of changes in the patch.

1) It removes the dependency on ctools, replace the multistep wizard with two forms, one for selecting and configuring plugins and a second for selecting and configuring widgets.

  • /admin/config/content/entity_browser/{entity_browser}/edit
  • /admin/config/content/entity_browser/{entity_browser}/widgets

2) It adds operations link for "Edit Widgets" to allow going straight from the entity list page to edit widgets.

3) It adds sub tabs to allow toggling between the main edit form and the widget edit form.

4) adds isConfigurable() to DisplayBase class so that plugins can indicate to the form if they are configurable without having to load the form and check if it's empty. It seemed checking a boolean is more efficient than having to load the form just to see if it's configurable.

5) remove PluginConfigFormBase and the various plugin config forms. These were basically an intermediary between the wizard and the plugin's configuration form hooks and aren't needed since you can validate and submit them using validateConfigurationForm and submitConfigurationForm on the plugin object. The tricky thing is pulling out a SubFormState, see buildEntity and validateForm in EntityBrowserEditForm.

6) Add new ajax functionality to main entity browser form to update the plugin configuration form for each of the three plugin types the entity browser supports. This makes separate tabs for configuring these plugins unnecessary and since these plugins often only have a few options and many have no options, it's more efficient and user-friendly to do it this way.

7) Revise the description text to be more semantic.

8) GeneralInfoConfig (the first part of the wizard) becomes the main entity form for entity browsers, EntityBrowserEditForm.

9) WidgetsConfig now extends EntityForm

10) in WidgetsConfig, moved the temp storage in ($form_state->getTemporaryValue('wizard')) to using \Drupal::service('tempstore.shared'), this is one area where we we might be able to improve the patch by using storage on the formState object. I originally wanted to keep the form as close to the original version to prevent regressions. But I think the tempstore service may be unnecessary and the changes could be store in the formstate object.

11) Set width and height parameter in IFrame display config to required

12) set the width and height text fields for the IFrame and Modal plugins to #size 10, since they were much bigger than anyone would ever need.

13) Updated tests to work with new UI.

oknate’s picture

StatusFileSize
new75.84 KB
new1.46 KB

Updating the test ConfingUITest based on https://www.drupal.org/project/entity_browser/issues/2966853

oknate’s picture

StatusFileSize
new75.92 KB

very slight change from 43, adding variable description

oknate’s picture

StatusFileSize
new75.92 KB

Reroll of patch 45 against 8.x-1.x branch

oknate’s picture

renaming a file to fix failure in test in Drupal 8.6 (see https://www.drupal.org/project/entity_browser/issues/2966853)

oknate’s picture

reroll for 8.x-1.x branch

oknate’s picture

StatusFileSize
new82.84 KB

reroll for 8.x-2.x branch

oknate’s picture

StatusFileSize
new82.84 KB

reroll for 8.x-2.x branch, fixing file name

The last submitted patch, 47: entity-browser-81-drop-wizard-2764875-47.patch, failed testing. View results

The last submitted patch, 48: entity-browser-81-drop-wizard-2764875-48.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 49: entity-browser-82-drop-wizard-2764875-49.patch, failed testing. View results

oknate’s picture

StatusFileSize
new75.93 KB

reroll for 8.x-2.x branch, last one failed to apply

oknate’s picture

reroll for 8.x-1.x branch, last one failed to apply

szeidler’s picture

Status: Needs work » Needs review

I tested the patch in #54 and it makes the configuration (especially while creating a new entity browser) much faster.

oknate’s picture

Thanks for testing it. I've been using it for a couple of months. One thing I think we could add when you first create an entity browser and submit, it should automatically go to the widgets page. This would only be on the initial submit / creation of the entity browser.

frob’s picture

@oknate +1 on #56

oknate’s picture

Here's an updated patch (for 8.x-2.x branch and 8.x-1.x branch) as well as an interdiff on the change. It now redirects to widget edit on entity browser initial creation.

Status: Needs review » Needs work

The last submitted patch, 58: interdiff-redirect-to-widgets-on-creation.patch, failed testing. View results

oknate’s picture

A few tests need updating

oknate’s picture

oknate’s picture

still one fail, and it looks like a lot of drupal standards fixes need to be added.

oknate’s picture

StatusFileSize
new104.86 KB
new104.86 KB

added a fix for the one test that failed. Testing against Drupal 8.7.

oknate’s picture

StatusFileSize
new105.27 KB
new105.27 KB

Added some standards fixes and testing against 8.6

oknate’s picture

StatusFileSize
new112.58 KB
new112.58 KB

Adding some more standards fixes.

oknate’s picture

StatusFileSize
new114.35 KB
new114.36 KB

This patch gets the number of standards errors down from 79 down to 29 (in #61)

oknate’s picture

StatusFileSize
new115.55 KB
new115.56 KB

Adding some more standards fixes, down to 17 standards messages, many can't be changed because of backwards compatibility.

oknate’s picture

Status: Needs work » Needs review
oknate’s picture

StatusFileSize
new116.32 KB

Rerolling against against latest 8.x-2.x branch.

oknate’s picture

Rerolling against current head.

berdir’s picture

Tried the UI and I think it looks really nice. The way the different plugin options are described is a bit uncommon but it looks good.

However, the patch is absolutely massive and based on a quick glance, a ton of things are not directly to this but are all kinds of cleanups.

It would help to split up everything that's clearly unrelated cleanup into a separate issue, then we can get that in first. I'd approach that by committing the patch to a branch and then do git checkout -p and pull in everything that is clearly standalone cleanup like the CSS stuff, documentation improvements and so on.

oknate’s picture

Thanks for the review. I created a separate issue for the coding standard changes #3031794: Coding Standard Fixes. I will remove them from the patch and post a new patch without them.

oknate’s picture

Here's an updated patch without the coding standard changes. I'm not going to test it right now, as all the tests are failing.

berdir’s picture

Well, testing actually makes sense, because this should fix most of the test fails by not relying on ctools anymore.

Status: Needs review » Needs work

The last submitted patch, 73: entity-browser-82-drop-wizard-2764875-73.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

berdir’s picture

As expected, all tests are passing on 8.6 with the exception of the messed up update test, which is fixed in the other issue. Great.

Overall, I think this looks great, some feedback on ajax/tempstore stuff in the form.

  1. +++ b/src/Form/EntityBrowserEditForm.php
    @@ -0,0 +1,457 @@
    +    if (empty($entity_browser->id())) {
    

    isNew() would be a bit cleaner here.

  2. +++ b/src/Form/EntityBrowserEditForm.php
    @@ -0,0 +1,457 @@
    +      $help_text .= '<p>' . $this->t("Note: After you submit this form, you'll need to visit the other tabs. On this first form you need define the main characteristics of the Entity Browser (in other words, which plugins will be used for each functionality).  On the other tabs you will configure the plugins.") . '</p>';
    +      $help_text .= '<p>' . $this->t('You can find more detailed information about creating and configuring Entity Browsers at the <a href="@guide_href" target="_blank">official documentation</a>.', ['@guide_href' => 'https://drupal-media.gitbooks.io/drupal8-guide/content/modules/entity_browser/intro.html']) . '</p>';
    

    "the other tabs" is a bit strange considering there is now AFAIK only a single additional tab/local task?

    Can't we just redirect there by default when saving a new browser?

  3. +++ b/src/Form/EntityBrowserEditForm.php
    @@ -0,0 +1,457 @@
    +      '#limit_validation_errors' => [],
    ...
    +  public static function submitUpdateDisplayPluginSettings($form, FormStateInterface $form_state) {
    +    $display = $form_state->getUserInput()['display'];
    +    $form_state->getFormObject()->getEntity()->setDisplay($display);
    +    $form_state->setRebuild();
    

    Using getUserInput() here is necessary because limit validation errors is an empty array. This is problematic as it is not safe, it could be any value.

    Instead, you should set limit_validation_errors so that only the select is validated and then you can access it with getValue:

    '#limit_validation_errors' => [['display']],
    
  4. +++ b/src/Form/EntityBrowserEditForm.php
    @@ -0,0 +1,457 @@
    +    if ($widget_selector_plugin->isConfigurable()) {
    +      $widget_selector_config_form = $widget_selector_plugin->buildConfigurationForm([], $form_state);
    +      $form['widget_selector_wrapper']['widget_selector_configuration'] = array_merge($form['widget_selector_wrapper']['widget_selector_configuration'], $widget_selector_config_form);
    +    }
    +    else {
    +      $form['widget_selector_wrapper']['widget_selector_configuration']['no_options'] = [
    +        '#prefix' => '<p>',
    +        '#suffix' => '</p>',
    +        '#markup' => $this->t('This plugin has no configuration options.'),
    +      ];
    +    }
    

    isConfigurable() is a new method? Can't we just check whether $widget_selector_config_form is empty?

  5. +++ b/src/Form/EntityBrowserEditForm.php
    @@ -0,0 +1,457 @@
    +      case 'display':
    +        $intro = $this->t('Choose here how the browser(s) should be presented to the end user.');
    

    we always configure one, so (s) is not needed? Also here it's just browser while below we use "entity browser", I think the second is better as it is more specific.

  6. +++ b/src/Form/EntityBrowserEditForm.php
    @@ -0,0 +1,457 @@
    +   * {@inheritdoc}
    +   */
    +  public function buildEntity(array $form, FormStateInterface $form_state) {
    +
    

    In fact buildEntity() might just work then and you could possibly have a single submit that does nothing but a rebuild for all 3 cases.

  7. +++ b/src/Form/EntityBrowserEditForm.php
    @@ -0,0 +1,457 @@
    +    // If this is a new entity, redirect to the widget edit form.
    +    if ($this->entity->isNew()) {
    +      $params = [
    +        'entity_browser' => $this->entity->id(),
    +      ];
    +      $form_state->setRedirect('entity.entity_browser.edit_widgets', $params);
    +    }
    

    Ah you even have that code here? So not sure why that description is necessary?

  8. +++ b/src/Form/WidgetsConfig.php
    @@ -49,8 +49,30 @@ class WidgetsConfig extends FormBase {
    +
    +    $user_input = $form_state->getUserInput();
    +
         /** @var \Drupal\entity_browser\EntityBrowserInterface $entity_browser */
    -    $entity_browser = $form_state->getTemporaryValue('wizard')['entity_browser'];
    +    $entity_browser = \Drupal::routeMatch()
    +      ->getParameter('entity_browser');
    +
    +    if (empty($user_input)) {
    +      $tempstore->set($entity_browser->id(), $entity_browser);
    +    }
    +    else {
    +      $entity_browser_id = $user_input['entity_browser_id'];
    +
    +      /** @var \Drupal\entity_browser\EntityBrowserInterface $entity_browser */
    +      $entity_browser = $tempstore->get($entity_browser_id);
    +    }
    

    I never liked this pattern from ctools, because it means that simply by accessing that page, you create the tempstore data, afaik there is also no UI telling you about unsaved data?

    I prefer the approach in views, where the tempstore data is set on the first change, and then there's a warning message that points out that there is unsaved data, with an option to cancel.

  9. +++ b/src/Form/WidgetsConfig.php
    @@ -173,13 +204,15 @@ class WidgetsConfig extends FormBase {
    -    $cached_values = $form_state->getTemporaryValue('wizard');
    +    $tempstore = \Drupal::service('tempstore.shared')
    +      ->get('entity_browser.config');
    +
    +    $entity_browser_id = $form_state->getUserInput()['entity_browser_id'];
    

    this part needs to be a bit more dynamic then, as it might not yet exist in tempstore but otherwise it shouldn't be much more complicated.

  10. +++ b/src/Form/WidgetsConfig.php
    @@ -194,8 +227,13 @@ class WidgetsConfig extends FormBase {
    +
    +    $entity_browser_id = $form_state->getUserInput()['entity_browser_id'];
    +
    

    for the ID, I would use #type value and then $form_state->getValue(). Unlikely in an admin form but still, someone could mess things up real good by submitting a different value here.

berdir’s picture

Title: [META] Config UI improvement » Remove ctools dependency by building own admin UI
Priority: Normal » Critical

Changing this to critical and giving a more specific, non-meta title.

oknate’s picture

StatusFileSize
new8 KB
new69.84 KB

Addressing some of the easier changes suggested in #76, (1, 2, 3, 4 and 5).

Still needs addressing: 6, 8, 9 and 10. Updated 8, 9 and 10 addressed in #81.

I'm not sure I understand what is being suggested in 6. I think to use rebuild entity in the ajax callbacks when changing plugins to reduce the amount of code.

Also
$tempstore = \Drupal::service('tempstore.shared')->get('entity_browser.config');

the tempstore shared should be injected in the constructor rather than called directly.

oknate’s picture

Fixing a typo in new verbiage.

oknate’s picture

The subform validation was running when switching plugins after adding the limit validation errors. Testing a fix.

oknate’s picture

StatusFileSize
new70.92 KB
new7.33 KB

- Injecting temp store for non-static methods in WidgetsConfig.
- removing automatic setting of tempstore on visiting widgets form, per #76 suggestion number 8
- updating the retrieval of tempstore data in WidgetsConfig, since this is an entity form now, we don't need to retrieve the entity browser id from user submitted data.

oknate’s picture

StatusFileSize
new1.98 KB
new70.96 KB

Oops, the logic was slightly off in #81, updating.

oknate’s picture

Status: Needs work » Needs review
StatusFileSize
new52.89 KB

When tempstore is not cleared, (this would happen if you navigate away without saving), when you return, a warning is now displayed:

warning with unsaved changes

oknate’s picture

Fixing typos, it's weird this didn't break anything.

Status: Needs review » Needs work

The last submitted patch, 84: entity-browser-82-drop-wizard-2764875-83.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

oknate’s picture

Status: Needs work » Needs review
oknate’s picture

StatusFileSize
new16.04 KB

Adding an interdiff from #73 to #84 so one can see all the changes at once.

berdir’s picture

Tested manually a bit and I think it works well enough to commit it so we can unblock testbot and likely do a release then.

That said, I'm wondering if we need the tempstore at all for this. We no longer have complex multistep processes, there's no preview functionality that would need to access the altered config on a separate request like views. At this point, it's pretty close to the core entity form/view display configuration and that works just fine with repeated, regular ajax updates/form rebuilds until we eventually save it.

Another possible improvement would be to make sure that the "there are unsaved changes" already shows up after making any change, so that its clear that it is not saved yet.

Thoughts? Happy to try to look into that in a follow-up and getting it in like this now.

oknate’s picture

I think the tempstore is left over from the ctools wizard. So I think it would be great to remove it. But I think getting stable builds should come first. We can create a separate issue to remove it.

I also agree about the unsaved changes. But if we can remove the tempstore, we won't even need that message.

berdir’s picture

It is a ctools thing, but it is also basically just custom code now, so as long as we keep $this->entity up to date, it should just work without it.

I think we won't commit this tonight anymore anyway (pretty late already for me and Primoz) so if you want to give removing that a try, go for it :)

oknate’s picture

OK, If I have time tonight, I'll see if I can get it working without it.

oknate’s picture

StatusFileSize
new68.48 KB
new6.52 KB

Here's an update that removes the tempstore factory from the WidgetsConfig form. That was a good suggestion, it's totally unnecessary.

The only surprising thing was that deleting a widget was taking affect immediately, but that was easy to track down, the EntityBrowser::deleteWidget method was saving the EntityBrowser. I checked where the method is used, and it's only used in WidgetsConfig, so it's safe to update it. I suppose it's an API change, so we should document it, but I doubt it would break any 3rd party integrations.

oknate’s picture

berdir’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/src/Form/WidgetsConfig.php
@@ -65,20 +54,6 @@ class WidgetsConfig extends EntityForm {
-      $form['changed'] = [
-        '#type' => 'container',
-        '#attributes' => ['class' => ['view-changed', 'messages', 'messages--warning']],
-        '#children' => $this->t('You have unsaved changes.'),
-        '#weight' => -10,
-      ];
-    }

Something like this would still be useful IMHO, but we can look into that in a follow-up. Might be a simple as adding that as a real message, the ajax system should take care of displaying that above the replaced part automatically.

primsi’s picture

Status: Reviewed & tested by the community » Needs work

Looks great to me and great work!

I just have a few nitpicks.

  1. +++ b/src/Form/EntityBrowserEditForm.php
    @@ -0,0 +1,453 @@
    +  protected function getPluginDescription($plugin_type = 'string') {
    

    Couldn't this be just '' instead of 'string'.

  2. +++ b/src/Form/EntityBrowserEditForm.php
    @@ -0,0 +1,453 @@
    +    $output = "<p>$intro</p>";
    +    $output .= '<p>' . $this->t('The available plugins are:') . '</p>';
    

    This part and below could be a render array, but not super important.

  3. +++ b/src/Form/EntityBrowserEditForm.php
    @@ -0,0 +1,453 @@
    +    $subFormState = SubformState::createForSubform($form['display_wrapper']['display_configuration'], $form, $form_state);
    

    No camel casing.

  4. +++ b/src/Form/EntityBrowserEditForm.php
    @@ -0,0 +1,453 @@
    +    $subFormState = SubformState::createForSubform($form['display_wrapper']['display_configuration'], $form, $form_state);
    

    Same.

Maybe we could also remove the ctools downloading step from travis-before.sh.

oknate’s picture

Status: Needs work » Needs review
StatusFileSize
new6.79 KB
new70.66 KB

Updated patch based on feedback in #95.

  • Primsi committed 647ceac on 8.x-2.x authored by oknate
    Issue #2764875 by oknate, frob, Berdir, Primsi: Remove ctools dependency...
primsi’s picture

Great work! Thank you.

primsi’s picture

Version: 8.x-2.x-dev » 8.x-1.x-dev
Status: Needs review » Needs work

Oh,.. for 8.x-1.x needs a re-roll.

oknate’s picture

StatusFileSize
new70.66 KB

Reroll against 8.x-1.x branch.

eelkeblok’s picture

Really exciting, thanks for the great work.

primsi’s picture

Status: Needs work » Needs review

  • Primsi committed e71c7ee on 8.x-1.x authored by oknate
    Issue #2764875 by oknate, frob, Berdir, Primsi: Remove ctools dependency...
primsi’s picture

Status: Needs review » Fixed

Nice, committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.