]> git.llucax.com Git - software/sercom.git/blobdiff - sercom/widgets.py
faltaba tirar un error
[software/sercom.git] / sercom / widgets.py
index 08adea7dbd34c6b6b96471f98f35f2232a460ac0..309adc0e9d1a2296b99ae8ee236b80373e362675 100644 (file)
@@ -17,4 +17,60 @@ class CustomTextField(widgets.TextField):
          />
          <span id="${field_id}_info" />
         </span>
+'''
+
+AlumnoMultiSelectAjax = '''
+    function agregar_a_la_lista(texto, lista)
+    {
+        t = MochiKit.DOM.getElement(texto);
+        MochiKit.DOM.appendChildNodes(lista, OPTION(t.value));
+        t.value = "";
+    }
+
+    function sacar_de_la_lista(lista)
+    {
+        l = MochiKit.DOM.getElement(lista);
+        if (l.selectedIndex < 0) return;
+
+        for (i=l.selectedIndex; i<l.options.length-1;i++)
+            l.options[i] = l.options[i+1];
+    }
+'''
+
+class AlumnoMultiSelect(widgets.MultipleSelectField):
+    template = '''
+    <table xmlns:py="http://purl.org/kid/ns#" style="border:none; width:0%;">  
+    <tr><td>
+    <input type="text" id="${field_id}_nuevo" /><input type="button" id="_agregar" value="Agregar"
+        onClick=" agregar_a_la_lista('${field_id}_nuevo', '${field_id}'); " />
+    </td></tr>
+    <tr><td>
+    <select  
+        multiple="multiple"  
+        size="${size}"  
+        name="${name}"  
+        class="${field_class}"  
+        id="${field_id}"  
+        py:attrs="attrs"  
+        style="width:250px;"
+    >
+        <optgroup py:for="group, options in grouped_options"  
+            label="${group}"  
+            py:strip="not group"  
+        >  
+        <option py:for="value, desc, attrs in options"  
+            value="${value}"  
+            py:attrs="attrs"  
+            py:content="desc"  
+        />  
+        </optgroup>  
+    </select>
+    </td></tr>
+    <tr><td align="center">
+    <input type="button" id="_sacar" value="Borrar"
+        onClick="sacar_de_la_lista('${field_id}'); " />
+    </td></tr>
+    </table>
     '''
+    javascript = [widgets.JSSource(AlumnoMultiSelectAjax)]
+