diff --git a/src/app/components/data-page/data-page.component.html b/src/app/components/data-page/data-page.component.html index 00a4921..867f760 100644 --- a/src/app/components/data-page/data-page.component.html +++ b/src/app/components/data-page/data-page.component.html @@ -60,6 +60,7 @@ [editable]="data.isLockedByMe" [tableDataGQLType]="object.tableDataGQLType" (referenceIds)="addReferenceIdsToObject($event, object)" + [editableReferences]="object.editableReferences" > diff --git a/src/app/components/data-page/data-page.component.scss b/src/app/components/data-page/data-page.component.scss index 6083b22..a4e4b8a 100644 --- a/src/app/components/data-page/data-page.component.scss +++ b/src/app/components/data-page/data-page.component.scss @@ -7,24 +7,25 @@ overflow: auto; padding: 2em; .inline-card { - display: inline-table; - min-width: 20em; - margin: 1em; + display: inline-table; + min-width: 20em; + margin: 1em; } } #floating-fab-button-box { - position: absolute; - bottom: 2em; - right: 2em; - display: flex; - flex-direction: column; - align-items: center; - .floating-fab-button { - margin-top: 0.5em; - } - } - .floating-fab-button-top { - position: absolute; - top: 2em; - right: 2em; + z-index: 999; + position: absolute; + bottom: 2em; + right: 2em; + display: flex; + flex-direction: column; + align-items: center; + .floating-fab-button { + margin-top: 0.5em; } +} +.floating-fab-button-top { + position: absolute; + top: 2em; + right: 2em; +} diff --git a/src/app/components/reference-table/reference-table.component.html b/src/app/components/reference-table/reference-table.component.html index 41f774a..9ef7177 100644 --- a/src/app/components/reference-table/reference-table.component.html +++ b/src/app/components/reference-table/reference-table.component.html @@ -1,6 +1,6 @@
-
+ {{ nameToShowInSelection(element) }} @@ -62,12 +66,21 @@ - + + + + {{ element[column.dataPath] }} {{ element[column.dataPath] }} - + diff --git a/src/app/components/reference-table/reference-table.component.ts b/src/app/components/reference-table/reference-table.component.ts index ae2661b..046cc0a 100644 --- a/src/app/components/reference-table/reference-table.component.ts +++ b/src/app/components/reference-table/reference-table.component.ts @@ -47,9 +47,24 @@ export class ReferenceTableComponent { } _editable: boolean = false; + @Input() + set editableReferences(value: boolean) { + if (value === false) { + this._editableReferences = false; + } else { + this._editableReferences = true; + } + } + get editableReferences(): boolean { + return this._editableReferences; + } + _editableReferences: boolean = true; + @Input() set data(newdata) { - if (!newdata) { return; } + if (!newdata) { + return; + } this.dataSource.data = []; for (const element of newdata) { this.dataSource.data.push(flatten(element)); @@ -90,8 +105,9 @@ export class ReferenceTableComponent { this.columnInfo.forEach((column) => { this.displayedColumns.push(column.dataPath); }); - this.displayedColumns.push('buttons'); - + if (this.editableReferences) { + this.displayedColumns.push('buttons'); + } this.addForm .get('addGroup') .valueChanges.subscribe(() => this.filterPossibleValueOptions()); @@ -111,17 +127,20 @@ export class ReferenceTableComponent { } return item[columnName]; }; - - this.dataServiceThatProvidesThePossibleData.tableData.subscribe((data) => { - this.possibleValues = []; - if (data) { - for (const row of data) { - this.possibleValues.push(flatten(row)); + if (this.dataServiceThatProvidesThePossibleData) { + this.dataServiceThatProvidesThePossibleData.tableData.subscribe( + (data) => { + this.possibleValues = []; + if (data) { + for (const row of data) { + this.possibleValues.push(flatten(row)); + } + } + this.filterPossibleValueOptions(); } - } - this.filterPossibleValueOptions(); - }); - this.dataServiceThatProvidesThePossibleData.loadTableData(); + ); + this.dataServiceThatProvidesThePossibleData.loadTableData(); + } } addColumnPropertiesFromGQLSchemaToColumnInfo() { @@ -145,7 +164,9 @@ export class ReferenceTableComponent { const index = this.dataSource.data.findIndex( (element) => element.id === row.id ); - if (index === -1) { return; } + if (index === -1) { + return; + } this.dataSource.data.splice(index, 1); this.dataSource.data = this.dataSource.data; //needed to trigger update lol this.filterPossibleValueOptions(); diff --git a/src/app/components/table/table.component.html b/src/app/components/table/table.component.html index d407d1a..2718e37 100644 --- a/src/app/components/table/table.component.html +++ b/src/app/components/table/table.component.html @@ -169,6 +169,20 @@ [(max)]="element[column.dataPath + '.max']" > + + + diff --git a/src/app/components/table/table.component.ts b/src/app/components/table/table.component.ts index e2aa4ca..f1f4c52 100644 --- a/src/app/components/table/table.component.ts +++ b/src/app/components/table/table.component.ts @@ -211,6 +211,7 @@ export class TableComponent implements AfterViewInit { ? column.acceptedForCreation : typeInformation.isPartOfType; } + console.log(this.columnInfo); } getTranslation(dataPath: string) { diff --git a/src/app/components/tableComponents/cell/cell.component.html b/src/app/components/tableComponents/cell/cell.component.html index 4664825..f0b6ccc 100644 --- a/src/app/components/tableComponents/cell/cell.component.html +++ b/src/app/components/tableComponents/cell/cell.component.html @@ -30,31 +30,6 @@
- - - Zeitraum auswählen - - - - - - - - -
{ if (this.editable && this.required && this.inputType !== 'Boolean') { diff --git a/src/app/components/tableComponents/date-range-cell/date-range-cell.component.html b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.html index a1b96fb..0e27bdc 100644 --- a/src/app/components/tableComponents/date-range-cell/date-range-cell.component.html +++ b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.html @@ -1 +1,25 @@ -

date-range-cell works!

+ + {{label}} + + + + + + + + +
{{toLocaleDate(from)}} bis {{toLocaleDate(to)}}
+
diff --git a/src/app/components/tableComponents/date-range-cell/date-range-cell.component.scss b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.scss index e69de29..dbc6e25 100644 --- a/src/app/components/tableComponents/date-range-cell/date-range-cell.component.scss +++ b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.scss @@ -0,0 +1,6 @@ +.date-range-input { + min-width: 11em; +} +.date-string { + min-width: 10em; +} \ No newline at end of file diff --git a/src/app/components/tableComponents/date-range-cell/date-range-cell.component.ts b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.ts index 82be446..90c46ba 100644 --- a/src/app/components/tableComponents/date-range-cell/date-range-cell.component.ts +++ b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.ts @@ -1,4 +1,13 @@ -import { Component, OnInit } from '@angular/core'; +import { DatePipe } from '@angular/common'; +import { + Component, + Input, + Output, + EventEmitter, + ChangeDetectorRef, + OnInit, +} from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; @Component({ selector: 'app-date-range-cell', @@ -6,10 +15,49 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./date-range-cell.component.scss'] }) export class DateRangeCellComponent implements OnInit { + @Input() + from: string; - constructor() { } + @Input() + to: string; - ngOnInit(): void { + @Output() fromChange = new EventEmitter(); + @Output() toChange = new EventEmitter(); + + @Input() + editable = false; + + @Input() + required = false; + @Input() + label: string = null; + @Output() validityChange = new EventEmitter(); + isValid = true; + + constructor(private cdr: ChangeDetectorRef, public datepipe: DatePipe) {} + + ngOnInit() { + } + + startDateChange(event): void { + this.from = this.transformDate(event.value); + this.fromChange.emit(this.from); + } + + endDateChange(event) { + this.to = this.transformDate(event.value); + this.toChange.emit(this.to); + } + + transformDate(date) { + return this.datepipe.transform(date, 'yyyy-MM-dd'); + } + + toLocaleDate(date: string): string { + if (date == "") { + return ""; + } + return new Date(date).toLocaleDateString(); } } diff --git a/src/app/pages/dataPages/bike/bike.component.ts b/src/app/pages/dataPages/bike/bike.component.ts index 946f70b..4c64042 100644 --- a/src/app/pages/dataPages/bike/bike.component.ts +++ b/src/app/pages/dataPages/bike/bike.component.ts @@ -219,6 +219,21 @@ export class BikeComponent implements OnInit { }, propertyNameOfUpdateInput: 'equipmentIds', }, + { + type: 'ReferenceTable', + title: 'Zeitscheiben', + dataPath: 'timeFrames', + dataService: null, + columnInfo: [ + { dataPath: 'dateRange', translation: 'Zeitraum' }, + { dataPath: 'lendingStation.name', translation: 'Standort' }, + ], + editableReferences: false, + linkToTable: (element) => '/table/timeFrames', + linkToTableParams: (bike) => { + return { filter: bike.name }; + }, + }, ]; headlineDataPath = 'name'; diff --git a/src/app/pages/tables/time-frames/time-frames.component.ts b/src/app/pages/tables/time-frames/time-frames.component.ts index 0d305db..c870aab 100644 --- a/src/app/pages/tables/time-frames/time-frames.component.ts +++ b/src/app/pages/tables/time-frames/time-frames.component.ts @@ -9,7 +9,7 @@ export class TimeFramesComponent implements OnInit { headline = 'Zeitscheiben'; columnInfo = [ - { dataPath: 'dataRange', translation: 'Zeitraum', type: 'DateRange', readonly: false }, + { dataPath: 'dateRange', translation: 'Zeitraum', type: 'DateRange', readonly: false }, { dataPath: 'cargoBike.name', translation: 'Lastenrad', @@ -19,7 +19,7 @@ export class TimeFramesComponent implements OnInit { }, { dataPath: 'lendingStation.name', - translation: 'Ausleihstation', + translation: 'Standort', link: (element) => { return '/lendingStation/' + element['lendingStation.id']; },