From 086a346cf040ba3224a4edd4db6087c257740dc2 Mon Sep 17 00:00:00 2001 From: mhirtie Date: Tue, 28 Apr 2015 14:10:07 +0300 Subject: [PATCH] Add title labels. Remove console.log call. --- .../inplace_editor/custom/editable/date.html | 6 ++++- .../date/date-range-picker-directive.js | 27 +++++++++---------- frontend/app/ui_components/index.js | 3 ++- .../editable/inplace-editor-date-directive.js | 8 ++---- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/frontend/app/templates/work_packages/inplace_editor/custom/editable/date.html b/frontend/app/templates/work_packages/inplace_editor/custom/editable/date.html index 3a1f5455bb..0953662291 100644 --- a/frontend/app/templates/work_packages/inplace_editor/custom/editable/date.html +++ b/frontend/app/templates/work_packages/inplace_editor/custom/editable/date.html @@ -1,4 +1,8 @@
- +
diff --git a/frontend/app/ui_components/date/date-range-picker-directive.js b/frontend/app/ui_components/date/date-range-picker-directive.js index 096537e309..88f1f54636 100644 --- a/frontend/app/ui_components/date/date-range-picker-directive.js +++ b/frontend/app/ui_components/date/date-range-picker-directive.js @@ -27,7 +27,8 @@ //++ module.exports = function(TimezoneService, ConfigurationService, - I18n, $timeout) { + I18n, $timeout, WorkPackageFieldService, + EditableFieldsState) { var parseDate = TimezoneService.parseDate, parseISODate = TimezoneService.parseISODate, formattedDate = function(date) { @@ -39,8 +40,10 @@ module.exports = function(TimezoneService, ConfigurationService, customFormattedDate = function(date) { return parseISODate(date).format(customDateFormat); }, - noStartDate = I18n.t('js.label_no_start_date'), - noEndDate = I18n.t('js.label_no_due_date'); + getLabel = WorkPackageFieldService.getLabel.bind(null, EditableFieldsState.workPackage), + getTitle = function(labelName) { + return I18n.t('js.inplace.button_edit', {attribute: getLabel(labelName)}); + }; return { restrict: 'EA', replace: true, @@ -59,18 +62,16 @@ module.exports = function(TimezoneService, ConfigurationService, divEnd = element.find('.inplace-edit--date-range-end-date-picker'), prevStartDate = '', prevEndDate = '', - setDate = function(div, input, date, noDate) { + setDate = function(div, input, date) { if(date) { div.datepicker('option', 'defaultDate', formattedDate(date)); div.datepicker('option', 'setDate', formattedDate(date)); input.val(customFormattedDate(date)); - input.attr('title', customFormattedDate(date)); } else { div.datepicker('option', 'defaultDate', null); div.datepicker('option', 'setDate', null); input.val(''); input.change(); - input.attr('title', noDate); date = null; } }; @@ -82,12 +83,12 @@ module.exports = function(TimezoneService, ConfigurationService, inputStart.attr({ 'placeholder': customDateFormat, 'aria-label': customDateFormat, - 'title': noStartDate + 'title': getTitle('startDate') }); inputEnd.attr({ 'placeholder': customDateFormat, 'aria-label': customDateFormat, - 'title': noEndDate + 'title': getTitle('dueDate') }); inputStart.on('change', function() { @@ -96,7 +97,6 @@ module.exports = function(TimezoneService, ConfigurationService, scope.startDate = null; }); inputStart.val(''); - inputStart.attr('title', noStartDate); divEnd.datepicker('option', 'minDate', null); $timeout.cancel(startTimerId); return; @@ -108,7 +108,6 @@ module.exports = function(TimezoneService, ConfigurationService, if(isValid){ scope.startDate = formattedISODate(parseDate(date, customDateFormat)); - inputStart.attr('title', customFormattedDate(date)); } }, 1000); }); @@ -119,7 +118,6 @@ module.exports = function(TimezoneService, ConfigurationService, scope.endDate = null; }); inputEnd.val(''); - inputEnd.attr('title', noEndDate); divStart.datepicker('option', 'maxDate', null); $timeout.cancel(endTimerId); return; @@ -131,7 +129,6 @@ module.exports = function(TimezoneService, ConfigurationService, if(isValid){ scope.endDate = formattedISODate(parseDate(date, customDateFormat)); - inputEnd.attr('title', customFormattedDate(date)); } }, 1000); }); @@ -206,10 +203,10 @@ module.exports = function(TimezoneService, ConfigurationService, divEnd.datepicker('option', 'minDate', formattedDate(scope.startDate)); } - setDate(divStart, inputStart, scope.startDate, noStartDate); - setDate(divEnd, inputEnd, scope.endDate, noEndDate); + setDate(divStart, inputStart, scope.startDate); + setDate(divEnd, inputEnd, scope.endDate); $timeout(function() { - inputStart.click(); + inputStart.click().focus(); }); inputStart.on('click', function() { diff --git a/frontend/app/ui_components/index.js b/frontend/app/ui_components/index.js index 9160e7ba6f..9c357fd486 100644 --- a/frontend/app/ui_components/index.js +++ b/frontend/app/ui_components/index.js @@ -47,7 +47,8 @@ angular.module('openproject.uiComponents') .directive('opDateTime', ['$compile', 'TimezoneService', require('./date/date-time-directive')]) .directive('emptyElement', [require('./empty-element-directive')]) .directive('opDateRangePicker', ['TimezoneService', 'ConfigurationService', - 'I18n', '$timeout', require('./date/date-range-picker-directive')]) + 'I18n', '$timeout', 'WorkPackageFieldService', + 'EditableFieldsState', require('./date/date-range-picker-directive')]) .constant('ENTER_KEY', 13) .directive('executeOnEnter', ['ENTER_KEY', require( './execute-on-enter-directive')]) diff --git a/frontend/app/work_packages/directives/inplace_editor/custom/editable/inplace-editor-date-directive.js b/frontend/app/work_packages/directives/inplace_editor/custom/editable/inplace-editor-date-directive.js index 6acaf1eadf..edf40db459 100644 --- a/frontend/app/work_packages/directives/inplace_editor/custom/editable/inplace-editor-date-directive.js +++ b/frontend/app/work_packages/directives/inplace_editor/custom/editable/inplace-editor-date-directive.js @@ -62,13 +62,11 @@ module.exports = function(WorkPackageFieldService, EditableFieldsState, div.datepicker('option', 'defaultDate', formattedDate(date)); div.datepicker('option', 'setDate', formattedDate(date)); inp.val(customFormattedDate(date)); - inp.attr('title', customFormattedDate(date)); } else { div.datepicker('option', 'defaultDate', null); div.datepicker('option', 'setDate', null); inp.val(''); inp.change(); - inp.attr('title', ''); date = null; } }; @@ -79,11 +77,9 @@ module.exports = function(WorkPackageFieldService, EditableFieldsState, input.attr({ 'placeholder': '-', - 'aria-label': customDateFormat, - 'title': customDateFormat + 'aria-label': customDateFormat }); - console.log(input); input.on('change', function() { if(input.val().trim() === '') { $timeout(function() { @@ -144,7 +140,7 @@ module.exports = function(WorkPackageFieldService, EditableFieldsState, setDate(datepickerContainer, input, scope.fieldController.writeValue); $timeout(function() { - input.click(); + input.click().focus(); }); angular.element('.work-packages--details-content').on('click', function(e) {