Skip to content

Commit e51e25d

Browse files
committed
PTBAS-738: fix element not present error for booking hint. also show booking hint when manually added. prefix booking hint. show (i) at the end
1 parent 5b07c3d commit e51e25d

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/main/java/de/doubleslash/keeptime/controller/HeimatController.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public List<Mapping> getTableRows(final LocalDate currentReportDate, final List<
110110
String heimatNotes = "";
111111
long heimatTimeSeconds = 0;
112112
boolean isMappedInHeimat = false;
113+
String bookingHint = "";
113114
final Optional<ExternalProjectMapping> optHeimatMapping = mappedProjects.stream()
114115
.filter(mp -> mp.getProject().getId()
115116
== project.getId())
@@ -118,6 +119,11 @@ public List<Mapping> getTableRows(final LocalDate currentReportDate, final List<
118119
Optional<Mapping> optionalExistingMapping = Optional.empty();
119120
if (optHeimatMapping.isPresent()) {
120121
isMappedInHeimat = true;
122+
bookingHint = heimatTasks.stream()
123+
.filter(ht -> ht.id() == optHeimatMapping.get().getExternalTaskId())
124+
.map(HeimatTask::bookingHint)
125+
.findAny()
126+
.orElseGet(String::new);
121127
optionalExistingMapping = list.stream()
122128
.filter(mapping -> mapping.heimatTaskId == optHeimatMapping.get()
123129
.getExternalTaskId())
@@ -161,12 +167,6 @@ public List<Mapping> getTableRows(final LocalDate currentReportDate, final List<
161167
new StyledMessage.TextSegment("\n(" + externalProjectMapping.getExternalProjectName() + ")"));
162168
}
163169

164-
final String bookingHint = heimatTasks.stream()
165-
.filter(ht -> ht.id() == optHeimatMapping.get().getExternalTaskId())
166-
.map(HeimatTask::bookingHint)
167-
.findAny()
168-
.orElseGet(String::new);
169-
170170
if (optionalExistingMapping.isPresent()) {
171171
final Mapping existingMapping = optionalExistingMapping.get();
172172
final ArrayList<Project> projects = new ArrayList<>(existingMapping.projects());
@@ -212,8 +212,7 @@ public List<Mapping> getTableRows(final LocalDate currentReportDate, final List<
212212
}
213213

214214
final Mapping mapping = new Mapping(id, true, false,
215-
StyledMessage.of(new StyledMessage.TextSegment("Not mapped in KeepTime\n\n" + taskName)), "",
216-
times,
215+
StyledMessage.of(new StyledMessage.TextSegment("Not mapped in KeepTime\n\n" + taskName)), "", times,
217216

218217
new ArrayList<>(0), heimatNotes, "", heimatTimeSeconds, 0);
219218
list.add(mapping);

src/main/java/de/doubleslash/keeptime/view/ExternalProjectsSyncController.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public void initForDate(LocalDate currentReportDate, List<Work> currentWorkItems
223223
new StyledMessage.TextSegment("\n(" + selectedTask.taskHolderName() + ")"));
224224

225225
TableRow addedRow = new TableRow(
226-
new HeimatController.Mapping(selectedTask.id(), true, true, syncMessage, "", List.of(), List.of(), "",
226+
new HeimatController.Mapping(selectedTask.id(), true, true, syncMessage, selectedTask.bookingHint(), List.of(), List.of(), "",
227227
"", 0, 0), "", 0);
228228
items.add(addedRow);
229229
itemsForBindings.add(addedRow); // add new row also to items2 - as it is not added automatically :(
@@ -443,12 +443,13 @@ protected void updateItem(TableRow item, boolean empty) {
443443
.map(n -> ((Text) n).getText())
444444
.collect(Collectors.joining());
445445

446-
if (!item.bookingHint.isEmpty().get()) {
446+
final String bookingHint = item.bookingHint.get();
447+
if (!bookingHint.isEmpty()) {
447448
statusFlow = new TextFlow(statusFlow);
448-
tooltip.setText(statusForTooltip + "\n" + item.bookingHint.get());
449-
Text icon = new Text("");
449+
tooltip.setText(statusForTooltip + "\nBookinghint: " + bookingHint);
450+
Text icon = new Text("");
450451
icon.setStyle("-fx-text-fill: #1c2070; -fx-font-size: 14px;");
451-
statusFlow.getChildren().add(0, icon);
452+
statusFlow.getChildren().add(icon);
452453
} else {
453454
tooltip.setText(statusForTooltip);
454455
}

0 commit comments

Comments
 (0)