Commit b0b564e6 authored by Frank Bergmann's avatar Frank Bergmann

- Timesheet Intervals:

  Added Esc key to abort current logging
parent 016bb01e
...@@ -117,23 +117,26 @@ function launchTreePanel(){ ...@@ -117,23 +117,26 @@ function launchTreePanel(){
tooltip: 'Stop logging', tooltip: 'Stop logging',
id: 'buttonStopLogging', id: 'buttonStopLogging',
disabled: true disabled: true
}, {
icon: '/intranet/images/navbar_default/clock_delete.png',
tooltip: 'Cancel logging',
id: 'buttonCancelLogging',
disabled: true
}] }]
}); });
// Use the button panel as a container for the task tree and the hour grid // Use the button panel as a container for the task tree and the hour grid
var hourIntervalButtonPanel = Ext.create('PO.view.timesheet.HourIntervalButtonPanel', { var hourIntervalButtonPanel = Ext.create('PO.view.timesheet.HourIntervalButtonPanel', {
renderTo: '@task_editor_id@',
width: width, width: width,
height: height, height: height,
resizable: true, // Add handles to the panel, so the user can change size resizable: true, // Add handles to the panel, so the user can change size
items: [ items: [
hourIntervalGrid, hourIntervalGrid,
ganttTreePanel ganttTreePanel
], ]
renderTo: '@task_editor_id@'
}); });
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Controller for interaction between Tree and Grid // Controller for interaction between Tree and Grid
// //
...@@ -164,6 +167,7 @@ function launchTreePanel(){ ...@@ -164,6 +167,7 @@ function launchTreePanel(){
this.control({ this.control({
'#buttonStartLogging': { click: this.onButtonStartLogging }, '#buttonStartLogging': { click: this.onButtonStartLogging },
'#buttonStopLogging': { click: this.onButtonStopLogging }, '#buttonStopLogging': { click: this.onButtonStopLogging },
'#buttonCancelLogging': { click: this.onButtonCancelLogging },
scope: me.ganttTreePanel scope: me.ganttTreePanel
}); });
...@@ -173,9 +177,21 @@ function launchTreePanel(){ ...@@ -173,9 +177,21 @@ function launchTreePanel(){
// Listen to a click into the empty space below the grid entries in order to start creating a new entry // Listen to a click into the empty space below the grid entries in order to start creating a new entry
me.hourIntervalGrid.on('containerclick', this.onGridContainerClick, me); me.hourIntervalGrid.on('containerclick', this.onGridContainerClick, me);
// Catch a global Esc button in order to abort logging
// For some reaons this doesn't work on the level of the HourButtonPanel, so
// we go for the global "window" here.
Ext.EventManager.on(window, 'keydown', this.onKeyEsc, me);
return this; return this;
}, },
// Esc (Escape) button pressed somewhere in the application window
onKeyEsc: function() {
console.log('GanttButtonController.onKeyEsc');
this.onButtonCancelLogging();
},
// Click into the empty space below the grid entries in order to start creating a new entry // Click into the empty space below the grid entries in order to start creating a new entry
onGridContainerClick: function() { onGridContainerClick: function() {
console.log('GanttButtonController.GridContainerClick'); console.log('GanttButtonController.GridContainerClick');
...@@ -195,8 +211,10 @@ function launchTreePanel(){ ...@@ -195,8 +211,10 @@ function launchTreePanel(){
console.log('GanttButtonController.ButtonStartLogging'); console.log('GanttButtonController.ButtonStartLogging');
var buttonStartLogging = Ext.getCmp('buttonStartLogging'); var buttonStartLogging = Ext.getCmp('buttonStartLogging');
var buttonStopLogging = Ext.getCmp('buttonStopLogging'); var buttonStopLogging = Ext.getCmp('buttonStopLogging');
var buttonCancelLogging = Ext.getCmp('buttonCancelLogging');
buttonStartLogging.disable(); buttonStartLogging.disable();
buttonStopLogging.enable(); buttonStopLogging.enable();
buttonCancelLogging.enable();
rowEditing.cancelEdit(); rowEditing.cancelEdit();
...@@ -223,8 +241,10 @@ function launchTreePanel(){ ...@@ -223,8 +241,10 @@ function launchTreePanel(){
console.log('GanttButtonController.ButtonStopLogging'); console.log('GanttButtonController.ButtonStopLogging');
var buttonStartLogging = Ext.getCmp('buttonStartLogging'); var buttonStartLogging = Ext.getCmp('buttonStartLogging');
var buttonStopLogging = Ext.getCmp('buttonStopLogging'); var buttonStopLogging = Ext.getCmp('buttonStopLogging');
var buttonCancelLogging = Ext.getCmp('buttonCancelLogging');
buttonStartLogging.enable(); buttonStartLogging.enable();
buttonStopLogging.disable(); buttonStopLogging.disable();
buttonCancelLogging.disable();
// Complete the hourInterval created when starting to log // Complete the hourInterval created when starting to log
this.loggingInterval.set('interval_end', new Date()); this.loggingInterval.set('interval_end', new Date());
...@@ -238,6 +258,24 @@ function launchTreePanel(){ ...@@ -238,6 +258,24 @@ function launchTreePanel(){
this.loggingStartTime = null; this.loggingStartTime = null;
}, },
onButtonCancelLogging: function() {
console.log('GanttButtonController.ButtonCancelLogging');
var buttonStartLogging = Ext.getCmp('buttonStartLogging');
var buttonStopLogging = Ext.getCmp('buttonStopLogging');
var buttonCancelLogging = Ext.getCmp('buttonCancelLogging');
buttonStartLogging.enable();
buttonStopLogging.disable();
buttonCancelLogging.disable();
// Delete the started line
rowEditing.cancelEdit();
hourIntervalStore.remove(this.loggingInterval);
// Stop logging
this.loggingTask = null;
this.loggingStartTime = null;
},
/** /**
* Control the enabled/disabled status of the Start/Stop logging buttons * Control the enabled/disabled status of the Start/Stop logging buttons
*/ */
...@@ -269,6 +307,18 @@ function launchTreePanel(){ ...@@ -269,6 +307,18 @@ function launchTreePanel(){
} }
}, },
/**
* Handle various key actions
*/
onCellKeyDown: function(table, htmlTd, cellIndex, record, htmlTr, rowIndex, e, eOpts) {
console.log('GanttButtonController.onCellKeyDown');
var keyCode = e.getKey();
var keyCtrl = e.ctrlKey;
console.log('GanttButtonController.onCellKeyDown: code='+keyCode+', ctrl='+keyCtrl);
},
/** /**
* The windows as a whole was resized * The windows as a whole was resized
*/ */
...@@ -314,6 +364,7 @@ function launchTreePanel(){ ...@@ -314,6 +364,7 @@ function launchTreePanel(){
}); });
var sideBarTab = Ext.get('sideBarTab'); var sideBarTab = Ext.get('sideBarTab');
var hourIntervalController = Ext.create('PO.controller.timesheet.HourIntervalController', { var hourIntervalController = Ext.create('PO.controller.timesheet.HourIntervalController', {
'hourIntervalButtonPanel': hourIntervalButtonPanel, 'hourIntervalButtonPanel': hourIntervalButtonPanel,
...@@ -323,6 +374,11 @@ function launchTreePanel(){ ...@@ -323,6 +374,11 @@ function launchTreePanel(){
}); });
hourIntervalController.init(this).onLaunch(this); hourIntervalController.init(this).onLaunch(this);
// Testing events
hourIntervalButtonPanel.fireEvent('keypress');
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Handle collapsable side menu // Handle collapsable side menu
sideBarTab.on('click', hourIntervalController.onSideBarResize, hourIntervalController); sideBarTab.on('click', hourIntervalController.onSideBarResize, hourIntervalController);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment