Skip to content

Commit

Permalink
[3523] [WIP] Support rounding dates when changing dates from gantt
Browse files Browse the repository at this point in the history
Bug: #3523
Signed-off-by: Laurent Fasani <[email protected]>
  • Loading branch information
lfasani committed Jun 18, 2024
1 parent 9742458 commit 90448fd
Show file tree
Hide file tree
Showing 57 changed files with 464 additions and 2,267 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ More existing APIs will be migrated to this new common pattern.
- [releng] Switch to `maven-checkstyle-plugin` 3.3.1
- [releng] Remove the dependency to `reflect-metadata`
- [releng] Switch to `subscriptions-transport-ws` 0.11.0
- https://github.com/eclipse-sirius/sirius-web/issues/3466[#3466] [gantt] Move to @ObeoNetwork/gantt-task-react 0.4.14 to benefit for enhancements
- [releng] Switch to EMF Json 2.3.10
- https://github.com/eclipse-sirius/sirius-web/issues/3523[#3523] [gantt] Move to @ObeoNetwork/gantt-task-react 0.4.16 to benefit for enhancements


=== Bug fixes
Expand All @@ -65,6 +65,7 @@ More existing APIs will be migrated to this new common pattern.
- https://github.com/eclipse-sirius/sirius-web/issues/3563[#3563] [sirius-web] Improve NavigationBar extensibility to allow the contribution of components on the left and right of the navigation bar.
- https://github.com/eclipse-sirius/sirius-web/issues/3344[#3344] [core] Add support for reloading representations from the database
- https://github.com/eclipse-sirius/sirius-web/issues/3553[#3553] [core] Add RepresentationFactory extension point
- https://github.com/eclipse-sirius/sirius-web/issues/3523[#3523] [gantt] Support rounding dates when changing dates from gantt

=== Improvements

Expand Down
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ type Gantt implements Representation {
targetObjectId: ID!
tasks: [Task!]!
columns: [GanttColumn!]!
dateRounding: GanttDateRounding!
}

type GanttDateRounding {
value : Int!
timeUnit : GanttDateRoundingTimeUnit!
}

enum GanttDateRoundingTimeUnit {
MINUTE
HOUR
DAY
}

type GanttColumn {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @author lfasani
*/
public record Gantt(String id, String descriptionId, String targetObjectId, String label, List<Task> tasks, List<GanttColumn> columns) implements IRepresentation {
public record Gantt(String id, String descriptionId, String targetObjectId, String label, List<Task> tasks, List<GanttColumn> columns, GanttDateRounding dateRounding) implements IRepresentation {

public static final String KIND = IRepresentation.KIND_PREFIX + "?type=Gantt";

Expand Down Expand Up @@ -68,7 +68,7 @@ public String getKind() {
*/
@SuppressWarnings("checkstyle:HiddenField")
public static final class Builder {
private String id;
private final String id;

private String targetObjectId;

Expand All @@ -80,6 +80,8 @@ public static final class Builder {

private List<GanttColumn> columns;

private GanttDateRounding dateRounding;

private Builder(String id) {
this.id = Objects.requireNonNull(id);
}
Expand All @@ -89,6 +91,7 @@ private Builder(Gantt gantt) {
this.targetObjectId = gantt.getTargetObjectId();
this.descriptionId = gantt.getDescriptionId();
this.label = gantt.getLabel();
this.dateRounding = gantt.dateRounding();
}

public Builder targetObjectId(String targetObjectId) {
Expand Down Expand Up @@ -116,8 +119,13 @@ public Builder columns(List<GanttColumn> columns) {
return this;
}

public Builder dateRounding(GanttDateRounding dateRounding) {
this.dateRounding = Objects.requireNonNull(dateRounding);
return this;
}

public Gantt build() {
Gantt gantt = new Gantt(this.id, this.descriptionId, this.targetObjectId, this.label, this.tasks, this.columns);
Gantt gantt = new Gantt(this.id, this.descriptionId, this.targetObjectId, this.label, this.tasks, this.columns, this.dateRounding);
return gantt;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/

package org.eclipse.sirius.components.gantt;

/**
* Class representing how the date should be rounded in Gantt.
*/
public record GanttDateRounding(Integer value, GanttDateRoundingTimeUnit timeUnit) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/

package org.eclipse.sirius.components.gantt;

/**
* Enum representing a time unit.
*
* @author lfasani
*/
public enum GanttDateRoundingTimeUnit {
MINUTE, HOUR, DAY
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,80 +32,4 @@ public record Task(String id, String descriptionId, String targetObjectId, Strin
Objects.requireNonNull(taskDependencyIds);
Objects.requireNonNull(subTasks);
}

/**
* The builder used to create the task.
*
* @author lfasani
*/
@SuppressWarnings("checkstyle:HiddenField")
public static final class Builder {
private String id;

private String targetObjectId;

private String targetObjectKind;

private String targetObjectLabel;

private String descriptionId;

private TaskDetail taskDetail;

private List<String> taskDependencyIds;

private List<Task> subTasks;

private Builder(String id) {
this.id = Objects.requireNonNull(id);
}

private Builder() {
}

public Builder label(String id) {
this.id = Objects.requireNonNull(id);
return this;
}

public Builder targetObjectId(String targetObjectId) {
this.targetObjectId = Objects.requireNonNull(targetObjectId);
return this;
}

public Builder targetObjectKind(String targetObjectKind) {
this.targetObjectKind = Objects.requireNonNull(targetObjectKind);
return this;
}

public Builder targetObjectLabel(String targetObjectLabel) {
this.targetObjectLabel = Objects.requireNonNull(targetObjectLabel);
return this;
}

public Builder descriptionId(String descriptionId) {
this.descriptionId = Objects.requireNonNull(descriptionId);
return this;
}

public Builder taskDetail(TaskDetail taskDetail) {
this.taskDetail = Objects.requireNonNull(taskDetail);
return this;
}

public Builder taskDependencyIds(List<String> taskDependencyIds) {
this.taskDependencyIds = Objects.requireNonNull(taskDependencyIds);
return this;
}

public Builder subTasks(List<Task> subTasks) {
this.subTasks = Objects.requireNonNull(subTasks);
return this;
}

public Task build() {
Task task = new Task(this.id, this.targetObjectId, this.targetObjectKind, this.targetObjectLabel, this.descriptionId, this.taskDetail, this.taskDependencyIds, this.subTasks);
return task;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
@PublicApi
public record GanttDescription(String id, String label, Function<VariableManager, String> idProvider, Function<VariableManager, String> labelProvider,
Function<VariableManager, String> targetObjectIdProvider, Predicate<VariableManager> canCreatePredicate, List<TaskDescription> taskDescriptions, Consumer<VariableManager> createTaskProvider,
Consumer<VariableManager> editTaskProvider, Consumer<VariableManager> deleteTaskProvider, Consumer<VariableManager> dropTaskProvider, Consumer<VariableManager> createTaskDependencyProvider) implements IRepresentationDescription {
Consumer<VariableManager> editTaskProvider, Consumer<VariableManager> deleteTaskProvider, Consumer<VariableManager> dropTaskProvider, Consumer<VariableManager> createTaskDependencyProvider,
Function<VariableManager, String> dateRoundingProvider) implements IRepresentationDescription {

public static final String LABEL = "label";

Expand Down Expand Up @@ -63,6 +64,7 @@ public record GanttDescription(String id, String label, Function<VariableManager
Objects.requireNonNull(canCreatePredicate);
Objects.requireNonNull(targetObjectIdProvider);
Objects.requireNonNull(taskDescriptions);
Objects.requireNonNull(dateRoundingProvider);
}

@Override
Expand Down Expand Up @@ -98,7 +100,7 @@ public String toString() {
@SuppressWarnings("checkstyle:HiddenField")
public static final class Builder {

private String id;
private final String id;

private String label;

Expand All @@ -122,6 +124,8 @@ public static final class Builder {

private List<TaskDescription> taskDescriptions;

private Function<VariableManager, String> dateRoundingProvider;

private Builder(String id) {
this.id = Objects.requireNonNull(id);
}
Expand Down Expand Up @@ -181,9 +185,14 @@ public Builder taskDescriptions(List<TaskDescription> taskDescriptions) {
return this;
}

public Builder dateRoundingProvider(Function<VariableManager, String> dateRoundingProvider) {
this.dateRoundingProvider = Objects.requireNonNull(dateRoundingProvider);
return this;
}

public GanttDescription build() {
GanttDescription ganttDescription = new GanttDescription(this.id, this.label, this.idProvider, this.labelProvider, this.targetObjectIdProvider, this.canCreatePredicate,
this.taskDescriptions, this.createTaskProvider, this.editTaskProvider, this.deleteTaskProvider, this.dropTaskProvider, this.createTaskDependencyProvider);
this.taskDescriptions, this.createTaskProvider, this.editTaskProvider, this.deleteTaskProvider, this.dropTaskProvider, this.createTaskDependencyProvider, this.dateRoundingProvider);
return ganttDescription;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private Gantt instantiateGantt(GanttElementProps props, List<Object> children) {
.map(Task.class::cast)
.toList();

return new Gantt(props.id(), props.descriptionId(), props.targetObjectId(), props.label(), tasks, props.columns());
return new Gantt(props.id(), props.descriptionId(), props.targetObjectId(), props.label(), tasks, props.columns(), props.dateRounding());
}

private Task instantiateTask(TaskElementProps props, List<Object> children) {
Expand All @@ -58,7 +58,7 @@ private Task instantiateTask(TaskElementProps props, List<Object> children) {
.toList();

TaskDetail detail = props.detail();
if (detail.computeStartEndDynamically()) {
if (detail.computeStartEndDynamically() && !subTasks.isEmpty()) {

Instant startTime = subTasks.stream()
.filter(task -> task.detail().startTime() != null)
Expand Down
Loading

0 comments on commit 90448fd

Please sign in to comment.