]> git.llucax.com Git - software/sercom.git/blobdiff - sercom/subcontrollers/curso/templates/edit.kid
Hago que se borren los elementos de FROM que ya estan en TO al editar.
[software/sercom.git] / sercom / subcontrollers / curso / templates / edit.kid
index 6939753915f5a141d5910be465af3279ede9cdcc..feda8f50789bc654a46efcca17aa64454b0ab9fa 100644 (file)
@@ -9,37 +9,26 @@
     function init_data() {
  //       MochiKit.DOM.getElement('form_responsable').focus();
         MochiKit.DOM.getElement('form_anio').focus();
     function init_data() {
  //       MochiKit.DOM.getElement('form_responsable').focus();
         MochiKit.DOM.getElement('form_anio').focus();
-        <span py:for="d in record.docentes_curso" py:strip="True">
-            MochiKit.DOM.appendChildNodes("form_docentes_curso", OPTION({"value":${d['id']}}, '${d['label']}'))
+        <span py:for="d in record.docentes_to" py:strip="True">
+            MochiKit.DOM.appendChildNodes("form_docentes_to", OPTION({"value":${d['id']}}, '${d['label']}'))
         </span>
         
         <span py:for="a in record.alumnos_inscriptos" py:strip="True">
             MochiKit.DOM.appendChildNodes("form_alumnos", OPTION({"value":${a['id']}}, '${a['label']}'))
         </span>
         </span>
         
         <span py:for="a in record.alumnos_inscriptos" py:strip="True">
             MochiKit.DOM.appendChildNodes("form_alumnos", OPTION({"value":${a['id']}}, '${a['label']}'))
         </span>
-    }
+                               // Saco de FROM los que ya estan en TO
+                               replaceChildNodes('form_docentes_from', list(ifilterfalse(
+                                       partial(esta_en_to, $('form_docentes_to').options),
+                                       $('form_docentes_from').options
+                               )));
+               }
+               function esta_en_to (options, i) {
+                       for (j=0; j &lt; options.length; j++)
+                               if (options[j].value == i.value)
+                                       return true;
+                       return false;
+               }
     MochiKit.DOM.addLoadEvent(init_data)
     MochiKit.DOM.addLoadEvent(init_data)
-    
-    function makeOption(option) {
-        return OPTION({"value": option.value}, option.text);
-    }
-                   
-    function moveOption( fromSelect, toSelect) {
-        // add 'selected' nodes toSelect
-        appendChildNodes(toSelect,
-        map( makeOption,ifilter(itemgetter('selected'), $(fromSelect).options)));
-        // remove the 'selected' fromSelect
-        // replaceChildNodes(fromSelect,
-        // list(ifilterfalse(itemgetter('selected'), $(fromSelect).options)));
-    }
-    
-    function mover( src, dest ) {
-        moveOption(src, dest)    
-    }
-    
-    function remover (src, dest) {
-        replaceChildNodes(src,list(ifilterfalse(itemgetter('selected'), $(src).options)))
-    }
-    
 </script>
 <body>
 
 </script>
 <body>