From e06f52663e5bec7db2bf165fc7bffa2b495841da Mon Sep 17 00:00:00 2001 From: "jouni%heikniemi.net" <> Date: Mon, 12 Jul 2004 12:06:30 +0000 Subject: Bug 244265: Abstract out the typical admin page table to a separate template. r=vladd, a=justdave --- template/en/default/admin/keywords/list.html.tmpl | 88 ++++++++-------------- template/en/default/admin/table.html.tmpl | 92 +++++++++++++++++++++++ template/en/default/filterexceptions.pl | 10 +-- 3 files changed, 127 insertions(+), 63 deletions(-) create mode 100644 template/en/default/admin/table.html.tmpl diff --git a/template/en/default/admin/keywords/list.html.tmpl b/template/en/default/admin/keywords/list.html.tmpl index d73e529e3..fbfc92142 100755 --- a/template/en/default/admin/keywords/list.html.tmpl +++ b/template/en/default/admin/keywords/list.html.tmpl @@ -18,13 +18,12 @@ # # Contributor(s): Terry Weissman # Vlad Dascalu + # Jouni Heikniemi #%] [%# INTERFACE: - # max_table_size: number. Determines the maximum number of - # rows in each keywords table. # keywords: array with keyword objects having the properties: - # - keyword_id: number. The ID of the keyword. + # - id: number. The ID of the keyword. # - name: string. The name of the keyword. # - description: string. The description of the keyword. # - bug_count: number. The number of bugs with the keyword. @@ -36,62 +35,35 @@ title = "Select keyword" %] -[% max_table_size = 50 %] - -[% BLOCK table_header %] - - - - - - - -[% END %] - -[% BLOCK table_footer %] -
Edit keyword ...Description[% terms.Bugs %]Action
-[% END %] - -[% PROCESS table_header %] - -[% FOREACH keyword = keywords %] - [% IF !loop.first() && loop.count() % max_table_size == 1 %] - [% PROCESS table_header %] - [% END %] - - - - [% keyword.name FILTER html %] - - - [% IF keyword.description %] - [% keyword.description FILTER html %] - [% ELSE %] - missing - [% END %] - - - [% IF keyword.bug_count %] - [% keyword.bug_count %] - [% ELSE %] - none - [% END %] - - - Delete - - - - [% IF !loop.last() && loop.count() % max_table_size == 0 %] - [% PROCESS table_footer %] - [% END %] -[% END %] +[% columns = [ + { + name => "name" + heading => "Edit keyword..." + contentlink => "editkeywords.cgi?action=edit&id=%id%" + }, + { + name => "description" + heading => "Description" + }, + { + name => "bug_count" + heading => "Bugs" + align => "right" + }, + { + heading => "Action" + content => "Delete" + contentlink => "editkeywords.cgi?action=delete&id=%id%" + } + ] +%] - - Add a new keyword - Add - +[% PROCESS admin/table.html.tmpl + columns = columns + data = keywords + footer = footer_row +%] -[% PROCESS table_footer %] +

Add a new keyword

[% PROCESS global/footer.html.tmpl %] diff --git a/template/en/default/admin/table.html.tmpl b/template/en/default/admin/table.html.tmpl new file mode 100644 index 000000000..8647aea76 --- /dev/null +++ b/template/en/default/admin/table.html.tmpl @@ -0,0 +1,92 @@ +[%# 1.0@bugzilla.org %] +[%# The contents of this file are subject to the Mozilla Public + # License Version 1.1 (the "License"); you may not use this file + # except in compliance with the License. You may obtain a copy of + # the License at http://www.mozilla.org/MPL/ + # + # Software distributed under the License is distributed on an "AS + # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + # implied. See the License for the specific language governing + # rights and limitations under the License. + # + # The Original Code is the Bugzilla Bug Tracking System. + # + # The Initial Developer of the Original Code is Netscape Communications + # Corporation. Portions created by Netscape are + # Copyright (C) 1998 Netscape Communications Corporation. All + # Rights Reserved. + # + # Contributor(s): Jouni Heikniemi + # + #%] + +[%# INTERFACE: + # + # columns: + # array of hashes representing the columns in the table. + # Each hash contains data for a single column. Hash keys: + # name: Name of the field in the data param + # heading: The text to print at the header cell + # contentlink: URI to which the content of a data cell shall be linked to. + # Expressions of format %xxx% are replaced with value + # with the key xxx in data hash of the current row. + # content: If specified, the content of this variable is used + # instead of the data pulled from the current row. + # NOTE: This value is not HTML filtered at output! + # align: left/center/right. Controls the horizontal alignment of the + # text in the column. + # + # data: + # array of hashes representing the data for the table. + # Each hash contains data for a single row of data. The + # keys are column names from columns subhashes name field. + # + #%] + +[%################### TABLE HEADER ######################%] + + + + [% FOREACH c = columns %] + [%# Default to align left for headers %] + + [% END %] + + + +[%################### TABLE CONTENT ######################%] + +[% FOREACH row = data %] + + [% FOREACH c = columns %] + + [% END %] + +[% END %] + +[%################### TABLE FOOTER ######################%] + +
+ [% c.heading FILTER html %] +
+ + [% IF c.contentlink %] + [% link_uri = c.contentlink %] + [% FOREACH m = link_uri.match('%(.+?)%'); %] + [% replacement_value = FILTER url_quote; row.$m; END %] + [% link_uri = link_uri.replace("%$m%", replacement_value) %] + [% END %] + + [% END %] + + [% IF c.content %] + [% c.content %] + [% ELSE %] + [% row.${c.name} FILTER html %] + [% END %] + + [% IF c.contentlink %] + + [% END %] + +
diff --git a/template/en/default/filterexceptions.pl b/template/en/default/filterexceptions.pl index c030fa04f..3f9f9ab01 100644 --- a/template/en/default/filterexceptions.pl +++ b/template/en/default/filterexceptions.pl @@ -479,6 +479,11 @@ 'section_num' ], +'admin/table.html.tmpl' => [ + 'link_uri', + 'c.content' +], + 'admin/products/groupcontrol/confirm-edit.html.tmpl' => [ 'group.count', ], @@ -493,11 +498,6 @@ 'const.CONTROLMAPMANDATORY', ], -'admin/keywords/list.html.tmpl' => [ - 'keyword.id', - 'keyword.bug_count', -], - 'admin/keywords/edit.html.tmpl' => [ 'keyword_id', 'bug_count', -- cgit v1.2.3-24-g4f1b