|
|
|
@@ -1,6 +1,9 @@
|
|
|
|
|
// Generated by CoffeeScript 1.12.5
|
|
|
|
|
// Generated by CoffeeScript 2.7.0
|
|
|
|
|
//projectGetWorkflowActionDefinitionOffsets = () ->
|
|
|
|
|
// true
|
|
|
|
|
//export default projectGetWorkflowActionDefinitionOffsets
|
|
|
|
|
var OffsetNode, RecordNode, WorkflowActionDefinitionOffsetNodes,
|
|
|
|
|
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
|
|
|
|
indexOf = [].indexOf;
|
|
|
|
|
|
|
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
|
@@ -10,7 +13,7 @@ RecordNode = Ember.Object.extend({
|
|
|
|
|
var title, value_shift;
|
|
|
|
|
title = this.get('record.title');
|
|
|
|
|
if (value_shift = this.get('value_shift')) {
|
|
|
|
|
title = " " + title + " (" + value_shift + "d)";
|
|
|
|
|
title = ` ${title} (${value_shift}d)`;
|
|
|
|
|
}
|
|
|
|
|
return title;
|
|
|
|
|
})
|
|
|
|
@@ -30,12 +33,10 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
batch_size: 0,
|
|
|
|
|
active_project_scenario: null,
|
|
|
|
|
forEach: function() {
|
|
|
|
|
var ref;
|
|
|
|
|
return (ref = this.get('processed_workflow_action_definitions')).forEach.apply(ref, arguments);
|
|
|
|
|
return this.get('processed_workflow_action_definitions').forEach(...arguments);
|
|
|
|
|
},
|
|
|
|
|
filterBy: function() {
|
|
|
|
|
var ref;
|
|
|
|
|
return (ref = this.get('processed_workflow_action_definitions')).filterBy.apply(ref, arguments);
|
|
|
|
|
return this.get('processed_workflow_action_definitions').filterBy(...arguments);
|
|
|
|
|
},
|
|
|
|
|
get_resolved: function() {
|
|
|
|
|
return this.get('processed_workflow_action_definitions').filterBy('resolved');
|
|
|
|
@@ -58,16 +59,16 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
action_added = false;
|
|
|
|
|
if (workflow_action_definition.get('offset_type') === 'configured') {
|
|
|
|
|
workflow_action_definition.get('workflow_action_offsets').forEach(function(workflow_action_offset) {
|
|
|
|
|
var absolute_value, date, offset_date, offset_value, record_wrapper, ref, ref1, value_shift;
|
|
|
|
|
var absolute_value, date, offset_date, offset_value, record_wrapper, value_shift;
|
|
|
|
|
if (action_added) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (active_scenario_identifier && workflow_action_offset.get('project_scenario.identifier') && workflow_action_offset.get('project_scenario.identifier') !== active_scenario_identifier) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!workflow_action_offset.get('base_workflow_action_definition.content')) {
|
|
|
|
|
ref = base.get_offset_for_target(workflow_action_offset, 0), offset_date = ref[0], offset_value = ref[1];
|
|
|
|
|
ref1 = base.get_dynamic_offset_for_target(workflow_action_offset, offset_value), date = ref1[0], value_shift = ref1[1];
|
|
|
|
|
if (!workflow_action_offset.get('base_workflow_action_definition.content')) { // x_based
|
|
|
|
|
[offset_date, offset_value] = base.get_offset_for_target(workflow_action_offset, 0);
|
|
|
|
|
[date, value_shift] = base.get_dynamic_offset_for_target(workflow_action_offset, offset_value);
|
|
|
|
|
absolute_value = offset_value + value_shift;
|
|
|
|
|
record_wrapper = RecordNode.create({
|
|
|
|
|
record: workflow_action_definition,
|
|
|
|
@@ -97,32 +98,31 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
this.set('processed_workflow_action_definitions', first_loop_actions);
|
|
|
|
|
this.set('working_workflow_action_definitions', working_workflow_action_definitions);
|
|
|
|
|
this.incrementProperty('iteration_context_counter');
|
|
|
|
|
//@set 'working_workflow_action_definitions', @get('workflow_action_definitions').filterBy('offset_type', 'configured')
|
|
|
|
|
this.run_critical_path_resolve_loop();
|
|
|
|
|
resolve_level = this.get('iteration_context_counter');
|
|
|
|
|
return this.get('working_workflow_action_definitions').forEach((function(_this) {
|
|
|
|
|
return function(unresolved_workflow_action_definition) {
|
|
|
|
|
var offset_wrappers;
|
|
|
|
|
offset_wrappers = [];
|
|
|
|
|
unresolved_workflow_action_definition.get('workflow_action_offsets').forEach(function(action_offset) {
|
|
|
|
|
var ref;
|
|
|
|
|
if (ref = action_offset.get('base_workflow_action_definition.id'), indexOf.call(scope_workflow_action_definition_ids, ref) < 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
return offset_wrappers.push(OffsetNode.create({
|
|
|
|
|
total_offset: action_offset.get('offset_value'),
|
|
|
|
|
record: action_offset
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
return _this.get('processed_workflow_action_definitions').push(RecordNode.create({
|
|
|
|
|
record: unresolved_workflow_action_definition,
|
|
|
|
|
record_id: unresolved_workflow_action_definition.get('id'),
|
|
|
|
|
offset_wrappers: offset_wrappers,
|
|
|
|
|
resolved: false,
|
|
|
|
|
resolve_level: resolve_level,
|
|
|
|
|
resolve_type: 'unresolved'
|
|
|
|
|
return this.get('working_workflow_action_definitions').forEach((unresolved_workflow_action_definition) => { // add unresolved records
|
|
|
|
|
var offset_wrappers;
|
|
|
|
|
offset_wrappers = [];
|
|
|
|
|
unresolved_workflow_action_definition.get('workflow_action_offsets').forEach(function(action_offset) {
|
|
|
|
|
var ref;
|
|
|
|
|
if (ref = action_offset.get('base_workflow_action_definition.id'), indexOf.call(scope_workflow_action_definition_ids, ref) < 0) { // do not add offsets from other scenarios
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
return offset_wrappers.push(OffsetNode.create({
|
|
|
|
|
total_offset: action_offset.get('offset_value'),
|
|
|
|
|
record: action_offset
|
|
|
|
|
}));
|
|
|
|
|
};
|
|
|
|
|
})(this));
|
|
|
|
|
});
|
|
|
|
|
return this.get('processed_workflow_action_definitions').push(RecordNode.create({
|
|
|
|
|
record: unresolved_workflow_action_definition,
|
|
|
|
|
record_id: unresolved_workflow_action_definition.get('id'),
|
|
|
|
|
offset_wrappers: offset_wrappers,
|
|
|
|
|
resolved: false,
|
|
|
|
|
resolve_level: resolve_level,
|
|
|
|
|
resolve_type: 'unresolved'
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
get_dynamic_offset_for_target: function(target, absolute_value) {
|
|
|
|
|
var base_date, batch_size, empty, offset_value, operation, period_unit, shifted_date, threshold, threshold_exceedance, value_shift;
|
|
|
|
@@ -134,14 +134,14 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
if (!(threshold = target.get('batch_element_threshold_value'))) {
|
|
|
|
|
return empty;
|
|
|
|
|
}
|
|
|
|
|
if (!(threshold_exceedance = Math.floor(batch_size / (0.1 + parseInt(threshold))))) {
|
|
|
|
|
if (!(threshold_exceedance = Math.floor(batch_size / (0.1 + parseInt(threshold))))) { // + 0.1 (delta) to exclude exact match of batch_size and threshold. First day is action day
|
|
|
|
|
return empty;
|
|
|
|
|
}
|
|
|
|
|
period_unit = target.get('batch_element_threshold_unit');
|
|
|
|
|
offset_value = target.get('offset_value');
|
|
|
|
|
operation = offset_value < 0 ? 'subtract' : 'add';
|
|
|
|
|
if (period_unit === 'businessday') {
|
|
|
|
|
operation = "business" + (operation.capitalize());
|
|
|
|
|
operation = `business${operation.capitalize()}`;
|
|
|
|
|
shifted_date = base_date.clone()[operation](threshold_exceedance, {
|
|
|
|
|
business_days: target.get('batch_element_threshold_business_days')
|
|
|
|
|
});
|
|
|
|
@@ -161,7 +161,7 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
period_unit = target.get('offset_unit');
|
|
|
|
|
operation = offset_value < 0 ? 'subtract' : 'add';
|
|
|
|
|
if (period_unit === 'businessday') {
|
|
|
|
|
operation = "business" + (operation.capitalize());
|
|
|
|
|
operation = `business${operation.capitalize()}`;
|
|
|
|
|
shifted_date = base_date.clone()[operation](Math.abs(offset_value), {
|
|
|
|
|
business_days: target.get('offset_business_days')
|
|
|
|
|
});
|
|
|
|
@@ -169,6 +169,7 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
shifted_date = base_date.clone()[operation](Math.abs(offset_value), period_unit);
|
|
|
|
|
}
|
|
|
|
|
value_shift = shifted_date.diff(base_date, 'day');
|
|
|
|
|
//debugger if target.get('workflow_action_definition.title') is 'Initial check done'
|
|
|
|
|
return [shifted_date, value_shift];
|
|
|
|
|
},
|
|
|
|
|
run_critical_path_resolve_loop: function() {
|
|
|
|
@@ -188,24 +189,26 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
farthest_absolute_value = 0;
|
|
|
|
|
farthest_absolute_value_value_shift = 0;
|
|
|
|
|
farthest_result_total_offset = 0;
|
|
|
|
|
date = null;
|
|
|
|
|
date = null; // scoping
|
|
|
|
|
resolved_offset_wrappers = [];
|
|
|
|
|
all_offsets_resolved = working_workflow_action_definition.get('workflow_action_offsets').every(function(workflow_action_offset) {
|
|
|
|
|
var current_connection_absolute_value, current_connection_total_offset_value, current_connection_value_shift, offset_date, processed_absolute_value, processed_base_workflow_action_definition_wrapper, ref, ref1, ref2, working_offset_value;
|
|
|
|
|
var current_connection_absolute_value, current_connection_total_offset_value, current_connection_value_shift, offset_date, processed_absolute_value, processed_base_workflow_action_definition_wrapper, ref, working_offset_value;
|
|
|
|
|
if (active_scenario_identifier && workflow_action_offset.get('project_scenario.identifier') && workflow_action_offset.get('project_scenario.identifier') !== active_scenario_identifier) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (!(processed_base_workflow_action_definition_wrapper = processed_workflow_action_definitions.findBy('record_id', workflow_action_offset.get('base_workflow_action_definition.id')))) {
|
|
|
|
|
if (ref = workflow_action_offset.get('base_workflow_action_definition.id'), indexOf.call(scope_workflow_action_definition_ids, ref) < 0) {
|
|
|
|
|
if (ref = workflow_action_offset.get('base_workflow_action_definition.id'), indexOf.call(scope_workflow_action_definition_ids, ref) < 0) { // base is not present in this scenario, do not pursue this connection
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
processed_absolute_value = processed_base_workflow_action_definition_wrapper.get('absolute_value');
|
|
|
|
|
ref1 = get_offset_for_target(workflow_action_offset, processed_absolute_value), offset_date = ref1[0], working_offset_value = ref1[1];
|
|
|
|
|
ref2 = get_dynamic_offset_for_target(workflow_action_offset, processed_absolute_value + working_offset_value), date = ref2[0], current_connection_value_shift = ref2[1];
|
|
|
|
|
[offset_date, working_offset_value] = get_offset_for_target(workflow_action_offset, processed_absolute_value);
|
|
|
|
|
[date, current_connection_value_shift] = get_dynamic_offset_for_target(workflow_action_offset, processed_absolute_value + working_offset_value);
|
|
|
|
|
current_connection_total_offset_value = current_connection_value_shift + working_offset_value;
|
|
|
|
|
current_connection_absolute_value = processed_absolute_value + current_connection_total_offset_value;
|
|
|
|
|
//debugger if processed_base_workflow_action_definition_wrapper.get('record.title') is 'Initial check done'
|
|
|
|
|
//debugger if working_workflow_action_definition.get('title') is 'Initial check done'
|
|
|
|
|
if (Math.abs(current_connection_absolute_value) > Math.abs(farthest_absolute_value)) {
|
|
|
|
|
farthest_absolute_value = current_connection_absolute_value;
|
|
|
|
|
farthest_absolute_value_value_shift = current_connection_value_shift;
|
|
|
|
@@ -217,7 +220,7 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
total_offset: current_connection_total_offset_value,
|
|
|
|
|
resulting_absolute_value: current_connection_absolute_value
|
|
|
|
|
}));
|
|
|
|
|
return true;
|
|
|
|
|
return true; // indicate processed_base_workflow_action_definition_wrapper found for all_offsets_resolved value
|
|
|
|
|
});
|
|
|
|
|
if (all_offsets_resolved && resolved_offset_wrappers.length) {
|
|
|
|
|
record_wrapper = RecordNode.create({
|
|
|
|
@@ -262,10 +265,10 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
farthest_absolute_value = 0;
|
|
|
|
|
farthest_absolute_value_value_shift = 0;
|
|
|
|
|
farthest_result_total_offset = 0;
|
|
|
|
|
date = null;
|
|
|
|
|
date = null; // scoping
|
|
|
|
|
resolved_offset_wrappers = [];
|
|
|
|
|
working_workflow_action_definition.get('workflow_action_offsets').forEach(function(workflow_action_offset) {
|
|
|
|
|
var current_connection_absolute_value, current_connection_total_offset_value, current_connection_value_shift, offset_date, processed_absolute_value, processed_base_workflow_action_definition_wrapper, ref, ref1, ref2, working_offset_value;
|
|
|
|
|
var current_connection_absolute_value, current_connection_total_offset_value, current_connection_value_shift, offset_date, processed_absolute_value, processed_base_workflow_action_definition_wrapper, ref, working_offset_value;
|
|
|
|
|
if (active_scenario_identifier && workflow_action_offset.get('project_scenario.identifier') && workflow_action_offset.get('project_scenario.identifier') !== active_scenario_identifier) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@@ -276,10 +279,12 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
processed_absolute_value = processed_base_workflow_action_definition_wrapper.get('absolute_value');
|
|
|
|
|
ref1 = get_offset_for_target(workflow_action_offset, processed_absolute_value), offset_date = ref1[0], working_offset_value = ref1[1];
|
|
|
|
|
ref2 = get_dynamic_offset_for_target(workflow_action_offset, processed_absolute_value + working_offset_value), date = ref2[0], current_connection_value_shift = ref2[1];
|
|
|
|
|
[offset_date, working_offset_value] = get_offset_for_target(workflow_action_offset, processed_absolute_value);
|
|
|
|
|
[date, current_connection_value_shift] = get_dynamic_offset_for_target(workflow_action_offset, processed_absolute_value + working_offset_value);
|
|
|
|
|
current_connection_total_offset_value = current_connection_value_shift + working_offset_value;
|
|
|
|
|
current_connection_absolute_value = processed_absolute_value + current_connection_total_offset_value;
|
|
|
|
|
//debugger if processed_base_workflow_action_definition_wrapper.get('record.title') is 'Initial check done'
|
|
|
|
|
//debugger if working_workflow_action_definition.get('title') is 'Initial check done'
|
|
|
|
|
if (Math.abs(current_connection_absolute_value) > Math.abs(farthest_absolute_value)) {
|
|
|
|
|
farthest_absolute_value = current_connection_absolute_value;
|
|
|
|
|
farthest_absolute_value_value_shift = current_connection_value_shift;
|
|
|
|
@@ -296,7 +301,7 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
record_wrapper = RecordNode.create({
|
|
|
|
|
record: working_workflow_action_definition,
|
|
|
|
|
record_id: working_workflow_action_definition.get('id'),
|
|
|
|
|
offset_wrappers: resolved_offset_wrappers,
|
|
|
|
|
offset_wrappers: resolved_offset_wrappers, // .clone()?
|
|
|
|
|
value_shift: farthest_absolute_value_value_shift,
|
|
|
|
|
absolute_value: farthest_absolute_value,
|
|
|
|
|
date: date,
|
|
|
|
@@ -331,10 +336,10 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
farthest_absolute_value = 0;
|
|
|
|
|
farthest_absolute_value_value_shift = 0;
|
|
|
|
|
farthest_result_total_offset = 0;
|
|
|
|
|
date = null;
|
|
|
|
|
date = null; // scoping
|
|
|
|
|
resolved_offset_wrappers = [];
|
|
|
|
|
working_workflow_action_definition.get('dependent_workflow_action_offsets').forEach(function(workflow_action_offset) {
|
|
|
|
|
var current_connection_absolute_value, current_connection_total_offset_value, current_connection_value_shift, offset_date, processed_absolute_value, processed_base_workflow_action_definition_wrapper, ref, ref1, ref2, working_offset_value;
|
|
|
|
|
var current_connection_absolute_value, current_connection_total_offset_value, current_connection_value_shift, offset_date, processed_absolute_value, processed_base_workflow_action_definition_wrapper, ref, working_offset_value;
|
|
|
|
|
if (active_scenario_identifier && workflow_action_offset.get('project_scenario.identifier') && workflow_action_offset.get('project_scenario.identifier') !== active_scenario_identifier) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@@ -344,11 +349,15 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
if (!(processed_base_workflow_action_definition_wrapper = processed_workflow_action_definitions.findBy('record_id', workflow_action_offset.get('workflow_action_definition.id')))) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//return if workflow_action_offset.get('workflow_action_definition.offset_type') is 'none' # do not resolve on none offset typed nodes
|
|
|
|
|
processed_absolute_value = processed_base_workflow_action_definition_wrapper.get('absolute_value');
|
|
|
|
|
ref1 = get_offset_for_target(workflow_action_offset, processed_absolute_value), offset_date = ref1[0], working_offset_value = ref1[1];
|
|
|
|
|
ref2 = get_dynamic_offset_for_target(workflow_action_offset, processed_absolute_value + working_offset_value), date = ref2[0], current_connection_value_shift = ref2[1];
|
|
|
|
|
[offset_date, working_offset_value] = get_offset_for_target(workflow_action_offset, processed_absolute_value);
|
|
|
|
|
[date, current_connection_value_shift] = get_dynamic_offset_for_target(workflow_action_offset, processed_absolute_value + working_offset_value);
|
|
|
|
|
current_connection_total_offset_value = current_connection_value_shift + working_offset_value;
|
|
|
|
|
//NOTE MINUS!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
current_connection_absolute_value = processed_absolute_value - current_connection_total_offset_value;
|
|
|
|
|
//debugger if processed_base_workflow_action_definition_wrapper.get('record.title') is 'Initial check done'
|
|
|
|
|
//debugger if working_workflow_action_definition.get('title') is 'Initial check done'
|
|
|
|
|
if (Math.abs(current_connection_absolute_value) > Math.abs(farthest_absolute_value)) {
|
|
|
|
|
farthest_absolute_value = current_connection_absolute_value;
|
|
|
|
|
farthest_absolute_value_value_shift = current_connection_value_shift;
|
|
|
|
@@ -365,7 +374,7 @@ WorkflowActionDefinitionOffsetNodes = Ember.Object.extend({
|
|
|
|
|
record_wrapper = RecordNode.create({
|
|
|
|
|
record: working_workflow_action_definition,
|
|
|
|
|
record_id: working_workflow_action_definition.get('id'),
|
|
|
|
|
offset_wrappers: resolved_offset_wrappers,
|
|
|
|
|
offset_wrappers: resolved_offset_wrappers, // .clone()?
|
|
|
|
|
value_shift: farthest_absolute_value_value_shift,
|
|
|
|
|
absolute_value: farthest_absolute_value,
|
|
|
|
|
date: date,
|
|
|
|
|