Commit 3599f4dd authored by Frank Bergmann's avatar Frank Bergmann

- Added numeric_roll_up DynField widget processing

  that creates a numeric field with aggregation
  bottom-up in the Gantt Editor
parent ca13b4e5
......@@ -79,8 +79,7 @@ Ext.define('PO.view.gantt.GanttTreePanel', {
// Veto editing planned_units of parent objects except for the name.
if (model.childNodes.length > 0) { // If this is a parent object with children
if ("planned_units" == field) { return false; }
if ("percent_completed" == field) { return false; }
if (@non_editable_summary_activities_json;noquote@.includes(field)) { return false; }
}
return true;
},
......@@ -192,28 +191,22 @@ Ext.define('PO.view.gantt.GanttTreePanel', {
}},
{text: 'Work', stateId: 'treegrid-work', width: 55, align: 'right', dataIndex: 'planned_units', hidden: true,
editor: { xtype: 'numberfield', minValue: 0 },
renderer: function(value, context, model) {
// Calculate the UoM unit
renderer: function(value, context, model) { // Calculate the UoM unit
var planned_units = model.get('planned_units');
if (0 == model.childNodes.length) {
// A leaf task - just show the units
if (0 == model.childNodes.length) { // A leaf task - just show the units
if ("" == planned_units) return "";
var pu = parseFloat(planned_units);
if ("number" == typeof pu) { planned_units = Math.round(100.0 * pu) / 100.0 }
if ("" != planned_units) { planned_units = planned_units + "h"; }
return planned_units;
} else {
// A parent node - sum up the planned units of all leafs.
} else { // A parent node - sum up the planned units of all leafs.
var plannedUnits = 0.0;
model.cascadeBy(function(child) {
if (0 == child.childNodes.length) { // Only consider leaf tasks
var puString = child.get('planned_units');
if ("" != puString) {
var pu = parseFloat(puString);
if ("number" == typeof pu) {
plannedUnits = plannedUnits + pu;
}
}
if ("" == puString) return;
var pu = parseFloat(puString);
if ("number" == typeof pu) plannedUnits = plannedUnits + pu;
}
});
var pu = parseFloat(plannedUnits);
......@@ -226,22 +219,17 @@ Ext.define('PO.view.gantt.GanttTreePanel', {
renderer: function(value, context, model) {
// Calculate the UoM unit
var billable_units = model.get('billable_units');
if (0 == model.childNodes.length) {
// A leaf task - just show the units
if (0 == model.childNodes.length) { // A leaf task - just show the units
if ("" != billable_units) { billable_units = billable_units + "h"; }
return billable_units;
} else {
// A parent node - sum up the billable units of all leafs.
} else { // A parent node - sum up the billable units of all leafs.
var billableUnits = 0.0;
model.cascadeBy(function(child) {
if (0 == child.childNodes.length) { // Only consider leaf tasks
var puString = child.get('billable_units');
if ("" != puString) {
var pu = parseFloat(puString);
if ("number" == typeof pu) {
billableUnits = billableUnits + pu;
}
}
if ("" == puString) return;
var pu = parseFloat(puString);
if ("number" == typeof pu) billableUnits = billableUnits + pu;
}
});
return "<b>"+billableUnits+"h</b>";
......@@ -411,7 +399,7 @@ Ext.define('PO.view.gantt.GanttTreePanel', {
// DynFields
<multiple name=dynfields>
,{text: '@dynfields.pretty_name@', stateId: 'treegrid-@dynfields.name@', flex: 1, dataIndex: '@dynfields.name@', hidden: true, sortable: false @dynfields.editor;noquote@}
,{text: '@dynfields.pretty_name@', stateId: 'treegrid-@dynfields.name@', flex: 1, dataIndex: '@dynfields.name@', hidden: true, sortable: false @dynfields.editor;noquote@ @dynfields.renderer;noquote@}
</multiple>
],
......
......@@ -67,10 +67,12 @@ set attributes_sql "
# ad_return_complaint 1 [im_ad_hoc_query -format html $attributes_sql]
set errors {}
multirow create dynfields name pretty_name widget editor
multirow create dynfields name pretty_name widget editor renderer
set non_editable_summary_activities [list "planned_units" "billable_units" "percent_completed"]
db_foreach attributes $attributes_sql {
set editor "undefined"
set renderer ""
# Handle specific ]po[ widgets.
# For example, both "numeric" and textarea_small are of TCL widget "text",
......@@ -79,7 +81,37 @@ db_foreach attributes $attributes_sql {
checkbox { set editor "" }
date - timestamp { set editor ", editor: 'podatefield'" }
integer { set editor ", editor: 'numberfield'" }
numeric { set editor ", editor: 'numberfield'" }
numeric {
set editor ", editor: 'numberfield'"
}
numeric_roll_up {
lappend non_editable_summary_activities $attribute_name
set editor ", editor: 'numberfield'"
set renderer "
, renderer: function(orgValue, context, model) {
// Calculate the UoM unit
var value = model.get('$attribute_name');
if (0 == model.childNodes.length) { // A leaf task - just show the value
if ('' == value) return '';
var valueFloat = parseFloat(value);
if ('number' == typeof valueFloat) { value = Math.round(100.0 * valueFloat) / 100.0 }
return value;
} else { // A parent node - sum up the leaf values
var valueSum = 0.0;
model.cascadeBy(function(child) {
if (0 == child.childNodes.length) { // Only consider leaf tasks
var valueString = child.get('$attribute_name');
if ('' == valueString) return;
var value = parseFloat(valueString);
if ('number' == typeof value) valueSum = valueSum + value;
}
});
valueSum = Math.round(100.0 * valueSum) / 100.0;
return '<b>'+valueSum+'</b>';
}
},\n"
}
richtext { set editor ", editor: true" }
textarea_small - textarea_small_nospell - textbox_large - textbox_medium - textbox_small { set editor ", editor: true" }
}
......@@ -164,19 +196,22 @@ db_foreach attributes $attributes_sql {
# Still undefined - Return an error
if {"undefined" eq $editor} {
lappend errors "<b>GanttTreePanel.tcl: Unknown widget</b><br> \
<ul> \
<li>attribute_name=$attribute_name \
<li>widget=$widget_name \
<li>tcl_widget=$tcl_widget \
<li>parameters=$parameters \
</ul><br> \
Tell your SysAdmin to remove attribute=$attribute_name"
<ul> \
<li>attribute_name=$attribute_name \
<li>widget=$widget_name \
<li>tcl_widget=$tcl_widget \
<li>parameters=$parameters \
</ul><br> \
Tell your SysAdmin to remove attribute=$attribute_name"
}
multirow append dynfields $attribute_name $pretty_name $widget_name $editor
multirow append dynfields $attribute_name $pretty_name $widget_name $editor $renderer
}
set non_editable_summary_activities_json "\['[join $non_editable_summary_activities "', '"]'\]"
set error_tbar ""
if {"" ne $errors} {
set error_tbar "tbar: \[\{ xtype: 'panel', html: '<font color=red>Errors:<br>[join $errors "<br>"]</font>' \}\],"
......
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