[Bast-commits] r3181 - trunk/Anything/root/base
castaway at dev.catalyst.perl.org
castaway at dev.catalyst.perl.org
Sun Apr 8 02:08:31 GMT 2007
Author: castaway
Date: 2007-04-08 02:08:30 +0100 (Sun, 08 Apr 2007)
New Revision: 3181
Added:
trunk/Anything/root/base/Field_edit.tt
trunk/Anything/root/base/Field_name.tt
trunk/Anything/root/base/Field_view.tt
trunk/Anything/root/base/Field_viewshort.tt
trunk/Anything/root/base/ttform.tt
Log:
Templates for forms system attempt
Added: trunk/Anything/root/base/Field_edit.tt
===================================================================
--- trunk/Anything/root/base/Field_edit.tt (rev 0)
+++ trunk/Anything/root/base/Field_edit.tt 2007-04-08 01:08:30 UTC (rev 3181)
@@ -0,0 +1,20 @@
+[% SET value = row.get_field(column) IF !value;
+ SET inputname = value.get_inputname;
+ ## Store size/type in the Field?
+ SET size = row.column_info(column).size IF row.has_column(column);
+ relvalues = item.related_items(column);
+%]
+[% IF use_related && relvalues.count %]
+ <select name=" [% column %]>
+ [% WHILE (item = relvalues.next) %]
+ <option value="[% item.ID %]" [% IF value == item.ID %] selected [% END %]>[% item.Name %]</option>
+ [% END %]
+ </select>
+[% ELSE %]
+ [% IF size && size > 255 %]
+ <textarea name="[% inputname %]" value="[% value || '' %]" />
+ [% ELSE %]
+ <input type="textfield" name="[% inputname %]" value="[% value || ''%]" />
+ [% END %]
+[% END %]
+
Added: trunk/Anything/root/base/Field_name.tt
===================================================================
--- trunk/Anything/root/base/Field_name.tt (rev 0)
+++ trunk/Anything/root/base/Field_name.tt 2007-04-08 01:08:30 UTC (rev 3181)
@@ -0,0 +1,10 @@
+[% SET value = column IF !value;
+ namespace = row.related_namespace(column);
+ '<span class="input_field">';
+ IF use_related && namespace;
+%]
+ <a href="[% uri_for_list(namespace, link_params) %]">[% value | $filter %]</a>
+[% ELSE %]
+ [% value | $filter %]
+[% END %]
+ </span>
Added: trunk/Anything/root/base/Field_view.tt
===================================================================
--- trunk/Anything/root/base/Field_view.tt (rev 0)
+++ trunk/Anything/root/base/Field_view.tt 2007-04-08 01:08:30 UTC (rev 3181)
@@ -0,0 +1,13 @@
+[%
+ namespace = item.related_namespace(column);
+ SET value = row.get_field(column) IF !value;
+ IF use_related && namespace;
+ SET value = row.$column;
+ link_params.push(value.id)
+%]
+ <a href="[% uri_for_list(namespace, link_params) %]">[% value | $filter %]</a>
+[% ELSE %]
+ [% value | $filter %]
+[% END %]
+
+
Added: trunk/Anything/root/base/Field_viewshort.tt
===================================================================
--- trunk/Anything/root/base/Field_viewshort.tt (rev 0)
+++ trunk/Anything/root/base/Field_viewshort.tt 2007-04-08 01:08:30 UTC (rev 3181)
@@ -0,0 +1,10 @@
+[%# - INCLUDE $fieldtype_$displaytype rs = , row =, column =, value = , use_related = , env = c %]
+[% IF use_related;
+ namespace = is_relation(rs, column);
+ IF namespace %]
+ <a href="[% uri_for_list(namespace, link_params) %]">[% column_moniker.$column | $filter %]</a>
+ [% END %]
+[% ELSE %]
+ [% SET value = row.get_column(column) IF !value %]
+ [% value | $filter %]
+[% END %]
Added: trunk/Anything/root/base/ttform.tt
===================================================================
--- trunk/Anything/root/base/ttform.tt (rev 0)
+++ trunk/Anything/root/base/ttform.tt 2007-04-08 01:08:30 UTC (rev 3181)
@@ -0,0 +1,17 @@
+[% MACRO to_field(row, column, displaytype, use_related, link_params, value, filter, fieldtype) BLOCK;
+ SET fieldtype = row.get_field(column).fieldtype IF !fieldtype;
+# SET fieldtype = 'Field' IF !fieldtype;
+## remove filter and replace it by asking the fieldtype!
+ SET filter = 'html' IF !filter;
+# fieldtype; ' ';displaytype;
+ SET filename = fieldtype.Name _ '_' _ displaytype _ '.tt';
+ TRY;
+ PROCESS $filename;
+ CATCH file;
+ # Eww, evil string matching.
+ THROW error.type error.info IF error.info != filename _ ': not found';
+# THROW file "Cannot find " _ displaytype _ " template (even in parent types) for " _ column IF fieldtype.ID == 0;
+
+ to_field(row, column, displaytype, use_related, link_params, value, filter, fieldtype.ParentID) IF fieldtype.ParentID;
+ END;
+END %]
\ No newline at end of file
More information about the Bast-commits
mailing list