[Rt-commit] rt branch, 4.4/ajax-edit-custom-fields, created. rt-4.4.0-53-ge808d61
Dustin Graves
dustin at bestpractical.com
Thu Feb 25 15:44:34 EST 2016
The branch, 4.4/ajax-edit-custom-fields has been created
at e808d61d224783177d5f09f2238f21ecd4889b89 (commit)
- Log -----------------------------------------------------------------
commit e808d61d224783177d5f09f2238f21ecd4889b89
Author: Dustin Graves <dustin at bestpractical.com>
Date: Thu Feb 25 00:58:41 2016 +0000
add ajax custom field loading and change basics page to use it as proof of concept
diff --git a/share/html/Elements/AjaxEditCustomFieldCustomGroupings b/share/html/Elements/AjaxEditCustomFieldCustomGroupings
new file mode 100644
index 0000000..00ee823
--- /dev/null
+++ b/share/html/Elements/AjaxEditCustomFieldCustomGroupings
@@ -0,0 +1,82 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%ARGS>
+$Object
+</%ARGS>
+<%INIT>
+my %params = %ARGS;
+delete $params{Object};
+
+my $url = RT->Config->Get('WebPath') . '/Helpers/EditCustomFieldCustomGroupings?'.
+ $m->comp('/Elements/QueryString', %params,
+ ClassName => ref $Object, ObjectId => $Object->id);
+</%INIT>
+
+<script type="text/javascript">
+jQuery(function() {
+ var customFieldPlaceholder = jQuery('#CustomFieldPlaceholder'),
+ customFieldForm = customFieldPlaceholder.closest('form');
+
+ var loadCustomFields = function() {
+ var queue, url;
+
+ customFieldPlaceholder.html('');
+
+ if (this.value) queue = jQuery(this).val();
+ url = '<% $url |n %>' + (queue ? '&Queue=' + queue : '');
+
+ customFieldPlaceholder.load(url);
+ }
+ customFieldForm.find('select[name=Queue]').change(loadCustomFields);
+ customFieldForm.find('input[name=Queue]').change(loadCustomFields);
+});
+</script>
+
+<div id="CustomFieldPlaceholder">
+ <& /Elements/EditCustomFieldCustomGroupings, %ARGS &>
+</div>
diff --git a/share/html/Elements/AjaxEditCustomFields b/share/html/Elements/AjaxEditCustomFields
new file mode 100644
index 0000000..2d949df
--- /dev/null
+++ b/share/html/Elements/AjaxEditCustomFields
@@ -0,0 +1,108 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%ARGS>
+$Object
+$Grouping => undef
+</%ARGS>
+<%INIT>
+my %params = %ARGS;
+delete $params{Object};
+
+my $url = RT->Config->Get('WebPath') . '/Helpers/EditCustomFields?'.
+ $m->comp('/Elements/QueryString', %params,
+ ClassName => ref $Object, ObjectId => $Object->id);
+
+my $placeholder_id = "CustomFieldPlaceholder" . ($Grouping || '');
+</%INIT>
+
+<script type="text/javascript">
+jQuery(function() {
+ var customFieldPlaceholder = jQuery('#<% $placeholder_id %>'),
+ customFieldForm = customFieldPlaceholder.closest('form');
+
+ var loadCustomFields = function() {
+ var queue, url;
+
+ customFieldPlaceholder.html('');
+
+ if (this.value) queue = jQuery(this).val();
+ url = '<% $url |n %>' + (queue ? '&Queue=' + queue : '');
+
+ customFieldPlaceholder.load(url, null, equalizeTables);
+ };
+
+ var equalizeTables = function() {
+ var titleBox = customFieldPlaceholder.closest('div.titlebox-content');
+ var tables = titleBox.find('table');
+
+ if (tables.length < 2) return;
+
+ var minWidth = 0;
+ tables.each(function () {
+ var currentTable = jQuery(this);
+ var currentWidth = currentTable.find('td').first().width();
+ if (currentWidth > minWidth) minWidth = currentWidth;
+ });
+ tables.each(function () {
+ var currentTable = jQuery(this);
+ var labelCell = currentTable.find('td').first();
+ var currentWidth = labelCell.width();
+ if (currentWidth < minWidth) labelCell.css('min-width', minWidth + 'px');
+ });
+ };
+
+ customFieldForm.find('select[name=Queue]').change(loadCustomFields);
+ customFieldForm.find('input[name=Queue]').change(loadCustomFields);
+
+ customFieldPlaceholder.each(equalizeTables);
+});
+</script>
+
+<div id="<% $placeholder_id %>">
+ <& /Elements/EditCustomFields, %ARGS &>
+</div>
diff --git a/share/html/Elements/EditCustomFields b/share/html/Elements/EditCustomFields
index 79174de..3b9123f 100644
--- a/share/html/Elements/EditCustomFields
+++ b/share/html/Elements/EditCustomFields
@@ -88,7 +88,12 @@
% $m->callback( CallbackName => 'AfterCustomFields', Object => $Object,
% Grouping => $Grouping, ARGSRef => \%ARGS );
<%INIT>
-$CustomFields ||= $Object->CustomFields;
+if (ref $Object eq 'RT::Ticket' && $Queue && !$CustomFields) {
+ $CustomFields = RT::CustomFields->new( $session{CurrentUser} );
+ $CustomFields->LimitToGlobalOrQueue( $Queue );
+} else {
+ $CustomFields ||= $Object->CustomFields;
+}
$CustomFields->LimitToGrouping( $Object => $Grouping ) if defined $Grouping;
@@ -116,4 +121,5 @@ $Grouping => undef
$AsTable => 1
$InTable => 0
$ShowHints => 1
+$Queue => undef
</%ARGS>
diff --git a/share/html/Helpers/EditCustomFieldCustomGroupings b/share/html/Helpers/EditCustomFieldCustomGroupings
new file mode 100644
index 0000000..05913f0
--- /dev/null
+++ b/share/html/Helpers/EditCustomFieldCustomGroupings
@@ -0,0 +1,63 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%args>
+$ClassName
+$ObjectId
+$Queue => undef
+</%args>
+<%init>
+my %params = %ARGS;
+delete $params{ClassName};
+delete $params{ObjectId};
+
+my $object = $ClassName->new( $session{CurrentUser} );
+$object->Load($ObjectId);
+$m->abort() unless $object->Id;
+</%init>
+<& /Elements/EditCustomFieldCustomGroupings, %params, Object => $object &>
+% $m->abort();
diff --git a/share/html/Helpers/EditCustomFields b/share/html/Helpers/EditCustomFields
new file mode 100644
index 0000000..fe0fcc4
--- /dev/null
+++ b/share/html/Helpers/EditCustomFields
@@ -0,0 +1,63 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%args>
+$ClassName
+$ObjectId
+$Queue => undef
+</%args>
+<%init>
+my %params = %ARGS;
+delete $params{ClassName};
+delete $params{ObjectId};
+
+my $object = $ClassName->new( $session{CurrentUser} );
+$object->Load($ObjectId);
+$m->abort() unless $object->Id;
+</%init>
+<& /Elements/EditCustomFields, %params, Object => $object &>
+% $m->abort();
diff --git a/share/html/Ticket/Modify.html b/share/html/Ticket/Modify.html
index fb8fb08..89a1d08 100644
--- a/share/html/Ticket/Modify.html
+++ b/share/html/Ticket/Modify.html
@@ -56,14 +56,14 @@
<input type="hidden" class="hidden" name="id" value="<% $TicketObj->Id %>" />
<&| /Widgets/TitleBox, title => loc('Modify ticket #[_1]',$TicketObj->Id), class=>'ticket-info-basics' &>
-<table>
-<& Elements/EditBasics, TicketObj => $TicketObj, defaults => \%ARGS, InTable => 1 &>
-<& /Elements/EditCustomFields, Object => $TicketObj, Grouping => 'Basics', InTable => 1 &>
-</table>
+%#<table>
+<& Elements/EditBasics, TicketObj => $TicketObj, defaults => \%ARGS &>
+<& /Elements/AjaxEditCustomFields, Object => $TicketObj, Grouping => 'Basics' &>
+%#</table>
</&>
% $m->callback( CallbackName => 'AfterBasics', Ticket => $TicketObj );
-<& /Elements/EditCustomFieldCustomGroupings, Object => $TicketObj &>
+<& /Elements/AjaxEditCustomFieldCustomGroupings, Object => $TicketObj &>
<& /Elements/Submit, Name => 'SubmitTicket', Label => loc('Save Changes'), Caption => loc("If you've updated anything above, be sure to"), color => "#993333" &>
</form>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list