How to do get value from custom geojson prop without properties for paint expression in Mapbox - expression

I want to change features style according to in features style property. But style is not in properties. A sample feature is like that,
{
type:"feature",
style:{polygon:{"line-color":"#FF0000"}},
properties:{...},
geometry:{...}
}
So, according to documents 'get' expression does not work. Because, it looks for property section Document Mapbox Expressions.
I was wondering, are there any method to get information from style section in the features?

No, in a style, there is no way to access any part of an object other than in the properties section. (The one exception to this is the id property).
You will need to process your data differently.

Related

Add textfield for Classes in cq dialog

If we want to add an Id to an AEM Core component such as image, there is this field:
.content.xml
<id
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="HTML ID attribute to apply to the component."
fieldLabel="ID"
name="./id"/>
which gives this textfield in the dialog.
But what if we want to create the same textfield, but for CLASSES instead? The core components only seems to use the "./id" name, and nothing for classes.
As you can see I am an absolute beginner, so any pointer or help is much appreciated.
--- Edit (June 17, 2022):
Following Vlad's answer, I needed to narrow down where I am having issue:
I don't know how to "add a textfield for classes". For example, the id field has name="./id" in the xml, which can be accessed as "${image.id}" in the html. But the same doesn't exist for Classes.
How would the Textfield look like if I am adding it for Classes? Like this one obviously wouldn't work as "./class" is not connected to anywhere.
<class
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="HTML CLASS attribute to apply to the component."
fieldLabel="CLASS"
name="./class"/>
I guess that the name="./id" of the Textfield is tied to some Java logic so we can retrieve it via "${image.id}". I have looked at image's java code, but don't see how they tied together.
I would need to understand the Java code in order to override it. Or am I missing anything and there is an easier way? Again, absolute beginner here.
You can override the dialog and add a textfield for classes, then overlay the HTL script and inject the classes in the markup. However, I recommend you look first into the OOTB Style System. It allows you to define classes in the component’s policy and then use them in the editor (they will be added on the component wrapper element).

How can I disable a custom toolbar button in CKEditor 5?

I implemented a version of the image insert Simple Plugin example from CKEditor 5's framework docs.
But the example doesn't cover how to disable the item when the editor's isReadOnly property is set (like it does by default for all the standard buttons). I found docs for an isEnabled prop as well as a bind method for ButtonView, but it quotes examples using a command item, rather than a view item. Problem is, the Simple Plugin example doesn't create a command to bind to.
So question is whether I need to create a command, or if there is some other way to make the view item's state sensitive to the readonly state of the editor instance.
Thanks, and my apologies if I've left out any needed context (new to posting here on SO). Feedback is welcome (and I know y'all will whip me into shape).
D'oh, I think I figured it out:
view.bind('isEnabled').to(editor, 'isReadOnly', isReadOnly => !isReadOnly);
Just needed to bind to the observable property of the editor. Seems to be working as I desired/expected.

What is the level displayed as "Default" in a apiblueprint document?

When i create a new api documentation in apiary.io, the rendered document and navigation shows structural level which are not visible in the editor:
INTRODUCTION
REFERENCE
Default
While I can accept the highest levels to generated magically, I would like to rename and duplicate the second level.
How do I do it? How is it called? It has CSS classes resourceGroupName but this does not appear to be the name.
Seems like I have overseen that some words that look like normal text are in fact keywords for the apiblueprint parser. One of them is Group, explained here: https://docs.apiary.io/api_101/api_blueprint_tutorial/#resource-groups

Orchard CMS widget Display Type

I have a widget which is using a query to display details. Is it possible to specify the display type of the widget (the query is using Summary and all is displayed as i want) because the header of the widget has a display type of Detail and i want it to use summary so i can override the shape when i place it in different sections (mainly the header text), but when in the content zone i would want it to be details. I am using the bootstrap theme. So basically if i stick my widget any where other than content i want it to use summary
Hope this makes sense.
Thanks
Ah, we meet again.
Widgets are built and injected into the layout in a class called Orchard.Widgets.Filters.WidgetFilter. There doesn't appear to be any way to modify the display type used for a widget (the default WidgetFilter uses the default value of "Detail").
To get around this, you can use your own implementation of WidgetFilter. Copy the existing code into your own class, and add an [OrchardSuppressDependency("Orchard.Widgets.Filters.WidgetFilter")] attribute to your class. This will make sure that the existing WidgetFilter isn't used, and yours is.
If you read through the OnResultExecuting method, you'll see that right near the end there is a call to BuildDisplay. The second argument to this method can be a display type. You can check widgetPart.Record.Zone to see where the widget has been placed, and pass in different values for the displayType parameter accordingly.
I'm not sure if this is the most elegant way, but it's where I'd start. Perhaps someone else might have a neater solution.

Dojo internationalization via markup outside of widgets

Dojo custom widgets can be internationalized via the _templated mixin following the steps outlined here and here. Then placeholders within the widget template like this: ${i18n.username} are automatically replaced with the appropriate language translation.
What is the simplest way to do similar nls language substitution outside of a widget? Ideally, I would like to add an attribute to a tag to have all the placeholders within substituted, including nested tags. Is there some type of container widget that already does this?
Or does Dojo development assume everything will be in a (custom) widget? I need to localize already existing code which doesn't use widgets.
The best solutions I have found so far are:
Using dojox.mobile.i18n, which is a "a thin wrapper around dojo.i18n, and has ability to replace strings, such as CDATA or attribute values, in dojo markup." However I'm afraid this is limited to a certain subset of mobile tags/widgets.
Disabling automatic parsing and manually searching/replacing the appropriate text before explicitly calling the parser in dojo.addOnLoad().
I assumed that the notation in the external html is ${i18n.username}.This will find any node that has class="i18nReplace" and replace the innerHTML of the node. I didn't test any of this, but I hope you can use it as a starting point.
dojo.require("dojo.i18n");
dojo.require("dojo.query");
dojo.requireLocalization("myI18n", "myI18N"); // This will need to be modified to get your i18n files
dojo.addOnLoad(function() {
var i18n = dojo.i18n.getLocalization("myI18n", "myI18N");
dojo.query(".i18nReplace").forEach(function(node, index, arr){
node.innerHTML = dojo.replace(node.innerHTML, { i18n: i18n } );
// blindly doing this, does not support nested tags.
// you could add conditional logic to check for children
// and if they exist separately process them, otherwise
// replace the html.
});
});

Resources