RailsAdmin multiple lines in list view cell - actionview

I'd like to get RailsAdmin to show two fields in one cell.
config.model Model do
list do
field :id do
label '#'
end
field :email do
label 'Customer'
formatted_value do
view = bindings[:view]
bindings[:view].content_tag(:div, [view.content_tag(:p, bindings[:object].email), view.content_tag(:p, bindings[:object].phone)])
end
end
end
end
This gives me the following output (escaped HTML basically).
[<p>...(email)...</p> <p>...(phone)...</p>]
I'm not sure what I'm doing wrong - being a rails beginner, maybe I'm not using the content_tag method correctly?

Related

Grouping Classes & Subclasses in saved search

I'm trying to create a saved search that sums total sales by the parent class. I'm trying a CASE statement but can't seem to get it to work. This is what I have:
CASE
WHEN {class} LIKE 'B2B%’ THEN 'B2B'
WHEN {class} LIKE 'Amazon%’ THEN 'Amazon'
WHEN {class} LIKE 'Website%’ THEN ' B2C'
ELSE ‘’
END
Not sure why but that format never works for me either, although Netsuite documentation suggests that it should/does. Try nested CASE statements.
CASE WHEN {class} LIKE 'B2B' THEN 'B2B' ELSE
CASE WHEN {class} LIKE 'Amazon%' THEN 'Amazon' ELSE
CASE WHEN {class} LIKE 'Website%' THEN ' B2C' ELSE '' END
END
END
Or you can use SUBSTR({class},0,INSTR({class},':')-2) to get just the part of the string before " :", assuming all of your classes have these characters present.
Once you have that column formula working, group results based on this formula, add total sales as a column and group that but select "Sum".

How to set up prefixes on saved search for multiple choices in netsuite?

I have a multiple select field that allows multiple selections of colors. I created a formula that would append a prefix of "color-" to each selected list, but it only appends it to the the beginning of the field. I'm not sure how I can split the field results up for the formula to where I can get it showing up for all results.
CASE WHEN {custitemtag_color1} is NULL
THEN ''
ELSE 'color-'||{custitemtag_color1}
END
Results with multiple selections show: color-Black,Lime Green,White
Expected Results need to show: color-Black,color-Lime Green,color-White
What's happening is that NetSuite returns "Black,Lime Green,White" as a single result for the multi-selection, then you're prepending "color-" to that text returned. To work around it within your saved search, you could simply replace any instances of the comma (",") with ",color-":
CASE WHEN {custitemtag_color1} is NULL THEN '' ELSE 'color-'|| REPLACE({custitemtag_color1}, ',', ',color-') END

OR Formula in Word document not returning a value

I am working on a document where I need to be able to test multiple options in an if statement to see if one of them are true to decide if a paragraph displays on the document. I have been trying to figure out why my OR formula is not returning a value for me to test and I am not sure why it is not showing anything when it is updating.
I have inserted a field and added a formula within that field that I am hoping will work with my If statement to show the proper paragraph contens.
When I use an Or statement, even one as simple as { OR(1=1) } and update and toggle the field I get no result. From what I have read I should get a 1 or a 0, but I don't seem to get either of these results. The line just ends up blank. When I test it with my If formula it always shows the false result, even when the Or contains a true result.
The formula I am currently working with is:
{ IF{ OR("$event.eventType.name}" = "Birthday", "$event.eventType.name}" =
"Conference" } "Yes" "No" }
If I update and toggle the Or field it shows blank, no result either true or false, and makes the If formula show as false event on results where it should show true. As I mentioned above I even tried setting it to 1=1 and still could not get it to show as true. Not sure if there is something I am missing in working with the formula.
Any suggestions would be appreciated.
It's not clear from your post what $event.eventType.name is. Presumably it's a field generated by an Addin. In that case, you should be able to use something like:
{IF{={IF{$event.eventType.name}= "Birthday" 1 0}+{IF{$event.eventType.name}= "Conference" 1 0}# 0}> 0 "Yes" "No"}
or:
{={IF{$event.eventType.name}= "Birthday" 1 0}+{IF{$event.eventType.name}= "Conference" 1 0} \# "'Yes',,'No'"}
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field constructions are all required. If your fields are a kind of mergefield, you'll need to insert 'MERGEFIELD ' at the start of each one, thus:
{MERGEFIELD $event.eventType.name}

fetch html data from website into excel vba

Object does not support this property or method.
Error occur on this line:
For Each ele In objIE.document.getElementsByClassName("table info-table").getElementsByTagName("tr")
getElementsByClassName() returns a collection of matching elements (even if there's only one match), so you need something like (e.g.):
For Each ele In objIE.document.getElementsByClassName( _
"table info-table")(0).getElementsByTagName("tr")
which will loop over the tr elements in the first table with a matching class name.
If you need a different table you'll need to adjust the (0)

How do I make Active Admin show code DRY across models?

I have a number of models within Active Admin that have very similar (but not exactly the same) show pages along the lines of:
show do |ad|
attributes_table do
row :name
row :length
row :width
row :height
...
end
panel "Images" do
text_node link_to 'Add Image', new_admin_image_path(...)
table_for ad.images do
column "Image" do |image|
image_tag(...)
end
column do |data|
link_to :edit, edit_admin_image_path(...)
end
column do |data|
link_to :delete, admin_image_path(data), method: :delete
end
end
end
end
The 'panel "Images" do' code will be duplicated exactly within each model, so I'd like to put it somewhere else. I've been going down the ViewHelper and render partial paths, but in both cases I end up with something that doesn't know what "panel", "text_node", "table_for", etc. is. Guidance as to what is the right way to do this?
Arbre, the template language ActiveAdmin uses, does support partials. You can
move the duplicated code into an arb partial such as
app/views/admin/_images_panel.html.arb. Then your ActiveAdmin resources
can simply call render with the partial path and any needed local
variables.
show do
attributes_table do
# ...
end
render 'admin/images_panel', data: data
end
The partial may also reference the generic method resource to eliminate
the need to pass in local variables. Resource is whatever resource the
admin is managing. For example:
panel "Images" do
table_for resource.images do
# Note use of `resource` instead of `ad` above.
# ...
end
end

Resources