Problem/Motivation

By default there is only one custom block view mode, creating a select list on the configure block modal with only one option. If there's only one option, we shouldn't show the view mode option.

Proposed resolution

Hide the field when only one view mode exists

Remaining tasks

None

User interface changes

Field hidden if not relevant

API changes

None

Original report by @chris_h

By default there is only one custom block view mode, creating a select list on the configure block modal with only one option. If there's only one option, we shouldn't show the view mode option.

Configure block

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because UX
Issue priority Normal because just a UX nicety
Prioritized changes The main goal of this issue is usability. This is a prioritized change for the beta phase.
Disruption None

Comments

dasjo’s picture

Hiding the possibility makes sense.

We also discussed if there should be a link to manage view modes (admin/structure/display-modes/view) or create a new view mode (admin/structure/display-modes/view/add/block_content). This could be done as an improvement, but would need to check if the current user has the permission to edit view modes.

dasjo’s picture

Issue tags: +SprintWeekend2015
chris_h’s picture

StatusFileSize
new53.13 KB

I don't think that should be on the configure block form. It would make more sense on manage display:

Manage display

dasjo’s picture

Assigned: Unassigned » dasjo

taking a stab at this

dasjo’s picture

Assigned: dasjo » Unassigned
Status: Active » Needs review
StatusFileSize
new1.14 KB

here's a patch that will hide the select element if no more than 1 view modes exist. didn't implement the configure link

chris_h’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new193 KB
new190.29 KB
new76.71 KB

This works as expected. I'll open a new issue re: view modes as it will have to be dealt with consistently in the UI for all view modes.

Before:

configure block

After #1:

configure block

After #2: (having added a second view mode)

configure block

dasjo’s picture

thanks chris_h! could you also link to the follow-up issue once created?

chris_h’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

We can (and should) add a test for this.

dasjo’s picture

Assigned: Unassigned » dasjo
dasjo’s picture

Assigned: dasjo » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.71 KB

phew, it took me a while to figure out that after

    $this->drupalPostForm('block/add/basic', $edit, t('Save'));

we are automatically on the block instance form where we can check the view_mode settings.

i decided to add a second testBlockContentCreationMultipleViewModes test function, because the inter-dependencies of view modes and the test cases just got a bit too crazy from me when i tried to integrate the multiple check into the existing one :)

thanks for reviewing!

dasjo’s picture

StatusFileSize
new3.84 KB
new2.71 KB

sorry now the correct patch version with interdiff

The last submitted patch, 11: 2409545-11.patch, failed testing.

mglaman’s picture

Status: Needs review » Reviewed & tested by the community

Applies, works as expected. Should make the form simpler by removing a field not always of concern to a user, because there is one option.

larowlan’s picture

+1 RTBC - thanks

larowlan’s picture

Issue summary: View changes
Issue tags: -Needs tests

Added beta-eval and used the issue summary template

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for adding the test. Committed 7e57c75 and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed 7e57c75 on
    Issue #2409545 by chris_h, dasjo: Custom block view mode should only...

Status: Fixed » Closed (fixed)

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