X-Git-Url: https://git.llucax.com/software/sercom.git/blobdiff_plain/cc39dd201027d32cadcca25f954291432c43d1af..2c23f36223624514f3ad84a7c629792a27e74a68:/sercom/widgets.py diff --git a/sercom/widgets.py b/sercom/widgets.py index 309adc0..218fb3a 100644 --- a/sercom/widgets.py +++ b/sercom/widgets.py @@ -20,10 +20,31 @@ class CustomTextField(widgets.TextField): ''' AlumnoMultiSelectAjax = ''' + + function _on_alumno_get_result(lista, results) + { + load.style.visibility = 'hidden'; + if (results.error) { + alert(results.msg); + return; + } + MochiKit.DOM.appendChildNodes(lista, OPTION(results.msg)); + } + + function _on_alumno_get_error(results) + { + alert(results) + load.style.visibility = 'hidden'; + } + function agregar_a_la_lista(texto, lista) { + load = MochiKit.DOM.getElement('loading'); + load.style.visibility = 'visible'; t = MochiKit.DOM.getElement(texto); - MochiKit.DOM.appendChildNodes(lista, OPTION(t.value)); + url = "/grupo/get_inscripto?cursoid=1&padron="+t.value; + var d = loadJSONDoc(url); + d.addCallbacks(partial(_on_alumno_get_result, lista), _on_alumno_get_error); t.value = ""; } @@ -31,6 +52,12 @@ AlumnoMultiSelectAjax = ''' { l = MochiKit.DOM.getElement(lista); if (l.selectedIndex < 0) return; + + /* caso especial, 1 solo item */ + if (l.options.length == 1) { + l.options.length = 0 + return; + } for (i=l.selectedIndex; i - + +