Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Allow overriding scheduling in the table by mapping attributes

Oliver Günther02a8a92540b7
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index 173f1cf1a5a..6ae50e5b9f8 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -866,7 +866,7 @@ en:
text_no_results: "No matching views were found."
scheduling:
is_parent: "The dates of this work package are automatically deduced from its children. Activate 'Manual scheduling' to set the dates."
- is_switched_from_manual_to_automatic: "The dates of this work package will need to be recalculated after switching from manual to automatic scheduling."
+ is_switched_from_manual_to_automatic: "The dates of this work package may need to be recalculated after switching from manual to automatic scheduling due to relationships with other work packages."
table:
configure_button: 'Configure work package table'
summary: "Table with rows of work package and columns of work package attributes."
diff --git a/frontend/src/app/components/datepicker/datepicker.modal.html b/frontend/src/app/components/datepicker/datepicker.modal.html
index 671602b4056..21c5a1908ba 100644
--- a/frontend/src/app/components/datepicker/datepicker.modal.html
+++ b/frontend/src/app/components/datepicker/datepicker.modal.html
@@ -1,5 +1,6 @@
<div class="op-modal--portal -transparent">
- <div class="op-modal--modal-container datepicker-modal loading-indicator--location"
+ <div #modalContainer
+ class="op-modal--modal-container datepicker-modal loading-indicator--location"
[attr.id]="htmlId"
data-indicator-name="modal"
tabindex="0">
diff --git a/frontend/src/app/components/datepicker/datepicker.modal.sass b/frontend/src/app/components/datepicker/datepicker.modal.sass
index fd26b52b69a..da06693595c 100644
--- a/frontend/src/app/components/datepicker/datepicker.modal.sass
+++ b/frontend/src/app/components/datepicker/datepicker.modal.sass
@@ -1,8 +1,7 @@
.datepicker-modal
position: relative
z-index: 500
- width: fit-content
- padding: 5px 0
+ width: 700px
box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.25)
.op-modal--modal-body
diff --git a/frontend/src/app/components/datepicker/datepicker.modal.ts b/frontend/src/app/components/datepicker/datepicker.modal.ts
index e101da4a2eb..fb0b4e26c04 100644
--- a/frontend/src/app/components/datepicker/datepicker.modal.ts
+++ b/frontend/src/app/components/datepicker/datepicker.modal.ts
@@ -34,7 +34,7 @@ import {
ElementRef,
EventEmitter,
Inject,
- Injector,
+ Injector, ViewChild,
ViewEncapsulation
} from "@angular/core";
import {OpModalComponent} from "core-components/op-modals/op-modal.component";
@@ -64,6 +64,8 @@ export class DatePickerModal extends OpModalComponent implements AfterViewInit {
@InjectField() datepickerHelper:DatePickerModalHelper;
@InjectField() browserDetector:BrowserDetector;
+ @ViewChild('modalContainer') modalContainer:ElementRef<HTMLElement>;
+
text = {
save: this.I18n.t('js.button_save'),
cancel: this.I18n.t('js.button_cancel'),
@@ -234,6 +236,7 @@ export class DatePickerModal extends OpModalComponent implements AfterViewInit {
}
private initializeDatepicker() {
+ this.datePickerInstance?.destroy();
this.datePickerInstance = new DatePicker(
'#flatpickr-input',
this.singleDate ? this.dates.date : [this.dates.start, this.dates.end],
diff --git a/frontend/src/app/components/wp-edit-form/display-field-renderer.ts b/frontend/src/app/components/wp-edit-form/display-field-renderer.ts
index 1855f931bde..d884b84877e 100644
--- a/frontend/src/app/components/wp-edit-form/display-field-renderer.ts
+++ b/frontend/src/app/components/wp-edit-form/display-field-renderer.ts
@@ -14,6 +14,7 @@ import {SchemaCacheService} from "core-components/schemas/schema-cache.service";
import {SchemaResource} from "core-app/modules/hal/resources/schema-resource";
import {ISchemaProxy} from "core-app/modules/hal/schemas/schema-proxy";
import {HalResourceEditingService} from "core-app/modules/fields/edit/services/hal-resource-editing.service";
+import {DateDisplayField} from "core-app/modules/fields/display/field-types/date-display-field.module";
export const editableClassName = '-editable';
export const requiredClassName = '-required';
@@ -55,13 +56,13 @@ export class DisplayFieldRenderer<T extends HalResource = HalResource> {
}
public renderFieldValue(resource:T,
- name:string,
+ requestedAttribute:string,
change:ResourceChangeset<T>|null,
placeholder?:string):[DisplayField|null, HTMLSpanElement] {
const span = document.createElement('span');
const schema = this.schema(resource, change);
- const attributeName = this.attributeName(name, schema);
- const fieldSchema = schema.ofProperty(name);
+ const attributeName = this.attributeName(requestedAttribute, schema);
+ const fieldSchema = schema.ofProperty(attributeName);
// If the resource does not have that field, return an empty
// span (e.g., for the table).
@@ -83,12 +84,12 @@ export class DisplayFieldRenderer<T extends HalResource = HalResource> {
public getField(resource:T,
fieldSchema:IFieldSchema,
- name:string,
+ attributeName:string,
change:ResourceChangeset<T>|null):DisplayField {
- let field = this.fieldCache[name];
+ let field = this.fieldCache[attributeName];
if (!field) {
- field = this.fieldCache[name] = this.getFieldForCurrentContext(resource, name, fieldSchema);
+ field = this.fieldCache[attributeName] = this.getFieldForCurrentContext(resource, attributeName, fieldSchema);
}
field.apply(resource, fieldSchema);
@@ -97,25 +98,31 @@ export class DisplayFieldRenderer<T extends HalResource = HalResource> {
return field;
}
- private getFieldForCurrentContext(resource:T, name:string, fieldSchema:IFieldSchema):DisplayField {
+ private getFieldForCurrentContext(resource:T, attributeName:string, fieldSchema:IFieldSchema):DisplayField {
const context:DisplayFieldContext = {container: this.container, injector: this.injector, options: this.options};
// We handle multi value fields differently in the single view context
const isCustomMultiLinesField = ['[]CustomOption'].indexOf(fieldSchema.type) >= 0;
if (this.container === 'single-view' && isCustomMultiLinesField) {
- return new MultipleLinesStringObjectsDisplayField(name, context) as DisplayField;
+ return new MultipleLinesStringObjectsDisplayField(attributeName, context) as DisplayField;
}
const isUserMultiLinesField = ['[]User'].indexOf(fieldSchema.type) >= 0;
if (this.container === 'single-view' && isUserMultiLinesField) {
- return new MultipleLinesUserFieldModule(name, context) as DisplayField;
+ return new MultipleLinesUserFieldModule(attributeName, context) as DisplayField;
}
// We handle progress differently in the timeline
- if (this.container === 'timeline' && name === 'percentageDone') {
- return new ProgressTextDisplayField(name, context);
+ if (this.container === 'timeline' && attributeName === 'percentageDone') {
+ return new ProgressTextDisplayField(attributeName, context);
}
- return this.displayFieldService.getField(resource, name, fieldSchema, context);
+ // We want to render an combined edit field but the display field must
+ // show the original attribute
+ if (this.container === 'table' && ['startDate', 'dueDate', 'date'].includes(attributeName)) {
+ return new DateDisplayField(attributeName, context);
+ }
+
+ return this.displayFieldService.getField(resource, attributeName, fieldSchema, context);
}
private getText(field:DisplayField, fieldSchema:IFieldSchema, placeholder?:string):string {
@@ -128,7 +135,7 @@ export class DisplayFieldRenderer<T extends HalResource = HalResource> {
private setSpanAttributes(span:HTMLElement, field:DisplayField, name:string, resource:T, change:ResourceChangeset<T>|null):void {
span.classList.add(displayClassName, name);
- span.dataset['fieldName'] = name;
+ span.dataset.fieldName = name;
// Make span tabbable unless it's an id field
span.setAttribute('tabindex', name === 'id' ? '-1' : '0');
diff --git a/frontend/src/app/components/wp-edit-form/table-edit-form.ts b/frontend/src/app/components/wp-edit-form/table-edit-form.ts
index 092db0663c0..223c0e5e5c4 100644
--- a/frontend/src/app/components/wp-edit-form/table-edit-form.ts
+++ b/frontend/src/app/components/wp-edit-form/table-edit-form.ts
@@ -152,5 +152,4 @@ export class TableEditForm extends EditForm<WorkPackageResource> {
private get rowContainer() {
return jQuery(this.table.tableAndTimelineContainer).find(`.${this.classIdentifier}-table`);
}
-
}
diff --git a/spec/support/edit_fields/date_edit_field.rb b/spec/support/edit_fields/date_edit_field.rb
index 3fc8479df06..13ca301290a 100644
--- a/spec/support/edit_fields/date_edit_field.rb
+++ b/spec/support/edit_fields/date_edit_field.rb
@@ -2,14 +2,17 @@ require_relative './edit_field'
class DateEditField < EditField
attr_accessor :milestone
+ attr_accessor :is_table
def initialize(context,
property_name,
selector: nil,
- is_milestone: false)
+ is_milestone: false,
+ is_table: false)
super(context, property_name, selector: selector)
self.milestone = is_milestone
+ self.is_table = is_table
end
def datepicker
@@ -17,7 +20,7 @@ class DateEditField < EditField
end
def modal_selector
- "#wp-datepicker-#{property_name}"
+ ".datepicker-modal"
end
def input_selector
diff --git a/spec/support/pages/work_packages/work_packages_table.rb b/spec/support/pages/work_packages/work_packages_table.rb
index 1ebb5466c18..3381e7a8169 100644
--- a/spec/support/pages/work_packages/work_packages_table.rb
+++ b/spec/support/pages/work_packages/work_packages_table.rb
@@ -276,7 +276,7 @@ module Pages
def work_package_field(work_package, context, key)
case key.to_sym
when :date, :startDate, :dueDate
- DateEditField.new context, key, is_milestone: work_package.milestone?
+ DateEditField.new context, key, is_milestone: work_package.milestone?, is_table: true
else
EditField.new context, key
end