diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 18cb82e..e12be28 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -63,8 +63,8 @@ export class AppComponent { } logout() { + this.navService.closeNav(); this.authService.logout().subscribe().add(() => this.router.navigate(['login'])); - this.sideNav.close(); } ngAfterViewInit() { diff --git a/src/app/components/sidenav-profile/sidenav-profile.component.html b/src/app/components/sidenav-profile/sidenav-profile.component.html index 275b3cd..0164f65 100644 --- a/src/app/components/sidenav-profile/sidenav-profile.component.html +++ b/src/app/components/sidenav-profile/sidenav-profile.component.html @@ -1,4 +1,4 @@ -
{{name}}
{{email}}
diff --git a/src/app/components/sidenav-profile/sidenav-profile.component.scss b/src/app/components/sidenav-profile/sidenav-profile.component.scss index 59bf5b8..d210ece 100644 --- a/src/app/components/sidenav-profile/sidenav-profile.component.scss +++ b/src/app/components/sidenav-profile/sidenav-profile.component.scss @@ -5,4 +5,8 @@ height:100px; border-radius:50%; margin-top:10px; +} + +.sidenav-profile { + outline: none; } \ No newline at end of file diff --git a/src/app/components/tableComponents/cell/cell.component.spec.ts b/src/app/components/tableComponents/cell/cell.component.spec.ts new file mode 100644 index 0000000..fee8bb2 --- /dev/null +++ b/src/app/components/tableComponents/cell/cell.component.spec.ts @@ -0,0 +1,137 @@ +import {async, TestBed} from '@angular/core/testing'; +import {CellComponent} from './cell.component'; +import {DatePipe} from '@angular/common'; + +describe('CellComponent', () => { + let fixture, cell; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [CellComponent], + providers: [DatePipe] + }); + + fixture = TestBed.createComponent(CellComponent); + cell = fixture.componentInstance; + }); + + it('should accept value true', async(() => { + cell._value = true; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell._value).toBe(true); + }); + })); + + + it('should set value true', async(() => { + cell.value = true; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell._value).toBe(true); + }); + })); + + it('should return value false', async(() => { + cell._value = false; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell.value).toBe(false); + }); + })); + + it('should accept editable true', async(() => { + cell._editable = true; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell._editable).toBe(true); + }); + })); + + it('should set editable false', async(() => { + cell.editable = false; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell._editable).toBe(false); + }); + })); + + it('should return editable false', async(() => { + cell._editable = false; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell.editable).toBe(false); + }); + })); + + + it('should accept input type String', async(() => { + cell._inputType = 'String'; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell._inputType).toBe('String'); + }); + })); + + it('should set input type String', async(() => { + cell.inputType = 'String'; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell._inputType).toBe('String'); + }); + })); + + it('should return input type String', async(() => { + cell._inputType = 'String'; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell.inputType).toBe('String'); + }); + })); + + + it('should accept required true', async(() => { + cell._required = true; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell._required).toBe(true); + }); + })); + + it('should set required false', async(() => { + cell.required = false; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell._required).toBe(false); + }); + })); + + it('should return required true', async(() => { + cell._required = true; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell.required).toBe(true); + }); + })); + + it('should return html input type text', async(() => { + cell.getHtmlInputType('String'); + expect(cell.htmlInputType).toBe('text'); + })); + + it('should return html input type enum', async(() => { + cell.getHtmlInputType('Enum'); + expect(cell.htmlInputType).toBe('enum'); + })); + + it('should return html input type number', async(() => { + cell.getHtmlInputType('Int'); + expect(cell.htmlInputType).toBe('number'); + })); + + it('should return html input type boolean', async(() => { + cell.getHtmlInputType('Boolean'); + expect(cell.htmlInputType).toBe('boolean'); + })); + +}); diff --git a/src/app/components/tableComponents/date-range-cell/date-range-cell.component.spec.ts b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.spec.ts new file mode 100644 index 0000000..ce6ec4c --- /dev/null +++ b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.spec.ts @@ -0,0 +1,50 @@ +import {async, TestBed} from "@angular/core/testing"; +import {CellComponent} from "../cell/cell.component"; +import {DatePipe} from "@angular/common"; +import {DateRangeCellComponent} from "./date-range-cell.component"; + +describe('DateRangeCellComponent', () => { + let fixture, daterangecell; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [DateRangeCellComponent], + providers: [DatePipe] + }); + fixture = TestBed.createComponent(DateRangeCellComponent); + daterangecell = fixture.componentInstance; + }); + + it('should set from date value', async(() => { + let event = { + value: '2020-11-23' + }; + daterangecell.startDateChange(event); + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(daterangecell.from).toBe('2020-11-23'); + }); + })); + + it('should set to date value', async(() => { + let event = { + value: '2020-11-23' + }; + daterangecell.endDateChange(event); + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(daterangecell.to).toBe('2020-11-23'); + }); + })); + + it('should transform 23-Nov-2020 to 2020-11.23', async(() => { + + expect(daterangecell.transformDate('23-Nov-2020')).toBe('2020-11-23'); + })); + + it('should return 2020-11-23 as 23.11.2020 ', async(() => { + expect(daterangecell.toLocaleDate('2020-11-23')).toBe('23.11.2020'); + })); + + +}); diff --git a/src/app/components/tableComponents/number-range-cell/number-range-cell.component.spec.ts b/src/app/components/tableComponents/number-range-cell/number-range-cell.component.spec.ts new file mode 100644 index 0000000..0a42c72 --- /dev/null +++ b/src/app/components/tableComponents/number-range-cell/number-range-cell.component.spec.ts @@ -0,0 +1,139 @@ +import {async, TestBed} from '@angular/core/testing'; +import {DatePipe} from '@angular/common'; +import {NumberRangeCellComponent} from './number-range-cell.component'; +import {FormControl, FormGroup} from '@angular/forms'; + +describe('NumberRangeCellComponent', () => { + let fixture, cell; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [NumberRangeCellComponent], + providers: [DatePipe] + }); + + fixture = TestBed.createComponent(NumberRangeCellComponent); + cell = fixture.componentInstance; + }); + + it('should set minimum value as 0', async(() => { + cell.min = 0; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell._min).toBe(0); + }); + })); + + it('should return minimum value 0', async(() => { + cell._min = 0; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell.min).toBe(0); + }); + })); + + it('should set max value as 100', async(() => { + cell.max = 100; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell._max).toBe(100); + }); + })); + + it('should return max value 100', async(() => { + cell._max = 100; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell.max).toBe(100); + }); + })); + + it('should set editable true', async(() => { + cell.editable = true; + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell._editable).toBe(true); + }); + })); + + it('should change min value, from event with value -5, to 5', async(() => { + const targ = { + value: -5 + }; + const event = { + target: targ + }; + let rangeForm = new FormGroup({ + minValue: new FormControl(), + maxValue: new FormControl(), + }); + cell.rangeForm = rangeForm; + cell.minValueChange(event); + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell.min).toBe(5); + }); + })); + + + it('should change max value, from event with value -100, to 100', async(() => { + const targ = { + value: -100 + }; + const event = { + target: targ + }; + let rangeForm = new FormGroup({ + minValue: new FormControl(), + maxValue: new FormControl(), + }); + cell.rangeForm = rangeForm; + cell.maxValueChange(event); + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(cell.max).toBe(100); + }); + })); + + it('should set rangeError at check for invalid range of min 50 and max 10', async(() => { + let rangeForm = new FormGroup({ + minValue: new FormControl(), + maxValue: new FormControl(), + }); + cell.rangeForm = rangeForm; + cell.min = 50; + cell.max = 10; + cell.checkIfRangeIsValid(); + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(rangeForm.controls['minValue'].errors.rangeError).toBe(true); + expect(rangeForm.controls['maxValue'].errors.rangeError).toBe(true); + + }); + })); + + it('should set rangeError for parameter true', async(() => { + let rangeForm = new FormGroup({ + minValue: new FormControl(), + maxValue: new FormControl(), + }); + cell.rangeForm = rangeForm; + cell.setRangeError(true); + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(rangeForm.controls['minValue'].errors.rangeError).toBe(true); + expect(rangeForm.controls['maxValue'].errors.rangeError).toBe(true); + + }); + })); + + it('should return 5 from string -5', async(() => { + expect(cell.toPositiveNumber('-5')).toBe(5); + })); + + it('should return null from string "" ', async(() => { + expect(cell.toPositiveNumber('')).toBe(null); + })); + + +}); diff --git a/src/app/graphqlOperations/fragments/participant.graphql b/src/app/graphqlOperations/fragments/participant.graphql index 2d9fc72..d82450d 100644 --- a/src/app/graphqlOperations/fragments/participant.graphql +++ b/src/app/graphqlOperations/fragments/participant.graphql @@ -1,7 +1,9 @@ fragment ParticipantFieldsForBikePage on Participant { id - start - end + dateRange { + from + to + } usernamefLotte usernameSlack contactInformation { diff --git a/src/app/pages/dataPages/bike/bike.component.ts b/src/app/pages/dataPages/bike/bike.component.ts index a9eda96..8ed87ea 100644 --- a/src/app/pages/dataPages/bike/bike.component.ts +++ b/src/app/pages/dataPages/bike/bike.component.ts @@ -226,10 +226,14 @@ export class BikeComponent implements OnInit { dataService: null, columnInfo: [ { dataPath: 'dateRange', translation: 'Zeitraum' }, - { dataPath: 'lendingStation.name', translation: 'Standort' }, + { + dataPath: 'lendingStation.name', + translation: 'Standort', + link: (row) => '/lendingStation/' + row["lendingStation.id"], + }, ], editableReferences: false, - linkToTable: (element) => '/table/timeFrames', + linkToTable: () => '/table/timeFrames', linkToTableParams: (bike) => { return { filter: bike.name }; }, @@ -237,7 +241,7 @@ export class BikeComponent implements OnInit { ]; headlineDataPath = 'name'; - headlineIconName = 'directions_bike' + headlineIconName = 'directions_bike'; pageDataGQLType: string = 'CargoBike'; pageDataGQLUpdateInputType: string = 'CargoBikeUpdateInput'; diff --git a/src/app/pages/dataPages/lending-station/lending-station.component.ts b/src/app/pages/dataPages/lending-station/lending-station.component.ts index b689c97..3ecb516 100644 --- a/src/app/pages/dataPages/lending-station/lending-station.component.ts +++ b/src/app/pages/dataPages/lending-station/lending-station.component.ts @@ -43,7 +43,9 @@ export class LendingStationComponent implements OnInit { ' ' + contact.email + ' ' + - contact.phone + contact.phone + + ' ' + + contact.note ); }, propertyPrefixToOverwrite: 'contactInformationIntern', @@ -85,7 +87,9 @@ export class LendingStationComponent implements OnInit { ' ' + contact.email + ' ' + - contact.phone + contact.phone + + ' ' + + contact.note ); }, propertyPrefixToOverwrite: 'contactInformationExtern', @@ -115,26 +119,6 @@ export class LendingStationComponent implements OnInit { { dataPath: 'contactInformationExtern.note', translation: 'Anmerkung' }, ], }, - /* - { - type: 'ReferenceTable', - title: 'Equipment', - dataPath: 'equipment', - dataService: null, - columnInfo: [ - { dataPath: 'serialNo', translation: 'Seriennummer' }, - { dataPath: 'title', translation: 'Name' }, - { dataPath: 'description', translation: 'Beschreibung' }, - ], - nameToShowInSelection: (element) => { - return element.title + ' (' + element.serialNo + ')'; - }, - linkToTable: (element) => '/table/equipment', - linkToTableParams: (lendingStation) => { - return { filter: lendingStation.name }; - }, - propertyNameOfUpdateInput: 'equipmentIds', - }, { type: 'ReferenceTable', title: 'Zeitscheiben', @@ -142,14 +126,18 @@ export class LendingStationComponent implements OnInit { dataService: null, columnInfo: [ { dataPath: 'dateRange', translation: 'Zeitraum' }, - { dataPath: 'lendingStation.name', translation: 'Standort' }, + { + dataPath: 'cargoBike.name', + translation: 'Lastenrad', + link: (row) => '/bike/' + row['cargoBike.id'], + }, ], editableReferences: false, - linkToTable: (element) => '/table/timeFrames', + linkToTable: () => '/table/timeFrames', linkToTableParams: (lendingStation) => { return { filter: lendingStation.name }; }, - },*/ + }, ]; headlineDataPath = 'name'; @@ -163,9 +151,6 @@ export class LendingStationComponent implements OnInit { private lendingStationsService: LendingStationsService, private contactInformationService: ContactInformationService ) { - /*this.propertiesInfo.find( - (prop) => prop.dataPath === 'equipmentType' - ).dataService = this.equipmentTypeService;*/ this.contactInformationService.loadTableData(); this.contactInformationService.tableData.subscribe((data) => { this.propertiesInfo.find( diff --git a/src/app/pages/login/login.component.html b/src/app/pages/login/login.component.html index 29f2c04..8487c7b 100644 --- a/src/app/pages/login/login.component.html +++ b/src/app/pages/login/login.component.html @@ -1,41 +1,46 @@ -