-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the "Entity view mode" module to core #315
Comments
Yes please! 👍 |
Like other "Add X module to core" issues, I'd like to clarify that we're not planning on just adding a port of the module directly into core. The functionality from this module should be integrated directly into either the core entity.module or field.module. |
In my opinion, custom view modes (or display modes) are especially helpful when you work with references. (Quick example: two content types, let's say Team member and Event. On the Event page you want to reference Team members who registered for the Event, but not the full information but only name and photo) As Reference(s) is/are going to be integrated in core in 1.6, the need to build custom display modes via the UI will increase, so let's add the ability to do so in release 1.6 as well. @quicksketch @jenlampton What do you think about it? See also @quicksketch's statement on #2084 (comment):
|
This is part of #378, as in D8 they have already implemented this feature... From #2250 (closed as duplicate of this issue):
|
It has always struck me as weird that you can't arbitrarily create new view modes in the ui, since there is so little to them. The only tricky part is figuring out how to handle it I think the ui. Adding an interface under structure seems like a good idea. And when you create one, you can just enter the name and then check which entity types it should be available for. |
Additionally, we could add a link "Add new custom display" on the Manage Display page of a content type, that would be under the "Custom display settings". Side note: "Custom display (setting)" seems to be the Backdrop name for view mode, so Structure > Custom displays? |
Yep, and that's what D8 users will expect.
Fully agree with you there @mikemccaffrey. D8's approach is really odd: first you select from a list of links the entity type the view mode should be applied to: ...and then (no matter what entity type you have chosen in the previous page) you are requested to enter a name for it: In this last page that requires the user to enter a view mode name, although the page title and path changes, it is (from a form point of view) basically the same for all entity types. So this 2-page wizard could as well be a single page (or dialog in our case) that allows entering a view mode name and then selecting either one entity (drop-down select or radio set) or multiple entities (checkbox set) that the view should be applied to. Not sure if the D8 approach that forces the selection of a single entity type is a technical limitation (view modes are allowed to be attached to a single entity type) or a UI implementation shortcoming (requiring selecting a single entity type in step 1 of the wizard). In D8, they also have a page where all view modes are listed and can be edited/deleted: ...but as @olafgrabienski said, we should also have it so that people can add a view mode via a dialog without ever having to leave the "Manage display" page of the content type they are currently editing ("connect the dots" as @jenlampton says). That is more or less what I have also previously suggested over at #2205 (comment):
That is just the label of the fieldset that is used to hold the set of existing view modes. If you expand that fieldset, you'll see that it says "Use custom display settings for the following view modes". This is not a Backdrop thing, we inherited the same UI from D7: ...plus I think that changing the terminology is not a good thing. In D7 it was view modes and D8 has kept the same thing. They also added the "sibling" form modes that is a prelude I guess to handle the display of forms, since in D8 there's already a separate "Manage form display" tab for each content type: |
@klonos - Re "Custom displays" vs. "View modes": You're absolutely right! |
First push; need tests still. |
Just had a look at the test site. At the moment, it's not possible to visit |
That's not a valid path. Replace the uppercase with a type name. |
Sorry for being unclear, it was a generic placeholder. Here the two valid paths in a default installation:
|
Sorry to delay reply, but actually @olafgrabienski is right. There's a silly error in the code which I fixed yesterday but haven't pushed. Will do so later. |
Should be fixed, including new tests. |
Should also say, its not polished yet, some code comment lines need moving, and I'm not happy with the local actions code. This is up for review actually. |
@olafgrabienski I checked on the bold and it's definitely in the css. I closed and reopened the PR to get a fresh sandbox. I pushed a new PR that uses the word 'Enable' in the action link for the not-customized view modes. I think I like this better. It's not obstructionist by hiding the action, but is also less inviting than the word 'Customize' which doesn't communicate to the user that it hadn't been "customized" already. I also added the bundle label in the Customized / Not customised headings, I thought that would help make it clear that different view modes could be customized (or not) for different content types. I changed the action link back to simply edit: I also removed the select list from the |
@quicksketch I think this is ready for a code review - the feature is close enough that we can iterate on UI changes after Jan 1st - but I want to make sure you are on board with where the code was added (field UI module) and what it looks like. |
Posted a hella code review to the PR: backdrop/backdrop#1689 (review) Overall, in concept everything looks great, though there are tons of typos and code style recommendations. The big things that need addressing code-wise:
|
@jenlampton you rock! I feel that everything is so much better in this new iteration for all the reasons that @quicksketch mentioned. May I suggest a change in the help text and please feel free to ignore as I'd hate to start bike-shading over this issue further...
I feel that this help text is better than the current one for the following reasons:
|
I totally agree. Unfortunately both instances are already in core. We can change one, but I'm not sure what the ramifications of doing so would be. See underscores in field_view_mode_settings() vs spaces in entity_get_info(). Maybe we create a follow-up issue? (see #2449)
I tried to kill it in the most recent PRs. I'll double check and see if I missed any.
okay. I'll try that now. |
Thank you @klonos @docwilmot @herbdool and @quicksketch for the reviews and feedback! I've addressed all the comments and pushed a PR: backdrop/backdrop#1689 |
I like the new iteration very much, thank you for working so long on it! Maybe I found another small bug: After having added a view mode for Posts, I get the following page:
Afterwards, I was however able to customize the new view mode. |
Thanks @olafgrabienski, can you please list the steps to reproduce the problem? |
@jenlampton I can't reproduce the issue anymore. Anyway, these were the steps:
|
Thanks! I may have fixed it with the last push of the PR. :) |
@jenlampton I had a look at the DBlog where I found a message related to the "Access denied" error, see http://1689.backdrop.backdrop.qa.backdropcms.org/admin/reports/event/74. At the same time there was a php notice. When you have a look at the DBlog, you'll see that some PHP notices appear also later. I guess these happened when I tried to reproduce the "Access denied" error. |
There are some failing tests related to testing the old Field UI in I also noticed that now we have restored the "Enable" link on the listing page, that these links are not CSRF protected by a token like other similar links. I can add a token and check to the access check as well. |
Okay I added a commit to the PR at backdrop/backdrop#1689. If all tests are passing, we're finally good to go on this one I think. @olafgrabienski It appears the access denied problems may have been caused by the |
Hm, it looked like tests were failing. I closed/opened the PR to run them again. |
BACKFLIPS |
This has been merged into 1.x for 1.6.0. THANK YOU everyone for the help on this issue. This was probably one of our most bikesheddy issues to date, but we arrived at a solution with which everyone seems satisfied. |
This simple module provides a lightweight UI for adding additional view modes, and provides expected template suggestion hooks. https://www.drupal.org/project/entity_view_mode
PR by @docwilmot: backdrop/backdrop#1645 initial portLatest PR by @jenlampton backdrop/backdrop#1689
The text was updated successfully, but these errors were encountered: