X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=templates%2Ffactory%2Fmacros;h=59d6c925358a9cfa57a27f981a21ed927ab4f339;hb=12d8a77a713d5ed4f08414e5f34e96d45f60e2d3;hp=2442dd5d32b11bfb8b3273a3189f049127e4b9e3;hpb=77fb5cc34c9a87077dc65548f0d890b366e78c61;p=maypole.git diff --git a/templates/factory/macros b/templates/factory/macros index 2442dd5..59d6c92 100644 --- a/templates/factory/macros +++ b/templates/factory/macros @@ -7,13 +7,15 @@ system. =head2 link -This creates an to a command in the Apache::MVC system by catenating the base URL, table, command, and any arguments. #%] [% MACRO link(table, command, additional, label) BLOCK; - ''; + SET lnk = base _ "/" _ table _ "/" _ command _ "/" _ additional; + lnk = lnk | uri | html; + ''; label; ""; END; @@ -32,8 +34,8 @@ command for that object. Otherwise, it just displays the data. [% MACRO maybe_link_view(object) BLOCK; - IF object.table; # It's an object, i.e. a has-a - link(object.table, "view", object.id, object); + IF object.isa('Maypole::Model::Base'); + link(object.table, "view", object.id.join('/'), object); ELSE; object; END; @@ -52,20 +54,23 @@ for some. #%] [% MACRO display_line(item) BLOCK; - FOR col = classmetadata.columns; + FOR col = classmetadata.list_columns; NEXT IF col == "id"; ""; - IF col == "url"; - " "; item.url; ""; - ELSIF col == item.stringify_column; + IF col == "url" AND item.url; + ' '; item.url; ''; + ELSIF col == classmetadata.stringify_column; maybe_link_view(item); ELSE; - maybe_link_view(item.$col); + accessor = item.accessor_name(col); + maybe_link_view(item.$accessor); END; ""; END; + ''; button(item, "edit"); button(item, "delete"); + ""; END %] [%# @@ -77,11 +82,10 @@ This is a generic button, which performs an action on an object. #%] [% MACRO button(obj, action) BLOCK; %] - -
- -
- +[% IF obj.is_public(action) %] +
+
+[% END %] [% END %] [%# @@ -98,7 +102,7 @@ brewery) calls the accesor, and displays a list of the results. [% MACRO view_related(object) BLOCK; FOR accessor = classmetadata.related_accessors.list; - "

"; accessor | ucfirst; "

\n"; + "
"; accessor | ucfirst; "
\n"; "