In Active Admin / Arbre form, how I can put HTML (specifically a line break) in a label? - activeadmin

This is a little unorthodox, but I don't think it should be difficult.
I have a Active Admin form:
form do |f|
f.semantic_errors(*f.object.errors.keys)
f.inputs do
f.input :email
f.input :name
# read-only field that still matches formatting of form
li do
label "Last Update Time<br/>(except password changes)"
div f.object.last_update_time
end
end
f.actions
end
When rendered, the last_update_time label does not convert the <br/> into a line break. Similarly, html entity codes such as © (the copyright (c)) aren't converted either.
How can I get html to render in that label?
Stuff I tried that doesn't work:
label "foo<br/>bar".html_safe
label raw("foo<br/>bar")
a block like this (gets an error on label: "wrong number of arguments (given 0, expected 1..3)"):
label do
"foo"
br
"bar"
end
Anybody know the trick?

Try next:
li do
text_node "<label>Last Update Time<br/>(except password changes)"</label>".html_safe
div f.object.last_update_time
end
© must be inside a text_node too like:
text_node "©".html_safe

Alas Formtastic is not built on Arbre and is somewhat hacked into ActiveAdmin. I would try replacing Formtastic's label here with Arbre's text_node

Related

Python Selenium: Select input with dynamic id in form

I want to make a Python program with Selenium to fill out a form. Part of the process involves filling out a title. I used xpath to find the input associated with title, but then found out that it only works sometimes because its id is dynamic and keeps changing. Here is the html code associated with the title input box:
<div class='g5ia77ul buofh1pr d2edcug0 l9j0dhe7'>
<span class="m9osqain t5a262vz a8c37x1j b5fwa0m2 jagab5yi knj5qynh fo6rh5oj d2edcug0 ni8dbmo4 stjgntxs hzruof5a pmk7jnqg re5koujm ltmttdrg fgv6swy9 dd2scrzq ms05siws flx89l3n b7h9ocf4 g0qnabr5">Title</span>
<input dir="auto" aria-invalid="false" id="jsc_c_6" class="oajrlxb2 rq0escxv f1sip0of hidtqoto lzcic4wl g5ia77u1 gcieejh5 bn081pho humdl8nn izx4hr6d oo9gr5id qc3s4z1d knj5qynh fo6rh5oj osnr6wyh hv4rvrfc dati1w0a p0x8y401 k4urcfbm iu8raji3" type="text" value="">
</div>
Other boxes in the form have similar id, they all seem to start with "jsc_c_" like "jsc_c_a" or "jsc_c_8". Here is a picture of what part of the form looks like:
[][1
This is some of the code I have tried to select the title box:
titlePath = '//*[#id="jsc_c_6"]'
titleText = 'myTitle'
titleBox = driver.find_element_by_xpath(titlePath)
titleBox.send_keys(titleText)
I think that perhaps I could select the title input box by checking for the presence of the text "Title" in the box. However, I am not sure how this can be done. Any help or suggestions would be greatly appreciated.
Probably you can give it a try with
//span[text()='Title']/following-sibling::input

Getting the q-item-label text

I have this code using Quasar/VueJS. What I want to do is update the dropdown text label (keyDropDownLabel) based on the selected <q-item-label>.
So in this example below, I want the newLabelGoesHere part to be Key 1/2/3, depending on which was clicked.
<q-btn-dropdown stretch flat :label="keyDropDownLabel">
<q-list>
<q-item v-for="n in 3" :key="`x.${n}`" clickable v-close-popup tabindex="0">
<q-item-section #click="keyDropDownLabel = 'newLabelGoesHere'">
<q-item-label>Key {{ n }}</q-item-label>
<q-item-label caption>1234567890</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
Anyone help please??
Just modify the q-item-section click method like below:
<q-item-section #click="keyDropDownLabel('Key'+n)">

xpages dojo text area binding to a dialog list field

I have a Dojo Text Area control binding to a field from a form, the field is a Dialog list which uses a simple #DBColumn formula:
_view := "vwAuthor";
#Unique ( #DbColumn( "" : "NoCache" ; #DbName ; _view ; 1 ) )
I have saved one doc. with the Dojo text area control = Name1, but when I create another new doc. is there any chance to have that "auto-refresh" from Clasic Lotus Notes so that When I just type N the Name1 should be displayed?
Thanks for your time!
Create instead of the value picker for your Dojo Text Area a dialog box with an input text field with type ahead.
Feed the type ahead with the first column of your view "vwAuthor":
<xp:inputText
...>
<xp:typeAhead
mode="full"
minChars="1">
<xp:this.valueList><![CDATA[#{javascript:
#Unique(#DbColumn("", "vwAuthor", 1))
}]]></xp:this.valueList>
</xp:typeAhead>
</xp:inputText>
A text area by default does not offer any data entry assistance. Switch to a regular input box and use the type-ahead support build into XPages. Check the basic workshop, especially Exercise 7.

ActiveAdmin - Custom action with reusing the show form

I am creating a custom action that serve as show view with ActiveAdmin, is there any helper I can reused on the partial so I can reuse the ActiveAdmin show view template.
I reckons with show action, you could customise the arrangement with attributes_tables, is there something similar I could reuse for the view?
show do |ad|
attributes_table do
row :title
end
end
Here's my custom action:
member_action :read do
#app = App.find(params[:id])
#Rendering Partial
end
You could use partials in both views, with a bit of a hack:
app/admin/apps.rb
ActiveAdmin.register App do
show do
#app = App.find(params[:id])
render "show", context: self
end
member_action :read do
#app = App.find(params[:id])
end
end
app/views/admin/apps/_show.builder
context.instance_eval do
div do
panel "Address" do
attributes_table_for #address do
row :address_line_1
end
end
active_admin_comments_for #address
end
end
app/views/admin/apps/read.builder
render "show", context: self
Edit: Made it work!
Edit 2: Made comments work!

ExtJs layout + Window

While adding component dynamically, 'this.container is null' is displayed in firebug.
I have a window with some combo boxes say combo1, combo2, combo3 and a label. Based on the selection value of combo3 the 'label' field is removed and replaced with combobox or text field. i do this my using
form.items.removeAt(4);
form.items.insert(4, newItem); #here newItem can be combox/textfield
form.doLayout();
The form resides inside a panel.
When above lines are execueted. 'this.container is null' is displayed and component fails to insert/add in appropiate position.
Any suggestions?
You should not be modifying the underlying items collection. Use the remove/insert methods on the container.
Try to comment those lines line-by-line to see which one produces error like
form.items.removeAt(4);
//form.items.insert(4, newItem); #here newItem can be combox/textfield
//form.doLayout();
form.items.removeAt(4);
form.items.insert(4, newItem); #here newItem can be combox/textfield
//form.doLayout();
form.items.removeAt(4);
form.items.insert(4, newItem); #here newItem can be combox/textfield
form.doLayout();
Your problem could take place because of inserted/replaced object is no yet prepared when you try to insert it. Give us your newItem initilization code.
Upd
Or you can wrap your changing components (label, combobox, textfields) in a panel with card layout. And on change of combo3 simply select exact card in that panel.

Resources