From: Brian O'Connor Date: Sun, 12 Oct 2003 02:08:22 +0000 (+0000) Subject: Now supports rendering list view as list of PK. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=136556a6e9382e0baaf99539f24fff96d1810de3;p=dbsrgits%2FSQL-Translator.git Now supports rendering list view as list of PK. --- diff --git a/lib/SQL/Translator/Producer/Turnkey.pm b/lib/SQL/Translator/Producer/Turnkey.pm index 815c9c5..7b72866 100644 --- a/lib/SQL/Translator/Producer/Turnkey.pm +++ b/lib/SQL/Translator/Producer/Turnkey.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::Turnkey; # ------------------------------------------------------------------- -# $Id: Turnkey.pm,v 1.1.2.4 2003-10-10 21:32:41 allenday Exp $ +# $Id: Turnkey.pm,v 1.1.2.5 2003-10-12 02:08:22 boconnor Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Allen Day , # Ying Zhang @@ -23,7 +23,7 @@ package SQL::Translator::Producer::Turnkey; use strict; use vars qw[ $VERSION $DEBUG ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.1.2.4 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.1.2.5 $ =~ /(\d+)\.(\d+)/; $DEBUG = 1 unless defined $DEBUG; use SQL::Translator::Schema::Constants; @@ -315,6 +315,7 @@ sub render { # Assumption here that if it's not rendering on it's own dbobject # then it's a list. This will be updated when AtomLists are implemented -boconnor if(ref($dbobject) eq 'Turnkey::Model::[% package.key FILTER ucfirst %]') { + $self->focus("yes"); return(_render_record($dbobject)); } else { return(_render_list($dbobject)); } @@ -555,13 +556,16 @@ my $turnkey_template_tt2 = <<'EOF'; [% MACRO renderatom(atom, dbobject) SWITCH atom.name %] [- FOREACH package = linkable -] [% CASE '[- package.key FILTER ucfirst -]' %] - [% render[- package.key FILTER ucfirst -]Atom(atom.render(dbobject)) %] + [% render[- package.key FILTER ucfirst -]Atom(atom, dbobject) %] [- END -] [% CASE DEFAULT %] - [% renderlist(atom.render(dbobject)) %] + [% renderlist(atom, dbobject) %] [% END %] [- FOREACH package = linkable -] -[% MACRO render[- package.key FILTER ucfirst -]Atom(lstArr) BLOCK %] +[% MACRO render[- package.key FILTER ucfirst -]Atom(atom, dbobject) BLOCK %] + [% lstArr = atom.render(dbobject) %] + [% rowcount = 0 %] + [% IF atom.focus == "yes" %] [% FOREACH record = lstArr %] [% field = record.data %] [- pname = package.key FILTER ucfirst -] @@ -579,11 +583,20 @@ my $turnkey_template_tt2 = <<'EOF'; [- FOREACH field = packages.$pkey.columns_others -] [- field -][% obj2link(field.[- field -]) %] [- END -] -
+ [% IF (rowcount > 1) %]
[% END %] + [% rowcount = rowcount + 1 %] + [% END %] + [% ELSE %] + + [% FOREACH record = lstArr %] + [% record.id %]
+ [% END %] + [% END %] [% END %] [- END -] -[% MACRO renderlist(lstArr) BLOCK %] +[% MACRO renderlist(atom, dbobject) BLOCK %] + [% lstArr = atom.render(dbobject) %] [% FOREACH item = lstArr %] [% item %] [% END %]