SUPPORT-8728: fix case parent id = self id;
+ add sort order
This commit is contained in:
parent
2c8ef2bf75
commit
88ef5237a7
3 changed files with 31 additions and 21 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package component.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
|
@ -14,10 +15,12 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import ru.cg.webbpm.modules.database.api.bean.TableRow;
|
||||
import ru.cg.webbpm.modules.database.api.dao.option.LoadOptions;
|
||||
import ru.cg.webbpm.modules.database.api.dao.option.SortOrder;
|
||||
import ru.cg.webbpm.modules.database.bean.annotation.GraphSource;
|
||||
import ru.cg.webbpm.modules.database.bean.annotation.TypedColumn;
|
||||
import ru.cg.webbpm.modules.database.bean.entity_graph.EntityColumn;
|
||||
import ru.cg.webbpm.modules.database.bean.entity_graph.EntityColumnType;
|
||||
import ru.cg.webbpm.modules.standard_annotations.editor.AdvancedProperty;
|
||||
import ru.cg.webbpm.modules.standard_annotations.validation.NotNull;
|
||||
|
||||
/**
|
||||
|
|
@ -39,6 +42,12 @@ public class TreeItemService {
|
|||
public EntityColumn labelColumn;
|
||||
@GraphSource(value = TreeItemRpcService.class, scanMode = GraphSource.ScanMode.SELF)
|
||||
public EntityColumn businessIdColumn;
|
||||
@AdvancedProperty
|
||||
@GraphSource(value = TreeItemRpcService.class, scanMode = GraphSource.ScanMode.SELF)
|
||||
public EntityColumn sortColumn;
|
||||
@AdvancedProperty
|
||||
@NotNull(predicate = "sortColumn != null")
|
||||
public SortOrder sortOrder;
|
||||
|
||||
public List<TreeItemDto> loadTreeData() {
|
||||
List<TreeItemDto> loadedTreeItems = loadTreeItems();
|
||||
|
|
@ -48,7 +57,12 @@ public class TreeItemService {
|
|||
}
|
||||
|
||||
private List<TreeItemDto> loadTreeItems() {
|
||||
List<TreeItemDto> loadedList = this.loadDao.load(getColumns(), new LoadOptions()).stream()
|
||||
LoadOptions loadOptions = new LoadOptions();
|
||||
if (sortColumn != null && sortOrder != null) {
|
||||
loadOptions.setSortFields(Collections.singletonMap(sortColumn, sortOrder));
|
||||
}
|
||||
|
||||
List<TreeItemDto> loadedList = this.loadDao.load(getColumns(), loadOptions).stream()
|
||||
.map(this::toTreeItemDto)
|
||||
.toList();
|
||||
|
||||
|
|
@ -87,6 +101,9 @@ public class TreeItemService {
|
|||
TreeItemDto treeItemDto = new TreeItemDto(
|
||||
tableRow.get(idColumn), tableRow.get(parentIdColumn), (String) tableRow.get(labelColumn)
|
||||
);
|
||||
if (treeItemDto.parentId == treeItemDto.id) {
|
||||
treeItemDto.parentId = null;
|
||||
}
|
||||
if (businessIdColumn != null) {
|
||||
treeItemDto.businessId = tableRow.get(businessIdColumn);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export class DropdownTreeViewComponent extends InputControl {
|
|||
this.items = res.map(value => new TreeviewItem(this.createTreeItem(value)));
|
||||
const rootItem = this.items[0];
|
||||
this.i18n.selectedItem = rootItem;
|
||||
this.value = rootItem.value;
|
||||
this.value = rootItem ? rootItem.value : rootItem;
|
||||
this.doCollapseLevel();
|
||||
this.cd.markForCheck();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3014,25 +3014,6 @@
|
|||
<entry>
|
||||
<key>service</key>
|
||||
<value>
|
||||
<complex>
|
||||
<entry>
|
||||
<key>loadDao</key>
|
||||
<value>
|
||||
<complex>
|
||||
<entry>
|
||||
<key>graph</key>
|
||||
<value>
|
||||
<simple>null</simple>
|
||||
</value>
|
||||
</entry>
|
||||
</complex>
|
||||
<implRef type="JAVA">
|
||||
<className>DefaultLoadDao</className>
|
||||
<packageName>database.dao</packageName>
|
||||
</implRef>
|
||||
</value>
|
||||
</entry>
|
||||
</complex>
|
||||
<implRef/>
|
||||
</value>
|
||||
</entry>
|
||||
|
|
@ -3114,6 +3095,18 @@
|
|||
<simple>{"schema":"summonses_list","table":"summonses_reason","entity":"summonses_reason","name":"parent_summonses_reason_id"}</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>sortColumn</key>
|
||||
<value>
|
||||
<simple>{"schema":"summonses_list","table":"summonses_reason","entity":"summonses_reason","name":"summonses_reason_id"}</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>sortOrder</key>
|
||||
<value>
|
||||
<simple>"ASC"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
</complex>
|
||||
</value>
|
||||
</entry>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue