Skip to content

Commit bc4912b

Browse files
authored
Merge pull request #90 from netgrif/NAE-1690
[NAE-1690] Fix header responsive overflow mode
2 parents 3ae96f5 + 72bfeb0 commit bc4912b

File tree

17 files changed

+85
-54
lines changed

17 files changed

+85
-54
lines changed

projects/nae-example-app/src/app/doc/case-view/case-view.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AfterViewInit, Component, ViewChild} from '@angular/core';
1+
import {AfterViewInit, Component, Optional, ViewChild} from '@angular/core';
22
import {
33
AbstractCaseViewComponent,
44
Case,
@@ -34,8 +34,8 @@ const baseFilterFactory = () => {
3434
providers: [
3535
CategoryFactory,
3636
CaseViewService,
37-
OverflowService,
3837
SearchService,
38+
OverflowService,
3939
{ provide: NAE_BASE_FILTER,
4040
useFactory: baseFilterFactory},
4141
{ provide: AllowedNetsService,
@@ -52,7 +52,7 @@ export class CaseViewComponent extends AbstractCaseViewComponent implements Afte
5252

5353
additionalFilterData: TaskSetDataRequestFields;
5454

55-
constructor(caseViewService: CaseViewService, protected overflowService: OverflowService) {
55+
constructor(caseViewService: CaseViewService, @Optional() overflowService: OverflowService) {
5656
super(caseViewService, overflowService, undefined, {
5757
enableCaseTitle: true,
5858
isCaseTitleRequired: false

projects/nae-example-app/src/app/doc/tabbed-case-view/tabbed-case-view/tabbed-case-view.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AfterViewInit, Component, Inject, ViewChild} from '@angular/core';
1+
import {AfterViewInit, Component, Inject, Optional, ViewChild} from '@angular/core';
22
import {
33
CaseViewService,
44
CategoryFactory,
@@ -75,7 +75,7 @@ export class TabbedCaseViewComponent extends AbstractTabbedCaseViewComponent imp
7575

7676
constructor(caseViewService: CaseViewService,
7777
loggerService: LoggerService,
78-
overflowService: OverflowService,
78+
@Optional() overflowService: OverflowService,
7979
@Inject(NAE_TAB_DATA) injectedTabData: InjectedTabbedCaseViewData) {
8080
super(caseViewService, loggerService, injectedTabData, overflowService, undefined, undefined, {
8181
enableCaseTitle: true,

projects/nae-example-app/src/app/doc/tabbed-case-view/tabbed-task-view/tabbed-task-view.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
TaskViewService,
1212
ViewIdService,
1313
NAE_BASE_FILTER,
14+
OverflowService,
1415
AllowedNetsService,
1516
AllowedNetsServiceFactory,
1617
tabbedAllowedNetsServiceFactory,
@@ -35,6 +36,7 @@ const baseFilterFactory = (injectedTabData: InjectedTabbedTaskViewData) => {
3536
TaskViewService,
3637
SearchService,
3738
ChangedFieldsService,
39+
OverflowService,
3840
{
3941
provide: NAE_BASE_FILTER,
4042
useFactory: baseFilterFactory,

projects/nae-example-app/src/app/doc/task-view/task-view.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
NAE_VIEW_ID_SEGMENT,
1212
ViewIdService,
1313
CategoryFactory,
14+
OverflowService,
1415
NAE_SEARCH_CATEGORIES,
1516
defaultTaskSearchCategoriesFactory,
1617
NAE_ASYNC_RENDERING_CONFIGURATION,

projects/netgrif-components-core/src/lib/header/abstract-header-service.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {SortDirection} from '@angular/material/sort';
1616
import {HeaderChangeType} from './models/user-changes/header-change-type';
1717
import {ViewIdService} from '../user/services/view-id.service';
1818
import {Net} from '../process/net';
19-
import { OverflowService } from './services/overflow.service';
19+
import {OverflowService} from './services/overflow.service';
2020

2121
@Injectable()
2222
export abstract class AbstractHeaderService implements OnDestroy {
@@ -81,7 +81,11 @@ export abstract class AbstractHeaderService implements OnDestroy {
8181
}
8282

8383
get overflowMode(): boolean {
84-
return this._overflowService.overflowMode;
84+
if (!!this._overflowService) {
85+
return this._overflowService.overflowMode;
86+
} else {
87+
return false;
88+
}
8589
}
8690

8791
get headerColumnCount(): number {
@@ -304,7 +308,11 @@ export abstract class AbstractHeaderService implements OnDestroy {
304308
header.sortDirection = '';
305309
}
306310
});
307-
this._headerChange$.next({headerType: this.headerType, changeType: HeaderChangeType.SORT, description: sortChangeDescription});
311+
this._headerChange$.next({
312+
headerType: this.headerType,
313+
changeType: HeaderChangeType.SORT,
314+
description: sortChangeDescription
315+
});
308316
}
309317

310318
/**

projects/netgrif-components-core/src/lib/header/abstract-header.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Injector, Input, OnDestroy, OnInit} from '@angular/core';
1+
import {Component, Injector, Input, OnDestroy, OnInit, Optional} from '@angular/core';
22
import {AbstractHeaderService} from './abstract-header-service';
33
import {CaseHeaderService} from './case-header/case-header.service';
44
import {TaskHeaderService} from './task-header/task-header.service';
@@ -40,7 +40,7 @@ export abstract class AbstractHeaderComponent implements OnInit, OnDestroy {
4040

4141
constructor(protected _injector: Injector,
4242
protected _translate: TranslateService,
43-
protected _overflowService: OverflowService) {
43+
@Optional() protected _overflowService: OverflowService) {
4444
(this._overflowService !== null) ?
4545
this.initializeFormControls(true) :
4646
this.initializeFormControls(false);

projects/netgrif-components-core/src/lib/header/services/overflow.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface OverflowState {
1010
@Injectable()
1111
export class OverflowService {
1212

13-
protected readonly DEFAULT_COLUMN_WIDTH = 190;
13+
protected readonly DEFAULT_COLUMN_WIDTH = 200;
1414
protected readonly DEFAULT_COLUMN_COUNT = 6;
1515
private _overflowMode: boolean;
1616
private _columnWidth: number;

projects/netgrif-components-core/src/lib/panel/abstract/panel-with-header-binding.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import {Component, OnDestroy, OnInit} from '@angular/core';
1+
import {Component, OnDestroy, OnInit, Optional} from '@angular/core';
22
import {Observable, Subscription} from 'rxjs';
33
import {HeaderColumn, HeaderColumnType} from '../../header/models/header-column';
44
import {FeaturedValue} from './featured-value';
5+
import {OverflowService} from '../../header/services/overflow.service';
56

67
@Component({
78
selector: 'ncc-abstract-panel-with-header-binding',
@@ -14,7 +15,15 @@ export abstract class AbstractPanelWithHeaderBindingComponent implements OnInit,
1415
protected _lastSelectedHeaders: Array<HeaderColumn>;
1516
protected sub: Subscription;
1617

17-
protected constructor() {
18+
protected constructor(@Optional() protected _overflowService: OverflowService) {
19+
}
20+
21+
get overflowMode(): boolean {
22+
if(!!this._overflowService){
23+
return this._overflowService.overflowMode;
24+
} else {
25+
return false;
26+
}
1827
}
1928

2029
ngOnInit(): void {

projects/netgrif-components-core/src/lib/panel/abstract/panel-with-immediate-data.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {AbstractPanelWithHeaderBindingComponent} from './panel-with-header-bindi
22
import {NaeDate, toMoment} from '../../resources/types/nae-date-type';
33
import {DATE_FORMAT_STRING, DATE_TIME_FORMAT_STRING} from '../../moment/time-formats';
44
import {TranslateService} from '@ngx-translate/core';
5-
import {Component, OnDestroy} from '@angular/core';
5+
import {Component, OnDestroy, Optional} from '@angular/core';
66
import {FeaturedValue} from './featured-value';
77
import {CurrencyPipe} from '@angular/common';
88
import {ImmediateData} from '../../resources/interface/immediate-data';
@@ -15,12 +15,8 @@ import {OverflowService} from '../../header/services/overflow.service';
1515
export abstract class AbstractPanelWithImmediateDataComponent extends AbstractPanelWithHeaderBindingComponent implements OnDestroy {
1616
protected constructor(protected _translate: TranslateService,
1717
protected _currencyPipe: CurrencyPipe,
18-
protected _overflowService: OverflowService) {
19-
super();
20-
}
21-
22-
get overflowMode(): boolean {
23-
return this._overflowService.overflowMode;
18+
@Optional() protected _overflowService: OverflowService) {
19+
super(_overflowService);
2420
}
2521

2622
ngOnDestroy(): void {

projects/netgrif-components-core/src/lib/panel/case-panel/abstract-case-panel.component.spec.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ describe('AbstractCasePanelComponent', () => {
6363
{provide: AuthenticationMethodService, useClass: MockAuthenticationMethodService},
6464
{provide: AuthenticationService, useClass: MockAuthenticationService},
6565
SignUpService,
66-
{provide: AllowedNetsService, useFactory: TestCaseViewAllowedNetsFactory, deps: [AllowedNetsServiceFactory]}
66+
{
67+
provide: AllowedNetsService,
68+
useFactory: TestCaseViewAllowedNetsFactory,
69+
deps: [AllowedNetsServiceFactory]
70+
}
6771
],
6872
declarations: [
6973
TestCasePanelComponent,
@@ -101,13 +105,17 @@ describe('AbstractCasePanelComponent', () => {
101105
template: ''
102106
})
103107
class TestCasePanelComponent extends AbstractCasePanelComponent {
104-
constructor(protected _caseResourceService: CaseResourceService, protected _caseViewService: CaseViewService,
105-
protected _snackBarService: SnackBarService, protected _translateService: TranslateService,
106-
protected _log: LoggerService, @Optional() protected overflowService: OverflowService,
107-
protected _userService: UserService, protected _currencyPipe: CurrencyPipe,
108-
protected _permissionService: PermissionService) {
109-
super(_caseResourceService, _caseViewService, _snackBarService, _translateService, _log, overflowService,
110-
_userService, _currencyPipe, _permissionService);
108+
constructor(protected _caseResourceService: CaseResourceService,
109+
protected _caseViewService: CaseViewService,
110+
protected _snackBarService: SnackBarService,
111+
protected _translateService: TranslateService,
112+
protected _log: LoggerService,
113+
protected _userService: UserService,
114+
protected _currencyPipe: CurrencyPipe,
115+
protected _permissionService: PermissionService,
116+
@Optional() protected overflowService: OverflowService) {
117+
super(_caseResourceService, _caseViewService, _snackBarService, _translateService, _log,
118+
_userService, _currencyPipe, _permissionService, overflowService,);
111119
}
112120
}
113121

@@ -116,7 +124,7 @@ class TestCasePanelComponent extends AbstractCasePanelComponent {
116124
template: '<ncc-test-case-panel [selectedHeaders$]="selectedHeaders" [case_]="case_"> </ncc-test-case-panel>'
117125
})
118126
class TestWrapperComponent {
119-
selectedHeaders = of([
127+
selectedHeaders = of([
120128
new HeaderColumn(HeaderColumnType.META, CaseMetaField.VISUAL_ID, 'string', 'string'),
121129
new HeaderColumn(HeaderColumnType.META, CaseMetaField.AUTHOR, 'string', 'string'),
122130
new HeaderColumn(HeaderColumnType.META, CaseMetaField.TITLE, 'string', 'string'),
@@ -155,7 +163,7 @@ class TestWrapperComponent {
155163
{stringId: 'date', title: 'string', type: 'date', value: [2020, 1, 1, 10, 10]},
156164
{stringId: 'string', title: 'string', type: 'string', value: 'dasdsadsad'},
157165
{stringId: 'dateTime', title: 'string', type: 'dateTime', value: [2020, 1, 1, 10, 10]},
158-
{stringId: 'enum', title: 'string', type: 'enumeration', value: { defaultValue: 'dasd'}},
166+
{stringId: 'enum', title: 'string', type: 'enumeration', value: {defaultValue: 'dasd'}},
159167
]
160168
};
161169
}

0 commit comments

Comments
 (0)