Skip to content

Commit b180a07

Browse files
committed
make the search summary closeable and openable
1 parent 7f12e26 commit b180a07

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/document/grid/DocumentGridUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public static void updateRecord(GUIDocument doc, Record rec) {
228228
rec.setAttribute(FOLDER_ID, doc.getId());
229229
rec.setAttribute(TENANT_ID, doc.getTenantId());
230230
} else {
231-
rec.setAttribute(SUMMARY, rec.getAttribute(SUMMARY));
231+
rec.setAttribute(SUMMARY, doc.getSummary());
232232

233233
updateId(doc, rec);
234234

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/document/grid/DocumentsListGrid.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ public class DocumentsListGrid extends RefreshableListGrid implements DocumentsG
134134
*/
135135
protected List<String> extendedAttributes = new ArrayList<>();
136136

137+
/*
138+
* A cache of summaries, it seems that a bug in SmartGWT deletes the content
139+
* of the summary field when the user expands the row the second time
140+
*/
141+
protected Map<Long, String> summaries = new HashMap<>();
142+
137143
private DocumentsListGrid(GUIFolder folder, List<String> extendedAttributes) {
138144
this.folder = folder;
139145
if (extendedAttributes != null)
@@ -219,7 +225,7 @@ public DocumentsListGrid(List<String> extendedAttributes) {
219225
* Prepares the map that contains all the possible fields we can use
220226
*/
221227
protected void prepareFieldsMap() {
222-
ListGridField id =new IdListGridField();
228+
ListGridField id = new IdListGridField();
223229
fieldsMap.put(id.getName(), id);
224230

225231
ListGridField size = new FileSizeListGridField("size", I18N.getAttributeLabel("size"));
@@ -763,21 +769,26 @@ public void setCanExpandRows() {
763769
setCanExpandRecords(true);
764770
setExpansionMode(ExpansionMode.DETAIL_FIELD);
765771
setDetailField(SUMMARY);
766-
767772
}
768773

769774
@Override
770775
protected Canvas getExpansionComponent(final ListGridRecord rec) {
771-
return new HTMLFlow("<div class='details'>"
772-
+ (rec.getAttributeAsString(SUMMARY) != null ? rec.getAttributeAsString(SUMMARY) : "") + "</div>");
776+
return new HTMLFlow("<span class='details'>" + summaries.get(rec.getAttributeAsLong("id")) != null
777+
? summaries.get(rec.getAttributeAsLong("id"))
778+
: "" + "</span>");
773779
}
774780

775781
@Override
776782
public void setDocuments(List<GUIDocument> documents) {
777783
List<ListGridRecord> records = new ArrayList<>();
784+
summaries.clear();
778785

779-
for (GUIDocument document : documents)
780-
records.add(DocumentGridUtil.fromDocument(document));
786+
for (GUIDocument document : documents) {
787+
ListGridRecord rec = DocumentGridUtil.fromDocument(document);
788+
records.add(rec);
789+
if (document.getSummary() != null && !document.getSummary().isBlank())
790+
summaries.put(rec.getAttributeAsLong("id"), document.getSummary());
791+
}
781792

782793
setRecords(records.toArray(new ListGridRecord[0]));
783794
}

0 commit comments

Comments
 (0)