4 from turbogears import widgets
6 class CustomTextField(widgets.TextField):
7 """Un input con un div al lado para ponerle info"""
9 <span xmlns:py="http://purl.org/kid/ns#">
13 class="${field_class}"
18 <span id="${field_id}_info" />
22 AlumnoMultiSelectAjax = '''
24 function _on_alumno_get_result(lista, results)
26 load.style.visibility = 'hidden';
31 MochiKit.DOM.appendChildNodes(lista, OPTION(results.msg));
34 function _on_alumno_get_error(results)
37 load.style.visibility = 'hidden';
40 function agregar_a_la_lista(texto, lista)
42 load = MochiKit.DOM.getElement('loading');
43 load.style.visibility = 'visible';
44 t = MochiKit.DOM.getElement(texto);
45 url = "/grupo/get_inscripto?cursoid=1&padron="+t.value;
46 var d = loadJSONDoc(url);
47 d.addCallbacks(partial(_on_alumno_get_result, lista), _on_alumno_get_error);
51 function sacar_de_la_lista(lista)
53 l = MochiKit.DOM.getElement(lista);
54 if (l.selectedIndex < 0) return;
56 /* caso especial, 1 solo item */
57 if (l.options.length == 1) {
62 for (i=l.selectedIndex; i<l.options.length-1;i++)
63 l.options[i] = l.options[i+1];
67 class AlumnoMultiSelect(widgets.MultipleSelectField):
69 <table xmlns:py="http://purl.org/kid/ns#" style="border:none; width:0%;">
71 <input type="text" id="${field_id}_nuevo" />
72 <img src="/static/images/loading.gif" align="baseline" style="visibility:hidden;" id="loading" width="16px" height="16px" />
73 <input type="button" id="_agregar" value="Agregar"
74 onClick=" agregar_a_la_lista('${field_id}_nuevo', '${field_id}'); " />
81 class="${field_class}"
86 <optgroup py:for="group, options in grouped_options"
90 <option py:for="value, desc, attrs in options"
98 <tr><td align="center">
99 <input type="button" id="_sacar" value="Borrar"
100 onClick="sacar_de_la_lista('${field_id}'); " />
104 javascript = [widgets.JSSource(AlumnoMultiSelectAjax)]