2013-08-21 17:25:42 +02:00
|
|
|
/**
|
|
|
|
* EGroupware - Timesheet - Javascript UI
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @package timesheet
|
|
|
|
* @author Hadi Nategh <hn-AT-stylite.de>
|
2016-02-17 20:56:54 +01:00
|
|
|
* @copyright (c) 2008-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
2013-08-21 17:25:42 +02:00
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UI for timesheet
|
|
|
|
*
|
|
|
|
* @augments AppJS
|
|
|
|
*/
|
2013-11-04 21:54:23 +01:00
|
|
|
app.classes.timesheet = AppJS.extend(
|
2013-08-21 17:25:42 +02:00
|
|
|
{
|
|
|
|
appname: 'timesheet',
|
|
|
|
/**
|
|
|
|
* et2 widget container
|
|
|
|
*/
|
|
|
|
et2: null,
|
|
|
|
/**
|
|
|
|
* path widget
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @memberOf app.timesheet
|
|
|
|
*/
|
|
|
|
init: function()
|
|
|
|
{
|
|
|
|
// call parent
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
destroy: function()
|
|
|
|
{
|
|
|
|
delete this.et2;
|
|
|
|
// call parent
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function is called when the etemplate2 object is loaded
|
|
|
|
* and ready. If you must store a reference to the et2 object,
|
|
|
|
* make sure to clean it up in destroy().
|
|
|
|
*
|
|
|
|
* @param et2 etemplate2 Newly ready object
|
|
|
|
*/
|
|
|
|
et2_ready: function(et2)
|
|
|
|
{
|
|
|
|
// call parent
|
|
|
|
this._super.apply(this, arguments);
|
2013-08-22 09:30:01 +02:00
|
|
|
|
2013-08-21 17:25:42 +02:00
|
|
|
if (typeof et2.templates['timesheet.index'] != "undefined")
|
|
|
|
{
|
2013-08-27 12:46:42 +02:00
|
|
|
this.filter_change();
|
2014-06-04 21:29:35 +02:00
|
|
|
this.filter2_change();
|
2013-08-21 17:25:42 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2013-08-27 12:46:42 +02:00
|
|
|
filter_change: function()
|
2013-08-21 17:25:42 +02:00
|
|
|
{
|
2013-08-22 09:30:01 +02:00
|
|
|
var filter = this.et2.getWidgetById('filter');
|
|
|
|
var dates = this.et2.getWidgetById('timesheet.index.dates');
|
|
|
|
|
|
|
|
if (filter && dates)
|
2013-08-21 17:25:42 +02:00
|
|
|
{
|
2013-08-22 09:30:01 +02:00
|
|
|
dates.set_disabled(filter.value !== "custom");
|
2016-02-17 20:56:54 +01:00
|
|
|
if (filter.value == "custom")
|
2016-04-25 23:21:40 +02:00
|
|
|
{
|
2016-02-17 20:56:54 +01:00
|
|
|
jQuery(this.et2.getWidgetById('startdate').getDOMNode()).find('input').focus();
|
|
|
|
}
|
2013-08-21 17:25:42 +02:00
|
|
|
}
|
2016-04-25 23:21:40 +02:00
|
|
|
return true;
|
2013-08-21 17:25:42 +02:00
|
|
|
},
|
2014-06-04 21:29:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* show or hide the details of rows by selecting the filter2 option
|
|
|
|
* either 'all' for details or 'no_description' for no details
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
filter2_change: function()
|
|
|
|
{
|
|
|
|
var nm = this.et2.getWidgetById('nm');
|
|
|
|
var filter2 = this.et2.getWidgetById('filter2');
|
|
|
|
|
|
|
|
if (nm && filter2)
|
|
|
|
{
|
|
|
|
egw.css("#timesheet-index span.timesheet_titleDetails","font-weight:" + (filter2.getValue() == '1' ? "bold;" : "normal;"));
|
|
|
|
// Show / hide descriptions
|
|
|
|
egw.css(".et2_label.ts_description","display:" + (filter2.getValue() == '1' ? "block;" : "none;"));
|
|
|
|
}
|
|
|
|
},
|
2014-10-14 17:58:37 +02:00
|
|
|
|
2016-08-12 18:39:06 +02:00
|
|
|
/**
|
|
|
|
* Wrapper so add action in the context menu can pass current
|
|
|
|
* filter values into new edit dialog
|
|
|
|
*
|
|
|
|
* @see add_with_extras
|
|
|
|
*
|
|
|
|
* @param {egwAction} action
|
|
|
|
* @param {egwActionObject[]} selected
|
|
|
|
*/
|
|
|
|
add_action_handler: function(action, selected)
|
|
|
|
{
|
|
|
|
var nm = action.getManager().data.nextmatch || false;
|
|
|
|
if(nm)
|
|
|
|
{
|
|
|
|
this.add_with_extras(nm);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens a new edit dialog with some extra url parameters pulled from
|
|
|
|
* nextmatch filters.
|
|
|
|
*
|
|
|
|
* @param {et2_widget} widget Originating/calling widget
|
|
|
|
*/
|
|
|
|
add_with_extras: function(widget)
|
|
|
|
{
|
|
|
|
var nm = widget.getRoot().getWidgetById('nm');
|
|
|
|
var nm_value = nm.getValue() || {};
|
|
|
|
|
|
|
|
var extras = {};
|
|
|
|
if(nm_value.cat_id)
|
|
|
|
{
|
|
|
|
extras.cat_id = nm_value.cat_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nm_value.col_filter && nm_value.col_filter.linked)
|
|
|
|
{
|
|
|
|
var split = nm_value.col_filter.linked.split(':') || '';
|
|
|
|
extras.link_app = split[0] || '';
|
|
|
|
extras.link_id = split[1] || '';
|
|
|
|
}
|
|
|
|
if(nm_value.col_filter && nm_value.col_filter.pm_id)
|
|
|
|
{
|
|
|
|
extras.link_app = 'projectmanager';
|
|
|
|
extras.link_id = nm_value.col_filter.pm_id;
|
|
|
|
}
|
|
|
|
else if (nm_value.col_filter && nm_value.col_filter.ts_project)
|
|
|
|
{
|
|
|
|
extras.ts_project = nm_value.col_filter.ts_project;
|
|
|
|
}
|
|
|
|
|
|
|
|
egw.open('','timesheet','add',extras);
|
|
|
|
},
|
|
|
|
|
2014-10-14 17:58:37 +02:00
|
|
|
/**
|
|
|
|
* Change handler for project selection to set empty ts_project string, if project get deleted
|
|
|
|
*
|
|
|
|
* @param {type} _egw
|
|
|
|
* @param {et2_widget_link_entry} _widget
|
|
|
|
* @returns {undefined}
|
|
|
|
*/
|
|
|
|
pm_id_changed: function(_egw, _widget)
|
|
|
|
{
|
2014-12-09 21:21:17 +01:00
|
|
|
// Update price list
|
|
|
|
var ts_pricelist = _widget.getRoot().getWidgetById('pl_id');
|
|
|
|
egw.json('projectmanager_widget::ajax_get_pricelist',[_widget.getValue()],function(value) {
|
|
|
|
ts_pricelist.set_select_options(value||{})
|
|
|
|
}).sendRequest(true);
|
|
|
|
|
2014-10-14 17:58:37 +02:00
|
|
|
var ts_project = this.et2.getWidgetById('ts_project');
|
|
|
|
if (ts_project)
|
|
|
|
{
|
|
|
|
ts_project.set_blur(_widget.getValue() ? _widget.search.val() : '');
|
|
|
|
}
|
2015-01-05 15:28:35 +01:00
|
|
|
},
|
2016-02-17 20:56:54 +01:00
|
|
|
|
2016-04-25 23:21:40 +02:00
|
|
|
/**
|
|
|
|
* Update custom filter timespan, without triggering a change
|
|
|
|
*/
|
|
|
|
update_timespan: function(start, end)
|
|
|
|
{
|
|
|
|
if(this && this.et2)
|
|
|
|
{
|
|
|
|
var nm = this.et2.getWidgetById('nm');
|
|
|
|
if(nm)
|
|
|
|
{
|
|
|
|
// Toggle update_in_progress to avoid another request
|
|
|
|
nm.update_in_progress = true;
|
|
|
|
this.et2.getWidgetById('startdate').set_value(start);
|
|
|
|
this.et2.getWidgetById('enddate').set_value(end);
|
|
|
|
nm.activeFilters.startdate = start;
|
|
|
|
nm.activeFilters.enddate = end;
|
|
|
|
nm.update_in_progress = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-01-05 15:28:35 +01:00
|
|
|
/**
|
|
|
|
* Get title in order to set it as document title
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
getWindowTitle: function()
|
|
|
|
{
|
|
|
|
var widget = this.et2.getWidgetById('ts_title');
|
|
|
|
if(widget) return widget.options.value;
|
2014-10-14 17:58:37 +02:00
|
|
|
}
|
2013-08-21 17:25:42 +02:00
|
|
|
});
|