|
|
@ -56,24 +56,30 @@ angular.module('openproject.timelines.directives') |
|
|
|
setHistoricalData(scope); |
|
|
|
setHistoricalData(scope); |
|
|
|
|
|
|
|
|
|
|
|
function getColumnData() { |
|
|
|
function getColumnData() { |
|
|
|
var map = { |
|
|
|
|
|
|
|
"type": "getTypeName", |
|
|
|
|
|
|
|
"status": "getStatusName", |
|
|
|
|
|
|
|
"responsible": "getResponsibleName", |
|
|
|
|
|
|
|
"assigned_to": "getAssignedName", |
|
|
|
|
|
|
|
"project": "getProjectName" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(scope.columnName) { |
|
|
|
switch(scope.columnName) { |
|
|
|
case 'start_date': |
|
|
|
case 'start_date': |
|
|
|
return scope.rowObject.start_date; |
|
|
|
return scope.rowObject.start_date; |
|
|
|
case 'due_date': |
|
|
|
case 'due_date': |
|
|
|
return scope.rowObject.due_date; |
|
|
|
return scope.rowObject.due_date; |
|
|
|
default: |
|
|
|
default: |
|
|
|
return scope.rowObject[map[scope.columnName]](); |
|
|
|
return scope.rowObject.getAttribute(getAttributeAccessor(scope.columnName)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getAttributeAccessor(attr) { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
"type": "getTypeName", |
|
|
|
|
|
|
|
"status": "getStatusName", |
|
|
|
|
|
|
|
"responsible": "getResponsibleName", |
|
|
|
|
|
|
|
"assigned_to": "getAssignedName", |
|
|
|
|
|
|
|
"project": "getProjectName" |
|
|
|
|
|
|
|
}[attr] || attr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function hasChanged(planningElement, attr) { |
|
|
|
|
|
|
|
return planningElement.does_historical_differ(getAttributeAccessor(attr)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getCustomFieldColumnData(object, customFieldName, customFields, users) { |
|
|
|
function getCustomFieldColumnData(object, customFieldName, customFields, users) { |
|
|
|
if(!customFields) return; // custom_fields provides necessary meta information about the custom field column
|
|
|
|
if(!customFields) return; // custom_fields provides necessary meta information about the custom field column
|
|
|
|
|
|
|
|
|
|
|
@ -85,21 +91,21 @@ angular.module('openproject.timelines.directives') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setHistoricalData() { |
|
|
|
function setHistoricalData() { |
|
|
|
scope.historicalDataDiffers = scope.rowObject.does_historical_differ(scope.columnName); |
|
|
|
scope.historicalDataDiffers = hasChanged(scope.rowObject, scope.columnName); |
|
|
|
|
|
|
|
|
|
|
|
scope.historicalDateKind = getHistoricalDateKind(scope.rowObject, scope.columnName); |
|
|
|
scope.historicalDateKind = getHistoricalDateKind(scope.rowObject, scope.columnName); |
|
|
|
scope.labelTimelineChanged = I18n.t('js.timelines.change'); |
|
|
|
scope.labelTimelineChanged = I18n.t('js.timelines.change'); |
|
|
|
|
|
|
|
|
|
|
|
if (scope.rowObject.historical_element) { |
|
|
|
if (scope.rowObject.historical_element) { |
|
|
|
scope.historicalData = scope.rowObject.historical_element[scope.columnName] || I18n.t('js.timelines.empty'); |
|
|
|
scope.historicalData = scope.rowObject.historical_element.getAttribute(getAttributeAccessor(scope.columnName)) || I18n.t('js.timelines.empty'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getHistoricalDateKind(object, value) { |
|
|
|
function getHistoricalDateKind(planningElement, attr) { |
|
|
|
if (!object.does_historical_differ(value)) return; |
|
|
|
if (!hasChanged(planningElement, attr)) return; |
|
|
|
|
|
|
|
|
|
|
|
var newDate = object[value]; |
|
|
|
var newDate = planningElement[attr]; |
|
|
|
var oldDate = object.historical()[value]; |
|
|
|
var oldDate = planningElement.historical_element[attr]; |
|
|
|
|
|
|
|
|
|
|
|
if (oldDate && newDate) { |
|
|
|
if (oldDate && newDate) { |
|
|
|
return (newDate < oldDate ? 'postponed' : 'preponed'); |
|
|
|
return (newDate < oldDate ? 'postponed' : 'preponed'); |
|
|
|