X-Git-Url: https://git.llucax.com/software/sercom.git/blobdiff_plain/db587d0d4ce6518b3c4f8cf18989fc1f65b40c5e..93ce2f28524a30624e197e523bf286efc7403a90:/sercom/widgets.py?ds=sidebyside diff --git a/sercom/widgets.py b/sercom/widgets.py index 08adea7..612d950 100644 --- a/sercom/widgets.py +++ b/sercom/widgets.py @@ -17,4 +17,94 @@ class CustomTextField(widgets.TextField): /> +''' + +MultiSelectAjax = ''' + + function _on_alumno_get_result(lista, loading, results) + { + load = MochiKit.DOM.getElement(loading); + load.style.visibility = 'hidden'; + if (results.error) { + alert(results.msg); + return; + } + MochiKit.DOM.appendChildNodes(lista, OPTION({'value':results.msg.id}, results.msg.value)); + l = MochiKit.DOM.getElement(lista); + } + + function _on_alumno_get_error(loading, results) + { + alert(results) + load = MochiKit.DOM.getElement(loading); + load.style.visibility = 'hidden'; + } + + function sacar_de_la_lista(lista) + { + replaceChildNodes(lista, + list(ifilterfalse(itemgetter('selected'), $(lista).options)) + ); + } + + function _do_add(callback, texto, lista, loading) + { + url = callback(texto, lista); + t = MochiKit.DOM.getElement(texto); + + load = MochiKit.DOM.getElement(loading); + load.style.visibility = 'visible'; + var d = loadJSONDoc(url); + d.addCallbacks(partial(_on_alumno_get_result, lista, loading), partial(_on_alumno_get_error, loading)); + t.value = 'padron'; + t.style.color = "#aaa"; + } +''' + +class AjaxMultiSelect(widgets.MultipleSelectField): + template = ''' +