[25026] Indicate fields of type WorkPackage to not be editable (#5357)

[ci skip]
pull/5358/head
Oliver Günther 8 years ago committed by GitHub
parent 2a4195a1a0
commit 0b3ed9b113
  1. 4
      frontend/app/components/wp-display/field-types/wp-display-work-package-field.module.ts
  2. 6
      frontend/app/components/wp-edit-form/work-package-edit-form.ts
  3. 36
      frontend/app/components/wp-edit/field-types/wp-edit-work-package-field.module.ts
  4. 2
      frontend/app/components/wp-edit/wp-edit-field/wp-edit-field.config.ts
  5. 2
      frontend/app/components/wp-fast-table/builders/cell-builder.ts

@ -74,6 +74,10 @@ export class WorkPackageDisplayField extends DisplayField {
return this.value.href.match(/(\d+)$/)[0]; return this.value.href.match(/(\d+)$/)[0];
} }
public get writable():boolean {
return false;
}
public get valueString() { public get valueString() {
return "#" + this.wpId; return "#" + this.wpId;
} }

@ -95,6 +95,11 @@ export class WorkPackageEditForm {
fieldName, fieldName,
schema[fieldName] schema[fieldName]
) as EditField; ) as EditField;
if (!field.writable) {
return this.$q.reject();
}
this.workPackage.storePristine(fieldName); this.workPackage.storePristine(fieldName);
return this.buildField(fieldName, field); return this.buildField(fieldName, field);
}); });
@ -185,7 +190,6 @@ export class WorkPackageEditForm {
// Accumulate errors for the given response // Accumulate errors for the given response
_.each(attributes, (fieldName:string) => { _.each(attributes, (fieldName:string) => {
// if the field does not exist, show it (e.g, add column in table)
this.editContext.requireVisible(fieldName).then(() => { this.editContext.requireVisible(fieldName).then(() => {
this.activate(fieldName); this.activate(fieldName);
}); });

@ -0,0 +1,36 @@
// -- 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 {TextEditField} from './wp-edit-text-field.module';
export class WorkPackageEditField extends TextEditField {
public get writable() {
return false;
}
}

@ -37,6 +37,7 @@ import {FloatEditField} from "../field-types/wp-edit-float-field.module";
import {BooleanEditField} from "../field-types/wp-edit-boolean-field.module"; import {BooleanEditField} from "../field-types/wp-edit-boolean-field.module";
import {DateEditField} from "../field-types/wp-edit-date-field.module"; import {DateEditField} from "../field-types/wp-edit-date-field.module";
import {WikiTextareaEditField} from "../field-types/wp-edit-wiki-textarea-field.module"; import {WikiTextareaEditField} from "../field-types/wp-edit-wiki-textarea-field.module";
import {WorkPackageEditField} from './../field-types/wp-edit-work-package-field.module';
import {openprojectModule} from "../../../angular-modules"; import {openprojectModule} from "../../../angular-modules";
//TODO: Implement //TODO: Implement
@ -66,6 +67,7 @@ openprojectModule
'[]User' '[]User'
]) ])
.addFieldType(FloatEditField, 'float', ['Float']) .addFieldType(FloatEditField, 'float', ['Float'])
.addFieldType(WorkPackageEditField, 'workPackage', ['WorkPackage'])
.addFieldType(IntegerEditField, 'integer', ['Integer']) .addFieldType(IntegerEditField, 'integer', ['Integer'])
.addFieldType(BooleanEditField, 'boolean', ['Boolean']) .addFieldType(BooleanEditField, 'boolean', ['Boolean'])
.addFieldType(DateEditField, 'date', ['Date']) .addFieldType(DateEditField, 'date', ['Date'])

@ -58,7 +58,7 @@ export class CellBuilder {
const field = this.wpDisplayField.getField(workPackage, name, fieldSchema) as DisplayField; const field = this.wpDisplayField.getField(workPackage, name, fieldSchema) as DisplayField;
let text; let text;
if (fieldSchema.writable && !field.hidden && workPackage.isEditable) { if (field.writable && !field.hidden && workPackage.isEditable) {
span.classList.add(editableClassName); span.classList.add(editableClassName);
} else { } else {
span.classList.add(readOnlyClassName); span.classList.add(readOnlyClassName);

Loading…
Cancel
Save