attributes use "_" instead of "-" in ruby-land, since "no-edit" is a 
subtraction in ruby.

no_edit ||= "skip" is a standard ruby idiom similar to "no_edit = skip 
if !no_edit".

cheers,
Bryan


Steve Van Bruwaene wrote:
> Cool!  thanks!
> 
> I've got the code updated to do what I want:
> <def tag="field-list" attrs="tag, no-edit">
>   <% tag ||= scope.in_form ? "input" : "view"; no_edit ||= "skip" %>
>   <labelled-item-list merge-attrs="&attributes - attrs_for(:with_fields)">
>     <with-fields merge-attrs="&attributes & attrs_for(:with_fields)">
>     <% field_name = this_field_name
>        input_attrs = {:no_edit => no_edit} if tag == "input" && no_edit 
> == "disable"
>     -%>
>       <labelled-item unless="&((tag == 'input' && no_edit == 'skip' && 
> !can_edit?) || (tag == 'view' && this.nil?))">
>         <item-label param="#{this_field.to_s.sub('?', '')}-label" 
> unless="&field_name.blank?">
>           <do param="label"><%= field_name %></do>
>         </item-label>
>         <item-value param="#{this_field.to_s.sub('?', '')}-view" 
> colspan="&2 if field_name.blank?">
>           <do param="view"><call-tag tag="&tag" 
> param="#{this_field.to_s.sub('?', '')}-tag" 
> merge-attrs="&input_attrs"/></do>
>           <div param="input-help" if="&tag.to_sym == :input && 
> !this_field_help.blank?"><%= this_field_help %></div>
>         </item-value>
>       </labelled-item>
>     </with-fields>
>   </labelled-item-list>
> </def>
> 
> I'm pretty new to ruby and rails, and especially hobo.  I'd love to 
> parametrize this so it can be added to the main hobo system rather than 
> needing to maintain my own.  Looking at the code here, I'm having 
> trouble figuring out how you currently pass stuff.  I'm guessing no-edit 
> (in the top attrs field) is a parameter being passed in.  I don't see 
> where it's used.  You set no_edit (with underscore rather than hyphen) 
> manually, but don't seem to be getting the data from anywhere.  Is this 
> a bug, or am I missing something?
> 
> Thanks for all the help.  hopefully as I learn more about hobo, I'll be 
> able to start contributing to the project too!
> 
> Steve.
> 
> --
> Steve Van Bruwaene
> 
> On Thu, Jul 16, 2009 at 12:38 PM, Bryan Larsen <[email protected] 
> <mailto:[email protected]>> wrote:
> 
> 
>     The original source uses scope.in_form
> 
>     Bryan
> 
>     Steve Van Bruwaene wrote:
>      > This works great for the show page.  Unfortunately it also
>     filters out
>      > all the null values on the edit page, which means I can't set them.
>      >
>      > I'm looking at the expanded stuff in rapid_core.dryml.  How can I
>      > determine if we're in view or edit mode?
>      >
>      > Thanks again!
>      >
>      > Steve.
>      >
>      > --
>      > Steve Van Bruwaene
> 
>      >
>      >
>      > On Thu, Jul 16, 2009 at 10:39 AM, Bryan Larsen
>     <[email protected] <mailto:[email protected]>
>      > <mailto:[email protected] <mailto:[email protected]>>>
>     wrote:
>      >
>      >
>      >     The tag definitions in Hobo can be pretty intimidating.  
>     Here's a
>      >     stripped down field-list that should be a lot easier to follow:
>      >
>      >     <def tag="field-list" attrs="fields">
>      >       <labelled-item-list>
>      >         <with-fields fields="&fields">
>      >           <labelled-item>
>      >             <item-label>
>      >               <%= this_field_name %>
>      >             </item-label>
>      >             <item-value>
>      >               <view/>
>      >             </item-value>
>      >           </labelled-item>
>      >         </with-fields>
>      >       </labelled-item-list>
>      >     </def>
>      >
>      >     Now you can modify that to add what you need:
>      >
>      >     <labelled-item if="&!this.nil?">
>      >
>      >     Try that out and see if it works -- I may have been a little
>     bit to
>      >     aggressive in stripping.   You can refer to the original
>     source if
>      >     something appears to be missing.
>      >
>      >     If it works for you, you can try modifying the original
>     field-list in
>      >     rapid_core.dryml to make this an optional feature.  Then you
>     can send in
>      >     a patch.   We love getting patches!
>      >
>      >     cheers,
>      >     Bryan
>      >
>      >     Steve VB wrote:
>      >      > When I look at a record, (show page), all fields (except
>     those flaged
>      >      > "never_show" are displayed, whether they have content or not.
>      >      >
>      >      > In my (and probably many others), null fields aren't
>     relevant here.
>      >      > For example, in an address-book type table, there may be 50
>      >     fields for
>      >      > different addresses, email, etc. When viewing the record,
>     only the
>      >      > subset of fields that actually has data is relevant.
>     Displaying all
>      >      > the null fields just wastes screen space, and makes it a
>     little
>      >     harder
>      >      > to see the relevant data.  Is there any way to only
>     display the
>      >     fields
>      >      > that actually have something in them?
>      >      >
>      >      > I see it's using Rapid's <field-list> to display fields.
>      Is there
>      >      > anything I can do to override <field-list>? Is there any
>     chance of
>      >      > <field-list> being updated to have the option of filtering
>     out null
>      >      > fields?
>      >      >
>      >      > Thanks!
>      >      >
>      >      > Steve.
> 
> 
> 
> > 


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to