Merge pull request #4230 from oliverguenther/feature/inline-edit-duration

Add duration field
pull/4203/merge
ulferts 9 years ago
commit 19434b7dca
  1. 6
      frontend/app/components/wp-edit/wp-edit-field/wp-edit-duration-field.directive.html
  2. 34
      frontend/app/components/wp-edit/wp-edit-field/wp-edit-duration-field.module.ts
  3. 7
      frontend/app/components/wp-edit/wp-edit-field/wp-edit-field.config.ts
  4. 46
      frontend/app/ui_components/duration-directive.js
  5. 1
      frontend/app/ui_components/index.js

@ -0,0 +1,6 @@
<input type="number"
wp-edit-field-requirements="vm.field.schema"
ng-model="vm.workPackage[vm.fieldName]"
duration-value
ng-blur="vm.deactivate()"
focus>

@ -0,0 +1,34 @@
// -- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
// ++
import {Field} from "./wp-edit-field.module";
import {WorkPackageEditFieldService} from "./wp-edit-field.service";
export class DurationField extends Field {
public template:string = '/components/wp-edit/wp-edit-field/wp-edit-duration-field.directive.html'
}

@ -29,6 +29,8 @@
import {WorkPackageEditFieldService} from "./wp-edit-field.service"; import {WorkPackageEditFieldService} from "./wp-edit-field.service";
import {Field} from "./wp-edit-field.module"; import {Field} from "./wp-edit-field.module";
import {TextField} from "./wp-edit-text-field.module"; import {TextField} from "./wp-edit-text-field.module";
import {IntegerField} from "./wp-edit-integer-field.module";
import {DurationField} from "./wp-edit-duration-field.module";
import {SelectField} from "./wp-edit-select-field.module"; import {SelectField} from "./wp-edit-select-field.module";
import {FloatField} from "./wp-edit-float-field.module"; import {FloatField} from "./wp-edit-float-field.module";
import {IntegerField} from "./wp-edit-integer-field.module"; import {IntegerField} from "./wp-edit-integer-field.module";
@ -38,9 +40,6 @@ import {DateField} from "./wp-edit-date-field.module";
//TODO: Implement //TODO: Implement
class DateRangeField extends Field {} class DateRangeField extends Field {}
//TODO: Implement
class DurationField extends Field {}
//TODO: Implement //TODO: Implement
class TextareaField extends Field {} class TextareaField extends Field {}
@ -52,6 +51,8 @@ angular
wpEditField.defaultType = 'text'; wpEditField.defaultType = 'text';
wpEditField wpEditField
.addFieldType(TextField, 'text', ['String']) .addFieldType(TextField, 'text', ['String'])
.addFieldType(IntegerField, 'integer', ['Integer'])
.addFieldType(DurationField, 'duration', ['Duration'])
.addFieldType(SelectField, 'select', ['Priority', .addFieldType(SelectField, 'select', ['Priority',
'Status', 'Status',
'Type', 'Type',

@ -0,0 +1,46 @@
//-- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
//++
module.exports = function($filter, TimezoneService) {
return {
restrict:'A',
require: 'ngModel',
link: function(scope, element, attrs, ngModelController) {
ngModelController.$parsers.push(function(value) {
if (value) {
var minutes = Number(moment.duration(value, 'hours').asMinutes().toFixed(2));
return moment.duration(minutes, 'minutes');
}
});
ngModelController.$formatters.push(function(value) {
return TimezoneService.formattedDuration(value);
});
}
};
};

@ -112,5 +112,6 @@ angular.module('openproject.uiComponents')
.directive('confirmPopup', ['$window', require('./confirm-popup-directive')]) .directive('confirmPopup', ['$window', require('./confirm-popup-directive')])
.directive('clickOnKeypress', [require('./click-on-keypress-directive')]) .directive('clickOnKeypress', [require('./click-on-keypress-directive')])
.directive('floatValue', ['$filter', require('./float-directive')]) .directive('floatValue', ['$filter', require('./float-directive')])
.directive('durationValue', ['$filter', 'TimezoneService', require('./duration-directive')])
.filter('external2internalFloat', ['$locale', require('./external-2-internal-float-filter')]) .filter('external2internalFloat', ['$locale', require('./external-2-internal-float-filter')])
.filter('internal2externalFloat', ['$locale', require('./internal-2-external-float-filter')]); .filter('internal2externalFloat', ['$locale', require('./internal-2-external-float-filter')]);

Loading…
Cancel
Save