SUPPORT-8939: fixes

This commit is contained in:
adel.kalimullin 2025-02-21 19:40:16 +03:00
parent bd373e7991
commit a091e5e47f
5 changed files with 162 additions and 43 deletions

View file

@ -21,9 +21,4 @@ public class TreeItemRpcService extends Behavior {
public List<TreeItemDto> loadTreeData() {
return treeItemService.loadTreeData();
}
@RpcCall
public List<TreeItemDto> loadTreeDataByDomainId(String domainId) {
return treeItemService.loadTreeDataByDomainId(domainId);
}
}

View file

@ -14,6 +14,8 @@ 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.security.api.runtime.SecurityContext;
import ru.cg.webbpm.modules.security.api.service.OrgUnitService;
import ru.cg.webbpm.modules.standard_annotations.validation.NotNull;
/**
@ -21,6 +23,8 @@ import ru.cg.webbpm.modules.standard_annotations.validation.NotNull;
*/
@Service
public class TreeItemService {
private final SecurityContext securityContext;
private final OrgUnitService orgUnitService;
@NotNull
public DefaultLoadDao loadDao;
@GraphSource(value = TreeItemRpcService.class, scanMode = GraphSource.ScanMode.SELF)
@ -38,21 +42,15 @@ public class TreeItemService {
@GraphSource(value = TreeItemRpcService.class, scanMode = GraphSource.ScanMode.SELF)
public EntityColumn domainIdColumn;
public List<TreeItemDto> loadTreeData() {
List<TreeItemDto> loadedTreeItems = loadTreeItems();
loadedTreeItems.forEach(item -> item.domainId = null);
return loadedTreeItems.stream()
.filter(item -> item.parentId == null)
.toList();
public TreeItemService(SecurityContext securityContext, OrgUnitService orgUnitService) {
this.securityContext = securityContext;
this.orgUnitService = orgUnitService;
}
public List<TreeItemDto> loadTreeDataByDomainId(String domainId) {
if (domainId == null || domainIdColumn == null) {
return loadTreeData();
}
public List<TreeItemDto> loadTreeData() {
String currentOrgUnitCode = securityContext.getCurrentOrgUnitCode();
List<TreeItemDto> filteredTreeItems = loadTreeItems().stream()
.filter(item -> item.domainId.equalsIgnoreCase(domainId))
.filter(item -> item.domainId.equalsIgnoreCase(currentOrgUnitCode))
.toList();
filteredTreeItems.forEach(this::setDomainIdToNull);
return filteredTreeItems;

View file

@ -1,6 +1,10 @@
<div class="row">
<div class="col-12">
<div class="form-group">
<label [ngbTooltip]="tooltip | emptyIfNull"
[hidden]="!label" class="control-label">
<span>{{label}}<span *ngIf="isRequired()" class="alarm"> *</span></span>
</label>
<div class="d-inline-block">
<ngx-dropdown-treeview-select
[items]="items"

View file

@ -14,7 +14,6 @@ import {
PageContextHolder,
PageObjectUtils,
TaskParamsProvider,
UserService,
Visible,
WebbpmStorage
} from "@webbpm/base-package";
@ -56,10 +55,8 @@ export class DropdownTreeViewComponent extends InputControl {
public items: TreeviewItem[];
@Visible("false")
public value: any;
@Visible("false")
public valueChangeEvent: Event<TreeItemDto> = new Event<TreeItemDto>();
private rpcService: TreeItemRpcService;
private localStorageService: LocalStorageService;
private taskParamsProvider: TaskParamsProvider;
@ -68,8 +65,7 @@ export class DropdownTreeViewComponent extends InputControl {
private storageKey: string;
constructor(el: ElementRef, cd: ChangeDetectorRef,
// todo replace UserService by another one from SUPPORT-8421 providing accountId or domainId
private i18n: DropdownTreeviewSelectI18n, private userService: UserService) {
private i18n: DropdownTreeviewSelectI18n) {
super(el, cd);
}
@ -113,27 +109,28 @@ export class DropdownTreeViewComponent extends InputControl {
@Visible()
public loadTreeItems(): void {
// todo replace the called method by
// this.rpcService.loadTreeDataByDomainId(domainId)
this.rpcService.loadTreeData()
.then((res: TreeItemDto[]) => {
this.items = res.map(value => new TreeviewItem(this.createTreeItem(value)));
const rootItem = this.items[0];
if (this.cachedValue) {
const matchedItem = this.findTreeItemByValue(this.items, this.cachedValue);
if (matchedItem) {
this.i18n.selectedItem = matchedItem;
this.value = matchedItem.value;
}
}
else {
this.i18n.selectedItem = rootItem;
this.value = rootItem.value;
}
this.doCollapseLevel();
this.valueChangeEvent.trigger(this.value);
this.cd.markForCheck();
});
this.rpcService.loadTreeData().then((res: TreeItemDto[]) => {
this.populateTree(res);
});
}
private populateTree(res: TreeItemDto[]){
this.items = res.map(value => new TreeviewItem(this.createTreeItem(value)));
const rootItem = this.items[0];
if (this.cachedValue) {
const matchedItem = this.findTreeItemByValue(this.items, this.cachedValue);
if (matchedItem) {
this.i18n.selectedItem = matchedItem;
this.value = matchedItem.value;
}
}
else {
this.i18n.selectedItem = rootItem;
this.value = rootItem.value;
}
this.doCollapseLevel();
this.valueChangeEvent.trigger(this.value);
this.cd.markForCheck();
}
private findTreeItemByValue(rootItems: TreeviewItem[], valueToFind: any): TreeviewItem | null {
@ -214,6 +211,14 @@ export class DropdownTreeViewComponent extends InputControl {
return null;
}
isValueEmpty(): boolean {
return this.value == null;
}
hasValidModel(): boolean {
return !this.isRequired() || !this.isValueEmpty()
}
getPresentationValue(): string | number | boolean {
return this.value;
}
@ -226,6 +231,10 @@ export class DropdownTreeViewComponent extends InputControl {
return this.value ? this.value : null;
}
getValueForForm(): any {
return this.getBusinessId();
}
setValue(value: any): any {
this.value = value;
}

View file

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlComponent>
<id>803bd971-3b5e-4344-b687-7e103b3d3326</id>
<name>DropdownTreeView</name>
<internal>false</internal>
<versions>
<studioVersion>3.185.1</studioVersion>
<packageVersions>
<entry>
<key>ru.cg.webbpm.packages.base.resources</key>
<value>3.185.2</value>
</entry>
</packageVersions>
</versions>
<rootObject id="8174c549-4b94-4c3e-9168-09610ade4c6e">
<name>DropdownTreeView</name>
<container>false</container>
<expanded>false</expanded>
<childrenReordered>false</childrenReordered>
<scripts id="d524f4d7-efdc-45ac-a9a5-a160e241b871">
<classRef type="TS">
<className>DropdownTreeViewComponent</className>
<packageName>account_applications.component.field</packageName>
</classRef>
<enabled>true</enabled>
<expanded>true</expanded>
<properties>
<entry>
<key>collapseLevel</key>
<value>
<simple>2.0</simple>
</value>
</entry>
<entry>
<key>visible</key>
<value>
<simple>true</simple>
</value>
</entry>
</properties>
</scripts>
<scripts id="e911e686-ce91-4aec-8554-0b6e44e7325d">
<classRef type="TS">
<className>DropdownTreeViewFilterComponent</className>
<packageName>account_applications.component.filter</packageName>
</classRef>
<enabled>true</enabled>
<expanded>true</expanded>
<properties>
<entry>
<key>operation</key>
<value>
<simple>null</simple>
</value>
</entry>
</properties>
</scripts>
<scripts id="77cc6e8e-3df7-4916-af81-1526a952d951">
<classRef type="JAVA">
<className>TreeItemRpcService</className>
<packageName>ru.micord.ervu.account_applications.component.rpc</packageName>
</classRef>
<enabled>true</enabled>
<expanded>true</expanded>
<properties>
<entry>
<key>treeItemService</key>
<value>
<complex>
<entry>
<key>businessIdColumn</key>
<value>
<simple>null</simple>
</value>
</entry>
<entry>
<key>idColumn</key>
<value>
<simple>null</simple>
</value>
</entry>
<entry>
<key>labelColumn</key>
<value>
<simple>null</simple>
</value>
</entry>
<entry>
<key>loadDao</key>
<value>
<complex>
<entry>
<key>graph</key>
<value>
<simple>null</simple>
</value>
</entry>
</complex>
</value>
</entry>
<entry>
<key>parentIdColumn</key>
<value>
<simple>null</simple>
</value>
</entry>
</complex>
</value>
</entry>
</properties>
</scripts>
</rootObject>
</xmlComponent>