Skip to content

Commit

Permalink
fix(bulk-changes): preview diff for created records
Browse files Browse the repository at this point in the history
  • Loading branch information
olovy committed Nov 15, 2024
1 parent 5446e29 commit 327d8fc
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -163,7 +164,6 @@ private Map<?,?> makePreviewChangeSet(RecordedChange recordChange) {
var recordAfter = getRecord.apply(recordChange.after());

var recordCopy = new LinkedHashMap<>(recordBefore.isEmpty() ? recordAfter : recordBefore);

// Remove @id from record to prevent it from being shown as a link in the diff view
recordBefore.remove(ID_KEY);
recordAfter.remove(ID_KEY);
Expand All @@ -179,6 +179,13 @@ private Map<?,?> makePreviewChangeSet(RecordedChange recordChange) {
// However when the diff is computed we need "@graph form", hence the same record copy at @graph,0 in both versions
var beforeDoc = new Document(Map.of(GRAPH_KEY, List.of(recordCopy, thingBefore)));
var afterDoc = new Document(Map.of(GRAPH_KEY, List.of(recordCopy, thingAfter)));
if (beforeDoc.getModified() == null) {
beforeDoc.setModified(new Date());
}
if (afterDoc.getModified() == null) {
afterDoc.setModified(new Date());
}

var id = (String) recordCopy.get(ID_KEY);

var result = getChangeSetsMap(beforeDoc, afterDoc, id);
Expand Down

0 comments on commit 327d8fc

Please sign in to comment.