Commit bf3b7721 authored by Frank Bergmann's avatar Frank Bergmann

- Formatting

parent 364b27ec
......@@ -108,13 +108,13 @@ Ext.define('GanttEditor.controller.GanttButtonController', {
var me = this;
if (me.debug) console.log('GanttButtonController.ButtonSave: Starting');
// Make sure there are no duplicate tasks
me.ganttTreePanelController.treeRenumber();
// Make sure there are no duplicate tasks
me.ganttTreePanelController.treeRenumber();
// Fix wrong milestone_p field
me.taskTreeStore.tree.root.eachChild(function(taskModel) {
var milestoneP = taskModel.get('milestone_p');
var m = milestoneP;
// Fix wrong milestone_p field
me.taskTreeStore.tree.root.eachChild(function(taskModel) {
var milestoneP = taskModel.get('milestone_p');
var m = milestoneP;
switch (milestoneP) {
case "true": m = 't'; break;
case true: m = 't'; break;
......@@ -122,12 +122,12 @@ Ext.define('GanttEditor.controller.GanttButtonController', {
case false: m = 'f'; break;
}
if (milestoneP != m) {
if (me.debug) console.log('GanttButtonController.ButtonSave: Fixing milestone_p from "'+milestoneP+'" to "'+m+'"');
taskModel.set('milestone_p', 'f');
}
if (milestoneP != m) {
if (me.debug) console.log('GanttButtonController.ButtonSave: Fixing milestone_p from "'+milestoneP+'" to "'+m+'"');
taskModel.set('milestone_p', 'f');
}
});
});
me.taskTreeStore.save({
......@@ -150,7 +150,7 @@ Ext.define('GanttEditor.controller.GanttButtonController', {
onTaskTreeStoreUpdate: function(treeStore, model, action, affectedColumns, eOpts) {
var me = this;
if (me.debug) console.log('GanttButtonController.onTaskTreeStoreUpdate');
if (!affectedColumns || 0 == affectedColumns.length) return;
if (!affectedColumns || 0 == affectedColumns.length) return;
// Check if read-only and abort in this case
var readOnly = me.senchaPreferenceStore.getPreferenceBoolean('read_only',true);
......
......@@ -46,43 +46,43 @@ Ext.define('GanttEditor.controller.GanttSchedulingController', {
var me = this;
if (me.debug) console.log('PO.controller.gantt_editor.GanttSchedulingController.onTreeStoreUpdate: Starting');
var dirty = false;
var dirty = false;
if (null != fieldsChanged) {
fieldsChanged.forEach(function(fieldName) {
if (me.debug) console.log('PO.controller.gantt_editor.GanttSchedulingController.onTreeStoreUpdate: Field changed='+fieldName);
switch (fieldName) {
case "start_date":
me.onStartDateChanged(treeStore, model, operation, event);
dirty = true;
dirty = true;
break;
case "end_date":
me.onEndDateChanged(treeStore, model, operation, event);
dirty = true;
dirty = true;
break;
case "planned_units":
me.onPlannedUnitsChanged(treeStore, model, operation, event);
dirty = true;
me.onPlannedUnitsChanged(treeStore, model, operation, event);
dirty = true;
break;
case "parent_id":
// Task has new parent - indentation or un-indentation
// Task has new parent - indentation or un-indentation
me.onStartDateChanged(treeStore, model, operation, event);
me.onEndDateChanged(treeStore, model, operation, event);
dirty = true;
dirty = true;
break;
case "leaf":
// A task has changed from leaf to tree or reverse:
// Don't do anything, this is handled with the "parent_id" field anyway
dirty = true;
// A task has changed from leaf to tree or reverse:
// Don't do anything, this is handled with the "parent_id" field anyway
dirty = true;
break;
}
});
}
if (dirty) {
if (dirty) {
me.ganttBarPanel.needsRedraw = true; // Force a redraw
var buttonSave = Ext.getCmp('buttonSave');
buttonSave.setDisabled(false); // Enable "Save" button
}
}
if (me.debug) console.log('PO.controller.gantt_editor.GanttSchedulingController.onTreeStoreUpdate: Finished');
},
......@@ -102,9 +102,9 @@ Ext.define('GanttEditor.controller.GanttSchedulingController', {
var plannedUnits = 0.0;
parent.eachChild(function(sibling) {
var siblingPlannedUnits = parseFloat(sibling.get('planned_units'));
if (!isNaN(siblingPlannedUnits)) {
plannedUnits = plannedUnits + siblingPlannedUnits;
}
if (!isNaN(siblingPlannedUnits)) {
plannedUnits = plannedUnits + siblingPlannedUnits;
}
});
// Check if we have to update the parent
......@@ -124,9 +124,9 @@ Ext.define('GanttEditor.controller.GanttSchedulingController', {
var me = this;
if (me.debug) console.log('PO.controller.gantt_editor.GanttSchedulingController.onStartDateChanged: Starting');
// Check for manually entered date. startDates start at 00:00:00 at night:
var myStartDate = model.get('start_date');
if (myStartDate.length == 10) { model.set('start_date', myStartDate + " 00:00:00"); }
// Check for manually entered date. startDates start at 00:00:00 at night:
var myStartDate = model.get('start_date');
if (myStartDate.length == 10) { model.set('start_date', myStartDate + " 00:00:00"); }
var parent = model.parentNode; //
if (!parent) return;
......@@ -150,7 +150,7 @@ Ext.define('GanttEditor.controller.GanttSchedulingController', {
parent.set('start_date', PO.Utilities.dateToPg(minStartDate)); // This will call this event recursively
}
me.checkStartEndDateConstraint(treeStore, model); // check start < end constraint
me.checkStartEndDateConstraint(treeStore, model); // check start < end constraint
if (me.debug) console.log('PO.controller.gantt_editor.GanttSchedulingController.onStartDateChanged: Finished');
},
......@@ -164,9 +164,9 @@ Ext.define('GanttEditor.controller.GanttSchedulingController', {
var me = this;
if (me.debug) console.log('PO.controller.gantt_editor.GanttSchedulingController.onEndDateChanged: Starting');
// Check for manually entered date. endDates end at 23:59:59 at night:
var myStartDate = model.get('start_date');
if (myStartDate.length == 10) { model.set('start_date', myStartDate + " 23:59:59"); }
// Check for manually entered date. endDates end at 23:59:59 at night:
var myStartDate = model.get('start_date');
if (myStartDate.length == 10) { model.set('start_date', myStartDate + " 23:59:59"); }
var parent = model.parentNode;
if (!parent) return;
......@@ -190,7 +190,7 @@ Ext.define('GanttEditor.controller.GanttSchedulingController', {
parent.set('end_date', PO.Utilities.dateToPg(maxEndDate)); // This will call this event recursively
}
me.checkStartEndDateConstraint(treeStore, model); // check start < end constraint
me.checkStartEndDateConstraint(treeStore, model); // check start < end constraint
if (me.debug) console.log('PO.controller.gantt_editor.GanttSchedulingController.onEndDateChanged: Finished');
},
......@@ -201,7 +201,7 @@ Ext.define('GanttEditor.controller.GanttSchedulingController', {
checkStartEndDateConstraint: function(treeStore, model) {
var me = this;
if (me.debug) console.log('PO.controller.gantt_editor.GanttSchedulingController.checkStartEndDateConstraint: Starting');
var startDate = PO.Utilities.pgToDate(model.get('start_date'));
var endDate = PO.Utilities.pgToDate(model.get('end_date'));
......@@ -209,12 +209,12 @@ Ext.define('GanttEditor.controller.GanttSchedulingController', {
var startTime = startDate.getTime();
var endTime = endDate.getTime();
if (startTime > endTime) {
// The user has entered inconsistent start/end dates
endTime = startTime + 1000 * 3600 * 24;
endDate = new Date(endTime);
endDateString = endDate.toISOString().substring(0,10);
model.set('end_date', endDateString);
}
// The user has entered inconsistent start/end dates
endTime = startTime + 1000 * 3600 * 24;
endDate = new Date(endTime);
endDateString = endDate.toISOString().substring(0,10);
model.set('end_date', endDateString);
}
}
if (me.debug) console.log('PO.controller.gantt_editor.GanttSchedulingController.checkStartEndDateConstraint: Finished');
......
......@@ -34,7 +34,7 @@ Ext.define('GanttEditor.controller.GanttTreePanelController', {
'#buttonAdd': { click: this.onButtonAdd},
'#buttonDelete': { click: this.onButtonDelete},
// Redraw GanttBars after changing the configuration
// Redraw GanttBars after changing the configuration
'#config_menu_show_project_dependencies': { click: this.redrawGanttBarPanel},
'#config_menu_show_project_assigned_resources': { click: this.redrawGanttBarPanel}
});
......@@ -57,26 +57,26 @@ Ext.define('GanttEditor.controller.GanttTreePanelController', {
var me = this;
console.log('PO.controller.GanttTreePanelController.readOnlyWarning');
if (0 == write_project_p) {
if (0 == write_project_p) {
Ext.Msg.alert("Read-Only Mode",
"<nobr>You don't have write permissions on this project.</nobr><br>"+
"<nobr>You won't be able to save your changes.</nobr><br>"+
"Please contact the project manager and request write permissions." +
"<br>&nbsp;<br>"
);
"<nobr>You don't have write permissions on this project.</nobr><br>"+
"<nobr>You won't be able to save your changes.</nobr><br>"+
"Please contact the project manager and request write permissions." +
"<br>&nbsp;<br>"
);
} else {
} else {
Ext.Msg.alert('This software is Beta',
'<nobr>This software is in Beta state and contains a number of known</nobr><br>'+
'and unknown issues (please see the "This is Beta") menu.<br> ' +
'<br>' +
'However, many users have asked for this feature and use this<br>' +
'Gantt Editor already successfully, working around existing issues.<br> ' +
'<br>' +
'In order to start working with the Gantt Editor, please uncheck<br>' +
'the Configuration -> Read Only option.<br>&nbsp;<br>'
);
}
'<nobr>This software is in Beta state and contains a number of known</nobr><br>'+
'and unknown issues (please see the "This is Beta") menu.<br> ' +
'<br>' +
'However, many users have asked for this feature and use this<br>' +
'Gantt Editor already successfully, working around existing issues.<br> ' +
'<br>' +
'In order to start working with the Gantt Editor, please uncheck<br>' +
'the Configuration -> Read Only option.<br>&nbsp;<br>'
);
}
},
/**
......@@ -134,9 +134,9 @@ Ext.define('GanttEditor.controller.GanttTreePanelController', {
var me = this;
if (me.debug) console.log('GanttTreePanelController.onButtonIncreaseIndent');
// Check if read-only and abort in this case
var readOnly = me.senchaPreferenceStore.getPreferenceBoolean('read_only',true);
if (readOnly) { me.readOnlyWarning(); return; }
// Check if read-only and abort in this case
var readOnly = me.senchaPreferenceStore.getPreferenceBoolean('read_only',true);
if (readOnly) { me.readOnlyWarning(); return; }
var ganttTreePanel = this.getGanttTreePanel();
var selectionModel = ganttTreePanel.getSelectionModel();
......@@ -154,16 +154,16 @@ Ext.define('GanttEditor.controller.GanttTreePanelController', {
prevNode.set('leaf', false);
prevNode.appendChild(lastSelected); // Add to the previous node as a child
prevNode.expand();
var prevNodeId = ""+prevNode.get('id');
var prevNodeId = ""+prevNode.get('id');
// Set the parent_id of the indented item
lastSelected.set('parent_id', prevNodeId); // This should trigger a Gantt re-schedule
// Set the parent_id of the indented item
lastSelected.set('parent_id', prevNodeId); // This should trigger a Gantt re-schedule
ganttTreePanel.getView().focusNode(lastSelected); // Focus back on the task for keyboard commands
me.treeRenumber(); // Update the tree's task numbering
me.getGanttBarPanel().needsRedraw = true; // Force delayed redraw
// ToDo: Re-schedule the tree
// ToDo: Re-schedule the tree
},
......@@ -174,9 +174,9 @@ Ext.define('GanttEditor.controller.GanttTreePanelController', {
var me = this;
if (me.debug) console.log('GanttTreePanelController.onButtonReduceIndent');
// Check if read-only and abort in this case
var readOnly = me.senchaPreferenceStore.getPreferenceBoolean('read_only',true);
if (readOnly) { me.readOnlyWarning(); return; }
// Check if read-only and abort in this case
var readOnly = me.senchaPreferenceStore.getPreferenceBoolean('read_only',true);
if (readOnly) { me.readOnlyWarning(); return; }
var ganttTreePanel = this.getGanttTreePanel();
var selectionModel = ganttTreePanel.getSelectionModel();
......@@ -208,9 +208,9 @@ Ext.define('GanttEditor.controller.GanttTreePanelController', {
var me = this;
if (me.debug) console.log('PO.view.gantt.GanttTreePanelController.onButtonAdd: ');
// Check if read-only and abort in this case
var readOnly = me.senchaPreferenceStore.getPreferenceBoolean('read_only',true);
if (readOnly) { me.readOnlyWarning(); return; }
// Check if read-only and abort in this case
var readOnly = me.senchaPreferenceStore.getPreferenceBoolean('read_only',true);
if (readOnly) { me.readOnlyWarning(); return; }
var ganttTreePanel = me.getGanttTreePanel();
var rowEditing = ganttTreePanel.plugins[0];
......@@ -259,7 +259,7 @@ Ext.define('GanttEditor.controller.GanttTreePanelController', {
r.set('material_id', ""+default_material_id);
r.set('uom_id', ""+default_uom_id);
r.set('project_name', 'New Task');
r.set('work', ""+8);
r.set('work', ""+8);
r.set('start_date', new Date().toISOString().substring(0,10)+" 00:00:00"); // Indicates start of the day at 00:00:00
r.set('end_date', new Date().toISOString().substring(0,10)+" 23:59:59"); // Same as start_date, but indicates 23:59:59
......@@ -273,7 +273,7 @@ Ext.define('GanttEditor.controller.GanttTreePanelController', {
r.set('id', object_id);
r.set('project_id', object_id_string);
r.set('task_id', object_id_string);
if ("" == r.get('project_nr')) r.set('project_nr', "task_"+object_id_string);
if ("" == r.get('project_nr')) r.set('project_nr', "task_"+object_id_string);
},
failure: function(response){
Ext.Msg.alert('Error retreiving object_id from server',
......@@ -302,9 +302,9 @@ Ext.define('GanttEditor.controller.GanttTreePanelController', {
var me = this;
if (me.debug) console.log('PO.view.gantt.GanttTreePanelController.onButtonDelete: ');
// Check if read-only and abort in this case
var readOnly = me.senchaPreferenceStore.getPreferenceBoolean('read_only',true);
if (readOnly) { me.readOnlyWarning(); return; }
// Check if read-only and abort in this case
var readOnly = me.senchaPreferenceStore.getPreferenceBoolean('read_only',true);
if (readOnly) { me.readOnlyWarning(); return; }
var ganttTreePanel = me.getGanttTreePanel();
var rowEditing = ganttTreePanel.plugins[0];
......@@ -342,7 +342,7 @@ Ext.define('GanttEditor.controller.GanttTreePanelController', {
selectionModel.select(newNode);
}
// Redraw, renumber and enable save button
// Redraw, renumber and enable save button
me.treeRenumber(); // Update the tree's task numbering
me.getGanttBarPanel().needsRedraw = true; // Force delayed redraw
var buttonSave = Ext.getCmp('buttonSave');
......
......@@ -45,12 +45,12 @@ Ext.define('GanttEditor.controller.GanttZoomController', {
'scope': this
});
// Check if there is a state stored from a previous session.
var persistedP = me.restoreFromPreferenceStore();
if (!persistedP) {
// Otherwise show the entire project as a default
me.zoomOnEntireProject();
}
// Check if there is a state stored from a previous session.
var persistedP = me.restoreFromPreferenceStore();
if (!persistedP) {
// Otherwise show the entire project as a default
me.zoomOnEntireProject();
}
if (me.debug) console.log('GanttEditor.controller.GanttZoomController.init: Finished');
},
......@@ -65,7 +65,7 @@ Ext.define('GanttEditor.controller.GanttZoomController', {
if (me.debug) console.log('GanttZoomController.restoreFromPreferenceStore: Started');
var ganttBarPanel = me.getGanttBarPanel();
var persistedP = false;
var persistedP = false;
me.senchaPreferenceStore.each(function(model) {
var preferenceKey = model.get('preference_key');
var preferenceValue = model.get('preference_value');
......@@ -80,7 +80,7 @@ Ext.define('GanttEditor.controller.GanttZoomController', {
});
if (me.debug) console.log('GanttZoomController.restoreFromPreferenceStore: Finished');
return persistedP;
return persistedP;
},
......@@ -89,7 +89,7 @@ Ext.define('GanttEditor.controller.GanttZoomController', {
* without scroll bar.
*/
zoomOnEntireProject: function() {
var me = this;
var me = this;
if (me.debug) console.log('GanttEditor.controller.GanttZoomController.zoomEntireProject: Started');
var ganttBarPanel = me.getGanttBarPanel();
......@@ -112,7 +112,7 @@ Ext.define('GanttEditor.controller.GanttZoomController', {
ganttBarPanel.axisStartDate = new Date(reportStartTime - marginTime);
ganttBarPanel.axisEndDate = new Date(reportEndTime + marginTime);
// persist the changes
// persist the changes
me.senchaPreferenceStore.setPreference('axisStartTime', ganttBarPanel.axisStartDate.getTime());
me.senchaPreferenceStore.setPreference('axisEndTime', ganttBarPanel.axisEndDate.getTime());
me.senchaPreferenceStore.setPreference('axisEndX', ganttBarPanel.axisEndX);
......@@ -167,9 +167,9 @@ Ext.define('GanttEditor.controller.GanttZoomController', {
var panelBox = ganttBarPanel.getBox();
var panelWidth = panelBox.width;
// Avoid zooming out more than panelWidth
var endX = ganttBarPanel.axisEndX / me.zoomFactor;
if (endX < panelWidth) endX = panelWidth;
// Avoid zooming out more than panelWidth
var endX = ganttBarPanel.axisEndX / me.zoomFactor;
if (endX < panelWidth) endX = panelWidth;
ganttBarPanel.axisEndX = endX;
me.getGanttBarPanel().needsRedraw = true;
......@@ -256,18 +256,18 @@ Ext.define('GanttEditor.controller.GanttZoomController', {
var panelWidth = panelBox.width;
var panelHeight = panelBox.height;
var surfaceWidth = ganttBarPanel.axisEndX;
var surfaceWidth = ganttBarPanel.axisEndX;
if (surfaceWidth < panelWidth) {
if (surfaceWidth < panelWidth) {
ganttBarPanel.axisEndX = panelWidth;
ganttBarPanel.surface.setSize(panelWidth,panelHeight);
// persist the changes
// persist the changes
me.senchaPreferenceStore.setPreference('axisEndX', ganttBarPanel.axisEndX);
me.senchaPreferenceStore.setPreference('scrollX', 0);
ganttBarPanel.needsRedraw = true; // request a redraw
}
}
if (me.debug) console.log('GanttEditor.controller.GanttZoomController.onSwitchToFullScreen: Finished');
}
......
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