diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 1312681..1df2a75 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -16,9 +16,10 @@ import { ProfileComponent } from './pages/profile/profile.component';
import { PersonsComponent } from './pages/tables/persons/persons.component';
import { ContactInformationComponent } from './pages/tables/contact-information/contact-information.component';
import { OrganisationsComponent } from './pages/tables/organisations/organisations.component';
-import { ProviderComponent } from './pages/tables/provider/provider.component';
+import { ProvidersComponent } from './pages/tables/providers/providers.component';
import { PersonComponent } from './pages/dataPages/person/person.component';
import { OrganisationComponent } from './pages/dataPages/organisation/organisation.component';
+import { ProviderComponent } from './pages/dataPages/provider/provider.component';
const routes: Routes = [
{ path: 'login', component: LoginComponent },
@@ -35,9 +36,10 @@ const routes: Routes = [
{ path: 'table/persons', component: PersonsComponent, canActivate: [AuthGuard] },
{ path: 'table/contactInformation', component: ContactInformationComponent, canActivate: [AuthGuard] },
{ path: 'table/organisations', component: OrganisationsComponent, canActivate: [AuthGuard] },
- { path: 'table/providers', component: ProviderComponent, canActivate: [AuthGuard] },
+ { path: 'table/providers', component: ProvidersComponent, canActivate: [AuthGuard] },
{ path: 'lendingStation/:id', component: LendingStationComponent, canActivate: [AuthGuard] },
{ path: 'person/:id', component: PersonComponent, canActivate: [AuthGuard] },
+ { path: 'provider/:id', component: ProviderComponent, canActivate: [AuthGuard] },
{ path: 'organisation/:id', component: OrganisationComponent, canActivate: [AuthGuard] },
{ path: '', redirectTo: 'tableOverview', pathMatch: 'full' },
{ path: 'table', redirectTo: 'tableOverview', pathMatch: 'full' },
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index a51f0f7..38572fd 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -71,9 +71,10 @@ import { HttpLinkModule } from 'apollo-angular-link-http';
import { PersonsComponent } from './pages/tables/persons/persons.component';
import { ContactInformationComponent } from './pages/tables/contact-information/contact-information.component';
import { OrganisationsComponent } from './pages/tables/organisations/organisations.component';
-import { ProviderComponent } from './pages/tables/provider/provider.component';
+import { ProvidersComponent } from './pages/tables/providers/providers.component';
import { OrganisationComponent } from './pages/dataPages/organisation/organisation.component';
import { PersonComponent } from './pages/dataPages/person/person.component';
+import { ProviderComponent } from './pages/dataPages/provider/provider.component';
@@ -109,9 +110,10 @@ import { PersonComponent } from './pages/dataPages/person/person.component';
PersonsComponent,
ContactInformationComponent,
OrganisationsComponent,
- ProviderComponent,
+ ProvidersComponent,
OrganisationComponent,
- PersonComponent
+ PersonComponent,
+ ProviderComponent
],
imports: [
BrowserModule,
diff --git a/src/app/components/data-page/data-page.component.html b/src/app/components/data-page/data-page.component.html
index b2e8db9..ece11b1 100644
--- a/src/app/components/data-page/data-page.component.html
+++ b/src/app/components/data-page/data-page.component.html
@@ -9,11 +9,17 @@
- {{ data[headlineDataPath] }}
+ {{ getHeadline !== undefined ? getHeadline(data) : data[headlineDataPath] }}
{{ headlineIconName }}
-
+
-
+
{{ object.title }}
string;
@Input()
headlineIconName: string = 'help_outline';
@Input()
@@ -112,6 +115,9 @@ export class DataPageComponent implements OnInit, OnDestroy {
addPropertiesFromGQLSchemaToObject(infoObject: any) {
for (const prop of infoObject) {
+ if (prop.type === 'Link') {
+ continue;
+ }
if (prop.type === 'Group') {
this.addPropertiesFromGQLSchemaToObject(prop.properties);
} else if (prop.type === 'ReferenceTable') {
diff --git a/src/app/components/table/table.component.ts b/src/app/components/table/table.component.ts
index e11d938..630bcba 100644
--- a/src/app/components/table/table.component.ts
+++ b/src/app/components/table/table.component.ts
@@ -102,6 +102,7 @@ export class TableComponent implements AfterViewInit {
ngAfterViewInit(): void {
this.addColumnPropertiesFromGQLSchemaToColumnInfo();
+ console.log(this.columnInfo)
this.data.paginator = this.paginator;
this.data.sortingDataAccessor = (item, columnName) => {
if (typeof item[columnName] === 'string') {
diff --git a/src/app/graphqlOperations/fragments/organisation.graphql b/src/app/graphqlOperations/fragments/organisation.graphql
index 506aabd..23e4bdc 100644
--- a/src/app/graphqlOperations/fragments/organisation.graphql
+++ b/src/app/graphqlOperations/fragments/organisation.graphql
@@ -26,7 +26,7 @@ fragment OrganisationFieldsForPage on Organisation {
name
}
provider {
- ...ProviderFieldsGeneral
+ ...ProviderFieldsForPage
}
}
diff --git a/src/app/graphqlOperations/provider.graphql b/src/app/graphqlOperations/provider.graphql
new file mode 100644
index 0000000..e528d46
--- /dev/null
+++ b/src/app/graphqlOperations/provider.graphql
@@ -0,0 +1,45 @@
+query GetProviders {
+ providers {
+ ...ProviderFieldsForTable
+ }
+}
+
+query GetProviderById($id: ID!) {
+ providerById(id: $id) {
+ ...ProviderFieldsForPage
+ }
+}
+
+query ReloadProviderById($id: ID!) {
+ providerById(id: $id) {
+ ...ProviderFieldsForTable
+ }
+}
+
+mutation CreateProvider($provider: ProviderCreateInput!) {
+ createProvider(provider: $provider) {
+ ...ProviderFieldsForTable
+ }
+}
+
+mutation UpdateProvider($provider: ProviderUpdateInput!) {
+ updateProvider(provider: $provider) {
+ ...ProviderFieldsForPage
+ }
+}
+
+mutation LockProvider($id: ID!) {
+ lockProvider(id: $id) {
+ ...ProviderFieldsForPage
+ }
+}
+
+mutation UnlockProvider($id: ID!) {
+ unlockProvider(id: $id) {
+ ...ProviderFieldsForPage
+ }
+}
+
+mutation DeleteProvider($id: ID!) {
+ deleteProvider(id: $id)
+}
diff --git a/src/app/pages/dataPages/bike/bike.component.ts b/src/app/pages/dataPages/bike/bike.component.ts
index 3092149..fda143e 100644
--- a/src/app/pages/dataPages/bike/bike.component.ts
+++ b/src/app/pages/dataPages/bike/bike.component.ts
@@ -155,26 +155,62 @@ export class BikeComponent implements OnInit {
},
{
type: 'Group',
- title: 'provider',
+ title: 'Anbieter (Person)',
+ hideCondition: (data) => data['provider.privatePerson.person.id'] == null,
properties: [
- { dataPath: 'provider.id', translation: '' },
- { dataPath: 'provider.formName', translation: '' },
- { dataPath: 'provider.privatePerson.id', translation: '' },
- { dataPath: 'provider.privatePerson.person.id', translation: '' },
- { dataPath: 'provider.privatePerson.person.name', translation: '' },
+ {
+ type: 'Link',
+ linkText: 'Zum Anbieter',
+ link: (data) => {
+ return '/provider/' + data['provider.id'];
+ },
+ },
+ { dataPath: 'provider.formName', translation: 'Formular Name' },
{
dataPath: 'provider.privatePerson.person.firstName',
- translation: '',
+ translation: 'Vorname',
+ },
+ { dataPath: 'provider.privatePerson.person.name', translation: 'Nachname' },
+ {
+ dataPath: 'provider.privatePerson.email',
+ translation: 'Email',
+ },
+ {
+ dataPath: 'provider.privatePerson.phone',
+ translation: 'Telefonnummer',
+ },
+ ],
+ },
+ {
+ type: 'Group',
+ title: 'Anbieter (Unternehmen)',
+ hideCondition: (data) => data['provider.organisation.id'] == null,
+ properties: [
+ {
+ type: 'Link',
+ linkText: 'Zum Anbieter',
+ link: (data) => {
+ return '/provider/' + data['provider.id'];
+ },
+ },
+ { dataPath: 'provider.organisation.name', translation: 'Name' },
+ {
+ dataPath: 'provider.organisation.address.street',
+ translation: 'Straße',
+ },
+ {
+ dataPath: 'provider.organisation.address.number',
+ translation: 'Hausnummer',
},
{
- dataPath: 'provider.privatePerson.person.contactInformation.email',
- translation: '',
+ dataPath: 'provider.organisation.address.zip',
+ translation: 'Postleitzahl',
},
],
},
{
type: 'Group',
- title: 'lendingstation',
+ title: 'Standort',
properties: [
{ dataPath: 'lendingStation.id', translation: '' },
{ dataPath: 'lendingStation.name', translation: '' },
@@ -211,7 +247,15 @@ export class BikeComponent implements OnInit {
{ dataPath: 'description', translation: 'Beschreibung' },
],
nameToShowInSelection: (element) => {
- return element.title + ' (' + element.serialNo + ')' + (element.cargoBike ? " [aktuell Teil von "+element.cargoBike.name+']' : '');
+ return (
+ element.title +
+ ' (' +
+ element.serialNo +
+ ')' +
+ (element.cargoBike
+ ? ' [aktuell Teil von ' + element.cargoBike.name + ']'
+ : '')
+ );
},
linkToTable: (element) => '/table/equipment',
linkToTableParams: (bike) => {
@@ -229,7 +273,7 @@ export class BikeComponent implements OnInit {
{
dataPath: 'lendingStation.name',
translation: 'Standort',
- link: (row) => '/lendingStation/' + row["lendingStation.id"],
+ link: (row) => '/lendingStation/' + row['lendingStation.id'],
},
],
editableReferences: false,
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 de92414..37d1ed2 100644
--- a/src/app/pages/dataPages/lending-station/lending-station.component.ts
+++ b/src/app/pages/dataPages/lending-station/lending-station.component.ts
@@ -43,11 +43,15 @@ export class LendingStationComponent implements OnInit {
type: 'Group',
title: 'Organisation',
properties: [
- { dataPath: 'organisation.name', translation: 'Name', link: (data)=> "/organisation/" + data["organisation.id"] },
- { dataPath: 'organisation.address.street', translation: 'Straße'},
- { dataPath: 'organisation.address.number', translation: 'Hausnummer'},
- { dataPath: 'organisation.address.zip', translation: 'Postleitzahl'},
- { dataPath: 'organisation.associationNo', translation: 'Nummer'},
+ {
+ dataPath: 'organisation.name',
+ translation: 'Name',
+ link: (data) => '/organisation/' + data['organisation.id'],
+ },
+ { dataPath: 'organisation.address.street', translation: 'Straße' },
+ { dataPath: 'organisation.address.number', translation: 'Hausnummer' },
+ { dataPath: 'organisation.address.zip', translation: 'Postleitzahl' },
+ { dataPath: 'organisation.associationNo', translation: 'Nummer' },
],
},
{
@@ -56,15 +60,15 @@ export class LendingStationComponent implements OnInit {
possibleObjects: [],
nameToShowInSelection: (contact) => {
return (
- contact.person.firstName +
+ (contact.person.firstName || '') +
' ' +
- contact.person.name +
+ (contact.person.name || '') +
' ' +
- contact.email +
+ (contact.email || '') +
' ' +
- contact.phone +
+ (contact.phone || '') +
' ' +
- contact.note
+ (contact.note || '')
);
},
propertyPrefixToOverwrite: 'contactInformationIntern',
@@ -100,15 +104,15 @@ export class LendingStationComponent implements OnInit {
possibleObjects: [],
nameToShowInSelection: (contact) => {
return (
- contact.person.firstName +
+ (contact.person.firstName || '') +
' ' +
- contact.person.name +
+ (contact.person.name || '') +
' ' +
- contact.email +
+ (contact.email || '') +
' ' +
- contact.phone +
+ (contact.phone || '') +
' ' +
- contact.note
+ (contact.note || '')
);
},
propertyPrefixToOverwrite: 'contactInformationExtern',
diff --git a/src/app/pages/dataPages/organisation/organisation.component.ts b/src/app/pages/dataPages/organisation/organisation.component.ts
index 110305a..db2751a 100644
--- a/src/app/pages/dataPages/organisation/organisation.component.ts
+++ b/src/app/pages/dataPages/organisation/organisation.component.ts
@@ -14,8 +14,8 @@ export class OrganisationComponent implements OnInit {
title: 'Allgemein',
properties: [
{ dataPath: 'name', translation: 'Name' },
- { dataPath: 'address.number', translation: 'Hausnummer' },
{ dataPath: 'address.street', translation: 'Straße' },
+ { dataPath: 'address.number', translation: 'Hausnummer' },
{ dataPath: 'address.zip', translation: 'Postleitzahl' },
{ dataPath: 'associationNo', translation: 'Vereinsnummer' },
@@ -66,8 +66,24 @@ export class OrganisationComponent implements OnInit {
{ dataPath: 'contactInformation.note', translation: 'Anmerkung' },
],
},
+ {
+ type: 'Group',
+ title: 'Anbieterinformationen',
+ hideCondition: (data) => data.provider === null,
+ properties: [
+ { dataPath: 'provider.formName', translation: 'Formularname' },
+ {
+ type: 'Link',
+ linkText: "Zur Anbieterseite",
+ link: (data) => {
+ return '/provider/' + data['provider.id'];
+ },
+ },
+ ],
+ },
{
type: 'ReferenceTable',
+ hideCondition: (data) => data.provider === null,
title: 'Bereitgestellte Lastenräder',
dataPath: 'provider.cargoBikes',
dataService: null,
@@ -75,31 +91,16 @@ export class OrganisationComponent implements OnInit {
{
dataPath: 'name',
translation: 'Lastenrad',
- link: (row) => '/bike/' + row['cargoBike.id'],
+ link: (row) => '/bike/' + row['id'],
},
],
editableReferences: false,
linkToTable: () => '/table/provider',
},
- /*{
- type: 'ReferenceTable',
- title: 'Fahrräder',
- dataPath: 'contactInformation',
- dataService: null,
- columnInfo: [
- { dataPath: 'email', translation: 'Email' },
- { dataPath: 'email2', translation: 'Email 2' },
- { dataPath: 'phone', translation: 'Telefonnummer' },
- { dataPath: 'phone2', translation: 'Telefonnummer 2' },
- { dataPath: 'note', translation: 'Anmerkung' },
- ],
- editableReferences: false,
- linkToTable: () => '/table/contactInformation',
- },*/
];
headlineDataPath = 'name';
- headlineIconName = 'organisation';
+ headlineIconName = 'business';
pageDataGQLType: string = 'Organisation';
pageDataGQLUpdateInputType: string = 'OrganisationUpdateInput';
diff --git a/src/app/pages/dataPages/provider/provider.component.html b/src/app/pages/dataPages/provider/provider.component.html
index 019430e..1e776e2 100644
--- a/src/app/pages/dataPages/provider/provider.component.html
+++ b/src/app/pages/dataPages/provider/provider.component.html
@@ -1 +1,12 @@
-provider works!
+
diff --git a/src/app/pages/dataPages/provider/provider.component.spec.ts b/src/app/pages/dataPages/provider/provider.component.spec.ts
deleted file mode 100644
index 22d4d9b..0000000
--- a/src/app/pages/dataPages/provider/provider.component.spec.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
-import { ProviderComponent } from './provider.component';
-
-describe('ProviderComponent', () => {
- let component: ProviderComponent;
- let fixture: ComponentFixture;
-
- beforeEach(async(() => {
- TestBed.configureTestingModule({
- declarations: [ ProviderComponent ]
- })
- .compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(ProviderComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-});
diff --git a/src/app/pages/dataPages/provider/provider.component.ts b/src/app/pages/dataPages/provider/provider.component.ts
index 357945e..c9ef758 100644
--- a/src/app/pages/dataPages/provider/provider.component.ts
+++ b/src/app/pages/dataPages/provider/provider.component.ts
@@ -1,15 +1,123 @@
import { Component, OnInit } from '@angular/core';
+import { bindNodeCallback } from 'rxjs';
+import { BikesService } from 'src/app/services/bikes.service';
+import { OrganisationsService } from 'src/app/services/organisation.service';
+import { PersonsService } from 'src/app/services/person.service';
+import { ProvidersService } from 'src/app/services/provider.service';
@Component({
selector: 'app-provider',
templateUrl: './provider.component.html',
- styleUrls: ['./provider.component.scss']
+ styleUrls: ['./provider.component.scss'],
})
export class ProviderComponent implements OnInit {
+ propertiesInfo = [
+ {
+ type: 'Group',
+ title: 'Allgemein',
+ hideCondition: (data) => data.privatePerson === null,
+ properties: [
+ {
+ type: 'Link',
+ linkText: "Zur Person",
+ link: (data) => {
+ return '/person/' + data['privatePerson.person.id'];
+ },
+ },
+ { dataPath: 'privatePerson.person.firstName', translation: 'Vorname' },
+ {
+ dataPath: 'privatePerson.person.name',
+ translation: 'Nachname',
+ },
+ {
+ dataPath: 'privatePerson.phone',
+ translation: 'Telefonnummer',
+ },
+ {
+ dataPath: 'privatePerson.phone2',
+ translation: 'Telefonnummer 2',
+ },
+ { dataPath: 'privatePerson.email', translation: 'Email' },
+ { dataPath: 'privatePerson.email2', translation: 'Email 2' },
+ { dataPath: 'privatePerson.note', translation: 'Anmerkung' },
+ ],
+ },
+ {
+ type: 'Group',
+ title: 'Allgemein',
+ hideCondition: (data) => data.organisation === null,
+ properties: [
+ {
+ type: 'Link',
+ linkText: "Zum Unternehmen",
+ link: (data) => {
+ return '/organisation/' + data['organisation.id'];
+ },
+ },
+ { dataPath: 'organisation.name', translation: 'Name' },
+ { dataPath: 'organisation.address.street', translation: 'Straße' },
+ { dataPath: 'organisation.address.number', translation: 'Hausnummer' },
+ { dataPath: 'organisation.address.zip', translation: 'Postleitzahl' },
+ ],
+ },
+ {
+ type: 'ReferenceTable',
+ title: 'Bereitgestellte Lastenräder',
+ dataPath: 'cargoBikes',
+ dataService: null,
+ columnInfo: [
+ {
+ dataPath: 'name',
+ translation: 'Name',
+ link: (row) => '/bike/' + row.id,
+ },
+ ],
+ nameToShowInSelection: (bike) => {
+ return bike.name;
+ },
+ linkToTable: (element) => '/table/bikes',
+ propertyNameOfUpdateInput: 'cargoBikeIds',
+ },
+ ];
- constructor() { }
+ getHeadline = (pageData) => {
+ return (
+ (pageData['privatePerson.person.firstName']
+ ? pageData['privatePerson.person.firstName'] +
+ ' ' +
+ pageData['privatePerson.person.name']
+ : pageData['organisation.name']) + ' (Anbieter)'
+ );
+ };
+ headlineDataPath = '';
+ headlineIconName = 'person';
+ pageDataGQLType: string = 'Provider';
+ pageDataGQLUpdateInputType: string = 'ProviderUpdateInput';
+
+ dataService: any;
+
+ constructor(
+ private providersService: ProvidersService,
+ private bikesService: BikesService
+ ) {
+ this.propertiesInfo.find(
+ (prop) => prop.dataPath === 'cargoBikes'
+ ).dataService = this.bikesService;
+ }
ngOnInit(): void {
+ this.dataService = this.providersService;
+ }
+
+ lock(row: any) {
+ this.providersService.lockProvider({ id: row.id });
+ }
+
+ save(row: any) {
+ this.providersService.updateProvider({ provider: row });
}
+ cancel(row: any) {
+ this.providersService.unlockProvider({ id: row.id });
+ }
}
diff --git a/src/app/pages/table-overview/table-overview.component.html b/src/app/pages/table-overview/table-overview.component.html
index e47b38d..50d5bca 100644
--- a/src/app/pages/table-overview/table-overview.component.html
+++ b/src/app/pages/table-overview/table-overview.component.html
@@ -14,7 +14,7 @@
Zeitscheiben
Unternehmen
Kontaktinformation
- Tabelle 11
+ Anbieter
Tabelle 12
Tabelle 13
Tabelle 14
diff --git a/src/app/pages/tables/provider/provider.component.html b/src/app/pages/tables/provider/provider.component.html
deleted file mode 100644
index 019430e..0000000
--- a/src/app/pages/tables/provider/provider.component.html
+++ /dev/null
@@ -1 +0,0 @@
-provider works!
diff --git a/src/app/pages/tables/provider/provider.component.spec.ts b/src/app/pages/tables/provider/provider.component.spec.ts
deleted file mode 100644
index 22d4d9b..0000000
--- a/src/app/pages/tables/provider/provider.component.spec.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
-import { ProviderComponent } from './provider.component';
-
-describe('ProviderComponent', () => {
- let component: ProviderComponent;
- let fixture: ComponentFixture;
-
- beforeEach(async(() => {
- TestBed.configureTestingModule({
- declarations: [ ProviderComponent ]
- })
- .compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(ProviderComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-});
diff --git a/src/app/pages/tables/provider/provider.component.ts b/src/app/pages/tables/provider/provider.component.ts
deleted file mode 100644
index 357945e..0000000
--- a/src/app/pages/tables/provider/provider.component.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-
-@Component({
- selector: 'app-provider',
- templateUrl: './provider.component.html',
- styleUrls: ['./provider.component.scss']
-})
-export class ProviderComponent implements OnInit {
-
- constructor() { }
-
- ngOnInit(): void {
- }
-
-}
diff --git a/src/app/pages/tables/providers/providers.component.html b/src/app/pages/tables/providers/providers.component.html
new file mode 100644
index 0000000..8c18b6a
--- /dev/null
+++ b/src/app/pages/tables/providers/providers.component.html
@@ -0,0 +1,14 @@
+
diff --git a/src/app/pages/tables/provider/provider.component.scss b/src/app/pages/tables/providers/providers.component.scss
similarity index 100%
rename from src/app/pages/tables/provider/provider.component.scss
rename to src/app/pages/tables/providers/providers.component.scss
diff --git a/src/app/pages/tables/providers/providers.component.ts b/src/app/pages/tables/providers/providers.component.ts
new file mode 100644
index 0000000..8827471
--- /dev/null
+++ b/src/app/pages/tables/providers/providers.component.ts
@@ -0,0 +1,131 @@
+import { Component, OnInit } from '@angular/core';
+import { ContactInformationService } from 'src/app/services/contactInformation.service';
+import { OrganisationsService } from 'src/app/services/organisation.service';
+import { PersonsService } from 'src/app/services/person.service';
+import { ProvidersService } from 'src/app/services/provider.service';
+
+@Component({
+ selector: 'app-providers',
+ templateUrl: './providers.component.html',
+ styleUrls: ['./providers.component.scss'],
+})
+export class ProvidersComponent implements OnInit {
+ columnInfo = [
+ {
+ dataPath: 'formName',
+ translation: 'Formular Name',
+ },
+ {
+ dataPath: 'organisation.name',
+ translation: 'Anbieter (Unternehmen)',
+ link: (row: any) => {
+ return '/provider/' + row['id'];
+ },
+ possibleObjects: [],
+ nameToShowInSelection: (o) => o.name,
+ propertyPrefixToOverwrite: 'organisation',
+ currentlySelectedObjectId: (provider) => {
+ return provider['organisation.id'];
+ },
+ propertyNameOfReferenceId: 'organisationId',
+ },
+ {
+ dataPath: 'privatePerson.person.firstName',
+ translation: 'Anbieter (Person) Vorname',
+ },
+ {
+ dataPath: 'privatePerson.person.name',
+ translation: 'Anbieter (Person) Nachname',
+ link: (row: any) => {
+ return '/provider/' + row['id'];
+ },
+ possibleObjects: [],
+ nameToShowInSelection: (contact) => {
+ return (
+ (contact.person.firstName || '') +
+ ' ' +
+ (contact.person.name || '') +
+ ' ' +
+ (contact.email || '') +
+ ' ' +
+ (contact.phone || '') +
+ ' ' +
+ (contact.note || '')
+ );
+ },
+ propertyPrefixToOverwrite: 'privatePerson',
+ currentlySelectedObjectId: (provider) => {
+ return provider['privatePerson.id'];
+ },
+ propertyNameOfReferenceId: 'privatePersonId',
+ },
+ {
+ dataPath: 'privatePerson.email',
+ translation: 'Anbieter (Person) Email',
+ },
+ {
+ dataPath: 'privatePerson.phone',
+ translation: 'Anbieter (Person) Telefonnummer',
+ },
+ {
+ dataPath: 'privatePerson.note',
+ translation: 'Anbieter (Person) Anmerkung',
+ },
+ ];
+
+ dataService: any;
+
+ tableDataGQLType: string = 'Provider';
+ tableDataGQLCreateInputType: string = 'ProviderCreateInput';
+ tableDataGQLUpdateInputType: string = 'ProviderUpdateInput';
+
+ headline = 'Anbieter';
+ headlineIconName = 'people';
+
+ loadingRowIds: string[] = [];
+ constructor(
+ private providersService: ProvidersService,
+ private contactInformationService: ContactInformationService,
+ private organisationsService: OrganisationsService
+ ) {
+ this.organisationsService.loadTableData();
+ this.organisationsService.tableData.subscribe((data) => {
+ this.columnInfo.find(
+ (column) => column.propertyPrefixToOverwrite === 'organisation'
+ ).possibleObjects = data;
+ });
+
+ this.contactInformationService.loadTableData();
+ this.contactInformationService.tableData.subscribe((data) => {
+ this.columnInfo.find(
+ (column) => column.propertyPrefixToOverwrite === 'privatePerson'
+ ).possibleObjects = data;
+ });
+ }
+
+ ngOnInit() {
+ this.dataService = this.providersService;
+ }
+
+ create(object: { currentId: string; row: any }) {
+ this.providersService.createProvider(object.currentId, {
+ provider: object.row,
+ });
+ }
+
+ lock(row: any) {
+ this.providersService.lockProvider({ id: row.id });
+ }
+
+ save(row: any) {
+ this.providersService.updateProvider({ provider: row });
+ }
+
+ cancel(row: any) {
+ this.providersService.unlockProvider({ id: row.id });
+ }
+
+ delete(row: any) {
+ this.providersService.deleteProvider({ id: row.id });
+ }
+}
diff --git a/src/app/services/provider.service.ts b/src/app/services/provider.service.ts
new file mode 100644
index 0000000..ad2d73b
--- /dev/null
+++ b/src/app/services/provider.service.ts
@@ -0,0 +1,160 @@
+import { Injectable } from '@angular/core';
+import { BehaviorSubject, Subject } from 'rxjs';
+import {
+ GetProvidersGQL,
+ ReloadProviderByIdGQL,
+ ReloadProviderByIdQueryVariables,
+ UpdateProviderGQL,
+ UpdateProviderMutationVariables,
+ LockProviderGQL,
+ LockProviderMutationVariables,
+ UnlockProviderGQL,
+ UnlockProviderMutationVariables,
+ CreateProviderGQL,
+ CreateProviderMutationVariables,
+ DeleteProviderGQL,
+ DeleteProviderMutationVariables,
+ GetProviderByIdGQL,
+ GetProviderByIdQueryVariables,
+} from '../../generated/graphql';
+
+@Injectable({
+ providedIn: 'root',
+})
+export class ProvidersService {
+ /** Providers Array */
+ tableData: BehaviorSubject = new BehaviorSubject(null);
+ loadingRowIds: BehaviorSubject = new BehaviorSubject([]);
+ successfullyCreatedRowWithId: Subject = new Subject();
+ pageData: BehaviorSubject = new BehaviorSubject(null);
+ isLoadingPageData: BehaviorSubject = new BehaviorSubject(false);
+
+ constructor(
+ private getProvidersGQL: GetProvidersGQL,
+ private getProviderByIdGQL: GetProviderByIdGQL,
+ private reloadProviderByIdGQL: ReloadProviderByIdGQL,
+ private updateProviderGQL: UpdateProviderGQL,
+ private lockProviderGQL: LockProviderGQL,
+ private unlockProviderGQL: UnlockProviderGQL,
+ private createProviderGQL: CreateProviderGQL,
+ private deleteProviderGQL: DeleteProviderGQL
+ ) {}
+
+ addLoadingRowId(id: string) {
+ this.loadingRowIds.next([...this.loadingRowIds.value, id]);
+ }
+
+ removeLoadingRowId(id: string) {
+ this.loadingRowIds.value.forEach((item, index) => {
+ if (item === id) {
+ this.loadingRowIds.value.splice(index, 1);
+ }
+ });
+ this.loadingRowIds.next(this.loadingRowIds.value);
+ }
+
+ loadTableData() {
+ this.tableData.next(null);
+ this.getProvidersGQL.fetch().subscribe((result) => {
+ this.tableData.next(result.data?.providers);
+ });
+ }
+
+ loadPageData(variables: GetProviderByIdQueryVariables) {
+ this.pageData.next(null);
+ this.isLoadingPageData.next(true);
+ this.getProviderByIdGQL
+ .fetch(variables)
+ .subscribe((result) => {
+ this.pageData.next(result.data.providerById);
+ })
+ .add(() => {
+ this.isLoadingPageData.next(false);
+ });
+ }
+
+ reloadProvider(variables: ReloadProviderByIdQueryVariables) {
+ this.addLoadingRowId(variables.id);
+ this.reloadProviderByIdGQL
+ .fetch(variables)
+ .subscribe((result) => {
+ this.updateDataRowFromResponse(result.data.providerById);
+ })
+ .add(() => {
+ this.removeLoadingRowId(variables.id);
+ });
+ }
+
+ createProvider(currentId: string, variables: CreateProviderMutationVariables) {
+ this.createProviderGQL.mutate(variables).subscribe((result) => {
+ const newProvider = result.data.createProvider;
+ this.tableData.next([newProvider, ...this.tableData.value]);
+ this.successfullyCreatedRowWithId.next(currentId);
+ });
+ }
+
+ updateProvider(variables: UpdateProviderMutationVariables) {
+ this.addLoadingRowId(variables.provider.id);
+ this.updateProviderGQL
+ .mutate(variables)
+ .subscribe((result) => {
+ this.updateDataRowFromResponse(result.data.updateProvider);
+ })
+ .add(() => {
+ this.removeLoadingRowId(variables.provider.id);
+ });
+ }
+
+ lockProvider(variables: LockProviderMutationVariables) {
+ this.addLoadingRowId(variables.id);
+ this.lockProviderGQL
+ .mutate(variables)
+ .subscribe((result) => {
+ this.updateDataRowFromResponse(result.data.lockProvider);
+ })
+ .add(() => {
+ this.removeLoadingRowId(variables.id);
+ });
+ }
+
+ unlockProvider(variables: UnlockProviderMutationVariables) {
+ this.addLoadingRowId(variables.id);
+ this.unlockProviderGQL
+ .mutate(variables)
+ .subscribe((result) => {
+ this.updateDataRowFromResponse(result.data.unlockProvider);
+ })
+ .add(() => {
+ this.removeLoadingRowId(variables.id);
+ });
+ }
+
+ deleteProvider(variables: DeleteProviderMutationVariables) {
+ this.addLoadingRowId(variables.id);
+ this.deleteProviderGQL
+ .mutate(variables)
+ .subscribe((result) => {
+ if (result.data) {
+ this.tableData.next(
+ [...this.tableData.value].filter((provider) => provider.id !== variables.id)
+ );
+ }
+ })
+ .add(() => {
+ this.removeLoadingRowId(variables.id);
+ });
+ }
+
+ private updateDataRowFromResponse(rowFromResponse: any) {
+ if (this.tableData.value) {
+ const newTableData = this.tableData.value.map((row) =>
+ rowFromResponse.id === row.id ? rowFromResponse : row
+ );
+ this.tableData.next(newTableData);
+ }
+ if (rowFromResponse.id === this.pageData?.value?.id) {
+ this.pageData.next(rowFromResponse);
+ }
+ }
+}
+
diff --git a/src/generated/graphql.schema.json b/src/generated/graphql.schema.json
index d09e75b..66de80a 100644
--- a/src/generated/graphql.schema.json
+++ b/src/generated/graphql.schema.json
@@ -5183,13 +5183,9 @@
"name": "formName",
"description": null,
"type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- }
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
},
"defaultValue": null
},
@@ -5990,18 +5986,6 @@
"isDeprecated": false,
"deprecationReason": null
},
- {
- "name": "otherData",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
{
"name": "isLocked",
"description": null,
@@ -6102,13 +6086,9 @@
"name": "associationNo",
"description": "registration number of association",
"type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- }
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
},
"defaultValue": null
},
@@ -6131,16 +6111,6 @@
"ofType": null
},
"defaultValue": null
- },
- {
- "name": "otherData",
- "description": null,
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "defaultValue": null
}
],
"interfaces": null,
@@ -6217,16 +6187,6 @@
},
"defaultValue": null
},
- {
- "name": "otherData",
- "description": null,
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "defaultValue": null
- },
{
"name": "keepLock",
"description": null,
diff --git a/src/generated/graphql.ts b/src/generated/graphql.ts
index a569b84..23e244b 100644
--- a/src/generated/graphql.ts
+++ b/src/generated/graphql.ts
@@ -736,7 +736,7 @@ export type Provider = {
/** (dt. Anbieter) */
export type ProviderCreateInput = {
- formName: Scalars['String'];
+ formName?: Maybe;
privatePersonId?: Maybe;
organisationId?: Maybe;
cargoBikeIds?: Maybe>;
@@ -830,7 +830,6 @@ export type Organisation = {
registeredAt?: Maybe;
provider?: Maybe;
contactInformation?: Maybe;
- otherData?: Maybe;
isLocked: Scalars['Boolean'];
isLockedByMe: Scalars['Boolean'];
/** null if not locked by other user */
@@ -842,11 +841,10 @@ export type OrganisationCreateInput = {
address: AddressCreateInput;
name: Scalars['String'];
/** registration number of association */
- associationNo: Scalars['String'];
+ associationNo?: Maybe;
/** If Club, at what court registered */
registeredAt?: Maybe;
contactInformationId?: Maybe;
- otherData?: Maybe;
};
export type OrganisationUpdateInput = {
@@ -858,7 +856,6 @@ export type OrganisationUpdateInput = {
/** If Club, at what court registered */
registeredAt?: Maybe;
contactInformationId?: Maybe;
- otherData?: Maybe;
keepLock?: Maybe;
};
@@ -2123,7 +2120,7 @@ export type OrganisationFieldsForTableFragment = (
export type OrganisationFieldsForPageFragment = (
{ __typename?: 'Organisation', lendingStations?: Maybe>, provider?: Maybe<(
{ __typename?: 'Provider' }
- & ProviderFieldsGeneralFragment
+ & ProviderFieldsForPageFragment
)> }
& OrganisationFieldsForTableFragment
);
@@ -2397,6 +2394,81 @@ export type DeletePersonMutationVariables = Exact<{
export type DeletePersonMutation = { __typename?: 'Mutation', deletePerson: boolean };
+export type GetProvidersQueryVariables = Exact<{ [key: string]: never; }>;
+
+
+export type GetProvidersQuery = { __typename?: 'Query', providers: Array<(
+ { __typename?: 'Provider' }
+ & ProviderFieldsForTableFragment
+ )> };
+
+export type GetProviderByIdQueryVariables = Exact<{
+ id: Scalars['ID'];
+}>;
+
+
+export type GetProviderByIdQuery = { __typename?: 'Query', providerById?: Maybe<(
+ { __typename?: 'Provider' }
+ & ProviderFieldsForPageFragment
+ )> };
+
+export type ReloadProviderByIdQueryVariables = Exact<{
+ id: Scalars['ID'];
+}>;
+
+
+export type ReloadProviderByIdQuery = { __typename?: 'Query', providerById?: Maybe<(
+ { __typename?: 'Provider' }
+ & ProviderFieldsForTableFragment
+ )> };
+
+export type CreateProviderMutationVariables = Exact<{
+ provider: ProviderCreateInput;
+}>;
+
+
+export type CreateProviderMutation = { __typename?: 'Mutation', createProvider: (
+ { __typename?: 'Provider' }
+ & ProviderFieldsForTableFragment
+ ) };
+
+export type UpdateProviderMutationVariables = Exact<{
+ provider: ProviderUpdateInput;
+}>;
+
+
+export type UpdateProviderMutation = { __typename?: 'Mutation', updateProvider: (
+ { __typename?: 'Provider' }
+ & ProviderFieldsForPageFragment
+ ) };
+
+export type LockProviderMutationVariables = Exact<{
+ id: Scalars['ID'];
+}>;
+
+
+export type LockProviderMutation = { __typename?: 'Mutation', lockProvider: (
+ { __typename?: 'Provider' }
+ & ProviderFieldsForPageFragment
+ ) };
+
+export type UnlockProviderMutationVariables = Exact<{
+ id: Scalars['ID'];
+}>;
+
+
+export type UnlockProviderMutation = { __typename?: 'Mutation', unlockProvider: (
+ { __typename?: 'Provider' }
+ & ProviderFieldsForPageFragment
+ ) };
+
+export type DeleteProviderMutationVariables = Exact<{
+ id: Scalars['ID'];
+}>;
+
+
+export type DeleteProviderMutation = { __typename?: 'Mutation', deleteProvider: boolean };
+
export type GetTimeFramesQueryVariables = Exact<{ [key: string]: never; }>;
@@ -2870,6 +2942,24 @@ export const OrganisationFieldsForTableFragmentDoc = gql`
}
${OrganisationFieldsGeneralFragmentDoc}
${ContactInformationFieldsGeneralFragmentDoc}`;
+export const ProviderFieldsForTableFragmentDoc = gql`
+ fragment ProviderFieldsForTable on Provider {
+ ...ProviderFieldsGeneral
+ isLocked
+ isLockedByMe
+ lockedBy
+ lockedUntil
+}
+ ${ProviderFieldsGeneralFragmentDoc}`;
+export const ProviderFieldsForPageFragmentDoc = gql`
+ fragment ProviderFieldsForPage on Provider {
+ ...ProviderFieldsForTable
+ cargoBikes {
+ id
+ name
+ }
+}
+ ${ProviderFieldsForTableFragmentDoc}`;
export const OrganisationFieldsForPageFragmentDoc = gql`
fragment OrganisationFieldsForPage on Organisation {
...OrganisationFieldsForTable
@@ -2878,11 +2968,11 @@ export const OrganisationFieldsForPageFragmentDoc = gql`
name
}
provider {
- ...ProviderFieldsGeneral
+ ...ProviderFieldsForPage
}
}
${OrganisationFieldsForTableFragmentDoc}
-${ProviderFieldsGeneralFragmentDoc}`;
+${ProviderFieldsForPageFragmentDoc}`;
export const PersonFieldsForTableFragmentDoc = gql`
fragment PersonFieldsForTable on Person {
id
@@ -2903,24 +2993,6 @@ export const PersonFieldsForPageFragmentDoc = gql`
}
${PersonFieldsForTableFragmentDoc}
${ContactInformationFieldsGeneralFragmentDoc}`;
-export const ProviderFieldsForTableFragmentDoc = gql`
- fragment ProviderFieldsForTable on Provider {
- ...ProviderFieldsGeneral
- isLocked
- isLockedByMe
- lockedBy
- lockedUntil
-}
- ${ProviderFieldsGeneralFragmentDoc}`;
-export const ProviderFieldsForPageFragmentDoc = gql`
- fragment ProviderFieldsForPage on Provider {
- ...ProviderFieldsForTable
- cargoBikes {
- id
- name
- }
-}
- ${ProviderFieldsForTableFragmentDoc}`;
export const TimeFrameFieldsFragmentDoc = gql`
fragment TimeFrameFields on TimeFrame {
id
@@ -3825,6 +3897,148 @@ export const DeletePersonDocument = gql`
export class DeletePersonGQL extends Apollo.Mutation {
document = DeletePersonDocument;
+ constructor(apollo: Apollo.Apollo) {
+ super(apollo);
+ }
+ }
+export const GetProvidersDocument = gql`
+ query GetProviders {
+ providers {
+ ...ProviderFieldsForTable
+ }
+}
+ ${ProviderFieldsForTableFragmentDoc}`;
+
+ @Injectable({
+ providedIn: 'root'
+ })
+ export class GetProvidersGQL extends Apollo.Query {
+ document = GetProvidersDocument;
+
+ constructor(apollo: Apollo.Apollo) {
+ super(apollo);
+ }
+ }
+export const GetProviderByIdDocument = gql`
+ query GetProviderById($id: ID!) {
+ providerById(id: $id) {
+ ...ProviderFieldsForPage
+ }
+}
+ ${ProviderFieldsForPageFragmentDoc}`;
+
+ @Injectable({
+ providedIn: 'root'
+ })
+ export class GetProviderByIdGQL extends Apollo.Query {
+ document = GetProviderByIdDocument;
+
+ constructor(apollo: Apollo.Apollo) {
+ super(apollo);
+ }
+ }
+export const ReloadProviderByIdDocument = gql`
+ query ReloadProviderById($id: ID!) {
+ providerById(id: $id) {
+ ...ProviderFieldsForTable
+ }
+}
+ ${ProviderFieldsForTableFragmentDoc}`;
+
+ @Injectable({
+ providedIn: 'root'
+ })
+ export class ReloadProviderByIdGQL extends Apollo.Query {
+ document = ReloadProviderByIdDocument;
+
+ constructor(apollo: Apollo.Apollo) {
+ super(apollo);
+ }
+ }
+export const CreateProviderDocument = gql`
+ mutation CreateProvider($provider: ProviderCreateInput!) {
+ createProvider(provider: $provider) {
+ ...ProviderFieldsForTable
+ }
+}
+ ${ProviderFieldsForTableFragmentDoc}`;
+
+ @Injectable({
+ providedIn: 'root'
+ })
+ export class CreateProviderGQL extends Apollo.Mutation {
+ document = CreateProviderDocument;
+
+ constructor(apollo: Apollo.Apollo) {
+ super(apollo);
+ }
+ }
+export const UpdateProviderDocument = gql`
+ mutation UpdateProvider($provider: ProviderUpdateInput!) {
+ updateProvider(provider: $provider) {
+ ...ProviderFieldsForPage
+ }
+}
+ ${ProviderFieldsForPageFragmentDoc}`;
+
+ @Injectable({
+ providedIn: 'root'
+ })
+ export class UpdateProviderGQL extends Apollo.Mutation {
+ document = UpdateProviderDocument;
+
+ constructor(apollo: Apollo.Apollo) {
+ super(apollo);
+ }
+ }
+export const LockProviderDocument = gql`
+ mutation LockProvider($id: ID!) {
+ lockProvider(id: $id) {
+ ...ProviderFieldsForPage
+ }
+}
+ ${ProviderFieldsForPageFragmentDoc}`;
+
+ @Injectable({
+ providedIn: 'root'
+ })
+ export class LockProviderGQL extends Apollo.Mutation {
+ document = LockProviderDocument;
+
+ constructor(apollo: Apollo.Apollo) {
+ super(apollo);
+ }
+ }
+export const UnlockProviderDocument = gql`
+ mutation UnlockProvider($id: ID!) {
+ unlockProvider(id: $id) {
+ ...ProviderFieldsForPage
+ }
+}
+ ${ProviderFieldsForPageFragmentDoc}`;
+
+ @Injectable({
+ providedIn: 'root'
+ })
+ export class UnlockProviderGQL extends Apollo.Mutation {
+ document = UnlockProviderDocument;
+
+ constructor(apollo: Apollo.Apollo) {
+ super(apollo);
+ }
+ }
+export const DeleteProviderDocument = gql`
+ mutation DeleteProvider($id: ID!) {
+ deleteProvider(id: $id)
+}
+ `;
+
+ @Injectable({
+ providedIn: 'root'
+ })
+ export class DeleteProviderGQL extends Apollo.Mutation {
+ document = DeleteProviderDocument;
+
constructor(apollo: Apollo.Apollo) {
super(apollo);
}