* added daily work summary setting doctype and code to support feature this will allow multiple setting for daily work summary * added daily work summary setting user doctype * made changes in daily work summary code * [minor] entry change in hr config file * deleted previous daily work summary settings (and its company) doctype * removed unwanted permission check * toggled read_only option for enabled field * removed print statements * add patch for the changes * doc changes * [minor] indentation fix * fixed tests * indentation fixes * codacy issue fix * formatting fixes * renamed doctype Renamed Daily Work Summary Setting to Daily Work Summary Group and did related code and doc changes * fixed typo * updated doc * codacy issue fix * [minor] renamed doctype name in json * Renamed old doctype * fixed indentation * codacy fix * indentation fix * renamed doctype * handled patch exception * fixed exception * Update daily_work_summary_group.py * rename patch file removed abbreviation in file name * handled exception in patch code * removed Unnecessary pass statement * [minor] indentation fix
		
			
				
	
	
		
			80 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| frappe.pages['team-updates'].on_page_load = function(wrapper) {
 | |
| 	var page = frappe.ui.make_app_page({
 | |
| 		parent: wrapper,
 | |
| 		title: __('Team Updates'),
 | |
| 		single_column: true
 | |
| 	});
 | |
| 
 | |
| 	frappe.team_updates.make(page);
 | |
| 	frappe.team_updates.run();
 | |
| 
 | |
| 	if(frappe.model.can_read('Daily Work Summary Group')) {
 | |
| 		page.add_menu_item(__('Daily Work Summary Group'), function() {
 | |
| 			frappe.set_route('Form', 'Daily Work Summary Group');
 | |
| 		});
 | |
| 	}
 | |
| }
 | |
| 
 | |
| frappe.team_updates = {
 | |
| 	start: 0,
 | |
| 	make: function(page) {
 | |
| 		var me = frappe.team_updates;
 | |
| 		me.page = page;
 | |
| 		me.body = $('<div></div>').appendTo(me.page.main);
 | |
| 		me.more = $('<div class="for-more"><button class="btn btn-sm btn-default btn-more">'
 | |
| 			+ __("More") + '</button></div>').appendTo(me.page.main)
 | |
| 			.find('.btn-more').on('click', function() {
 | |
| 				me.start += 40;
 | |
| 				me.run();
 | |
| 			});
 | |
| 	},
 | |
| 	run: function() {
 | |
| 		var me = frappe.team_updates;
 | |
| 		frappe.call({
 | |
| 			method: 'erpnext.hr.page.team_updates.team_updates.get_data',
 | |
| 			args: {
 | |
| 				start: me.start
 | |
| 			},
 | |
| 			callback: function(r) {
 | |
| 				if(r.message) {
 | |
| 					r.message.forEach(function(d) {
 | |
| 						me.add_row(d);
 | |
| 					});
 | |
| 				} else {
 | |
| 					frappe.show_alert({message:__('No more updates'), indicator:'darkgrey'});
 | |
| 					me.more.parent().addClass('hidden');
 | |
| 				}
 | |
| 			}
 | |
| 		});
 | |
| 	},
 | |
| 	add_row: function(data) {
 | |
| 		var me = frappe.team_updates;
 | |
| 
 | |
| 		data.by = frappe.user.full_name(data.sender);
 | |
| 		data.avatar = frappe.avatar(data.sender);
 | |
| 		data.when = comment_when(data.creation);
 | |
| 
 | |
| 		var date = frappe.datetime.str_to_obj(data.creation);
 | |
| 		var last = me.last_feed_date;
 | |
| 
 | |
| 		if((last && frappe.datetime.obj_to_str(last) != frappe.datetime.obj_to_str(date)) || (!last)) {
 | |
| 			var diff = frappe.datetime.get_day_diff(frappe.datetime.get_today(), frappe.datetime.obj_to_str(date));
 | |
| 			var pdate;
 | |
| 			if(diff < 1) {
 | |
| 				pdate = 'Today';
 | |
| 			} else if(diff < 2) {
 | |
| 				pdate = 'Yesterday';
 | |
| 			} else {
 | |
| 				pdate = frappe.datetime.global_date_format(date);
 | |
| 			}
 | |
| 			data.date_sep = pdate;
 | |
| 			data.date_class = pdate=='Today' ? "date-indicator blue" : "date-indicator";
 | |
| 		} else {
 | |
| 			data.date_sep = null;
 | |
| 			data.date_class = "";
 | |
| 		}
 | |
| 		me.last_feed_date = date;
 | |
| 
 | |
| 		$(frappe.render_template('team_update_row', data)).appendTo(me.body)
 | |
| 	}
 | |
| } |