[Rt-commit] rtir branch, 3.0/incident-children-config, updated. 2.6.1-486-gc317301
Ruslan Zakirov
ruz at bestpractical.com
Thu Oct 13 09:35:13 EDT 2011
The branch, 3.0/incident-children-config has been updated
via c317301e52bd528298ca00799ad2d497c86a1b04 (commit)
via ac7c63871715cc071f4733ac528aad523dbeeb61 (commit)
via 218e538cd2543ae2c412b24c92de4328898a285b (commit)
from 0902172dc373d65646cb067cd3d722cc8b9db5cf (commit)
Summary of changes:
html/NoAuth/js/jquery.uncheckable-radio-0.1.js | 72 ++++++++++++++++++++++++
html/RTIR/Create.html | 5 ++
html/RTIR/Elements/SelectIncident | 25 +++++++-
lib/RT/IR.pm | 2 +
4 files changed, 100 insertions(+), 4 deletions(-)
create mode 100644 html/NoAuth/js/jquery.uncheckable-radio-0.1.js
- Log -----------------------------------------------------------------
commit 218e538cd2543ae2c412b24c92de4328898a285b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Oct 13 13:57:50 2011 +0400
make selecting with radios more user friendly
* hide radio if we have only one Inc and it's required
* make radio uncheckable if incident optional
* show button next to input to make sure purpose is clear
diff --git a/html/RTIR/Elements/SelectIncident b/html/RTIR/Elements/SelectIncident
index 96f51af..c888ee8 100644
--- a/html/RTIR/Elements/SelectIncident
+++ b/html/RTIR/Elements/SelectIncident
@@ -11,9 +11,20 @@
ShowHeader => 0,
&>
% }
+% if ( $hide ) {
+ <input type="hidden" name="<% $Name %>" value="<% $potential[0] %>" />
+% }
<input type="text" name="<% $Name %>" size="16" maxsize="16" value="" />
-% if ( $config->{'Multiple'} ) {
- <input type="submit" name="<% "More$Name" %>" value="<% loc('More') %>" class="button" />
+% if ( $config->{'Multiple'} || @potential ) {
+ <input type="submit" name="<% "More$Name" %>" value="<% $config->{'Multiple'}? loc('More') : loc('Other') %>" class="button" />
+% }
+
+% if ( !$config->{'Required'} && $dformat =~ /RadioButton/ ) {
+<script type="text/javascript">
+//<![CDATA[
+jQuery(function(){ jQuery('input[type="radio"][name="<% $Name %>"]').uncheckable() });
+//]]>
+</script>
% }
</td>
</tr>
@@ -43,6 +54,12 @@ my $query = RT::IR->Query(
And => join ' OR ', map "id = $_", @potential
);
my $format = RT->Config->Get('RTIRSearchResultFormats')->{'LinkIncident'};
-my $dformat = '\'__'. ($config->{'Multiple'}? 'CheckBox' : 'RadioButton') .".{$Name}__\', "
- . $format;
+my ($dformat, $hide);
+if ( $config->{'Multiple'} ) {
+ $dformat = "'__CheckBox.{$Name}__', $format";
+} elsif ( @potential > 1 || !$config->{'Required'} ) {
+ $dformat = "'__RadioButton.{$Name}__', $format";
+} else {
+ ($dformat, $hide) = ($format, 1);
+}
</%INIT>
commit ac7c63871715cc071f4733ac528aad523dbeeb61
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Oct 13 17:29:47 2011 +0400
java script to make radios uncheckable
diff --git a/html/NoAuth/js/jquery.uncheckable-radio-0.1.js b/html/NoAuth/js/jquery.uncheckable-radio-0.1.js
new file mode 100644
index 0000000..0470a7f
--- /dev/null
+++ b/html/NoAuth/js/jquery.uncheckable-radio-0.1.js
@@ -0,0 +1,72 @@
+/**
+ * JQuery uncheckable radio plugin
+ *
+ * This plugin allow to unckeck radio buttons. Just call the plugin like this :
+ *
+ * jQuery('input[type="radio"]').uncheckable();
+ *
+ * It also add handlers on associated labels.
+ *
+ * @name jquery.uncheckable-radio-0.1.js
+ * @author Benoit Chenu <bchenu at gaya.fr>
+ * @copyright Copyright (c) 2002-2011 GAYA - La nouvelle agence - http://www.gaya.fr/
+ * @version 0.1
+**/
+
+(function($){
+
+ $.fn.extend({
+ uncheckable : function() {
+ return this.each(function() {
+ var $this = $(this);
+
+ $this.mousedown($this.ucr_getRadioSatus);
+ $this.click($this.ucr_setRadioSatus);
+
+ // Associated label with "for" attribute
+ if ($this.attr('id'))
+ {
+ $('label[for="'+$this.attr('id')+'"]').mousedown(function() {
+ $this.ucr_getRadioSatus();
+ });
+ /* Automatically called
+ $('label[for="'+$this.attr('id')+'"]').click(function() {
+ $this.ucr_setRadioSatus();
+ });
+ */
+ }
+
+ // Associated label defined as parent tag
+ $this.parents('label').each(function() {
+ // Check if handlers already defined
+ if ($this.attr('id') && $(this).attr('for') == $this.attr('id'))
+ return;
+
+ $(this).mousedown(function() {
+ $this.ucr_getRadioSatus();
+ });
+ /* Automatically called
+ $(this).click(function() {
+ $this.ucr_setRadioSatus();
+ });
+ */
+ });
+ });
+
+ },
+
+ ucr_getRadioSatus : function() {
+ _this = $(this).get(0);
+ _this.ucr_checked = $(_this).attr('checked');
+ },
+
+ ucr_setRadioSatus : function() {
+ _this = $(this).get(0);
+ if (_this.ucr_checked)
+ {
+ _this.ucr_checked = false;
+ $(_this).attr('checked', _this.ucr_checked);
+ }
+ }
+ });
+})(jQuery);;
\ No newline at end of file
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index e53ea66..8066aa9 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -77,6 +77,8 @@ my %TYPE = (
use Parse::BooleanLogic;
my $ticket_sql_parser = Parse::BooleanLogic->new;
+RT->AddJavaScript('jquery.uncheckable-radio-0.1.js');
+
=head1 FUNCTIONS
=head2 OurQueue
commit c317301e52bd528298ca00799ad2d497c86a1b04
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Oct 13 17:31:01 2011 +0400
if only one incident allowed then pick last
last is the one in the free form input box
diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index c452313..27ace84 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -369,6 +369,11 @@ foreach my $id ( grep $_, @Incident ) {
}
@Incident = map $_->id, @IncidentObj;
+if ( @Incident > 1 && !RT->Config->Get('RTIR_IncidentChildren')->{ $Type }{'Multiple'} ) {
+ push @{ $m->{'request_args'} }, Incident => $Incident[-1];
+ @Incident = ($Incident[-1]);
+}
+
$Subject ||= $IncidentObj[0]->Subject if @IncidentObj;
push @results, $m->comp( 'SELF:ProcessAttachments', %ARGS );
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list