Skip to content

Commit 3f660ec

Browse files
author
portmann
committed
#74: Fixed a bug where the "add note" dialog did not appear at switching
project after autosave. The issue showed up because the autosave set the note to the EMPTY_NOTE constant. When switching the current project it was only checked whether the note is empty. Now autosave leaves the note as an empty string and the EMPTY_NOTE constant is only used for better visualization in the ProjectReport View but not for storage.
1 parent 25fd8d3 commit 3f660ec

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ public Work saveCurrentWork(final LocalDateTime workEnd) {
9292
}
9393

9494
currentWork.setEndTime(workEnd);
95-
if (currentWork.getNotes().isEmpty()) {
96-
currentWork.setNotes("- No notes -");
97-
}
9895

9996
final String time = DateFormatter
10097
.secondsToHHMMSS(Duration.between(currentWork.getStartTime(), currentWork.getEndTime()).getSeconds());

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package de.doubleslash.keeptime.view;
1818

19-
import static de.doubleslash.keeptime.view.ReportController.EMPTY_NOTE;
2019
import static de.doubleslash.keeptime.view.ReportController.NOTE_DELIMETER;
2120

2221
import java.lang.invoke.MethodHandles;
@@ -42,7 +41,7 @@ public ProjectReport(final int size) {
4241

4342
public void appendToWorkNotes(final String currentWorkNote) {
4443
this.numberOfNotes++;
45-
if (!currentWorkNote.equals(EMPTY_NOTE)) {
44+
if (!currentWorkNote.isEmpty()) {
4645
if (this.numberOfNotes > 1) {
4746
this.sb.append(NOTE_DELIMETER);
4847
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ protected void updateItem(final TableRow item, final boolean empty) {
148148
setGraphic(null);
149149
setText(null);
150150
} else {
151-
final Text text = new Text(item.getNotes());
151+
final String notes = item.getNotes();
152+
final Text text = new Text(notes.isEmpty() ? EMPTY_NOTE : notes);
152153
text.wrappingWidthProperty().bind(noteColumn.widthProperty().subtract(35));
153154
text.setUnderline(item.isUnderlined());
154155
this.setGraphic(text);

src/test/java/de/doubleslash/keeptime/view/ProjectReportTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void setUp() throws Exception {
4040
@Test
4141
public void testAppendToWorkNotes() {
4242
this.uut.appendToWorkNotes("note 1 ");
43-
this.uut.appendToWorkNotes(ReportController.EMPTY_NOTE);
43+
this.uut.appendToWorkNotes("");
4444
this.uut.appendToWorkNotes("note 2 ");
4545
final String expected = "note 1; note 2";
4646
assertEquals(expected, this.uut.getNotes(false));
@@ -49,7 +49,7 @@ public void testAppendToWorkNotes() {
4949
@Test
5050
public void testAppendToWorkNotesAddNumberOfNotes() {
5151
this.uut.appendToWorkNotes("note 1 ");
52-
this.uut.appendToWorkNotes(ReportController.EMPTY_NOTE);
52+
this.uut.appendToWorkNotes("");
5353
this.uut.appendToWorkNotes("note 2 ");
5454
final String expected = "3 Notes: note 1; note 2";
5555
assertEquals(expected, this.uut.getNotes(true));
@@ -70,8 +70,8 @@ public void testAppendToWorkNotesAddNumberOfNotes_EmptyNotesAtTheEnd() {
7070
this.uut = new ProjectReport(4);
7171
this.uut.appendToWorkNotes("note 1");
7272
this.uut.appendToWorkNotes("note 2");
73-
this.uut.appendToWorkNotes(ReportController.EMPTY_NOTE);
74-
this.uut.appendToWorkNotes(ReportController.EMPTY_NOTE);
73+
this.uut.appendToWorkNotes("");
74+
this.uut.appendToWorkNotes("");
7575
final String expected = "4 Notes: note 1; note 2";
7676
assertEquals(expected, this.uut.getNotes(true));
7777
}

0 commit comments

Comments
 (0)