]> git.decadent.org.uk Git - maypole.git/commitdiff
Make the view page a bit prettier, and link has-a and url links nicely.
authorSimon Cozens <simon@simon-cozens.org>
Sat, 31 Jan 2004 14:02:15 +0000 (14:02 +0000)
committerSimon Cozens <simon@simon-cozens.org>
Sat, 31 Jan 2004 14:02:15 +0000 (14:02 +0000)
git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@23 48953598-375a-da11-a14b-00016c27c3ee

templates/factory/edit
templates/factory/list
templates/factory/list_macros [deleted file]
templates/factory/macros [new file with mode: 0644]
templates/factory/view

index 11a25393c11a6644951fb483e7cbf162c93d7100..712348a074635240665f574b5185e9e8f98a293f 100644 (file)
@@ -1,4 +1,4 @@
-[% PROCESS list_macros %]
+[% PROCESS macros %]
 [% INCLUDE header %]
 
 [% FOR item = objects; %]
index 69bb8680a8aa18820b83e3d1867d84b536cab702..5bd6a10f628edb0d2a39d57a7ebf28829f1786ff 100644 (file)
@@ -1,4 +1,4 @@
-[% PROCESS list_macros %]
+[% PROCESS macros %]
 
 [% INCLUDE header %]
 
diff --git a/templates/factory/list_macros b/templates/factory/list_macros
deleted file mode 100644 (file)
index 0a88996..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-[% MACRO display_line(item) BLOCK;
-     FOR col = classmetadata.columns;
-        NEXT IF col == "id";
-        "<td>";
-        "<A HREF='" _ base _ item.$col.moniker _ "/view/" _ 
-            item.$col.id _"'>" IF item.$col.moniker; # it's an object
-        item.$col;
-        "</A>" IF item.$col.moniker; 
-        "</td>";
-     END;
-    button(item, "edit");
-    button(item, "delete");
-END %]
-[% MACRO button(obj, action) BLOCK; %]
-
-<TD>
-<FORM METHOD="post" ACTION="[%base%]/[%classmetadata.moniker%]/[%action%]/[%obj.id%]">
-    <INPUT TYPE="submit" NAME="[%action%]" VALUE="[%action%]">
-</FORM>
-</TD>
-[% END %]
-
diff --git a/templates/factory/macros b/templates/factory/macros
new file mode 100644 (file)
index 0000000..b9b8dee
--- /dev/null
@@ -0,0 +1,34 @@
+[% MACRO maybe_link_view(object) BLOCK;
+    IF object.moniker; # It's an object, i.e. a has-a
+        "<A HREF='" _ base _ object.moniker _ "/view/" _ object.id _"'>";
+        object;
+        "</A>";
+    ELSE;
+        object;
+    END;
+END;
+%]
+
+[% MACRO display_line(item) BLOCK;
+     FOR col = classmetadata.columns;
+        NEXT IF col == "id";
+        "<td>";
+        IF col == "url";  # Possibly too much magic.
+            "<A HREF="; item.url; "> "; item.url; "</A>";
+        ELSE;
+            maybe_link_view(item.$col);
+        END;
+        "</td>";
+     END;
+    button(item, "edit");
+    button(item, "delete");
+END %]
+
+[% MACRO button(obj, action) BLOCK; %]
+<TD>
+<FORM METHOD="post" ACTION="[%base%]/[%obj.moniker%]/[%action%]/[%obj.id%]">
+    <INPUT TYPE="submit" NAME="[%action%]" VALUE="[%action%]">
+</FORM>
+</TD>
+[% END %]
+
index 48dec99074ebdb887c4cdb4056cbba6898805e2c..861e8761184e6dc33911aa2d1fe090cbeb81e24b 100644 (file)
@@ -1,26 +1,27 @@
-[% MACRO button(obj, action) BLOCK; %]
-
-<TD>
-<FORM METHOD="post" ACTION="[%base%]/[%classmetadata.moniker%]/[%action%]/[%obj.id%]">
-    <INPUT TYPE="submit" NAME="[%action%]" VALUE="[%action%]">
-</FORM>
-</TD>
-[% END %]
-
+[% PROCESS macros %]
 [% INCLUDE header %]
 
 [% FOR item = objects %]
 <h2> [% item.name %]</h2>
 
-[% FOR col = classmetadata.columns.list;
-    NEXT IF col == "id";
-    "<P>";
-    classmetadata.colnames.$col; ":";
-    " "; item.$col;"</p>";
-     END;
+[% INCLUDE navbar %]
+
+<TABLE class="view">
+[% 
+    FOR col = classmetadata.columns.list;
+    NEXT IF col == "id" OR col == "name";
+%]
+
+<TR>
+    <TD class="field"> [% classmetadata.colnames.$col; %] </TD>
+    <TD> [% maybe_link_view(item.$col) %] </TD>
+</TR>
+[% END; %]
+</TABLE>
+[%
     button(item, "edit");
     button(item, "delete");
-    "</tr>";
-END;
 %]
+</TABLE>
+[% END; %]