Mojolicious-Plugin-Tables

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/Tables/resources/templates/tables/view.html.ep  view on Meta::CPAN

                        % my $label  = $cinfo->{label};
                        % my $ptable = $cinfo->{ptable};
                        % my $val    = $row->$column;
                        % my $id     = ref $val? $val->id: $val;
                        %= label_for $column => "* $label", title => "$column -> $ptable.$fkey"
                        %= t span => (id=>$column, class=>"data") => begin
                            % if (defined $id) {
                                % my $url = url_for("/tables/$ptable/$id/view");
                                %= link_to $row->present($column, $cinfo) => $url
                            % } else {
                                 
                            % }
                        % end
                    % } elsif ($cinfo->{is_foreign_key} && $cinfo->{parent}) {
                        % my $parent = $cinfo->{parent};
                        % my $pinfo  = $bycolumn->{$parent};
                        % my $ptable = $pinfo->{ptable};
                        % my $val    = $row->$column;
                        %= label_for $column => "* $pinfo->{label}", title => "$column -> $parent"
                        %= t span => (id=>$column, class=>"data") => ($val||'')
                        %= t span => (id=>$parent, class=>"data") => begin
                            % if (defined $val) {
                                % my $url = url_for("/tables/$ptable/$val/view");
                                %= link_to $row->present($parent, $pinfo) => $url
                            % } else {
                                 
                            % }
                        % end
                    % } elsif (!$fkey) {
                        %= label_for $column => $cinfo->{label}, title => $column
                        %= t span => (id=>$column, class=>"data") => $row->present($column, $cinfo)
                    % }
                % end
            % }
        %= include 'view_extra_100'
        % end

        % if (my $child = stash('child')) {

            % my $ginfo  = $tinfo->{has_many}{$child} || die "$child is no child of $table";
            % my $ctable = $ginfo->{ctable};
            % my $cfkey  = $ginfo->{cfkey};
            %= t fieldset => begin
                %= t legend => "Add to $ginfo->{label} of $row"
                % my $save_url = url_for("/tables/$ctable/save")->query(redirect_to=>"/tables/$table/$id/view");
                %= form_for $save_url => (method=>'post') => begin
                    %= $save_buts->();
                    %= include 'tables/dml', ptable=>$table, table=>$ctable, dml_mode=>'add', parent_id=>$id, cfkey=>$cfkey, child=>$child
                % end
            % end

        % } else {
            %= t div => (class=>"ui-helper-clearfix") => begin
                % for my $grp (keys %{$tinfo->{has_many}}) {
                    % my $ginfo    = $tinfo->{has_many}{$grp};
                    % my $ctable   = $ginfo->{ctable};
                    % my $cpkey    = $ginfo->{cpkey};
                    % my $total    = $row->$grp->count;
                    % my @children = $row->$grp({}, {order_by=>{-asc=>$cpkey}, rows=>10});
                    % my $to       = scalar(@children);
                    % my %cdata    = ('data-ctable'     => $ctable,
                    %                 'data-collection' => $grp,
                    %                 'data-to'         => $to,
                    %                 'data-total'      => $total);
                    %= t fieldset => (class=>"group", %cdata) => begin
                        % my $nums = @children? sprintf('1 to %d of %d', $to, $total): 'none';
                        %= t legend => (title=>$grp) => begin
                            %== qq[$ginfo->{label}&nbsp;&mdash;&nbsp;<span class="numbers">$nums</span>]
                        % end
                        %= t div => begin
                            %= $paging_buts2->();
                            %= t table => (class=>'rows') => begin
                                % for my $child (@children) {
                                    % my $ckey = $child->compound_ids;
                                    %= t tr => begin
                                        %= t td => begin
                                            %= link_to $child => url_for("/tables/$ctable/$ckey/view")
                                        % end
                                    % end
                                % }
                            % end
                        % end
                    % end
                % }
            % end
        % }
    </div>

    <h3>Schema</h3>
    <div class="pad12">
        %= t h3 => begin
            %= t span => (title=>'Label')         => $tinfo->{label}
            /
            %= t span => (title=>'DB SourceName') => $tinfo->{source}
            /
            %= t span => (title=>'DB Name')       => $table
        % end
        %= t table => (id=>'sources-table') => begin
            %= t tr => begin
                %= t th => 'Label'
                %= t th => 'DB Name'
                %= t th => 'Primary Key'
                %= t th => 'Type'
                %= t th => 'Size'
                %= t th => 'Sequence'
                %= t th => 'Nullable?'
                %= t th => 'Refers To'
                %= t th => 'Referred From'
            % end
            % for my $column (@{$tinfo->{columns}}) {
                % my $info = $bycolumn->{$column};
                %= t tr => begin
                    %= t td => ($info->{label} . ($info->{fkey}?' *':''))
                    %= t td => $column
                    %= t td => $info->{is_primary_key}||''
                    %= t td => $info->{data_type}||''
                    %= t td => $info->{size}||''
                    %= t td => $info->{sequence}||''
                    %= t td => ($info->{is_nullable}?'Y':'')
                    %= t td => $info->{parent}||''
                    %= t td => $info->{fkey}||''
                % end
            % }
            % for my $grp (keys %{$tinfo->{has_many}}) {
                % my $ginfo = $tinfo->{has_many}{$grp};



( run in 0.493 second using v1.01-cache-2.11-cpan-d8267643d1d )