How to set/define the value for the label in the minimap - wagtail

Since Wagtail 4.1 a new minimap component is available in the editor interface.
For newly added blocks, the defined icon and the Meta class label of a subclassed StructBlock are shown.
However, after saving the page, the first field/block of the StructBlock is used as the label in the minimap.
How can I specify which field/block or text should be used as the label in the minimap?

The minimap uses the label_format attribute of the Meta class.
class PanelBlock(StructBlock):
headline = blocks.CharBlock(label=_('Headline'))
text = blocks.RichTextBlock(label=_('Text'))
class Meta:
label = _('Infobox')
icon = 'doc-empty'
label_format = 'This is the label' # <- This will be used as the label
label_format – Determines the label shown when the block is collapsed in the editing interface. By default, the value of the first sub-block in the StructBlock is shown, but this can be customised by setting a string here with block names contained in braces - for example label_format = "Profile for {first_name} {surname}"
Source: https://docs.wagtail.org/en/stable/reference/streamfield/blocks.html#wagtail.blocks.StructBlock

Related

Add an icon inside a Codename One TextModeLayout

My problem is that I didn't find any way to properly add an icon near a TextComponent, inside a TextModeLayout, to mask/unmask a password.
It's a layout problem only, because the code of the ActionListener to mask/unmask the password works correctly at least in the Simulator (it's taken from Codename One - Mask and Unmask Password Field on iOS).
On iPhone skin, the InputComponents labels and text fields are not aligned correctly:
On Android skin, the text is not aligned correctly if it doesn't valide:
About my code, instead of adding the InputComponent (of the password) directly to the TextModeLayout container, I enclosed the InputComponent and the Button inside a BorderLayout, and then I added the BorderLayout container to the TextModeLayout container.
When you do that the text mode layout stops working for that component as it's unaware of the layout in the hierarchy. The hierarchy in the border layout is the responsibility of that layout.
The solution is to extend the TextComponent and add that functionality to Codename One. As a workaround we might be able to rely on the behavior of the current component since the field is already in a border layout component. So something like this might work:
TextField tf = myTextComponent.getField();
Container b = tf.getParent();
b.add(EAST, unmask);

FloatingActionButton on TextArea not working as expected

I tried to use a com.codename1.components.FloatingActionButton in combination with a com.codename1.ui.TextArea.
Now I have two questions:
Apparently the valign is not honored - is it a bug?
The actionListener of the FloatingActionButton is not called. Is anything wrong with my usage or is it a bug?
Here is the code to demonstrate it:
public class FormFabOnText extends Form {
public FormFabOnText() {
setTitle("FormFabOnText");
setLayout(new BorderLayout());
Container contentPane = getContentPane();
contentPane.add(BorderLayout.NORTH, new SpanLabel(
"This form contains a TextArea and a FloatingActionButton combined by bindFabToContainer. "
+ "It demonstrates that the FloatingActionButton is not working in this constellation."));
TextArea textArea = new TextArea();
float iconDefaultSize = FloatingActionButton.getIconDefaultSize();
try {
FloatingActionButton.setIconDefaultSize(2.0f);
FloatingActionButton floatingActionButton = FloatingActionButton.createFAB(FontImage.MATERIAL_CLEAR);
Container containerFab = floatingActionButton.bindFabToContainer(textArea, Component.RIGHT, Component.CENTER);
floatingActionButton.addActionListener((e) -> textArea.setText(""));
contentPane.add(BorderLayout.CENTER, containerFab);
} finally {
FloatingActionButton.setIconDefaultSize(iconDefaultSize);
}
}
}
The text area has 0 height so when you valign to the center the button correctly places itself on top. Then you add it to a border layout which stretches it across but the preferred size of the text area determines the valign so it stays.
I'm not sure if there is a good workaround for that other than a bit of margin like we did in the msuikit demo.
The issue with tapping during editing is probably related to the native editing peer. Tapping inside the text area gets sent to the native layer for editing otherwise elements below might cause an issue. Text input is a peer but also a very special case.

How to make a word wrap in the text of an element (Text, Label, displayField) with ExtJS 4.2.1?

Must show a text that is greater than the component in which it is inserted. Currently, the text does not wrap automatically.
I've tried using the following components: Text, Label and Display Field
Have you tried a text that contains white space? A single word that is too long won't be wrapped ever, but multiple shorter, space-delimited words maybe will, depending on the component you use.
If you want to show a long text, use a container and put the text into the html configuration, and it will auto-wrap.
The components you named also have their usage, but not for simple long text:
text is from the draw package, and good for specialized formatting.
displayfield is good inside a form whenever you want to display (read-only) some value that is part of the record that you load into the form. displayfield won't wrap at all - try textareafield with readonly configuration for that.
label is good as the label of a form field, but only if used via the labelable mixin, which does most of the work. A label should make its content wrap around if you provide a fixed width or maxWidth, but it does not automatically adhere to the parent object layout.
you can simply add styles to extjs components (you can use any of them):
word-wrap: break-word;
There are some ways to apply custom css styles to ext's elements
style: {
"word-wrap": 'break-word'
}
Also you can do this:
Ext.get('txtElement').setStyle('word-wrap', 'break-word');

Cannot handle action events on Labels?

I've dynamically created a horizontal scrolling list of labels (with icon and bottom text) within a container in a tab.
However, I cannot seem to bind any action to this Label - I want touch, long press, options(commands), drag, etc
If I use Button instead of Label, I cannot seem to use URLImage to grab the icon from a url and save it to storage and use that as the button icon. It always uses only the placeholder from:
Image img = URLImage.createToStorage(placeholder, counter+"_thumbnail", thumbnailURL, URLImage.RESIZE_SCALE);
How do I grab events on the Labels? Here is a snippet of how I'm adding the labels to the container:
Container c = StateMachine.instance.findFirstListContainer();
for(...){
Label l = new Label();
l.setText(title);
l.setIcon(img);
l.setUIID("listItem");
l.setTextPosition(2);
c.addComponent(l);
}
You should use a Button rather than a Label and invoke the setUIID("Label") method.
The reason why you didn't do this is a separate question/issue: https://groups.google.com/d/msg/codenameone-discussions/5HoDEFjB5II/5dc4iKuYNSYJ

Is .x-form-arrow-trigger css class used only for down arrow image on ComboBox?

In ExtJS is .x-form-arrow-trigger css class used only for down arrow image on ComboBox or there are some other places where this class can be used?
Given that the only style rule for this class is a background image pointing to this file...
http://cdn.sencha.io/ext-4.0.7-gpl/resources/themes/images/default/boundlist/trigger-arrow.png
...then you can safely assume that it is only used where a down arrow trigger is implemented (and to my knowledge that is only on the combobox component - someone correct me if I'm wrong).
Ocasionally found in documentation for Ext.form.ComboBox
Section Configs:
triggerClass : String
An additional CSS class used to style the trigger button. The trigger will always get the class 'x-form-trigger' and triggerClass will be appended if specified (defaults to 'x-form-arrow-trigger' which displays a downward arrow icon).
Defaults to: "x-form-arrow-trigger"

Resources