Commit 0cb3371c authored by Frank Bergmann's avatar Frank Bergmann

- Fixed issues with Configuration menu

- Refactored configuration code
- Created ConfigMenu class in sencha-core
parent 505d4c65
......@@ -51,6 +51,7 @@ Ext.require([
'PO.view.gantt.GanttTaskPropertyPanel',
'PO.view.gantt.GanttTreePanel',
'PO.view.menu.AlphaMenu',
'PO.view.menu.ConfigMenu',
'PO.view.menu.HelpMenu'
]);
......@@ -107,56 +108,27 @@ function launchGanttEditor(debug){
/* ***********************************************************************
* Config Menu
*********************************************************************** */
var configMenuOnItemCheck = function(item, checked){
var me = this;
if (me.debug) console.log('configMenuOnItemCheck: item.id='+item.id);
senchaPreferenceStore.setPreference(item.id, checked);
}
var configMenu = Ext.create('Ext.menu.Menu', {
id: 'configMenu',
var configMenu = Ext.create('PO.view.menu.ConfigMenu', {
debug: debug,
style: {overflow: 'visible'}, // For the Combo popup
id: 'configMenu',
senchaPreferenceStore: senchaPreferenceStore,
items: [{
text: 'Reset Configuration',
handler: function() {
var me = this;
var menu = me.ownerCt;
if (menu.debug) console.log('configMenu.OnResetConfiguration');
senchaPreferenceStore.each(function(model) {
model.destroy();
});
}
}, '-']
});
// Setup the configMenu items
var confSetupStore = Ext.create('Ext.data.Store', {
fields: ['key', 'text', 'def'],
data : [
{key: 'read_only', text: 'Read Only (Beta version - use with caution!)', def: true},
{key: 'show_project_dependencies', text: 'Show Project Dependencies', def: true},
{key: 'show_project_resource_load', text: 'Show Project Assigned Resources', def: true}
]
});
confSetupStore.each(function(model) {
var key = model.get('key');
var def = model.get('def');
var checked = senchaPreferenceStore.getPreferenceBoolean(key, def);
if (!senchaPreferenceStore.existsPreference(key)) {
senchaPreferenceStore.setPreference(key, checked ? 'true' : 'false');
}
var item = Ext.create('Ext.menu.CheckItem', {
id: key,
text: model.get('text'),
checked: checked,
checkHandler: configMenuOnItemCheck
});
configMenu.add(item);
key: 'read_only',
text: 'Read Only (Beta version - use with caution!)',
checked: true
}, {
id: 'config_menu_show_project_dependencies',
key: 'show_project_dependencies',
text: 'Show Project Dependencies',
checked: true
}, {
id: 'config_menu_show_project_assigned_resources',
key: 'show_project_assigned_resources',
text: 'Show Project Assigned Resources',
checked: true
}]
});
/* ***********************************************************************
* Scheduling Menu
*********************************************************************** */
......@@ -245,7 +217,7 @@ function launchGanttEditor(debug){
var ganttTreePanelController = Ext.create('GanttEditor.controller.GanttTreePanelController', {
ganttTreePanel: ganttTreePanel,
senchaPreferenceStore: senchaPreferenceStore,
senchaPreferenceStore: senchaPreferenceStore,
debug: debug
});
ganttTreePanelController.init(this);
......@@ -255,12 +227,12 @@ function launchGanttEditor(debug){
// Right-hand side Gantt display
var ganttBarPanel = Ext.create('GanttEditor.view.GanttBarPanel', {
id: 'ganttBarPanel',
cls: 'gantt-bar-panel',
cls: 'gantt-bar-panel',
region: 'center',
debug: debug,
reportStartTime: reportStartTime,
reportEndTime: reportEndTime,
reportStartTime: reportStartTime,
reportEndTime: reportEndTime,
overflowX: 'scroll', // Allows for horizontal scrolling, but not vertical
scrollFlags: { x: true },
......@@ -303,8 +275,8 @@ function launchGanttEditor(debug){
ganttBarPanel: ganttBarPanel,
taskTreeStore: taskTreeStore,
resizeController: resizeController,
senchaPreferenceStore: senchaPreferenceStore,
ganttTreePanelController: ganttTreePanelController
senchaPreferenceStore: senchaPreferenceStore,
ganttTreePanelController: ganttTreePanelController
});
ganttButtonController.init(this).onLaunch(this);
......@@ -398,11 +370,11 @@ Ext.onReady(function() {
query: "user_id in ( \
select r.object_id_two \
from acs_rels r, \
im_projects main_p, \
im_projects sub_p \
im_projects main_p, \
im_projects sub_p \
where main_p.project_id = @project_id@ and \
sub_p.tree_sortkey between main_p.tree_sortkey and tree_right(main_p.tree_sortkey) and \
r.object_id_one = sub_p.project_id \
sub_p.tree_sortkey between main_p.tree_sortkey and tree_right(main_p.tree_sortkey) and \
r.object_id_one = sub_p.project_id \
)"
};
projectMemberStore.load();
......
......@@ -32,7 +32,11 @@ Ext.define('GanttEditor.controller.GanttTreePanelController', {
'#buttonReduceIndent': { click: this.onButtonReduceIndent},
'#buttonIncreaseIndent': { click: this.onButtonIncreaseIndent},
'#buttonAdd': { click: this.onButtonAdd},
'#buttonDelete': { click: this.onButtonDelete}
'#buttonDelete': { click: this.onButtonDelete},
// Redraw GanttBars after changing the configuration
'#config_menu_show_project_dependencies': { click: this.redrawGanttBarPanel},
'#config_menu_show_project_assigned_resources': { click: this.redrawGanttBarPanel}
});
// Listen to drop events from tree drag-and-drop
......
......@@ -401,7 +401,10 @@ Ext.define('GanttEditor.view.GanttBarPanel', {
},
/**
* Set axis and scroll configuration as stored
* in the SenchaPreferenceStore
*/
redrawSetScrolls: function() {
var me = this;
if (me.debug) console.log('PO.class.GanttDrawComponent.redrawSetScrolls: Started');
......@@ -607,31 +610,33 @@ Ext.define('GanttEditor.view.GanttBarPanel', {
}).show(true);
}
if (!drawn) { alert('GanttBarPanel.drawProjectBar: not drawn'); }
if (!drawn) { alert('GanttBarPanel.drawProjectBar: not drawn for some reason'); }
// Convert assignment information into a string
// and write behind the Gantt bar
var projectMemberStore = Ext.StoreManager.get('projectMemberStore');
var text = "";
if ("" != assignees) {
assignees.forEach(function(assignee) {
if (0 == assignee.percent) { return; } // Don't show empty assignments
var userModel = projectMemberStore.getById(""+assignee.user_id);
if (!userModel) return;
if ("" != text) { text = text + ', '; }
text = text + userModel.get('first_names').substr(0, 1) + userModel.get('last_name').substr(0, 1);
if (100 != assignee.percent) {
text = text + '['+assignee.percent+'%]';
}
});
var xOffset = w + 4; // Default: Start directly behind the bar
switch (drawn) {
// Draw assignee initials behind the Gantt bar.
var drawAssignees = me.preferenceStore.getPreferenceBoolean('show_project_assigned_resources', true);
if (drawAssignees) {
var projectMemberStore = Ext.StoreManager.get('projectMemberStore');
var text = "";
if ("" != assignees) {
assignees.forEach(function(assignee) {
if (0 == assignee.percent) { return; } // Don't show empty assignments
var userModel = projectMemberStore.getById(""+assignee.user_id);
if (!userModel) return;
if ("" != text) { text = text + ', '; }
text = text + userModel.get('first_names').substr(0, 1) + userModel.get('last_name').substr(0, 1);
if (100 != assignee.percent) {
text = text + '['+assignee.percent+'%]';
}
});
var xOffset = w + 4; // Default: Start directly behind the bar
switch (drawn) {
case 'milestone': xOffset = 8; // Milestone: Ignore bar width, but add some extra space
}
var axisText = surface.add({type:'text', text:text, x:x+xOffset, y:y+d, fill:'#000', font:"10px Arial"}).show(true);
}
}
var axisText = surface.add({type:'text', text:text, x:x+xOffset, y:y+d, fill:'#000', font:"10px Arial"}).show(true);
}
}
// Add a drag-and-drop configuration to all spriteBars (bar, supertask and milestone)
// in order to allow them to act as both source and target of inter-task dependencies.
......
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