table params generated from field attributes

3 views
Skip to first unread message

Andy Orahood

unread,
Oct 17, 2008, 12:15:10 PM10/17/08
to Hobo Users
In my show-page.dryml for a model called List I put a table. I
populate the table with a collection of ListItems . The ListItem is a
has_many_through model connecting Lists with Docs, so what I see in
the table is the set of docs that are ListItems in this list.

I want to see the doc object in the first column, and then the title
attribute of the doc in the second column, and the notes in the third
column. So my fields="doc, doc.title, notes". I see how hobo generates
the '-view' and '-heading' params from the field names for the 'doc'
and 'notes' fields, so I can pass <doc-view:> and <doc-heading:> and
<notes-view:> and <notes-heading:> params to customize those columns.

I don't understand what the names of the autogenerated params for the
'doc.title' field would be. If they are supposed to be <doc-title-
view:> and <doc-title-heading:>, those don't work for me. Am I
(probably) doing it wrong?

<table:list-items fields="doc, doc.title, notes">
<doc-view:>
<a><%= this.docid %></a>
</doc-view:>
<doc-title-view:>
This doesn't work.
</doc-title-view:>
<empty-message:>No documents</empty-message:>
</table:list-items>

Thanks,
Andy

Tom Locke

unread,
Oct 17, 2008, 1:13:56 PM10/17/08
to hobo...@googlegroups.com
> I don't understand what the names of the autogenerated params for the
> 'doc.title' field would be. If they are supposed to be <doc-title-
> view:> and <doc-title-heading:>, those don't work for me. Am I
> (probably) doing it wrong?

I think it's just <title-view>, which could run into problems
obviously : )

Tom

Orahood, James A

unread,
Oct 17, 2008, 1:53:34 PM10/17/08
to hobo...@googlegroups.com
I was wrong when I said the param <doc-title-heading:> isn't auto-generated from the 'doc.title' field; <doc-title-heading:> does get generated.

But Tom, you are correct that the view param generated from doc.title is just <title-view:>. It seems inconsistent to me to have <doc-title-heading:> but <title-view:>, why are they constructed differently? My wild-ass guess: scope, or nothing!

Thanks,
Andy

Tom Locke

unread,
Oct 17, 2008, 3:33:28 PM10/17/08
to hobo...@googlegroups.com
> But Tom, you are correct that the view param generated from
> doc.title is just <title-view:>. It seems inconsistent to me to have
> <doc-title-heading:> but <title-view:>, why are they constructed
> differently?

Yes - it's a work-in-progress : )

Tom

Andy Orahood

unread,
Oct 21, 2008, 10:44:05 AM10/21/08
to Hobo Users
Another question on this topic: if you have fields="this", as in the
agility tutorial <table-plus>, what are the params hobo generates to
allow tweaking the heading and view of the column corresponding to
"this"? Or does it not work that way?

Thanks,
Andy

blizz

unread,
Oct 21, 2008, 12:53:31 PM10/21/08
to Hobo Users
If this is a Project then it would be:

<Project-heading:>my custom header<Project-heading:/>

You need the capitalization here.

For the views it looks like it would be <[#record_id]-view> which
would be nearly useless except that a tag starting with a number is
invalid so it just doesn't work at all.

Something needs to be fixed there.

Brett

blizz

unread,
Oct 21, 2008, 1:09:12 PM10/21/08
to Hobo Users
A hack fix for the view of "this" parameter of table-plus, (or table
really cause thats where the fix is)

If you replace line 58 in rapid.dryml with this:

<td param="#{this_field.to_i.to_s==this_field.to_s ?
this.class.to_s : this_field.sub('?', '').gsub('.', '-')}-view"><call-
tag tag="&field_tag"/></td>

It will work like this:

<Project-view:> what ever you want to do with it <Project-view:/>

Brett

Andy Orahood

unread,
Oct 21, 2008, 3:28:34 PM10/21/08
to Hobo Users
So Blizz is awesome, thanks a lot!

My first thought about how to apply the fix was WHY NOT DO IT THE
DRYML WAY AND EXTEND THE TABLE TAG?!? So I looked at the table tag def
in hobo/taglibs/rapid.dryml and figured if I could find the smallest
enclosing param tag containing the bad code I could just replace it.
So it looked like the param I needed to replace was <tr:>, copying and
pasting the contents of the original <tr> into my extension version
with only the commented out line changed with Blizz's fix. Running my
app with my extended <table> gives me an error of

undefined method `fields' for #<ActionView::Base:0xb64357e0>

So: am I smoking crack, or am I on the right track but just missed
something?

<extend tag="table">
<old-table merge>
<tr: replace>
<if test="&fields">
<with-fields merge-attrs="&all_attributes &
attrs_for(:with_fields)" force-all>
<!-- <td param="#{this_field.to_s.sub('?', '').gsub('.',
'-')}-view"><call-tag tag="&field_tag"/></td>-->
<td param="#{(this_field.to_i.to_s == this_field.to_s) ?
this.class.to_s : this_field.sub('?', '').gsub('.', '-')}-view">
<call-tag tag="&field_tag"/>
</td>
</with-fields>
<td class="controls" param="controls"
if="&all_parameters[:controls]">
<a param="edit-link" action="edit">Edit</a>
<delete-button param/>
</td>
</if>
</tr:>
</old-table>
</extend>

Thanks,
Andy

blizz

unread,
Oct 21, 2008, 5:51:09 PM10/21/08
to Hobo Users
I haven't used extend, but you could copy the table-plus definition in
rapid_plus.dryml into applicaiton.dryml and call it my-table-plus.
Then within that change the reference to table to my-table and copy
the table out of rapid.dryml into application.dryml and call it my-
table. I have done this on occasion, and although it is kind of wet
it works in a pinch.

Then when it is fixed in hobo, just remove that and go back to the old
table-plus.

Brett
Reply all
Reply to author
Forward
0 new messages