Comments (18)
Just had an interesting discussion on twitter with someone who is trying to run a filter in a labelTemplate and whilst his doesn't work currently (because the value isn't in the right format for the filter) filters do actually run, so we actually have a way of running functions in label templates by making angular filters.
So, you could make a filter to fetch a node name, then in your label template, have something like {{mediaPicker|nodeName}} and the filter will process the id and do something with it. This in theory allows you to run custom code within your labels without us needing to support extra weirdness.
I still think we probably need a way to expose the index of the current item, but I'm pretty happy to call this a solution for any, more complex, label generation.
from umbraco-nested-content.
Man, didn't realize implementing a local cache was that hard ;)
https://gist.github.com/mattbrailsford/d7f512ca4a6f24ebe70ebed82eb163f5
from umbraco-nested-content.
The problem is, there is no nice way to go about this. Take Archetype for example https://github.com/kgiszewski/ArchetypeManual/blob/master/02%20-%20Configuration.md#label-template, they allow custom functions for labels, but it's just really cumbersome to implement IMO (For the record, I can't think of an alternative way, so what they have come up with is probably what I would have implemented).
First you need to create a js file, then include it via the package manifest (or I think they have a prevalue config option too), then you need to define your function accepting specific arguments (I guarantee someone will always want access to something not defined), and then you have to setup the label template. In addition, the likelihood is you are going to need to make HTTP requests to a web service to get the label names from some back office implementation which may also need building by yourself, then finally, the label templates are processed every time an item changes so you'll be potentially making a bunch of web requests all to get a label, when adding a simple "label" field on your NC doc type would circumvent all of this, but just require your users to name things.
I understand that this would be the problem of the developer wanting to create the label, but I just feel it'll open a heap of maintenance issues.
Given @greystate's comments saying it's more the "item 1, item 2, item 3" that is the issue for him, the only thing I can think to go is maybe expose the current index as a template parameter so you could define a label like "Item {index}" where you know it's going to be tricky to dynamically formulate a label?
I'm open to suggestions / PR's for ways to do this in a nicer way though.
from umbraco-nested-content.
It should fallback to "item 1, item 2, item 3" etc if it's empty. It's just tricky providing a way to do fancy labels as it's how we allow the logic to be defined. Maybe we can look at allowing developers to provide either a link to an angular include, or some angular markup to render as the label?
from umbraco-nested-content.
Yeah, the "Item 1", "Item 2" labels are probably the real issue. Would be so much nicer to be able to have them be meaningful with regards to the specific datatype, instead of overly generic as they currently are :)
from umbraco-nested-content.
I advocate going a step further and allowing a function to be specified to generate the label ( as per issue #41 ) or some other way which is just as flexible.
from umbraco-nested-content.
I was envisaging having to do all those steps you described (at least for more complex scenarios), but frankly probably the only scenario I'd bother with is taking the first line from an RTE. (and perhaps looking up node names)
from umbraco-nested-content.
Also just discovered I'd like to put HTML markup in the label, Currently I'm just thinking <strong>
but I imagine more complex layout may be useful too.
from umbraco-nested-content.
Sounds great, I'll have to give it a whirl :-)
from umbraco-nested-content.
@mattbrailsford I tried out a test filter, it gets called a LOT, as in at least 15 times on initial page load, then whenever angular tries to rebind the model. Just moving my mouse around made at least another 20 calls to the filter. Not sure if there's a way to prevent (or pause) the aggressive rebinding?
(Ignore until next week ππππΈπ )
from umbraco-nested-content.
Perhaps one could add a 'cooldown' guard condition to each filter? (bit naff, but should work)
from umbraco-nested-content.
@leekelleher did you ever come up with a solution for the filter getting called a ton of times?
from umbraco-nested-content.
@YodasMyDad Nope, I gave up on it, my Angular knowledge isn't that great π
from umbraco-nested-content.
It'd be great if it could convert content IDs to names for usability.
I had a play around with the script and saw the same issue with the getName function being called a whole load of times. Making a call off to fetch the name would be a real performance hit as it stands.
from umbraco-nested-content.
Hi @mattbrailsford , Did you close this because it is/will be included in a release, or because it will not be included? Just checking since the code link is a gist and not a PR....
from umbraco-nested-content.
from umbraco-nested-content.
Fantastic! Thanks for the info, @leekelleher
from umbraco-nested-content.
Could this feature go into the Developer's Guide document?
from umbraco-nested-content.
Related Issues (20)
- Renamed document types are not resolved HOT 1
- What would it take to get OfType<T>() to work with NC HOT 3
- Doc Types - Tab Drop Down List Not Saving When Setting Up New Data Type HOT 1
- Nested content not working inside doctype grid editor that is inside a Vorto editor HOT 6
- Featured Request : Deletion of Item Alert Message HOT 1
- Cannot add a new content if multiple document types have been specified HOT 8
- Cannot resolve NestedContent values for indexing due to UmbracoContext.Current == null HOT 1
- {{ pickerAlias | ncNodeName }} don't works with media picker HOT 6
- "Choose type of content" dialog always opens on top of the edit page HOT 5
- Review "Content Type selection" modal position
- Data type using nested content defaults to first tab in document type after save HOT 1
- Remove labels on nested property types HOT 1
- Performance - Nested content with RTE HOT 2
- Error saving content HOT 3
- How to render widget template on page template HOT 1
- Nested content title formatting with properties HOT 3
- Make obvious names for overview of the items inside the content HOT 2
- ncNodeName and ncMediaName not documented HOT 1
- Feature Request - Tabbed Interface HOT 1
- Add documentation for adding programmatically
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from umbraco-nested-content.