Giter VIP home page Giter VIP logo

Comments (18)

mattbrailsford avatar mattbrailsford commented on June 30, 2024 2

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.

mattbrailsford avatar mattbrailsford commented on June 30, 2024 2

Man, didn't realize implementing a local cache was that hard ;)

https://gist.github.com/mattbrailsford/d7f512ca4a6f24ebe70ebed82eb163f5

from umbraco-nested-content.

mattbrailsford avatar mattbrailsford commented on June 30, 2024 1

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.

mattbrailsford avatar mattbrailsford commented on June 30, 2024

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.

greystate avatar greystate commented on June 30, 2024

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.

Myster avatar Myster commented on June 30, 2024

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.

Myster avatar Myster commented on June 30, 2024

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.

Myster avatar Myster commented on June 30, 2024

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.

Myster avatar Myster commented on June 30, 2024

Sounds great, I'll have to give it a whirl :-)

from umbraco-nested-content.

leekelleher avatar leekelleher commented on June 30, 2024

@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.

Myster avatar Myster commented on June 30, 2024

Perhaps one could add a 'cooldown' guard condition to each filter? (bit naff, but should work)

from umbraco-nested-content.

YodasMyDad avatar YodasMyDad commented on June 30, 2024

@leekelleher did you ever come up with a solution for the filter getting called a ton of times?

from umbraco-nested-content.

leekelleher avatar leekelleher commented on June 30, 2024

@YodasMyDad Nope, I gave up on it, my Angular knowledge isn't that great πŸ˜”

from umbraco-nested-content.

dryton avatar dryton commented on June 30, 2024

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.

hfloyd avatar hfloyd commented on June 30, 2024

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.

leekelleher avatar leekelleher commented on June 30, 2024

from umbraco-nested-content.

hfloyd avatar hfloyd commented on June 30, 2024

Fantastic! Thanks for the info, @leekelleher

from umbraco-nested-content.

CostinTanasoiu avatar CostinTanasoiu commented on June 30, 2024

Could this feature go into the Developer's Guide document?

from umbraco-nested-content.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.