Improvement in hr-attendance absent/present widget with usermenu
bzr revid: tta@openerp.com-20120518134439-icg8i0uad64ewv4d
This commit is contained in:
parent
d1d4b1554c
commit
3a3a10ef46
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 756 B |
Binary file not shown.
After Width: | Height: | Size: 930 B |
|
@ -1,5 +1,5 @@
|
|||
openerp.hr_attendance = function(instance) {
|
||||
var QWeb = instance.web.qweb;
|
||||
/** var QWeb = instance.web.qweb;
|
||||
instance.hr_attendance.attendancestatus = false,
|
||||
instance.hr_attendance.checkstatus = function(){
|
||||
attendance = instance.hr_attendance.currentstatus;
|
||||
|
@ -27,9 +27,24 @@ openerp.hr_attendance = function(instance) {
|
|||
self.employee = employee[0];
|
||||
self.do_update_notifier();
|
||||
});
|
||||
var el = $("div.presence_slider");
|
||||
el.click(function(){
|
||||
if(self.employee.state == 'present'){
|
||||
el.animate({"left": "48px"}, "slow");
|
||||
self.on_click();
|
||||
}else{
|
||||
el.animate({"left": "-8px"}, "slow");
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
do_update_notifier: function(){
|
||||
var self = this;
|
||||
var el = $('img.oe_topbar_avatar');
|
||||
|
||||
|
||||
|
||||
|
||||
this.$element = $(QWeb.render(this.template, {'employee':this.employee}));
|
||||
this.$element.click(self.on_click);
|
||||
element = $('.oe_attendance_button')
|
||||
|
@ -46,12 +61,12 @@ openerp.hr_attendance = function(instance) {
|
|||
var self = this;
|
||||
hr_employee = new instance.web.DataSet(self, 'hr.employee');
|
||||
hr_employee.call('attendance_action_change', [[self.employee.id]]).done(function(result){
|
||||
window.location.reload();
|
||||
//self.renderElement()
|
||||
//window.location.reload();
|
||||
self.renderElement()
|
||||
});
|
||||
},
|
||||
});
|
||||
instance.web.DataSet.include({
|
||||
/* instance.web.DataSet.include({
|
||||
create: function(data, callback, error_callback) {
|
||||
if (this._model.name == "hr.attendance"){
|
||||
callback = instance.hr_attendance.callback(callback);
|
||||
|
@ -76,16 +91,55 @@ openerp.hr_attendance = function(instance) {
|
|||
}
|
||||
return this._super(method, args, callback, error_callback);
|
||||
},
|
||||
callback: function()
|
||||
{
|
||||
this.__super();
|
||||
|
||||
.....
|
||||
}
|
||||
|
||||
});
|
||||
}); */
|
||||
|
||||
instance.web.UserMenu.include({
|
||||
do_update: function() {
|
||||
do_update_attendance: function() {
|
||||
var self = this;
|
||||
this._super();
|
||||
this.update_promise.then(function() {
|
||||
instance.hr_attendance.checkstatus();
|
||||
console.log("click.........",self);
|
||||
hr_employee = new instance.web.DataSet(self, 'hr.employee');
|
||||
hr_employee.call('attendance_action_change', [[self.employee.id]]).done(function(result){
|
||||
if (!result) return;
|
||||
if(self.employee.state == 'present')
|
||||
self.employee.state = 'absent';
|
||||
else
|
||||
self.employee.state = 'present';
|
||||
self.do_slide(self.employee.state);
|
||||
});
|
||||
},
|
||||
do_slide:function(attendance_state)
|
||||
{
|
||||
if(attendance_state == 'present')
|
||||
this.oe_attendance_slider.animate({"left": "48px"}, "slow");
|
||||
else
|
||||
this.oe_attendance_slider.animate({"left": "-8px"}, "slow");
|
||||
},
|
||||
check_attendance: function(){
|
||||
var self = this;
|
||||
var employee = new instance.web.DataSetSearch(self, 'hr.employee', self.session.user_context, [['user_id','=', self.session.uid]]);
|
||||
return employee.read_slice(['id','name','state']).pipe(function(res) {
|
||||
if(_.isEmpty(res)) return;
|
||||
self.employee = res[0];
|
||||
self.do_slide(self.employee.state);
|
||||
});
|
||||
},
|
||||
do_update: function () {
|
||||
this._super();
|
||||
var self = this;
|
||||
var fct = function() {
|
||||
self.oe_attendance_slider = self.$element.find('.oe_attendance_slider');
|
||||
self.oe_attendance_slider.click(self.do_update_attendance);
|
||||
return self.check_attendance();
|
||||
|
||||
};
|
||||
this.update_promise = this.update_promise.pipe(fct, fct);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
<template>
|
||||
<t t-name="AttendanceNotifier">
|
||||
<img style="cursor: pointer;" t-attf-src="/hr_attendance/static/src/img/emp-#{employee.state}.png" class="oe_attendance_button" t-attf-title="You are #{employee.state}"></img>
|
||||
<t t-extend="UserMenu">
|
||||
<t t-jquery="li.oe_dropdown" t-operation="before" >
|
||||
<li>
|
||||
<div class="oe_attendance_status" style="height:20px;width:100px;background-color:white;padding: 5px 10px 7px;margin:3px;">
|
||||
<div class="oe_attendance_present" style="float:left;">Present</div>
|
||||
<div class="oe_attendance_absent" style="float:right">Absent</div>
|
||||
<div class="oe_attendance_slider" style="cursor:pointer;width: 60px;background-color: gray;position: relative;top: -4px;left: -8px;height: 30px;-webkit-border-radius:4px;"><span style="visibility:hidden;">slider</span></div>
|
||||
</div>
|
||||
</li>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue