Skip to content
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

V8.7RC Label with custom expression #8689

Closed
bjarnef opened this issue Aug 20, 2020 · 14 comments
Closed

V8.7RC Label with custom expression #8689

bjarnef opened this issue Aug 20, 2020 · 14 comments

Comments

@bjarnef
Copy link
Contributor

bjarnef commented Aug 20, 2020

With the new Block List we can use a custom expression for label, e.g. "Block {{myPropertyAlias}}".

However it would be great if we could use basic angular expression like we can in Nested Content, e.g. "Block {{$index + 1}}".
This expression seems just to render "Block 1" for all blocks.

@bjarnef bjarnef changed the title 8.7RC: Label expression 8.7RC: Label with custom expression Aug 20, 2020
@nul800sebastiaan
Copy link
Member

Seems like a great idea to me!

@bjarnef
Copy link
Contributor Author

bjarnef commented Aug 21, 2020

@umbrabot
Copy link

Hi @bjarnef,

We're writing to let you know that we would love some help with this issue. We feel that this issue is ideal to flag for a community member to work on it. Once flagged here, folk looking for issues to work on will know to look at yours. Of course, please feel free work on this yourself ;-). If there are any changes to this status, we'll be sure to let you know.

For more information about issues and states, have a look at this blog post

Thanks muchly, from your friendly Umbraco GitHub bot :-)

@nul800sebastiaan nul800sebastiaan changed the title 8.7RC: Label with custom expression V8.7RC Label with custom expression Aug 24, 2020
@nielslyngsoe
Copy link
Member

@bjarnef you should be able to use angular expressions, but $index is not available, you can only choose values of your content properties(by their alias). If you think index is a missing option, I think it would be fairly simple to make that available as well. :-)

@bjarnef
Copy link
Contributor Author

bjarnef commented Aug 26, 2020

@nielslyngsoe yes I think this is a missing option :) It would be great this is a bit consistent with Nested Content name template. See the link getName function in Nested Content 🙂

@nul800sebastiaan
Copy link
Member

nul800sebastiaan commented Aug 27, 2020

Additionally, @liquidkool is asking for the following feature:

I want to populate the label field with content from the settings tab. I can get content from the content tab using {{aliasName}}, however this doesn't work with content from the settings tab. I've tried {{settings.aliasName}}. Not sure if its possible?

@ronaldbarendse
Copy link
Contributor

Adding support to access both data/content and settings would mean the existing expressions need to change from {{myPropertyAlias}} to something like {{content.myPropertyAlias}}, so you can access settings with the same alias using {{settings.myPropertyAlias}}.

I don't know what data the custom AngularJS views (for displaying previews within the back-office) have access to, but it would make a lot of sense to make the namings/models the same for the name template!

@bjarnef
Copy link
Contributor Author

bjarnef commented Aug 30, 2020

The block label is generated in getBlockLabel method here:
https://github.com/umbraco/Umbraco-CMS/blob/v8/8.7/src/Umbraco.Web.UI.Client/src/common/services/blockeditormodelobject.service.js#L102-L112

Where the config label is being interpolated here:
https://github.com/umbraco/Umbraco-CMS/blob/v8/8.7/src/Umbraco.Web.UI.Client/src/common/services/blockeditormodelobject.service.js#L556-L558

However in Nested Content it pass in the index. Not sure if it is possible the generate the index without passing in the index or retrieve this index by the position of the item in the array.

Furthermore in Nested Content when using $index it actually render $index + 1:
https://github.com/umbraco/Umbraco-CMS/blob/v8/contrib/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js#L358

@bjarnef
Copy link
Contributor Author

bjarnef commented Sep 11, 2020

@nielslyngsoe do you know if we can do something to pass in $index to getBlockLabel similar to getName in Nested Content?

@nielslyngsoe
Copy link
Member

nielslyngsoe commented Sep 22, 2020

https://github.com/umbraco/Umbraco-CMS/blob/v8/8.7/src/Umbraco.Web.UI.Client/src/common/services/blockeditormodelobject.service.js#L108
@bjarnef so this is the line where the stuff happens. The object parsed here contains the variables available for the interpolation. So currently its just the content of 'data' that we have available, so if you like to make settings available you should make a new object, like:

var interpolateVars = Utilities.copy(blockObject.data);
interpolateVars.$settings = blockObject.settings; // edited to $settings as of ronaldbarendse comment.
interpolateVars.$index = block.index;//?

I would say we need to do it this way to stay backward compatible, I hope this helps and give some inspiration for how we can solve this one :-)

@ronaldbarendse
Copy link
Contributor

@nielslyngsoe I would change the name to $settings, so you don't get conflicts with data/content properties that have the same alias (as I described in #8689 (comment)). This will ensure it's backwards compatible, the syntax for accessing data/content is kept short (no prefixing with content.) and is similair to Nested Content 👍

@nielslyngsoe
Copy link
Member

nielslyngsoe commented Sep 22, 2020

@ronaldbarendse good point, I'm happy with that. Thanks for being aware :-)

@warrenbuckley
Copy link
Contributor

warrenbuckley commented Nov 23, 2020

Fixed in #9275
Due for release in 8.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants