Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NAE-2035] Implement Single-Task-View #264

Merged
merged 7 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AfterViewInit, Component, Inject, OnInit, ViewChild} from '@angular/core';
import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core';
import {
AbstractSingleTaskViewComponent,
AllowedNetsService,
Expand All @@ -22,9 +22,7 @@ import {
TaskRequestStateService,
TaskResourceServiceProvider,
TaskViewService,
ViewIdService,
BaseFilter,
NAE_BASE_FILTER
ViewIdService
} from '@netgrif/components-core';
import {ActivatedRoute, Router} from '@angular/router';
import {combineLatest} from 'rxjs';
Expand Down Expand Up @@ -60,7 +58,6 @@ const localAllowedNetsServiceFactory = (factory: AllowedNetsServiceFactory, rout
deps: [AllowedNetsServiceFactory, ActivatedRoute]
},
{provide: NAE_VIEW_ID_SEGMENT, useValue: 'publicTaskView'},
{provide: AllowedNetsServiceFactory, useClass: AllowedNetsServiceFactory},
ViewIdService,
{provide: TaskContentService, useClass: SingleTaskContentService},
TaskDataService,
Expand All @@ -81,9 +78,8 @@ export class PublicSingleTaskViewComponent extends AbstractSingleTaskViewCompone
constructor(taskViewService: TaskViewService,
publicTaskLoadingService: PublicTaskLoadingService,
activatedRoute: ActivatedRoute,
protected _router: Router,
@Inject(NAE_BASE_FILTER) baseFilter: BaseFilter) {
super(taskViewService, activatedRoute, baseFilter);
protected _router: Router) {
super(taskViewService, activatedRoute);
this.hidden = false;
this.loading$ = combineLatest(taskViewService.loading$, publicTaskLoadingService.loading$).pipe(
map(sources => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import {NAE_TASK_FORCE_OPEN, NAE_VIEW_ID_SEGMENT, TabContent, ViewIdService} fro
import {TabbedCaseViewComponent} from './tabbed-case-view/tabbed-case-view.component';
import {TabbedTaskViewComponent} from './tabbed-task-view/tabbed-task-view.component';
import {ReplaySubject} from 'rxjs';
import {
DefaultTabbedSingleTaskViewComponent
} from "@netgrif/components";

@Component({
selector: 'nae-app-tabbed-views-example',
Expand Down Expand Up @@ -32,7 +35,7 @@ export class TabbedViewsExampleComponent implements OnInit {
canBeClosed: false,
tabContentComponent: TabbedCaseViewComponent,
injectedObject: {
tabViewComponent: TabbedTaskViewComponent,
tabViewComponent: DefaultTabbedSingleTaskViewComponent,
tabViewOrder: 0,
exampleUseCache: true
}
Expand Down
14 changes: 9 additions & 5 deletions projects/nae-example-app/src/app/nae-example-app-view.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ import {ExampleRedirectComponent} from './doc/redirect/example-redirect.componen
import {ActiveGroupComponent} from './doc/active-group/active-group.component';
import {WrapperEmptyViewComponent} from './views/wrapper/wrapper-empty-view.component';
import {DoubleDrawerExampleComponent} from './doc/double-drawer-example/double-drawer-example.component';
import {PublicSingleTaskViewComponent} from './doc/public-single-task-view/public-single-task-view.component';
import {BreadcrumbsExampleComponent} from './doc/breadcrumbs-example/breadcrumbs-example.component';
import {DashboardCaseExampleComponent} from './doc/dashboard-case-example/dashboard-case-example.component';
import {ImpersonationDemoComponent} from './doc/impersonation-demo/impersonation-demo.component';
import {ChangePasswordComponent} from "./doc/forms/change-password/change-password.component";
import {
DefaultPublicResolverComponent, DefaultPublicSingleTaskViewComponent,
DefaultPublicTaskViewComponent,
DefaultPublicWorkflowViewComponent
} from "@netgrif/components";

@Injectable({
providedIn: 'root'
Expand All @@ -54,7 +58,7 @@ export class NaeExampleAppViewService extends ViewService {
{id: 'ImpersonationDemoComponent', class: ImpersonationDemoComponent},
{id: 'BreadcrumbsExampleComponent', class: BreadcrumbsExampleComponent},
{id: 'TitleConfigComponent', class: TitleConfigComponent},
{id: 'PublicSingleTaskViewComponent', class: PublicSingleTaskViewComponent},
{id: 'PublicSingleTaskViewComponent', class: DefaultPublicSingleTaskViewComponent},
{id: 'WrapperEmptyViewComponent', class: WrapperEmptyViewComponent},
{id: 'ActiveGroupComponent', class: ActiveGroupComponent},
{id: 'ExampleRedirectComponent', class: ExampleRedirectComponent},
Expand Down Expand Up @@ -88,9 +92,9 @@ export class NaeExampleAppViewService extends ViewService {
{id: 'AuthenticationComponent', class: AuthenticationComponent},
{id: 'RolesAssignComponent', class: RolesAssignComponent},
{id: 'LdapGroupRolesAssignComponent', class: LdapGroupRolesAssignComponent},
{id: 'PublicTaskViewComponent', class: PublicTaskViewComponent},
{id: 'PublicWorkflowViewComponent', class: PublicWorkflowViewComponent},
{id: 'PublicResolverComponent', class: PublicResolverComponent},
{id: 'PublicTaskViewComponent', class: DefaultPublicTaskViewComponent},
{id: 'PublicWorkflowViewComponent', class: DefaultPublicWorkflowViewComponent},
{id: 'PublicResolverComponent', class: DefaultPublicResolverComponent},
{
id: 'ResetPasswordFormComponent',
class: ResetPasswordFormComponent
Expand Down
3 changes: 2 additions & 1 deletion projects/netgrif-components-core/src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"finish": "Abschließen",
"cancel": "Stornieren",
"noData": "Diese Aufgabe hat keine Dateien. Schließen Sie die Aufgabe ab, um fortzufahren.",
"redirecting": "Umleiten..."
"redirecting": "Umleiten...",
"closeTab": "Schließen"
},
"footer": {
"defaultText": "NETGRIF, s.r.o. © 2022"
Expand Down
3 changes: 2 additions & 1 deletion projects/netgrif-components-core/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"finish": "Finish",
"cancel": "Cancel",
"noData": "This task has no data. Finish to continue.",
"redirecting": "Redirecting..."
"redirecting": "Redirecting...",
"closeTab": "Close"
},
"footer": {
"defaultText": "NETGRIF, s.r.o. © 2022"
Expand Down
3 changes: 2 additions & 1 deletion projects/netgrif-components-core/src/assets/i18n/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"finish": "Dokončiť",
"cancel": "Zrušiť",
"noData": "Táto úloha nemá žiadne údaje. Stlačte dokončiť pre pokračovanie.",
"redirecting": "Presmerovanie..."
"redirecting": "Presmerovanie...",
"closeTab": "Zavrieť"
},
"footer": {
"defaultText": "NETGRIF, s.r.o. © 2022"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ChangedFieldsService implements OnDestroy {
public parseChangedFieldsByCaseAndTaskIds(caseId: string, taskIds: Array<string>,
changedFieldsMap: ChangedFieldsMap): Array<ChangedFields> {
const changedFields: Array<ChangedFields> = [];
const filteredTaskIds: Array<string> = Object.keys(changedFieldsMap[caseId]).filter(taskId => taskIds.includes(taskId));
const filteredTaskIds: Array<string> = Object.keys(changedFieldsMap[caseId]).filter(taskId => taskIds?.includes(taskId));
filteredTaskIds.forEach(taskId => {
changedFields.push(changedFieldsMap[caseId][taskId]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export abstract class ConfigurationService {
map = this.getChildren(views, map, '');
if (map.get(url) === undefined) {
for (const [key, value] of map) {
if (key.includes('/**') && url.includes(key.split('/**')[0]))
if (key?.includes('/**') && url?.includes(key.split('/**')[0]))
return value;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ConfirmDialogComponent extends AbstractDialogComponent<ConfirmDialo
super(dialogRef, data);
this.choice = false;
if (data && data.content) {
this.parsedContent = sanitizer.bypassSecurityTrustHtml(data.content.replace('\\n', '<br>'));
this.parsedContent = sanitizer.bypassSecurityTrustHtml(data.content?.replace('\\n', '<br>'));
} else {
this.parsedContent = sanitizer.bypassSecurityTrustHtml('');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ export class EventService {
const setDataOutcome: SetDataEventOutcome = childOutcome as SetDataEventOutcome;
const outcomeChangedFields: ChangedFields = (childOutcome as SetDataEventOutcome).changedFields.changedFields;
const caseId = setDataOutcome.aCase.stringId;
if (!Object.keys(changedFieldsMap).includes(caseId)) {
if (!Object.keys(changedFieldsMap)?.includes(caseId)) {
changedFieldsMap[caseId] = {};
}
const taskId = setDataOutcome.task.stringId;
if (!Object.keys(changedFieldsMap[caseId]).includes(taskId)) {
if (!Object.keys(changedFieldsMap[caseId])?.includes(taskId)) {
changedFieldsMap[caseId][taskId] = {
taskId
};
}
Object.keys(outcomeChangedFields).forEach(fieldId => {
if (Object.keys(changedFieldsMap[caseId][taskId]).includes(fieldId)) {
if (Object.keys(changedFieldsMap[caseId][taskId])?.includes(fieldId)) {
Object.keys(outcomeChangedFields[fieldId]).forEach(attribute => {
changedFieldsMap[caseId][taskId][fieldId][attribute] = outcomeChangedFields[fieldId][attribute];
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class OverflowService {

const item = localStorage.getItem(viewId + '-' + id);
if (item !== null) {
if (id.includes('columnCount')) {
if (id?.includes('columnCount')) {
this._initializedCount = true;
}
return item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class LogPublisherService implements OnDestroy {
this._publishers = [];
const serviceConfig = config.get().services;
if (serviceConfig && serviceConfig.log && serviceConfig.log.publishers) {
Object.keys(PUBLISHERS).filter(p => serviceConfig.log.publishers.includes(p) && PUBLISHERS[p])
Object.keys(PUBLISHERS).filter(p => serviceConfig.log.publishers?.includes(p) && PUBLISHERS[p])
.forEach(key => new PUBLISHERS[key](this));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export abstract class AbstractBreadcrumbsComponent implements OnDestroy, AfterVi
let tmp = '';
return splitPath.filter(s => s !== "").map((value) => {
tmp += AbstractBreadcrumbsComponent.DELIMETER + value;
return tmp.replace("//", AbstractBreadcrumbsComponent.DELIMETER)
return tmp?.replace("//", AbstractBreadcrumbsComponent.DELIMETER)
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,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.uriPath)) {
this._uriService.activeNode = this._currentNode.parent;
this.itemClicked.emit({uriNode: this._uriService.activeNode, isHome: false});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export abstract class AbstractTaskPanelComponent extends AbstractPanelWithImmedi
});
this._subTaskData = _changedFieldsService.changedFields$.subscribe((changedFieldsMap: ChangedFieldsMap) => {
const filteredCaseIds: Array<string> = Object.keys(changedFieldsMap).filter(
caseId => Object.keys(this._taskContentService.referencedTaskAndCaseIds).includes(caseId)
caseId => Object.keys(this._taskContentService.referencedTaskAndCaseIds)?.includes(caseId)
);
const changedFields: Array<ChangedFields> = [];
filteredCaseIds.forEach(caseId => {
Expand All @@ -170,7 +170,7 @@ export abstract class AbstractTaskPanelComponent extends AbstractPanelWithImmedi
this.expand();
});
_taskOperations.close$.subscribe(() => {
if (!this._taskForceOpen) {
if (!(this._taskForceOpen || this.preventCollapse)) {
this.collapse();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export abstract class AbstractResourceProvider {


public static sanitizeUrl(endpoint?: string, url?: string): string {
if (endpoint.includes('http://') || (endpoint.includes('https://'))) {
if (endpoint?.includes('http://') || (endpoint?.includes('https://'))) {
if (url) {
if (endpoint.includes(url)) {
if (endpoint?.includes(url)) {
return endpoint;
} else {
return url.includes('https://') ? 'https://' +
endpoint.replace(/(^\w+:|^)\/\//, '') : 'http://' +
endpoint.replace(/(^\w+:|^)\/\//, '');
return url?.includes('https://') ? 'https://' +
endpoint?.replace(/(^\w+:|^)\/\//, '') : 'http://' +
endpoint?.replace(/(^\w+:|^)\/\//, '');
}
} else {
return endpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ export class RedirectService {

public parseRedirectPath(url: string): string {
let path: string;
if (url.includes('?')) {
if (url === undefined || url === null) {
return '';
}
if (url?.includes('?')) {
path = url.slice(0, url.indexOf('?'));
} else {
path = url;
}
return path.replace('/redirect', '');
return path?.replace('/redirect', '');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export class CaseDataset extends Category<Datafield> implements AutocompleteOpti
.filter(immediateData => {
return immediateData.title !== undefined
&& immediateData.title.trim().length > 0
&& !CaseDataset.DISABLED_TYPES.includes(immediateData.type);
&& !CaseDataset.DISABLED_TYPES?.includes(immediateData.type);
})
.forEach(immediateData => {
let type = immediateData.type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export abstract class Operator<T> {
* @param forceWrap if set to `true` the value will be wrapped regardless of it's content
*/
public static wrapInputWithQuotes(input: string, forceWrap = false): WrapResult {
if (typeof input === 'string' && (input.includes(' ') || forceWrap))
if (typeof input === 'string' && (input?.includes(' ') || forceWrap))
return {value: `"${input}"`, wasWrapped: true};
else
return {value: input, wasWrapped: false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Substring extends Operator<string> {
// TODO IMPROVEMENT 27.4.2020 - we could use regular expressions to search for substrings which would solve the unintuitive
// behavior that occurs when we search for strings that contain spaces. We need to escape the input string in a special way
// if we choose to do this
const escapedValue = Operator.escapeInput(args[0]).value.replace(/ /g, '\\ ');
const escapedValue = Operator.escapeInput(args[0]).value?.replace(/ /g, '\\ ');
return Operator.forEachKeyword(elasticKeywords, keyword => new Query(`(${keyword}:*${escapedValue}*)`));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class SearchService implements OnDestroy {
* @param searchedSubstring value that should be searched on all full text fields
*/
public setFullTextFilter(searchedSubstring: string): void {
const whiteSpacedSubstring = searchedSubstring.replace(/ /g, '\\ ');
const whiteSpacedSubstring = searchedSubstring?.replace(/ /g, '\\ ');
this._fullTextFilter = new SimpleFilter('', this._baseFilter.type, {fullText: whiteSpacedSubstring});
this.updateActiveFilter();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('AbstractMultiUserAssignListComponent', () => {

it('should select', () => {
component.select({id: '0'} as UserListItem)
expect(component.currentlySelectedUsers.includes('0')).toBeTruthy();
expect(component.currentlySelectedUsers?.includes('0')).toBeTruthy();
});

it('should get loading', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ describe('Subgrid', () => {

expect(titleElement.title).toBe('title');
expect(titleElement.type).toBe(TaskElementType.DATA_GROUP_TITLE);
expect(titleElement.gridAreaId.includes('group')).toBeTrue();
expect(titleElement.gridAreaId?.includes('group')).toBeTrue();

const field = createMockField(true, {x: 0, y: 0, rows: 1, cols: 2}, 'field');
const fieldElement = subgrid.addField(field, FieldTypeResource.BOOLEAN);

expect(fieldElement.gridAreaId.includes('field')).toBeTrue();
expect(fieldElement.gridAreaId?.includes('field')).toBeTrue();
expect(fieldElement.item).toBe(field);
});

Expand Down Expand Up @@ -77,7 +77,7 @@ describe('Subgrid', () => {
subgrid.addRow(['', '', '']);
} catch (e) {
thrown = true;
expect(e.message.includes(JSON.stringify(['', '', '']))).toBeTrue();
expect(e.message?.includes(JSON.stringify(['', '', '']))).toBeTrue();
}
expect(thrown).toBeTrue();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class Subgrid {
* @returns the base identifier, if it already is unique. A unique variation on the base identifier if it is already in use.
*/
protected assureUniqueness(identifier: string): string {
const alphaNumIdentifier = 'x' + identifier.replace(/[^0-9a-z]/gi, '');
const alphaNumIdentifier = 'x' + identifier?.replace(/[^0-9a-z]/gi, '');
if (!this._existingIdentifiers.has(alphaNumIdentifier)) {
this._existingIdentifiers.add(alphaNumIdentifier);
return alphaNumIdentifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class FieldConverterService {
return new BooleanField(item.stringId, item.name, item.value as boolean, item.behavior,
item.placeholder, item.description, item.layout, item.validations, item.component, item.parentTaskId);
case FieldTypeResource.TEXT:
if (this.textFieldNames.includes(item.component?.name)) {
if (this.textFieldNames?.includes(item.component?.name)) {
return new TextAreaField(item.stringId, item.name, this.resolveTextValue(item, item.value), item.behavior,
item.placeholder, item.description, item.layout, item.validations, item.component, item.parentTaskId);
}
Expand Down
Loading
Loading