From b8ba32e8cf8a818e442ca45e23854492534e625e Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Fri, 4 Jul 2014 10:59:57 +0200 Subject: [PATCH] Slightly more readable wp property formatting --- .../work-package-details-controller.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/angular/work_packages/controllers/work-package-details-controller.js b/app/assets/javascripts/angular/work_packages/controllers/work-package-details-controller.js index a8768ce3e4..3925acfda3 100644 --- a/app/assets/javascripts/angular/work_packages/controllers/work-package-details-controller.js +++ b/app/assets/javascripts/angular/work_packages/controllers/work-package-details-controller.js @@ -57,20 +57,22 @@ angular.module('openproject.workPackages.controllers') var workPackageProperties = DEFAULT_WORK_PACKAGE_PROPERTIES; - angular.forEach(workPackageProperties, function(property) { - var label = I18n.t('js.work_packages.properties.' + property), - value; - + function getFormattedPropertyValue(property) { if (property === 'date') { if (workPackage.props.startDate && workPackage.props.dueDate) { - value = WorkPackagesHelper.formatWorkPackageProperty(workPackage.props['startDate'], 'startDate') + - ' - ' + - WorkPackagesHelper.formatWorkPackageProperty(workPackage.props['dueDate'], 'dueDate'); + return WorkPackagesHelper.formatWorkPackageProperty(workPackage.props['startDate'], 'startDate') + + ' - ' + + WorkPackagesHelper.formatWorkPackageProperty(workPackage.props['dueDate'], 'dueDate'); } } else { - value = WorkPackagesHelper.formatWorkPackageProperty(workPackage.props[property], property); + return WorkPackagesHelper.formatWorkPackageProperty(workPackage.props[property], property); } + } + + angular.forEach(workPackageProperties, function(property) { + var label = I18n.t('js.work_packages.properties.' + property), + value = getFormattedPropertyValue(property); if (value) { $scope.presentWorkPackageProperties[label] = value;