-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stefan, looks so great! :)

Abrazo, Ibon.

Usa Software Libre, tus úlceras te lo agradecerán
Realizado con Software Libre.
- --
GPG public key at http://sinanimodelucro.net/ibon_gmail.asc
Finderprint: 1761 59B9 6DE6 0402 31B9 1872 178F A6FD 75F9 EB29

El 27/10/14 a las 11:57, Stefan Haslinger escribió:
> A small follow up, I wanted a nicely nested reusable
> tree-select-one for assigning a single record of one model in a
> belongs_to relation to a tree-structured model. So I modified (and
> simplified kicking out most of the options) the select-one tag like
> this:
> 
> <def attrs='include-none' tag='tree-select-one'><%
> 
> options = 
> this_field_reflection.klass.*sort_by_ancestry*(this_field_reflection.klass.all)
>
> 
*{|a, b| a.position <=> b.position}*
> 
> select_options = options.map { |x| [(*"&nbsp; &nbsp; &nbsp;" * 
> x.depth + "‣ " +* name(:with => x, :no_wrapper => 
> true))*.html_safe*,
> 
> x.id] }
> 
> attributes = add_classes(attributes, "input", "belongs_to", 
> type_and_field)
> 
> -%>
> 
> 
> <select name='#{param_name_for_this(true)}' 
> merge-attrs='&amp;attributes.except :name'>
> 
> <%= options_for_select(select_options, this ? this.id : "") %>
> 
> </select>
> 
> </def>
> 
> 
> The modification is mainly two ideas combined: - Using Ancestry's
> capabilty of creating a properly sorted array using the
> sort_by_ancestry method - Indenting the items with a formatting
> 
> It looks like this
> 
> <https://lh3.googleusercontent.com/-M4EjKg5xmWM/VE4jqPCsXZI/AAAAAAAAAVQ/KLBVYvD_xxo/s1600/tree-select-one.png>
>
>  and is called like this:
> 
> <extend tag="form" for="ContentElement">
> 
> <old-form merge>
> 
> <field-list: fields=" ... attributes as usual ... , *folder*"
> param>
> 
> *<folder-view:>*
> 
> *<tree-select-one />*
> 
> *</folder-view:>*
> 
> </field-list:>
> 
> </old-form>
> 
> </extend>
> 
> 
> Ciao, Stefan
> 
> -- You received this message because you are subscribed to the
> Google Groups "Hobo Users" group. To unsubscribe from this group
> and stop receiving emails from it, send an email to
> [email protected] 
> <mailto:[email protected]>. To post to this
> group, send email to [email protected] 
> <mailto:[email protected]>. Visit this group at
> http://groups.google.com/group/hobousers. For more options, visit
> https://groups.google.com/d/optout.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAlROXeYACgkQF4+m/XX56ykeowCghzu7bXJCUmPb7iExQiSIqhx3
zvcAoJd7ei6EQ3r+w1eM2LNFwhXVoZUN
=xn2O
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to