Commits

Olemis Lang committed b055784

BH Dashboard #146 : Inplace editor for ticket radio fields

Comments (0)

Files changed (1)

t146/t146_r1386655_bheditable.diff

 
 diff -r 90cba6d98860 bhdashboard/htdocs/js/bheditable.js
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/bhdashboard/htdocs/js/bheditable.js	Sat Sep 29 23:26:49 2012 -0500
-@@ -0,0 +1,204 @@
++++ b/bhdashboard/htdocs/js/bheditable.js	Sun Sep 30 02:12:55 2012 -0500
+@@ -0,0 +1,259 @@
 +/*
 +  Licensed to the Apache Software Foundation (ASF) under one
 +  or more contributor license agreements.  See the NOTICE file
 +        }
 +    });
 +
++  $.editable.addInputType('bhradio', 
++    {
++      element : function(settings, original) {
++          var dropdown = $('<div />').addClass('dropdown');
++          var label_box = $('<span />').addClass('uneditable-input')
++              .appendTo(dropdown);
++          var old_value = $( $.trim(original.revert) ).text();
++          $('<del />').text(old_value).appendTo(label_box);
++          var ul = $('<ul />').addClass('dropdown-menu').attr('role', 'menu')
++              .appendTo(dropdown);
++          var hidden = $('<input />').attr('type', 'hidden').appendTo(ul);
++          $(this).append(dropdown);
++          return(hidden);
++        },
++      content : function(data, settings, original) {
++          if (String == data.constructor)
++            /* If it is string assume it is json. */
++            var json = $.parseJSON(data);
++          else
++            /* Otherwise assume it is a hash already. */
++            var json = data;
++
++          /* Add options */
++          var options = json.options;
++          var origval = $.trim(original.revert);
++          for (var i=0; i < options.length; ++i) {
++            var o = options[i];
++            if (String == o.constructor)
++              v = t = o;
++            else {
++              v = o[0]; t = o[1];
++            }
++            var li = $('<li />');
++            var form = this;
++            var do_submit = !settings.submit;
++            var input = $('<input />').attr('type', 'radio').val(v);
++            var label = $('<label />').append(input).append(' '+t).appendTo(li);
++            if ((v === json['selected']) || (t === origval))
++              input.attr('checked', 'true');
++            $('ul', this).append(li);
++          }
++
++          /* Submit on click if no submit button defined. */
++          if (!settings.submit) {
++            var form = this;
++            $('input[type="radio"]', this).click(function() {
++                form.submit();
++            });
++          }
++        },
++      submit : function(settings, original) {
++          // TODO: Set value of hidden input according to selection
++        }
++    });
++
 + /* BLODDHOUND EDITABLE DATA-API
 +  * ============================ */
 +
 +
 diff -r 90cba6d98860 bhdashboard/htdocs/js/jquery.json.js
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/bhdashboard/htdocs/js/jquery.json.js	Sat Sep 29 23:26:49 2012 -0500
++++ b/bhdashboard/htdocs/js/jquery.json.js	Sun Sep 30 02:12:55 2012 -0500
 @@ -0,0 +1,23 @@
 +
 +(function($){var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};$.toJSON=typeof JSON==='object'&&JSON.stringify?JSON.stringify:function(o){if(o===null){return'null';}
 \ No newline at end of file
 diff -r 90cba6d98860 bhdashboard/util.py
 --- a/bhdashboard/util.py	Sat Sep 29 22:55:19 2012 -0500
-+++ b/bhdashboard/util.py	Sat Sep 29 23:26:49 2012 -0500
++++ b/bhdashboard/util.py	Sun Sep 30 02:12:55 2012 -0500
 @@ -176,6 +176,17 @@
      )