diff --git a/CHANGELOG.md b/CHANGELOG.md index 68f003fe0..224038646 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,8 @@ Full Changelog: [https://github.com/netgrif/components/commits/v6.4.0](https://g - [NAE-2019] Bugs after merge with 6.4.0 ### Changed -- [NAE- 1940] Update to new Angular +- [NAE-1940] Update to new Angular +- [NAE-2023] Update URI attributes on frontend ## [6.4.0](https://github.com/netgrif/components/releases/tag/v6.4.0) (2024-11-07) diff --git a/package.json b/package.json index 2fb0e86ed..bd8e03694 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@netgrif/components-project", - "version": "7.0.0-rc.1", + "version": "7.0.0-beta.2", "description": "Netgrif Application Engine Frontend project. Project includes angular libraries as base for NAE applications.", "homepage": "https://components.netgrif.com", "license": "SEE LICENSE IN LICENSE", diff --git a/projects/netgrif-components-core/package.json b/projects/netgrif-components-core/package.json index 896a37ff2..31c26e6cf 100644 --- a/projects/netgrif-components-core/package.json +++ b/projects/netgrif-components-core/package.json @@ -1,6 +1,6 @@ { "name": "@netgrif/components-core", - "version": "7.0.0-rc.1", + "version": "7.0.0-beta.2", "description": "Netgrif Application engine frontend core Angular library", "homepage": "https://components.netgrif.com", "license": "SEE LICENSE IN LICENSE", diff --git a/projects/netgrif-components-core/src/lib/navigation/breadcrumbs/abstract-breadcrumbs.component.ts b/projects/netgrif-components-core/src/lib/navigation/breadcrumbs/abstract-breadcrumbs.component.ts index 15f940570..015f2d9b8 100644 --- a/projects/netgrif-components-core/src/lib/navigation/breadcrumbs/abstract-breadcrumbs.component.ts +++ b/projects/netgrif-components-core/src/lib/navigation/breadcrumbs/abstract-breadcrumbs.component.ts @@ -97,7 +97,7 @@ export abstract class AbstractBreadcrumbsComponent implements OnDestroy, AfterVi this.nicePathSubscription = this.nicePath.subscribe(np => { if (!!np) { const path = np; - if (path?.length > this.partsAfterDots + 1 && this._uriService.activeNode?.uriPath.length > this.lengthOfPath && !this._showPaths) { + if (path?.length > this.partsAfterDots + 1 && this._uriService.activeNode?.path.length > this.lengthOfPath && !this._showPaths) { const newPath = [path[0], AbstractBreadcrumbsComponent.DOTS]; for (let i = path.length - this.partsAfterDots; i < path.length; i++) { newPath.push(path[i]); @@ -114,7 +114,7 @@ export abstract class AbstractBreadcrumbsComponent implements OnDestroy, AfterVi if (!this.redirectOnClick) { return; } - this._router.navigate(this.redirectUrls.get(this._uriService.activeNode.uriPath)).then(r => {}) + this._router.navigate(this.redirectUrls.get(this._uriService.activeNode.path)).then(r => {}) } public reset(): void { @@ -146,7 +146,7 @@ export abstract class AbstractBreadcrumbsComponent implements OnDestroy, AfterVi } private resultCounter(count: number, tmp: string[]): number { - if (tmp?.length > this.partsAfterDots + 1 && this._uriService.activeNode?.uriPath.length > this.lengthOfPath && !this._showPaths) { + if (tmp?.length > this.partsAfterDots + 1 && this._uriService.activeNode?.path.length > this.lengthOfPath && !this._showPaths) { return tmp.length - this.partsAfterDots + (count - 2); } return count; diff --git a/projects/netgrif-components-core/src/lib/navigation/model/uri-resource.ts b/projects/netgrif-components-core/src/lib/navigation/model/uri-resource.ts index 50c1fef1b..cdc9cb956 100644 --- a/projects/netgrif-components-core/src/lib/navigation/model/uri-resource.ts +++ b/projects/netgrif-components-core/src/lib/navigation/model/uri-resource.ts @@ -1,7 +1,6 @@ export interface UriNodeResource { - id: string; - uriPath: string; + path: string; name: string; parentId: string; parent: UriNodeResource; diff --git a/projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts b/projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts index 10f2b2068..b3a028e34 100644 --- a/projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts +++ b/projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts @@ -179,7 +179,7 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit, return; } if (node.parentId && !node.parent) { - if (node.parentId === this._uriService.root.id) { + if (this._uriService.isRoot(node)) { node.parent = this._uriService.root; } else { this.nodeLoading$.on(); @@ -206,7 +206,7 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit, this.leftItems = []; this.loadRightSide(); } else { - if (!this.leftItems.find(item => item.resource?.immediateData.find(f => f.stringId === GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH)?.value === node.uriPath)) { + if (!this.leftItems.find(item => item.resource?.immediateData.find(f => f.stringId === GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH)?.value === node.path)) { this.loadLeftSide(); } this.loadRightSide(); @@ -327,7 +327,7 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit, onItemClick(item: NavigationItem): void { if (item.resource === undefined) { // custom view represented only in nae.json - if (item.processUri === this.currentNode.uriPath) { + if (item.processUri === this.currentNode.path) { this._uriService.activeNode = this._currentNode; } else { this._uriService.activeNode = this._currentNode.parent; @@ -340,7 +340,7 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit, }, error => { this._log.error(error); }); - } else if (!path.includes(this.currentNode.uriPath)){ + } else if (!path.includes(this.currentNode.path)){ this._uriService.activeNode = this._currentNode.parent; } else { this._uriService.activeNode = this._currentNode; @@ -353,7 +353,7 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit, } isItemAndNodeEqual(item: NavigationItem, node: UriNodeResource): boolean { - return item.resource?.immediateData.find(f => f.stringId === GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH)?.value === node.uriPath + return item.resource?.immediateData.find(f => f.stringId === GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH)?.value === node.path } protected loadLeftSide() { @@ -485,14 +485,14 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit, } protected resolveCustomViewsInRightSide() { - if (!!this._childCustomViews[this._currentNode.uriPath]) { - this.rightItems.push(...Object.values(this._childCustomViews[this._currentNode.uriPath])); + if (!!this._childCustomViews[this._currentNode.path]) { + this.rightItems.push(...Object.values(this._childCustomViews[this._currentNode.path])); } } protected resolveCustomViewsInLeftSide() { - if (!!this._childCustomViews[this._currentNode.parent.uriPath]) { - this.leftItems.push(...Object.values(this._childCustomViews[this._currentNode.parent.uriPath])); + if (!!this._childCustomViews[this._currentNode.parent.path]) { + this.leftItems.push(...Object.values(this._childCustomViews[this._currentNode.parent.path])); } } @@ -567,7 +567,7 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit, } uriNodeTrackBy(index: number, node: UriNodeResource) { - return node.id; + return node.path; } itemsTrackBy(index: number, item: NavigationItem) { diff --git a/projects/netgrif-components-core/src/lib/navigation/service/uri.service.spec.ts b/projects/netgrif-components-core/src/lib/navigation/service/uri.service.spec.ts index 72ff8495d..46067a03c 100644 --- a/projects/netgrif-components-core/src/lib/navigation/service/uri.service.spec.ts +++ b/projects/netgrif-components-core/src/lib/navigation/service/uri.service.spec.ts @@ -42,7 +42,7 @@ describe('UriService', () => { it('should get root node', () => { const root = service.root; - expect(root.id).toEqual('root'); + expect(root.path).toEqual('root'); expect(service.isRoot(root)).toBeTruthy(); expect(service.activeNode).toEqual(root); }); @@ -59,8 +59,7 @@ describe('UriService', () => { it('should get node by path', done => { service.getNodeByPath(MockUriResourceService.TEST1_PATH).subscribe(res => { - expect(res.uriPath).toEqual(MockUriResourceService.TEST1_PATH); - expect(res.id).toEqual(MockUriResourceService.TEST1_ID); + expect(res.path).toEqual(MockUriResourceService.TEST1_PATH); done(); }); }); @@ -69,7 +68,7 @@ describe('UriService', () => { service.getChildNodes(service.root).subscribe(res => { expect(res.length).toEqual(2); res.forEach(r => { - expect(r.id).toContain('test'); + expect(r.path).toContain('test'); expect(r.parentId).toEqual('root'); }); done(); @@ -85,9 +84,9 @@ describe('UriService', () => { it('should get siblings of a node', done => { service.getNodeByPath(MockUriResourceService.TEST1_PATH).subscribe(node => { - expect(node.id).toEqual(MockUriResourceService.TEST1_ID); + expect(node.path).toEqual(MockUriResourceService.TEST1_PATH); service.getSiblingsOfNode(node).subscribe(siblings => { - expect(siblings.find(n => n.id === MockUriResourceService.TEST2_ID)).not.toBeUndefined(); + expect(siblings.find(n => n.path === MockUriResourceService.TEST2_PATH)).not.toBeUndefined(); done(); }); }); @@ -110,9 +109,7 @@ describe('UriService', () => { it('should get parts of path', done => { service.getNodeByPath(MockUriResourceService.TEST1_PATH).subscribe(node => { - const path = service.splitNodePath(node); - expect(path.length).toEqual(1); - expect(path[0]).toEqual(MockUriResourceService.TEST1_ID); + expect(node.path).toEqual(MockUriResourceService.TEST1_PATH); done(); }); }); diff --git a/projects/netgrif-components-core/src/lib/navigation/service/uri.service.ts b/projects/netgrif-components-core/src/lib/navigation/service/uri.service.ts index 4d1d132e5..93bd2646e 100644 --- a/projects/netgrif-components-core/src/lib/navigation/service/uri.service.ts +++ b/projects/netgrif-components-core/src/lib/navigation/service/uri.service.ts @@ -62,7 +62,7 @@ export class UriService implements OnDestroy { } public isRoot(node: UriNodeResource): boolean { - return node.id === this._rootNode.id && node.uriPath === this._rootNode.uriPath; + return node.path === this._rootNode.path; } public get activeNode(): UriNodeResource { @@ -71,7 +71,7 @@ export class UriService implements OnDestroy { public set activeNode(node: UriNodeResource) { if (node.parentId && !node.parent) { - if (node.parentId === this._rootNode.id) { + if (node.parentId === this._rootNode.path) { node.parent = this._rootNode; } else { this._parentLoading$.on(); @@ -137,7 +137,7 @@ export class UriService implements OnDestroy { */ public getChildNodes(node?: UriNodeResource): Observable> { if (!node) node = this.activeNode; - return this._resourceService.getNodesByParent(node.id).pipe( + return this._resourceService.getNodesByParent(node.path).pipe( map(nodes => { this.capitalizeNames(nodes); return nodes; @@ -155,7 +155,7 @@ export class UriService implements OnDestroy { public getCasesOfNode(node?: UriNodeResource, processIdentifiers?: Array, pageNumber: number = 0, pageSize: string | number = this.pageSize): Observable> { if (!node) node = this.activeNode; const searchBody: CaseSearchRequestBody = { - uriNodeId: node.id, + uriNodeId: node.path, }; if (!!processIdentifiers) { searchBody.process = processIdentifiers.map(id => ({identifier: id} as PetriNetSearchRequest)); @@ -182,7 +182,7 @@ export class UriService implements OnDestroy { } const searchBody: CaseSearchRequestBody = { data: { - [GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH] : node.uriPath + [GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH] : node.path }, process: {identifier: "preference_item"} }; @@ -216,7 +216,7 @@ export class UriService implements OnDestroy { if (level === 0) return of([this.root]); return this._resourceService.getByLevel(level).pipe( map(nodes => { - const ns = !!parent?.id ? nodes.filter(n => n.parentId === parent.id) : nodes; + const ns = !!parent?.path ? nodes.filter(n => n.parentId === parent.path) : nodes; this.capitalizeNames(ns); return ns; }), @@ -225,13 +225,13 @@ export class UriService implements OnDestroy { public resolveParentPath(node?: UriNodeResource): string { if (!node) node = this.activeNode; - const lastDelimiter = node.uriPath.lastIndexOf('/'); + const lastDelimiter = node.path.lastIndexOf('/'); if (lastDelimiter === 0) return '/'; - return node.uriPath.substring(0, lastDelimiter); + return node.path.substring(0, lastDelimiter); } public splitNodePath(node: UriNodeResource): Array { - return node?.uriPath.split('/').filter(s => s !== UriService.ROOT); + return node?.path.split('/').filter(s => s !== UriService.ROOT); } private capitalizeNames(nodes: Array) { diff --git a/projects/netgrif-components-core/src/lib/side-menu/content-components/import-net/abstract-import-net.component.ts b/projects/netgrif-components-core/src/lib/side-menu/content-components/import-net/abstract-import-net.component.ts index acffa19bd..1ff110918 100644 --- a/projects/netgrif-components-core/src/lib/side-menu/content-components/import-net/abstract-import-net.component.ts +++ b/projects/netgrif-components-core/src/lib/side-menu/content-components/import-net/abstract-import-net.component.ts @@ -126,7 +126,7 @@ export abstract class AbstractImportNetComponent implements AfterViewInit { protected uploadFile(file: FileUploadModel) { const fileFormData = new FormData(); fileFormData.append('file', file.data as File); - fileFormData.append('uriNodeId', this._uriService.activeNode.id); + fileFormData.append('uriNodeId', this._uriService.activeNode.path); fileFormData.append('meta', this.releaseTypeControl.value.toString().toUpperCase()); file.inProgress = true; diff --git a/projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-uri-resource.service.ts b/projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-uri-resource.service.ts index da55d714e..68ffed360 100644 --- a/projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-uri-resource.service.ts +++ b/projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-uri-resource.service.ts @@ -8,26 +8,22 @@ import {ResourceProvider} from '../../../resources/resource-provider.service'; @Injectable() export class MockUriResourceService extends UriResourceService { - static TEST1_ID = 'test1'; static TEST1_PATH = 'root/test1'; - static TEST2_ID = 'test2'; static TEST2_PATH = 'root/test2'; private _root: UriNodeResource = { - id: 'root', - uriPath: 'root', + path: 'root', name: 'root', parentId: null, parent: undefined, - childrenId: new Set([MockUriResourceService.TEST1_ID, MockUriResourceService.TEST2_ID]), + childrenId: new Set([MockUriResourceService.TEST1_PATH, MockUriResourceService.TEST2_PATH]), children: undefined, level: 0, contentTypes: undefined, } as UriNodeResource; private _test1Node: UriNodeResource = { - id: MockUriResourceService.TEST1_ID, - uriPath: MockUriResourceService.TEST1_PATH, - name: MockUriResourceService.TEST1_ID, + path: MockUriResourceService.TEST1_PATH, + name: MockUriResourceService.TEST1_PATH, parentId: 'root', parent: this._root, childrenId: undefined, @@ -36,9 +32,8 @@ export class MockUriResourceService extends UriResourceService { contentTypes: new Set([UriContentType.PROCESS]), } as UriNodeResource; private _test2Node: UriNodeResource = { - id: MockUriResourceService.TEST2_ID, - uriPath: MockUriResourceService.TEST2_PATH, - name: MockUriResourceService.TEST2_ID, + path: MockUriResourceService.TEST2_PATH, + name: MockUriResourceService.TEST2_PATH, parentId: 'root', parent: this._root, childrenId: undefined, diff --git a/projects/netgrif-components/package.json b/projects/netgrif-components/package.json index f6ddb7ddc..587de29d4 100644 --- a/projects/netgrif-components/package.json +++ b/projects/netgrif-components/package.json @@ -1,6 +1,6 @@ { "name": "@netgrif/components", - "version": "7.0.0-rc.1", + "version": "7.0.0-beta.2", "description": "Netgrif Application Engine frontend Angular components", "homepage": "https://components.netgrif.com", "license": "SEE LICENSE IN LICENSE", @@ -29,7 +29,7 @@ "nae frontend" ], "peerDependencies": { - "@netgrif/components-core": "7.0.0-rc.1", + "@netgrif/components-core": "7.0.0-beta.2", "@angular-material-components/datetime-picker": "~16.0.0", "@angular-material-components/moment-adapter": "~16.0.0", "@angular/animations": "~17.1.0", diff --git a/projects/netgrif-components/src/lib/dialog/import-net-dialog/import-net-dialog.component.ts b/projects/netgrif-components/src/lib/dialog/import-net-dialog/import-net-dialog.component.ts index 648f2ab6a..ccf0f558a 100644 --- a/projects/netgrif-components/src/lib/dialog/import-net-dialog/import-net-dialog.component.ts +++ b/projects/netgrif-components/src/lib/dialog/import-net-dialog/import-net-dialog.component.ts @@ -126,7 +126,7 @@ export class ImportNetDialogComponent implements AfterViewInit { protected uploadFile(file: FileUploadModel) { const fileFormData = new FormData(); fileFormData.append('file', file.data as File); - fileFormData.append('uriNodeId', this._uriService.activeNode.id); + fileFormData.append('uriNodeId', this._uriService.activeNode.path); fileFormData.append('meta', this.releaseTypeControl.value.toString().toUpperCase()); file.inProgress = true;