fields is not explicitly set in <def tag="table" -- maybe this is a
problem in attribute merging?
1. Leaving out extend tag="table", I confirm that inside of <def
tag="table" fields is indeed set to list of fields that I passed to
table-plus (<table-plus fields="this, custodian, data_type, origin,
date_from, date_to, volume, size_items">)
2. In this snippet to extend the table tag, however, referencing
fields generates an exception:
<extend tag="table">
<old-table merge>
<tr:>
<% require 'ruby-debug' ; debugger %>
<if test="&fields">
...
in the debugger,
all_attributes = {"fields"=>"this, custodian, data_type, origin,
date_from, date_to, volume, size_items">
but
fields --> Exception: undefined method 'fields' for #<ActionView::Base:
0x53f41e8>.
Shouldn't <old-table merge> set the value of fields, not just
all_attributes?
As a workaround, I am thinking I maybe can change <if test="&fields">
to <if test="&all_attributes['fields']">
On Jun 17, 5:35 pm, kevinpfromnm <[email protected]> wrote:
> The if test=... is straight from the hobo definition. probably the
> attribute is not set there.
>
> After your clarification, the part that takes care of the conditional
> class is this:
> #{'numeric-field' if this.is_a?(Numeric)}
>
> On Jun 17, 3:31 pm, Montgomery Kosma <[email protected]> wrote:
>
> > Cool, #1 is obvious on closer look at the source. However, the
> > snippet you suggested generates an "undefined methods 'fields'" error,
> > appears to be the line <if test="&fields"> -- the following
> > simplification still generates the error.
>
> > <extend tag="table">
> > <old-table merge>
> > <tr:>
> > <if test="&fields">
> > foo
> > </if>
> > </tr:>
> > </old-table>
> > </extend>
>
> > On question 2, the test I meant is the is_a?(Numeric) in the class=
> > parameter. On further reflection, looks like this should work. I.e.,
> > if I call:
>
> > <size_megabytes-view:>xxx</size_megabytes-view:>
>
> > The test for is_a?(Numeric) to set class should still occur, with the
> > expected value of "this". The <size_megabytes-view:> tag I gather
> > will replace ONLY the material between the > and < (inside the tag)
> > with 'xxx'.
>
> > On Jun 17, 12:16 pm, kevinpfromnm <[email protected]> wrote:
>
> > > 1. The tag is defined <tr param>... I believe. By default param name
> > > is the tag name.
>
> > > 2.
> > > a. I didn't see a test included there.
> > > b. the value of this is the value reported by the field.
>
> > > On Jun 15, 2:58 pm, Montgomery Kosma <[email protected]> wrote:
>
> > > > very interesting. Two questions/comments:
>
> > > > 1. <tr:> ? No idea I could do that with the generic tag and not one
> > > > named as param="xxx"
>
> > > > 2. looks like a good solution for the general case, but seems unlikely
> > > > to work if I apply a rails formatting helper to the field being
> > > > displayed. So if my view includes this:
>
> > > > <size_megabytes-view:><%= number_to_human_size(this*1024*1024) %></
> > > > size_megabytes-view:>
>
> > > > a. does the "numeric-field" test get bypassed entirely?
>
> > > > b. if not, what's the value of "this" that the test evaulates? I.e.,
> > > > does it see the original BigDecimal (e.g., 1.23) or the string
> > > > returned by number_to_human_size (e.g., "1.23 MB")?
>
> > > > On Jun 9, 5:49 pm, kevinpfromnm <[email protected]> wrote:
>
> > > > > You should be able to implement your first idea by extending the table
> > > > > tag.
> > > > > <extend tag="table">
> > > > > <old-table merge>
> > > > > <tr:>
> > > > > <if test="&fields">
> > > > > <with-fields merge-attrs="&all_attributes & attrs_for
> > > > > (:with_fields)" force-all>
> > > > > <td param="#{this_field.to_s.sub('?', '').gsub('.',
> > > > > '-')}-view" class="#{'numeric-field' if this.is_a?
> > > > > (Numeric)}"><call-tag tag="&field_tag"/></td>
> > > > > </with-fields>
> > > > > <td class="controls" param="controls"
> > > > > if="&all_parameters
> > > > > [:controls]">
> > > > > <a param="edit-link" action="edit"
> > > > > if="&can_edit?">Edit</a>
> > > > > <delete-button param/>
> > > > > </td>
> > > > > </if>
> > > > > ...
>
> > > > > Unfortunately you have to override the whole row since you won't know
> > > > > what the field name is to be able to target just the <td> tags.
>
> > > > > Or you could override the view for that type and add a class to it.
>
> > > > > If it's a one of a kind deal it's probably cleaner to just give the
> > > > > specific fields the class like you did.
>
> > > > > On Jun 9, 12:14 am, Montgomery Kosma <[email protected]> wrote:
>
> > > > > > to clarify my last point on right alignment ... I can obviously do
> > > > > > this in application.css:
>
> > > > > > td.size-megabytes-view,
> > > > > > td.size-items-view {
> > > > > > text-align: right;
>
> > > > > > }
>
> > > > > > but then I though, shouldn't we leverage the model's knowledge of
> > > > > > data
> > > > > > types to avoid specifying every numeric column explicitly in css?
>
> > > > > > One approach is to tweak the call to call-tag in def tag="table" in
> > > > > > rapid-core.dryml:
>
> > > > > > <td param="#{this_field.to_s.sub('?', '').gsub('.',
> > > > > > '-')}-view"><call-tag tag="&field_tag"/></td>
>
> > > > > > by adding something like <%= class="numeric-field" if this.is_a?
> > > > > > (Numeric) %>. However, my kung fu is too weak, I couldn't make this
> > > > > > work. Anyway, given my overrides to use number_with_delimiter and
> > > > > > number_with_human_size, I'm skipping over the default call to
> > > > > > call-tag
> > > > > > anyway.
>
> > > > > > So, the best solution I've devised is to add a class="numeric-field"
> > > > > > argument to the dryml tags for each numeric field, as shown here.
> > > > > > At
> > > > > > least that keeps the model out of my css. Love to hear of any
> > > > > > alternative ideas!
>
> > > > > > <index-page>
> > > > > > <collection: replace>
> > > > > > <table-plus fields="this, custodian, data_type, origin,
> > > > > > date_from,
> > > > > > date_to, size_megabytes, size_items">
> > > > > > <empty-message:>No file sets have been
> > > > > > created.</empty-message:>
> > > > > > <size_megabytes-heading-link:>Volume</size_megabytes-heading-
> > > > > > link:>
> > > > > > <size_megabytes-view: class="numeric-field"><%=
> > > > > > number_to_human_size(this*1024*1024) %></size_megabytes-view:>
> > > > > > <size_items-heading-link:>Items</size_items-heading-link:>
> > > > > > <size_items-view: class="numeric-field"><%=
> > > > > > number_with_delimiter
> > > > > > (this) %></size_items-view:>
> > > > > > </table-plus>
> > > > > > </collection:>
> > > > > > </index-page>
>
> > > > > > On Jun 9, 12:53 am, Montgomery Kosma <[email protected]> wrote:
>
> > > > > > > Throwing this out there to seed the google groups search engine,
> > > > > > > since
> > > > > > > it would have helped me...
>
> > > > > > > Using table-plus to implement my model's index page, I wanted to
> > > > > > > change the label above two of my columns.
>
> > > > > > > This is super-easy - table-plus offers a "xxx-heading-link" tag
> > > > > > > to do
> > > > > > > just this, where xxx is the column name. The only trick was
> > > > > > > figuring
> > > > > > > out the not-really-documented distinction between
> > > > > > > xxx-heading-link and
> > > > > > > xxx-heading.
>
> > > > > > > To illustrate, here's the index.dryml for my FileSet model:
>
> > > > > > > <index-page>
> > > > > > > <collection: replace>
> > > > > > > <table-plus fields="this, custodian, data_type, origin,
> > > > > > > date_from,
> > > > > > > date_to, size_megabytes, size_items">
> > > > > > > <empty-message:>No file sets have been
> > > > > > > created.</empty-message:>
> > > > > > >
> > > > > > > <size_megabytes-heading-link:>Volume</size_megabytes-heading-
> > > > > > > link:>
> > > > > > > <size_megabytes-view:><%=
> > > > > > > number_to_human_size(this*1024*1024)
> > > > > > > %></size_megabytes-view:>
> > > > > > > <size_items-heading:>Items</size_items-heading:>
> > > > > > > <size_items-view:><%= number_with_delimiter(this)
> > > > > > > %></size_items-
> > > > > > > view:>
> > > > > > > </table-plus>
> > > > > > > </collection:>
> > > > > > > </index-page>
>
> > > > > > > Above, <size_megabytes-heading-link:> shows the "right" way to
> > > > > > > override the column heading, as (despite its name) it doesn't mess
> > > > > > > with the link, just the text of the heading. Note however,
> > > > > > > <size_items-heading:> shows the "wrong" way to change the
> > > > > > > heading, as
> > > > > > > (despite its name) it changes the entire heading, meaning that it
> > > > > > > eliminates the click-to-sort link and the sort indicator arrows,
> > > > > > > in
> > > > > > > addition to the default heading text.
>
> > > > > > > (Illustration on calling rails number helpers included, at no
> > > > > > > extra
> > > > > > > charge!)
>
> > > > > > > Share & Enjoy.
>
> > > > > > > (Now, to figure out a DRY way to make all my numeric columns right
> > > > > > > align...)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---