[bugzilla-gnome-org-extensions] template overrides: Add attachment edit and list overrides for GnomeAttachmentStatus
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bugzilla-gnome-org-extensions] template overrides: Add attachment edit and list overrides for GnomeAttachmentStatus
- Date: Thu, 20 Nov 2014 22:06:33 +0000 (UTC)
commit ac760cf9b3e4d0551ce0ee240f7cdd4e1ca40d65
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Wed Nov 19 12:33:49 2014 +0100
template overrides: Add attachment edit and list overrides for GnomeAttachmentStatus
These are just copies taken from GnomeAttachmentStatus extension.
TemplateOverrides/lib/Util.pm | 2 +
.../template/en/default/attachment/edit.html.tmpl | 345 ++++++++++++++++++++
.../template/en/default/attachment/list.html.tmpl | 178 ++++++++++
3 files changed, 525 insertions(+), 0 deletions(-)
---
diff --git a/TemplateOverrides/lib/Util.pm b/TemplateOverrides/lib/Util.pm
index c546027..b3e6037 100644
--- a/TemplateOverrides/lib/Util.pm
+++ b/TemplateOverrides/lib/Util.pm
@@ -98,6 +98,8 @@ sub _check_overrides {
sub check_overridden_templates {
my ($silent) = @_;
my %digests = (
+ 'attachment/edit.html.tmpl' => '426ceeb820cefad35cbbf10ab053c1fc9f53fa71a63dd455418bff3221a46a0e',
+ 'attachment/list.html.tmpl' => 'b0c5edd84b8cc31666d0d0b4bf36cdb981ee322995dad891cf05f0f40b2d0392',
);
print "Checking overridden templates...\n" unless $silent;
diff --git a/TemplateOverrides/template/en/default/attachment/edit.html.tmpl
b/TemplateOverrides/template/en/default/attachment/edit.html.tmpl
new file mode 100644
index 0000000..6dceb31
--- /dev/null
+++ b/TemplateOverrides/template/en/default/attachment/edit.html.tmpl
@@ -0,0 +1,345 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ #
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
+ #%]
+
+[%# Define strings that will serve as the title and header of this page %]
+[% title = BLOCK %]
+ Attachment [% attachment.id %] Details for [% terms.Bug %] [%+ attachment.bug_id %]
+[% END %]
+[% header = BLOCK %]
+ Attachment [% attachment.id %] Details for
+ [%+ "$terms.Bug ${attachment.bug_id}" FILTER bug_link(attachment.bug_id) FILTER none %]
+[% END %]
+[% subheader = BLOCK %][% attachment.bug.short_desc FILTER html %][% END %]
+
+[% PROCESS global/header.html.tmpl
+ title = title
+ header = header
+ subheader = subheader
+ doc_section = "attachments.html"
+ javascript_urls = ['js/attachment.js', 'js/field.js',
'extensions/GnomeAttachmentStatus/web/gnome_attachment_status.js']
+ style_urls = ['skins/standard/attachment.css']
+ yui = [ 'autocomplete' ]
+ bodyclasses = "no_javascript"
+%]
+
+[%# No need to display the Diff button and iframe if the attachment is not a patch. %]
+[% use_patchviewer = (feature_enabled('patch_viewer') && attachment.ispatch) %]
+[% can_edit = attachment.validate_can_edit %]
+[% editable_or_hide = can_edit ? "" : " bz_hidden_option" %]
+
+<form method="post" action="attachment.cgi" onsubmit="normalizeComments();">
+ <input type="hidden" name="id" value="[% attachment.id %]">
+ <input type="hidden" name="action" value="update">
+ <input type="hidden" name="contenttypemethod" value="manual">
+ <input type="hidden" name="delta_ts" value="[% attachment.modification_time FILTER html %]">
+ [% IF user.id %]
+ <input type="hidden" name="token" value="[% issue_hash_token([attachment.id,
attachment.modification_time]) FILTER html %]">
+ [% END %]
+
+ <div id="attachment_info" class="attachment_info [% IF can_edit %] edit[% ELSE %] read[% END%]">
+ <div id="attachment_attributes">
+ <div id="attachment_information_read_only" class="[% "bz_private" IF attachment.isprivate %]">
+ <div class="title">
+ [% "[patch]" IF attachment.ispatch%]
+ <span class="[% "bz_obsolete" IF attachment.isobsolete %]" title="[% "obsolete" IF
attachment.isobsolete %]">
+ [% attachment.description FILTER html %]
+ </span>
+ [% IF can_edit %]
+ <span class="bz_edit">(<a href="javascript:toggle_attachment_details_visibility()">edit
details</a>)</span>
+ [% END %]
+ </div>
+ <div class="details">
+ [% attachment.filename FILTER html %] ([% attachment.contenttype FILTER html %]),
+ [% IF attachment.datasize %]
+ [%+ attachment.datasize FILTER unitconvert %]
+ [% ELSE %]
+ <em>deleted</em>
+ [% END %], created by [%+ INCLUDE global/user.html.tmpl who = attachment.attacher %] on [%+
attachment.attached FILTER time %]
+ [% IF attachment.isprivate %];
+ <span class="bz_private">only visible to <strong>[% Param('insidergroup') FILTER html
%]</strong> members</span>
+ [% END %]
+ </div>
+ </div>
+ <div id="attachment_information_edit">
+ <span class="bz_hide">
+ (<a href="javascript:toggle_attachment_details_visibility();">hide</a>)
+ </span>
+ <div id="attachment_description">
+ <label for="description">Description:</label>
+ [% INCLUDE global/textarea.html.tmpl
+ id = 'description'
+ name = 'description'
+ minrows = 3
+ cols = 25
+ wrap = 'soft'
+ classes = 'block' _ editable_or_hide
+ defaultcontent = attachment.description
+ %]
+ </div>
+
+ <div id="attachment_filename">
+ <label for="filename">Filename:</label>
+ <input type="text" size="20" class="text block[% editable_or_hide %]"
+ id="filename" name="filename"
+ value="[% attachment.filename FILTER html %]">
+ </div>
+
+ <div id="attachment_mimetype">
+ <label for="contenttypeentry">MIME Type:</label>
+ <input type="text" size="20" class="text block[% editable_or_hide %]"
+ id="contenttypeentry" name="contenttypeentry"
+ value="[% attachment.contenttype FILTER html %]">
+ </div>
+
+ <div id="attachment_creator">
+ <span class="label">Creator:</span>
+ [%+ INCLUDE global/user.html.tmpl who = attachment.attacher %]
+ </div>
+
+ <div id="attachment_created">
+ <span class="label">Created:</span>
+ [%+ attachment.attached FILTER time %]
+ </div>
+
+ <div id="attachment_size">
+ <span class="label">Size:</span>
+ [% IF attachment.datasize %]
+ [%+ attachment.datasize FILTER unitconvert %]
+ [% ELSE %]
+ <em>deleted</em>
+ [% END %]
+ </div>
+
+ <div id="attachment_ispatch">
+ <input type="checkbox" id="ispatch" name="ispatch" value="1"
+ [%+ 'checked="checked"' IF attachment.ispatch %]>
+ <label for="ispatch">patch</label>
+ </div>
+
+ <div class="readonly">
+ <div class="checkboxes">
+ <div id="attachment_isobsolete">
+ <input type="checkbox" id="isobsolete" name="isobsolete" value="1"
+ [%+ 'checked="checked"' IF attachment.isobsolete %]>
+ <label for="isobsolete">obsolete</label>
+ </div>
+
+ [% IF user.is_insider %]
+ <div id="attachment_isprivate">
+ <input type="checkbox" id="isprivate" name="isprivate" value="1"
+ [%+ 'checked="checked"' IF attachment.isprivate %]>
+ [% IF can_edit %]
+ <label for="isprivate">private (only visible to
+ <strong>[% Param('insidergroup') FILTER html %]</strong>)
+ </label>
+ [% ELSE %]
+ <span class="label">Is Private:</span>
+ [%+ attachment.isprivate ? "yes" : "no" %]
+ [% END %]
+ </div>
+ [% END %]
+ </div>
+ </div>
+ <div id="attachment_gnome_attachment_status_combo">
+ <input type="hidden" value="none" id="gnome_attachment_status_hidden"
name="gnome_attachment_status" [% IF attachment.ispatch %] disabled [% END %]/>
+ <b><label for="gnome_attachment_status">Status</label>:</b>
+ <select id="gnome_attachment_status_combo" name="gnome_attachment_status"
+ [% UNLESS attachment.ispatch %] disabled [% END %]>
+ [% FOREACH gnome_attachment_status = all_gnome_attachment_status_values %]
+ <option value="[% gnome_attachment_status.value FILTER html %]"
+ [% IF attachment.gnome_attachment_status == gnome_attachment_status.value %]
+ selected
+ [% END %]
+ >[% display_value("attachments.gnome_attachment_status", gnome_attachment_status.value)
%]</option>
+ [% END %]
+ </select>
+ </div>
+ </div>
+
+ <div id="attachment_view_window">
+ [% IF !attachment.datasize %]
+ <div><b>The content of this attachment has been deleted.</b></div>
+ [% ELSIF !Param("allow_attachment_display") %]
+ <div id="view_disabled">
+ <p><b>
+ The attachment is not viewable in your browser due to security
+ restrictions enabled by your [% terms.Bugzilla %] administrator.
+ </b></p>
+ <p><b>
+ In order to view the attachment, you first have to
+ <a href="attachment.cgi?id=[% attachment.id %]">download it</a>.
+ </b></p>
+ </div>
+ [% ELSIF attachment.is_viewable %]
+ <div>
+ [% INCLUDE global/textarea.html.tmpl
+ id = 'editFrame'
+ name = 'comment'
+ classes = 'bz_default_hidden'
+ minrows = 10
+ cols = 80
+ wrap = 'soft'
+ disabled = 'disabled'
+ defaultcontent = (attachment.contenttype.match('^text\/')) ?
+ attachment.data.replace('(.*\n|.+)', '>$1') : undef
+ %]
+ [% IF attachment.contenttype == 'text/plain' AND is_safe_url(attachment.data) %]
+ <p>
+ <a href="[% attachment.data FILTER html %]">
+ [% IF attachment.datasize < 120 %]
+ [% attachment.data FILTER html %]
+ [% ELSE %]
+ [% attachment.data FILTER truncate(80) FILTER html %]
+ ...
+ [% attachment.data.match('.*(.{20})$').0 FILTER html %]
+ [% END %]
+ </a>
+ </p>
+ [% ELSIF attachment.contenttype == "text/html" %]
+ [%# For security reasons (clickjacking, embedded scripts), we never
+ # render HTML pages from here. The source code is displayed instead. %]
+ [% INCLUDE global/textarea.html.tmpl
+ id = 'viewFrame'
+ minrows = 10
+ cols = 80
+ defaultcontent = attachment.data
+ readonly = 'readonly'
+ %]
+ [% ELSE %]
+ <iframe id="viewFrame" src="attachment.cgi?id=[% attachment.id %]">
+ <b>You cannot view the attachment while viewing its details because your browser does not
support IFRAMEs.
+ <a href="attachment.cgi?id=[% attachment.id %]">View the attachment on a separate
page</a>.</b>
+ </iframe>
+ [% END %]
+ <script type="text/javascript">
+ <!--
+ var patchviewerinstalled = 0;
+ var attachment_id = [% attachment.id %];
+ if (typeof document.getElementById == "function") {
+ [% IF use_patchviewer %]
+ var patchviewerinstalled = 1;
+ document.write('<iframe id="viewDiffFrame" class="bz_default_hidden"><\/iframe>');
+ [% END %]
+ [% IF user.id %]
+ document.write('<button type="button" id="editButton"
onclick="editAsComment(patchviewerinstalled);">Edit Attachment As Comment<\/button>');
+ document.write('<button type="button" id="undoEditButton"
onclick="undoEditAsComment(patchviewerinstalled);" class="bz_default_hidden">Undo Edit As Comment<\/button>');
+ document.write('<button type="button" id="redoEditButton"
onclick="redoEditAsComment(patchviewerinstalled);" class="bz_default_hidden">Redo Edit As Comment<\/button>');
+ var editFrame = document.getElementById('editFrame');
+ if (editFrame) {
+ editFrame.disabled = false;
+ }
+ [% END %]
+ [% IF use_patchviewer %]
+ document.write('<button type="button" id="viewDiffButton" onclick="viewDiff(attachment_id,
patchviewerinstalled);">View Attachment As Diff<\/button>');
+ [% END %]
+ document.write('<button type="button" id="viewRawButton"
onclick="viewRaw(patchviewerinstalled);" class="bz_default_hidden">View Attachment As Raw<\/button>');
+ }
+ //-->
+ </script>
+ </div>
+ [% ELSE %]
+ <div id="noview">
+ <p><b>
+ Attachment is not viewable in your browser because its MIME type
+ ([% attachment.contenttype FILTER html %]) is not one that your browser is
+ able to display.
+ </b></p>
+ <p><b>
+ <a href="attachment.cgi?id=[% attachment.id %]">Download the attachment</a>.
+ </b></p>
+ </div>
+ [% END %]
+ </div>
+ <div id="attachment_comments_and_flags">
+ [% IF user.id %]
+ <div id="smallCommentFrame" >
+ <label for="comment">Comment (on the [% terms.bug %]):</label>
+ [% classNames = 'block' %]
+ [% classNames = "$classes bz_private" IF attachment.isprivate %]
+ [% INCLUDE global/textarea.html.tmpl
+ id = 'comment'
+ name = 'comment'
+ minrows = 10
+ cols = 80
+ wrap = 'soft'
+ classes = classNames
+ %]
+ [% IF NOT attachment.bug.cc.contains(user.login) %]
+ <input type="checkbox" id="addselfcc" name="addselfcc"
+ [%~ ' checked="checked"'
+ IF user.settings.state_addselfcc.value == 'always'
+ || (!attachment.bug.user.has_any_role
+ && user.settings.state_addselfcc.value == 'cc_unless_role') %]>
+ <label for="addselfcc">Add me to CC list</label>
+ [% END %]
+ </div>
+ [% END %]
+ <div id="attachment_flags">
+ [% IF attachment.flag_types.size > 0 %]
+ [% PROCESS "flag/list.html.tmpl" flag_types = attachment.flag_types
+ read_only_flags = !can_edit
+ %]
+
+ [% END %]
+ </div>
+
+ [% Hook.process('form_before_submit') %]
+
+ [% IF user.id %]
+ <div id="update_container">
+ <input type="submit" value="Submit" id="update">
+ </div>
+ [% END %]
+ </div>
+ </div>
+ </div>
+</form>
+
+<div id="attachment_actions">
+ <span class="label">Actions:</span>
+ <a href="attachment.cgi?id=[% attachment.id %]">View</a>
+ [% IF use_patchviewer %]
+ | <a href="attachment.cgi?id=[% attachment.id %]&action=diff">Diff</a>
+ [% END %]
+ [% IF Param("allow_attachment_deletion")
+ && user.in_group('admin')
+ && attachment.datasize > 0 %]
+ | <a href="attachment.cgi?id=[% attachment.id %]&action=delete">Delete</a>
+ [% END %]
+ [% Hook.process('action') %]
+</div>
+
+<div id="attachment_list">
+ Attachments on [% "$terms.bug ${attachment.bug_id}" FILTER bug_link(attachment.bug_id) FILTER none %]:
+ [% FOREACH a = attachments %]
+ [% IF a.isobsolete %]
+ <span class="bz_obsolete">
+ [% END %]
+ [% IF a.id == attachment.id %]
+ [%+ a.id FILTER html %]
+ [% ELSE %]
+ <a href="attachment.cgi?id=[% a.id FILTER uri %]&action=edit"
+ title="[% a.description FILTER html %]">[% a.id FILTER html %]</a>
+ [% END %]
+ [% IF a.isobsolete %]
+ </span>
+ [% END %]
+ [% " |" UNLESS loop.last() %]
+ [% END %]
+</div>
+[% IF can_edit %]
+ <script type="text/javascript">
+ <!--
+ YAHOO.util.Dom.removeClass( document.body, "no_javascript" );
+ toggle_attachment_details_visibility( );
+ -->
+ </script>
+[% END %]
+[% Hook.process('end') %]
+
+[% PROCESS global/footer.html.tmpl %]
diff --git a/TemplateOverrides/template/en/default/attachment/list.html.tmpl
b/TemplateOverrides/template/en/default/attachment/list.html.tmpl
new file mode 100644
index 0000000..9818849
--- /dev/null
+++ b/TemplateOverrides/template/en/default/attachment/list.html.tmpl
@@ -0,0 +1,178 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ #
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
+ #%]
+
+[% RETURN UNLESS attachments.size || Param("maxattachmentsize") || Param("maxlocalattachment") %]
+
+<script type="text/javascript">
+<!--
+function toggle_display(link) {
+ var table = document.getElementById("attachment_table");
+ var view_all = document.getElementById("view_all");
+ var hide_obsolete_url_parameter = "&hide_obsolete=1";
+ // Store current height for scrolling later
+ var originalHeight = table.offsetHeight;
+ var rows = YAHOO.util.Dom.getElementsByClassName(
+ 'bz_tr_obsolete', 'tr', table);
+
+ for (var i = 0; i < rows.length; i++) {
+ bz_toggleClass(rows[i], 'bz_default_hidden');
+ }
+
+ if (YAHOO.util.Dom.hasClass(rows[0], 'bz_default_hidden')) {
+ link.innerHTML = "Show Obsolete";
+ view_all.href = view_all.href + hide_obsolete_url_parameter
+ }
+ else {
+ link.innerHTML = "Hide Obsolete";
+ view_all.href = view_all.href.replace(hide_obsolete_url_parameter,"");
+ }
+
+ var newHeight = table.offsetHeight;
+ // This scrolling makes the window appear to not move at all.
+ window.scrollBy(0, newHeight - originalHeight);
+
+ return false;
+}
+//-->
+</script>
+
+<br>
+<table id="attachment_table" cellspacing="0" cellpadding="4">
+ [% colspan = 2 %]
+ [% SET colspan = colspan + 1 IF show_attachment_flags %]
+ [% SET colspan = colspan + 1 IF show_gnome_attachment_status %]
+ <tr id="a0">
+ <th colspan="[% colspan %]" align="left">
+ Attachments
+ </th>
+ </tr>
+
+ [% count = 0 %]
+ [% obsolete_attachments = 0 %]
+ [% user_cache = template_cache.users %]
+
+ [% FOREACH attachment = attachments %]
+ [% count = count + 1 %]
+ [% IF !attachment.isprivate || user.is_insider || attachment.attacher.id == user.id %]
+ [% IF attachment.isobsolete %]
+ [% obsolete_attachments = obsolete_attachments + 1 %]
+ [% END %]
+ <tr id="a[% count %]" class="[% "bz_contenttype_" _ attachment.contenttype
+ FILTER css_class_quote %]
+ [% " bz_patch" IF attachment.ispatch %]
+ [% " bz_private" IF attachment.isprivate %]
+ [% " bz_tr_obsolete bz_default_hidden"
+ IF attachment.isobsolete %]">
+ <td valign="top">
+ [% IF attachment.datasize %]
+ <a href="attachment.cgi?id=[% attachment.id %]"
+ title="View the content of the attachment">
+ [% END %]
+ <b>[% attachment.description FILTER html FILTER obsolete(attachment.isobsolete) %]</b>
+ [% "</a>" IF attachment.datasize %]
+
+ <span class="bz_attach_extra_info">
+ [% IF attachment.datasize %]
+ ([% attachment.datasize FILTER unitconvert %],
+ [% IF attachment.ispatch %]
+ patch)
+ [% ELSE %]
+ [%+ attachment.contenttype FILTER html %])
+ [% END %]
+ [% ELSE %]
+ (<em>deleted</em>)
+ [% END %]
+
+ <br>
+ <a href="#attach_[% attachment.id %]"
+ title="Go to the comment associated with the attachment">
+ [%- attachment.attached FILTER time %]</a>,
+
+ [%# No need to recreate the exact same template if we already have it. %]
+ [% attacher_id = attachment.attacher.id %]
+ [% UNLESS user_cache.$attacher_id %]
+ [% user_cache.$attacher_id = BLOCK %]
+ [% INCLUDE global/user.html.tmpl who = attachment.attacher %]
+ [% END %]
+ [% END %]
+ [% user_cache.$attacher_id FILTER none %]
+ </span>
+ </td>
+
+ [% IF show_gnome_attachment_status %]
+ <td class="bz_attach_status" valign="top">
+ [% IF attachment.ispatch %]
+ [% attachment.gnome_attachment_status FILTER html %]
+ [% ELSE %]
+
+ [% END %]
+ </td>
+ [% END %]
+
+ [% IF show_attachment_flags %]
+ <td class="bz_attach_flags" valign="top">
+ [% IF attachment.flags.size == 0 %]
+ <i>no flags</i>
+ [% ELSE %]
+ [% FOREACH flag = attachment.flags %]
+ [% IF user.id %]
+ <span title="[% flag.setter.identity FILTER html %]">[% flag.setter.nick FILTER html
%]</span>:
+ [% ELSIF flag.setter.name %]
+ <span title="[% flag.setter.name FILTER html %]">[% flag.setter.nick FILTER html %]</span>:
+ [% ELSE %]
+ [% flag.setter.nick FILTER html %]:
+ [% END %]
+ [%+ flag.type.name FILTER html FILTER no_break %][% flag.status %]
+ [%+ IF flag.status == "?" && flag.requestee %]
+ [% IF user.id %]
+ (<span title="[% flag.requestee.identity FILTER html %]">[% flag.requestee.nick FILTER
html %]</span>)
+ [% ELSIF flag.requestee.name %]
+ (<span title="[% flag.requestee.name FILTER html %]">[% flag.requestee.nick FILTER html
%]</span>)
+ [% ELSE %]
+ ([% flag.requestee.nick FILTER html %])
+ [% END %]
+ [% END %]<br>
+ [% END %]
+ [% END %]
+ </td>
+ [% END %]
+
+ <td valign="top">
+ <a href="attachment.cgi?id=[% attachment.id %]&action=edit">Details</a>
+ [% IF attachment.ispatch && feature_enabled('patch_viewer') %]
+ | <a href="attachment.cgi?id=[% attachment.id %]&action=diff">Diff</a>
+ [% END %]
+ [% Hook.process("action") %]
+ </td>
+ </tr>
+ [% END %]
+ [% END %]
+
+ <tr class="bz_attach_footer">
+ <td colspan="[% colspan %]">
+ [% IF attachments.size %]
+ <span class="bz_attach_view_hide">
+ [% IF obsolete_attachments %]
+ <a href="#a0" onclick="return toggle_display(this);">Show
+ Obsolete</a> ([% obsolete_attachments %])
+ [% END %]
+ [% IF Param("allow_attachment_display") %]
+ <a id="view_all" href="attachment.cgi?bugid=
+ [%- bugid %]&action=viewall
+ [%- "&hide_obsolete=1" IF obsolete_attachments %]">View All</a>
+ [% END %]
+ </span>
+ [% END %]
+ [% IF Param("maxattachmentsize") || Param("maxlocalattachment") %]
+ <a href="attachment.cgi?bugid=[% bugid %]&action=enter">Add an attachment</a>
+ (proposed patch, testcase, etc.)
+ [% END %]
+ </td>
+ </tr>
+</table>
+<br>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]