[IMP]Onclick of publish/unpublish value is changed of recruitment or no recruitment...
authorbth-openerp <bth@tinyerp.com>
Wed, 21 Aug 2013 07:48:39 +0000 (13:18 +0530)
committerbth-openerp <bth@tinyerp.com>
Wed, 21 Aug 2013 07:48:39 +0000 (13:18 +0530)
bzr revid: bth@tinyerp.com-20130821074839-e5i73a8pmacetknb

addons/website_hr_recruitment/controllers/main.py
addons/website_hr_recruitment/static/src/js/recruitment.js
addons/website_hr_recruitment/views/website_hr_recruitment.xml

index e90142d..a75ceda 100644 (file)
@@ -110,7 +110,7 @@ class website_hr_recruitment(http.Controller):
            })
         return website.render("website_hr_recruitment.thankyou", values)
 
-    @http.route(['/recruitment/published'], type='http', auth="admin")
+    @http.route('/recruitment/published', type='json', auth="admin")
     def published (self, **post):
         hr_job = request.registry['hr.job']
         id = int(post['id'])
@@ -126,8 +126,8 @@ class website_hr_recruitment(http.Controller):
             vals['state'] = 'open'
             vals ['no_of_recruitment'] = 0.0
 
-        res  = hr_job.write(request.cr, request.uid, [rec.id], vals)
+        res = hr_job.write(request.cr, request.uid, [rec.id], vals)
         obj = hr_job.browse(request.cr, request.uid, id)
-        return obj.website_published and "1" or "0"
+        return { 'published': obj.website_published and "1" or "0", 'count': obj.no_of_recruitment }
 
 # vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
index 4b6eeb7..9b2474c 100644 (file)
@@ -5,13 +5,26 @@ $(function () {
         $link.find('.js_published, .js_unpublished').addClass("hidden");
         var $unp = $link.find(".js_unpublished");
         var $p = $link.find(".js_published");
-        $.post('/recruitment/published', {'id': $link.data('id'), 'object': $link.data('object')}, function (result) {
-            if (+result) {
+        openerp.jsonRpc('/recruitment/published', 'call', {'id': $link.data('id'), 'object': $link.data('object')}).then(function (result) {
+            if (+result['published']) {
                 $p.addClass("hidden");
                 $unp.removeClass("hidden");
+                $('tr[id='+$link.data('id')+']').find('span#norecruit').addClass("hidden");
+                $('tr[id='+$link.data('id')+']').find('span#counting').removeClass("hidden");
+                if ($.trim($('tr[id='+$link.data('id')+']').find('span#counting').html()).length == 0) {
+                    htmlcon = '<i class="icon-group"></i> No.of Post: <span id="counting_num">' + result['count'] + '</span>';
+                    $('tr[id='+$link.data('id')+']').find('span#counting').html(htmlcon);
+                } else {
+                    $('tr[id='+$link.data('id')+']').find('span#counting').find('span#counting_num').html(result['count']);
+                }
             } else {
                 $p.removeClass("hidden");
                 $unp.addClass("hidden");
+                $('tr[id='+$link.data('id')+']').find('span#counting').addClass("hidden");
+                $('tr[id='+$link.data('id')+']').find('span#norecruit').removeClass("hidden");
+                if ($.trim($('tr[id='+$link.data('id')+']').find('span#norecruit').html()).length == 0) {
+                    $('tr[id='+$link.data('id')+']').find('span#norecruit').html("Right now no recruitment is going on.")
+                }
             }
         });
     });
index 4d81067..3d41d8a 100644 (file)
                                 </thead>
                                 <tbody>
                                     <t t-foreach="res_job" t-as="job">
-                                        <tr t-if="job.company_id.id==company.id">
+                                        <tr t-if="job.company_id.id==company.id" t-att-id="job.id">
                                             <td>
                                                 <a t-att-href="'/job/detail/%%s' %% job.id"><span class="lead" t-field="job.name"/></a><br/>
                                                 <t t-if="job.department_id">
                                                     <span t-field="job.department_id.name"></span>
                                                 </t><br/>
                                                 <i class="icon-time"></i> <t t-esc="vals[job.id]['date_recruitment']"/><br/>
-                                                <t t-if="job.no_of_recruitment &gt; 0">
-                                                    <i class="icon-group"></i> No.of Post:
-                                                    <span id='counting'>
-                                                        <t t-esc="vals[job.id]['count']"></t>
-                                                    </span>
-                                                </t>
-                                                <t t-if="job.no_of_recruitment &lt; 1">
-                                                    <span id="norecruit">
+                                                <span id='counting'>
+                                                    <t t-if="job.no_of_recruitment &gt; 0">
+                                                        <i class="icon-group"></i> No.of Post:
+                                                        <span id='counting_num'>
+                                                            <t t-esc="vals[job.id]['count']"></t>
+                                                        </span>
+                                                    </t>
+                                                </span>
+                                                <span id="norecruit">
+                                                    <t t-if="job.no_of_recruitment &lt; 1">
                                                         Right now no recruitment is going on.
-                                                    </span>
-                                                </t><br/>
+                                                    </t>
+                                                </span>
+                                                <br/>
                                                 <span><i class="icon-map-marker"></i> <t t-field="res_company.city"/> 
                                                 <t t-if="res_company.state_id">
                                                     <span t-field="res_company.state_id.name"></span>