Autocomplete enterprise name in profile edition. (Closes #836)
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 5 Jun 2008 21:04:01 +0000 (23:04 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 5 Jun 2008 21:04:01 +0000 (23:04 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
htdocs/javascript/profile.js
modules/profile.php
templates/core/plwizard.tpl
templates/profile/jobs.job.tpl

index 5c25580..22d0976 100644 (file)
@@ -47,6 +47,7 @@ function wizPage_onLoad(id)
             updateJobSecteur(i, 'job_' + i, 'jobs[' + i + ']',
                              document.forms.prof_annu["jobs[" + i + "][ss_secteur]"].value);
         }
+        registerEnterpriseAutocomplete(-1);
         break;
     }
 }
@@ -350,6 +351,7 @@ function makeAddJob(id)
     return function(data)
     {
         $('#add_job').before(data);
+        registerEnterpriseAutocomplete(id);
         updateSecteur('job_' + id, 'jobs[' + id + ']', '');
     };
 }
@@ -494,4 +496,23 @@ function removeSecteur(s, ss)
     updateSSecteur();
 }
 
+function registerEnterpriseAutocomplete(id)
+{
+    alert("coucou");
+    $(".enterprise_name").each(
+      function() {
+        alert(this.name);
+        if (id == -1 || this.name == "jobs[" + id + "][name]") {
+            $(this).autocomplete(platal_baseurl + "search/autocomplete/entreprise",
+                                 {
+                                   selectOnly:1,
+                                   field:this.name,
+                                   matchSubset:0,
+                                   width:$(this).width()
+                                 });
+        }
+      }
+    );
+}
+
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index c72a9c0..bef05a8 100644 (file)
@@ -302,9 +302,9 @@ class ProfileModule extends PLModule
 
         // Build the page
         $page->addJsLink('ajax.js');
-        $page->addJsLink('profile.js');
         $page->addJsLink('applis.js');
         $page->addJsLink('grades.js');
+        $page->addJsLink('profile.js');
         $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true, true);
         require_once dirname(__FILE__) . '/profile/page.inc.php';
         $wiz->addPage('ProfileGeneral', 'Général', 'general');
index 0222eb0..da75308 100644 (file)
@@ -20,6 +20,8 @@
 {*                                                                        *}
 {**************************************************************************}
 {javascript name="jquery"}
+{javascript name="jquery.autocomplete"}
+
 <script type="text/javascript">//<![CDATA[
   {if ($stateless || $id gt $current) && $wiz_ajax}
   {literal}
index 07a50e6..d83b6a2 100644 (file)
@@ -42,7 +42,7 @@
           {include file="include/flags.radio.tpl" name="`$jobpref`[pub]" val=$job.pub}
         </div>
         Entreprise n°{$i+1}&nbsp;:
-        <input type="text" {if $job.name_error}class="error"{/if} size="35" maxlength="100"
+        <input type="text" class="enterprise_name {if $job.name_error}error{/if}" size="35" maxlength="100"
                name="{$jobpref}[name]" value="{$job.name}" />
         <a href="javascript:removeJob('{$jobid}', '{$jobpref}')">
           {icon name=cross title="Supprimer cet emploi"}