]> git.llucax.com Git - software/sercom.git/blobdiff - sercom/widgets.py
Mejorar listado de alumnos.
[software/sercom.git] / sercom / widgets.py
index b9a14c1769808eea4e40e0f48d18dcfea4e8ae73..3f2da586ffcaf2c07dd5a20a3a17daaa8e129ed8 100644 (file)
@@ -7,13 +7,13 @@ class CustomTextField(widgets.TextField):
     """Un input con un div al lado para ponerle info"""
     template = '''
         <span xmlns:py="http://purl.org/kid/ns#">
     """Un input con un div al lado para ponerle info"""
     template = '''
         <span xmlns:py="http://purl.org/kid/ns#">
-        <input  
-            type="text"  
-            name="${name}"  
-            class="${field_class}"  
-            id="${field_id}"  
-            value="${value}"  
-            py:attrs="attrs"  
+        <input
+            type="text"
+            name="${name}"
+            class="${field_class}"
+            id="${field_id}"
+            value="${value}"
+            py:attrs="attrs"
          />
          <span id="${field_id}_info" />
         </span>
          />
          <span id="${field_id}_info" />
         </span>
@@ -29,8 +29,17 @@ MultiSelectAjax = '''
             alert(results.msg);
             return;
         }
             alert(results.msg);
             return;
         }
-        MochiKit.DOM.appendChildNodes(lista, OPTION({'value':results.msg.id}, results.msg.value));
+        /* Verifico si esta y no lo agrego si esta repetido */
         l = MochiKit.DOM.getElement(lista);
         l = MochiKit.DOM.getElement(lista);
+        esta = false;
+        for(i=0; i<l.options.length; i++) {
+            if (results.msg.id == l.options[i].value) {
+                esta = true;
+                break;
+            }
+        }
+        if (!esta)
+            MochiKit.DOM.appendChildNodes(lista, OPTION({'value':results.msg.id}, results.msg.value));
     }
 
     function _on_alumno_get_error(loading, results)
     }
 
     function _on_alumno_get_error(loading, results)
@@ -63,7 +72,7 @@ MultiSelectAjax = '''
 
 class AjaxMultiSelect(widgets.MultipleSelectField):
     template = '''
 
 class AjaxMultiSelect(widgets.MultipleSelectField):
     template = '''
-    <div style="width:250px" xmlns:py="http://purl.org/kid/ns#">  
+    <div style="width:250px" xmlns:py="http://purl.org/kid/ns#">
     <div>
     <input type="text" id="${field_id}_nuevo" size="10" value="padron"
         style="color:#aaa;"
     <div>
     <input type="text" id="${field_id}_nuevo" size="10" value="padron"
         style="color:#aaa;"
@@ -74,25 +83,25 @@ class AjaxMultiSelect(widgets.MultipleSelectField):
         onClick=" _do_add(${on_add}, '${field_id}_nuevo', '${field_id}', '${name}_loading'); " />
     </div>
     <div>
         onClick=" _do_add(${on_add}, '${field_id}_nuevo', '${field_id}', '${name}_loading'); " />
     </div>
     <div>
-    <select  
-        multiple="multiple"  
-        size="${size}"  
-        name="${name}"  
-        class="${field_class}"  
-        id="${field_id}"  
-        py:attrs="attrs"  
+    <select
+        multiple="multiple"
+        size="${size}"
+        name="${name}"
+        class="${field_class}"
+        id="${field_id}"
+        py:attrs="attrs"
         style="width:250px;"
     >
         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>  
+        <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>
     </div>
     <div align="center">
     </select>
     </div>
     <div align="center">
@@ -123,12 +132,11 @@ DosListasAjax = '''
             list(ifilterfalse(itemgetter('selected'), $(fromSelect).options))
         );
     }
             list(ifilterfalse(itemgetter('selected'), $(fromSelect).options))
         );
     }
-
 '''
 
 class AjaxDosListasSelect(widgets.MultipleSelectField):
     template = '''
 '''
 
 class AjaxDosListasSelect(widgets.MultipleSelectField):
     template = '''
-    <div xmlns:py="http://purl.org/kid/ns#">  
+    <div xmlns:py="http://purl.org/kid/ns#">
     <table style="border:0; margin:0px; border-spacing:0px 0px">
     <tr class="nada">
         <td style="padding:0 0 0 0;" align="center">${title_from}</td>
     <table style="border:0; margin:0px; border-spacing:0px 0px">
     <tr class="nada">
         <td style="padding:0 0 0 0;" align="center">${title_from}</td>
@@ -137,7 +145,7 @@ class AjaxDosListasSelect(widgets.MultipleSelectField):
     </tr>
     <tr class="nada">
     <td style="padding:0 0 0 0;">
     </tr>
     <tr class="nada">
     <td style="padding:0 0 0 0;">
-    <select  
+    <select
         multiple="multiple"
         size="${size}"
         class="${field_class}"
         multiple="multiple"
         size="${size}"
         class="${field_class}"
@@ -146,18 +154,18 @@ class AjaxDosListasSelect(widgets.MultipleSelectField):
         py:attrs="attrs"
         style="width:200px;">
         <optgroup py:for="group, options in grouped_options" label="${group}" py:strip="not group">
         py:attrs="attrs"
         style="width:200px;">
         <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>  
+        <option py:for="value, desc, attrs in options" value="${value}" py:attrs="attrs" py:content="desc" />
+        </optgroup>
     </select>
     </td>
     <td style="padding:0 10px 0 10px;" valign="center" align="center">
     </select>
     </td>
     <td style="padding:0 10px 0 10px;" valign="center" align="center">
-        <input type="button" value="&gt;&gt;&gt;" style="font-size:90%;" onClick="moveOption('${field_id}_from', '${field_id}_to');" />
+        <input type="button" value="&gt;&gt;&gt;" style="font-size:90%;" onClick="moveOption('${field_id}_from', '${field_id}_to'); ${move_signal}; " />
         <br />
         <br />
         <br />
         <br />
-        <input type="button" value="&lt;&lt;&lt;" style="font-size:90%;" onClick="moveOption('${field_id}_to', '${field_id}_from');" />
+        <input type="button" value="&lt;&lt;&lt;" style="font-size:90%;" onClick="moveOption('${field_id}_to', '${field_id}_from'); ${move_signal}; " />
     </td>
     <td style="padding:0 0 0 0;">
     </td>
     <td style="padding:0 0 0 0;">
-    <select  
+    <select
         multiple="multiple"
         size="${size}"
         name="${name}_to"
         multiple="multiple"
         size="${size}"
         name="${name}_to"
@@ -174,11 +182,14 @@ class AjaxDosListasSelect(widgets.MultipleSelectField):
     javascript = [widgets.JSSource(DosListasAjax)]
     title_from = ""
     title_to = ""
     javascript = [widgets.JSSource(DosListasAjax)]
     title_from = ""
     title_to = ""
+    move_signal = ""
 
     def __init__(self, **kw):
         self.params.append('title_from')
         self.params.append('title_to')
 
     def __init__(self, **kw):
         self.params.append('title_from')
         self.params.append('title_to')
+        self.params.append('move_signal')
         self.title_from = "&nbsp;"
         self.title_to = "&nbsp;"
         self.title_from = "&nbsp;"
         self.title_to = "&nbsp;"
+        self.move_signal = ""
         widgets.MultipleSelectField.__init__(self, **kw)
 
         widgets.MultipleSelectField.__init__(self, **kw)