[KON-3] FE Bestätigungsseite zum Ausloggen/Browsertab schließen erstellen (analog zu anderen Modulen)
Signed-off-by: Dimitrios Chalepakis <dimitrios.chalepakis@pta.de>
diff --git a/hooks/pre-build.js b/hooks/pre-build.js
index 8cd3264..06f28d7 100644
--- a/hooks/pre-build.js
+++ b/hooks/pre-build.js
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -11,38 +11,35 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
var fs = require('fs-extra');
-var jsonConcat = require("json-concat");
+var jsonConcat = require('json-concat');
var localizationSourceFilesDE = [
- "./i18n/general.de.json",
- "./i18n/components.de.json",
- "./i18n/contacts.de.json",
- "./i18n/persons.de.json",
- "./i18n/salutations.de.json",
- "./i18n/company.de.json",
- "./i18n/admin.de.json",
- "./i18n/addresses.de.json",
- "./i18n/communications-data.de.json"
+ './i18n/general.de.json',
+ './i18n/components.de.json',
+ './i18n/contacts.de.json',
+ './i18n/persons.de.json',
+ './i18n/salutations.de.json',
+ './i18n/company.de.json',
+ './i18n/admin.de.json',
+ './i18n/addresses.de.json',
+ './i18n/communications-data.de.json',
+ './i18n/logout.de.json',
];
function mergeAndSaveJsonFiles(src, dest) {
- jsonConcat({ src: src, dest: dest },
- function (res) {
- console.log('Localization files successfully merged!');
- }
- );
+ jsonConcat({ src: src, dest: dest }, function(res) {
+ console.log('Localization files successfully merged!');
+ });
}
function setEnvironment(configPath, environment) {
- fs.writeJson(configPath, {env: environment},
- function (res) {
- console.log('Environment variable set to ' + environment)
- }
- );
+ fs.writeJson(configPath, { env: environment }, function(res) {
+ console.log('Environment variable set to ' + environment);
+ });
}
// Set environment variable to "production"
setEnvironment('./config/env.json', 'production');
// Merge all localization files into one
-mergeAndSaveJsonFiles(localizationSourceFilesDE, "./i18n/de.json");
+mergeAndSaveJsonFiles(localizationSourceFilesDE, './i18n/de.json');
diff --git a/hooks/pre-start.js b/hooks/pre-start.js
index 2530a4a..95e85a3 100644
--- a/hooks/pre-start.js
+++ b/hooks/pre-start.js
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -11,38 +11,35 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
var fs = require('fs-extra');
-var jsonConcat = require("json-concat");
+var jsonConcat = require('json-concat');
var localizationSourceFilesDE = [
- "./i18n/general.de.json",
- "./i18n/components.de.json",
- "./i18n/contacts.de.json",
- "./i18n/persons.de.json",
- "./i18n/salutations.de.json",
- "./i18n/company.de.json",
- "./i18n/admin.de.json",
- "./i18n/addresses.de.json",
- "./i18n/communications-data.de.json"
+ './i18n/general.de.json',
+ './i18n/components.de.json',
+ './i18n/contacts.de.json',
+ './i18n/persons.de.json',
+ './i18n/salutations.de.json',
+ './i18n/company.de.json',
+ './i18n/admin.de.json',
+ './i18n/addresses.de.json',
+ './i18n/communications-data.de.json',
+ './i18n/logout.de.json',
];
function mergeAndSaveJsonFiles(src, dest) {
- jsonConcat({ src: src, dest: dest },
- function (res) {
- console.log('Localization files successfully merged!');
- }
- );
+ jsonConcat({ src: src, dest: dest }, function(res) {
+ console.log('Localization files successfully merged!');
+ });
}
function setEnvironment(configPath, environment) {
- fs.writeJson(configPath, {env: environment},
- function (res) {
- console.log('Environment variable set to ' + environment)
- }
- );
+ fs.writeJson(configPath, { env: environment }, function(res) {
+ console.log('Environment variable set to ' + environment);
+ });
}
// Set environment variable to "development"
setEnvironment('./config/env.json', 'development');
// Merge all localization files into one
-mergeAndSaveJsonFiles(localizationSourceFilesDE, "./i18n/de.json");
+mergeAndSaveJsonFiles(localizationSourceFilesDE, './i18n/de.json');
diff --git a/i18n/logout.de.json b/i18n/logout.de.json
new file mode 100644
index 0000000..4c0c050
--- /dev/null
+++ b/i18n/logout.de.json
@@ -0,0 +1,8 @@
+{
+ "Logout": {
+ "YouAreLoggedout": "Sie wurden ausgeloggt ...",
+ "PortalNewLogin": "Über das Portal können Sie sich erneut einloggen",
+ "CloseTab": "Browser-Tab schließen",
+ "SubmitLogout": "Wollen Sie sich abmelden?"
+ }
+}
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 9661ec2..867220a 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -13,6 +13,8 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { PageNotFoundComponent } from '@shared/components/pageNotFound/pageNotFound.component';
+import { LogoutPageComponent } from '@app/pages/logout/logout/logout.component';
+import { LoggedoutPageComponent } from '@pages/logout/loggedout/loggedout.component';
const appRoutes: Routes = [
{ path: '', redirectTo: '/overview', pathMatch: 'full' },
@@ -20,6 +22,14 @@
path: 'admin',
loadChildren: './pages/admin/admin.module#AdminModule',
},
+ {
+ path: 'logout',
+ component: LogoutPageComponent,
+ },
+ {
+ path: 'loggedout',
+ component: LoggedoutPageComponent,
+ },
{ path: '**', component: PageNotFoundComponent },
];
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index dfca123..a0b5996 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -27,7 +27,7 @@
import { AppComponent } from '@app/app.component';
import { HttpServiceModule } from '@shared/asyncServices/http/http.module';
import { UtilityModule } from '@shared/utility';
-import { AngularFontAwesomeModule } from 'angular-font-awesome'
+import { AngularFontAwesomeModule } from 'angular-font-awesome';
//Feature Modules
import { ContactsModule } from '@pages/contacts/contacts.module';
@@ -54,9 +54,10 @@
import { environment } from 'environments/environment';
import { ContainersModule } from '@shared/containers';
import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
+import { LogoutModule } from '@pages/logout/logout.module';
/**
- * Get the BaseHref which is defined in the index.html ( <base href="/"> ).
+ * Get the BaseHref which is defined in the index.html ( <base href="/"> ).
* The "base href" in the index.html can be set via ng nuild for different enviroments.
* Example: ng build --prod --base-href ../contactdatabase/
*/
@@ -112,7 +113,8 @@
CompanyModule,
AdminModule,
AppRoutingModule,
- NgbModalModule
+ NgbModalModule,
+ LogoutModule,
],
providers: [
AuthGuard,
@@ -125,10 +127,10 @@
multi: true,
},
{
- provide: APP_BASE_HREF,
- useFactory: getBaseHref,
- deps: [PlatformLocation]
- }
+ provide: APP_BASE_HREF,
+ useFactory: getBaseHref,
+ deps: [PlatformLocation],
+ },
],
bootstrap: [AppComponent],
})
diff --git a/src/app/pages/logout/loggedout/loggedout.component.css b/src/app/pages/logout/loggedout/loggedout.component.css
new file mode 100644
index 0000000..3a31dc2
--- /dev/null
+++ b/src/app/pages/logout/loggedout/loggedout.component.css
@@ -0,0 +1,25 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+.logout-outer {
+ width: 100%;
+ height: 85%;
+ position: fixed;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: #f8fafd;
+}
+
+.logout-inner {
+ text-align: center;
+}
diff --git a/src/app/pages/logout/loggedout/loggedout.component.html b/src/app/pages/logout/loggedout/loggedout.component.html
new file mode 100644
index 0000000..bb50e53
--- /dev/null
+++ b/src/app/pages/logout/loggedout/loggedout.component.html
@@ -0,0 +1,23 @@
+<!-- /********************************************************************************
+* Copyright (c) 2020 Contributors to the Eclipse Foundation
+*
+* See the NOTICE file(s) distributed with this work for additional
+* information regarding copyright ownership.
+*
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v. 2.0 which is available at
+* http://www.eclipse.org/legal/epl-2.0.
+*
+* SPDX-License-Identifier: EPL-2.0
+********************************************************************************/ -->
+
+<div class="logout-outer">
+ <div class="logout-inner">
+ <img src="assets/img/logo_openkonsequenz.png" />
+ <div>
+ <h2>{{ 'Logout.YouAreLoggedout' | translate }}</h2>
+ <h4>{{ 'Logout.PortalNewLogin' | translate }}</h4>
+ <button #tabCloseBtn style="margin-top: 10%" type="button" class="btn btn-primary" onclick="window.close()">{{ 'Logout.CloseTab' | translate }}</button>
+ </div>
+ </div>
+</div>
diff --git a/src/app/pages/logout/loggedout/loggedout.component.spec.ts b/src/app/pages/logout/loggedout/loggedout.component.spec.ts
new file mode 100644
index 0000000..eba73fb
--- /dev/null
+++ b/src/app/pages/logout/loggedout/loggedout.component.spec.ts
@@ -0,0 +1,25 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+import { LoggedoutPageComponent } from '@pages/logout/loggedout/loggedout.component';
+
+describe('LoggedoutPageComponent', () => {
+ let component: LoggedoutPageComponent;
+
+ beforeEach(() => {
+ component = new LoggedoutPageComponent();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/pages/logout/loggedout/loggedout.component.ts b/src/app/pages/logout/loggedout/loggedout.component.ts
new file mode 100644
index 0000000..ea9f36b
--- /dev/null
+++ b/src/app/pages/logout/loggedout/loggedout.component.ts
@@ -0,0 +1,28 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
+
+@Component({
+ selector: 'app-loggedout',
+ templateUrl: './loggedout.component.html',
+ styleUrls: ['./loggedout.component.css'],
+})
+export class LoggedoutPageComponent implements OnInit {
+ constructor() {}
+
+ @ViewChild('tabCloseBtn', { static: true }) button: ElementRef;
+
+ ngOnInit() {
+ this.button.nativeElement.focus();
+ }
+}
diff --git a/src/app/pages/logout/logout-api-client.ts b/src/app/pages/logout/logout-api-client.ts
new file mode 100644
index 0000000..7dbaff7
--- /dev/null
+++ b/src/app/pages/logout/logout-api-client.ts
@@ -0,0 +1,28 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+import { Injectable } from '@angular/core';
+import { HttpService, GET } from '@shared/asyncServices/http';
+import { Observable } from 'rxjs';
+
+@Injectable()
+export class LogoutApiClient extends HttpService {
+ /**
+ * Logs out from portal
+ *
+ * @param contactId
+ */
+ @GET('/logout')
+ public logout(): Observable<any> {
+ return null;
+ }
+}
diff --git a/src/app/pages/logout/logout.module.ts b/src/app/pages/logout/logout.module.ts
new file mode 100644
index 0000000..1e3063f
--- /dev/null
+++ b/src/app/pages/logout/logout.module.ts
@@ -0,0 +1,42 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { RouterModule } from '@angular/router';
+import { ComponentsModule } from '@shared/components';
+import { TranslateModule } from '@ngx-translate/core';
+import { FormsModule } from '@angular/forms';
+import { DirectivesModule } from '@shared/directives';
+import { ContainersModule } from '@shared/containers';
+import { LogoutPageSandbox } from '@pages/logout/logout/logout.sandbox';
+import { LogoutPageComponent } from '@pages/logout/logout/logout.component';
+import { LoggedoutPageComponent } from '@pages/logout/loggedout/loggedout.component';
+import { LogoutApiClient } from '@pages/logout/logout-api-client';
+import { EffectsModule } from '@ngrx/effects';
+import { LogoutEffects } from '@shared/store/effects/logout/logout.effect';
+
+@NgModule({
+ imports: [
+ CommonModule,
+ ComponentsModule,
+ TranslateModule,
+ DirectivesModule,
+ RouterModule,
+ FormsModule,
+ ContainersModule,
+ EffectsModule.forFeature([LogoutEffects]),
+ ],
+ declarations: [LogoutPageComponent, LoggedoutPageComponent],
+ providers: [LogoutPageSandbox, LogoutApiClient],
+})
+export class LogoutModule {}
diff --git a/src/app/pages/logout/logout/logout.component.css b/src/app/pages/logout/logout/logout.component.css
new file mode 100644
index 0000000..06d8f33
--- /dev/null
+++ b/src/app/pages/logout/logout/logout.component.css
@@ -0,0 +1,35 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+.logout-outer {
+ width: 100%;
+ height: 85%;
+ position: fixed;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: #f8fafd;
+}
+
+.logout-inner {
+ text-align: center;
+}
+
+.center-margin {
+ text-align: center;
+ margin: 15px;
+}
+
+.btn-primary {
+ margin-right: 10px;
+ min-width: 60px;
+}
diff --git a/src/app/pages/logout/logout/logout.component.html b/src/app/pages/logout/logout/logout.component.html
new file mode 100644
index 0000000..33d505c
--- /dev/null
+++ b/src/app/pages/logout/logout/logout.component.html
@@ -0,0 +1,29 @@
+<!-- /********************************************************************************
+* Copyright (c) 2020 Contributors to the Eclipse Foundation
+*
+* See the NOTICE file(s) distributed with this work for additional
+* information regarding copyright ownership.
+*
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v. 2.0 which is available at
+* http://www.eclipse.org/legal/epl-2.0.
+*
+* SPDX-License-Identifier: EPL-2.0
+********************************************************************************/ -->
+
+<div class="logout-outer">
+ <div class="logout-inner">
+ <div class="center">
+ <img src="assets/img/logo_openkonsequenz.png" />
+ <h3>{{ 'Logout.SubmitLogout' | translate }}</h3>
+ </div>
+ <div class="center-margin">
+ <button #yesBtn id="logoutbutton" class="btn btn-primary" type="button" (click)="logoutPageSandBox.logout()">
+ {{ 'ConfirmDialog.SubmitBtn' | translate }}
+ </button>
+ <button type="button" id="homebutton" class=" btn btn-primary " (click)="logoutPageSandBox.goToOverview()">
+ {{ 'ConfirmDialog.CancelBtn' | translate }}
+ </button>
+ </div>
+ </div>
+</div>
diff --git a/src/app/pages/logout/logout/logout.component.spec.ts b/src/app/pages/logout/logout/logout.component.spec.ts
new file mode 100644
index 0000000..35d4dc5
--- /dev/null
+++ b/src/app/pages/logout/logout/logout.component.spec.ts
@@ -0,0 +1,37 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+import { LogoutPageComponent } from '@pages/logout/logout/logout.component';
+
+describe('LogoutPageComponent', () => {
+ let component: LogoutPageComponent;
+ let logoutPageSandBox: any;
+
+ beforeEach(() => {
+ logoutPageSandBox = {
+ endSubscriptions() {},
+ } as any;
+
+ component = new LogoutPageComponent(logoutPageSandBox);
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+
+ it('should end all subscriptions for this sandbox onDestroy', () => {
+ const spy = spyOn(logoutPageSandBox, 'endSubscriptions');
+ component.ngOnDestroy();
+
+ expect(spy).toHaveBeenCalled();
+ });
+});
diff --git a/src/app/pages/logout/logout/logout.component.ts b/src/app/pages/logout/logout/logout.component.ts
new file mode 100644
index 0000000..5d5e331
--- /dev/null
+++ b/src/app/pages/logout/logout/logout.component.ts
@@ -0,0 +1,35 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+
+import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
+import { LogoutPageSandbox } from '@pages/logout/logout/logout.sandbox';
+
+@Component({
+ selector: 'app-logout',
+ templateUrl: './logout.component.html',
+ styleUrls: ['./logout.component.css'],
+})
+export class LogoutPageComponent implements OnInit {
+ @ViewChild('yesBtn', { static: true }) button: ElementRef;
+ loggedOut = false;
+
+ constructor(public logoutPageSandBox: LogoutPageSandbox) {}
+
+ ngOnInit() {
+ this.button.nativeElement.focus();
+ }
+
+ ngOnDestroy() {
+ this.logoutPageSandBox.endSubscriptions();
+ }
+}
diff --git a/src/app/pages/logout/logout/logout.sandbox.spec.ts b/src/app/pages/logout/logout/logout.sandbox.spec.ts
new file mode 100644
index 0000000..ddfef03
--- /dev/null
+++ b/src/app/pages/logout/logout/logout.sandbox.spec.ts
@@ -0,0 +1,54 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+import { LogoutPageSandbox } from '@pages/logout/logout/logout.sandbox';
+import { of } from 'rxjs';
+
+describe('LogoutPageSandbox', () => {
+ let component: LogoutPageSandbox;
+ let appState: any;
+ let actionSubject: any;
+ let router: any;
+
+ beforeEach(() => {
+ router = { navigateByUrl() {} } as any;
+ appState = { dispatch: () => {}, pipe: () => of(true), select: () => of(true) } as any;
+ actionSubject = { pipe: () => of(true) } as any;
+
+ component = new LogoutPageSandbox(appState, actionSubject, router);
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+
+ it('should clear storage, user and got o loggedout page if call logout', () => {
+ const spy = spyOn(appState, 'dispatch');
+ const spyClearStorage = spyOn(component, 'clearStorage');
+ const spyRemoveUser = spyOn(component, 'removeUser');
+ const spyNavigate = spyOn(router, 'navigateByUrl');
+
+ component.logout();
+
+ expect(spy).toHaveBeenCalledTimes(1);
+ expect(spyClearStorage).toHaveBeenCalled();
+ expect(spyRemoveUser).toHaveBeenCalled();
+ expect(spyNavigate).toHaveBeenCalledWith('/loggedout');
+ });
+
+ it('should call naviagetByUrl with /overview', () => {
+ const spy = spyOn(router, 'navigateByUrl');
+ component.goToOverview();
+
+ expect(spy).toHaveBeenCalledWith('/overview');
+ });
+});
diff --git a/src/app/pages/logout/logout/logout.sandbox.ts b/src/app/pages/logout/logout/logout.sandbox.ts
new file mode 100644
index 0000000..9bd397d
--- /dev/null
+++ b/src/app/pages/logout/logout/logout.sandbox.ts
@@ -0,0 +1,40 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+import { Injectable } from '@angular/core';
+import { BaseSandbox } from '@shared/sandbox/base.sandbox';
+import { Store, ActionsSubject } from '@ngrx/store';
+import * as store from '@shared/store';
+import * as logoutActions from '@shared/store/actions/logout/logout.action';
+import { ofType } from '@ngrx/effects';
+import { takeUntil } from 'rxjs/operators';
+import { Router } from '@angular/router';
+
+@Injectable()
+export class LogoutPageSandbox extends BaseSandbox {
+ constructor(protected appState$: Store<store.State>, protected actionsSubject: ActionsSubject, private router: Router) {
+ super(appState$);
+ }
+
+ public logout(): void {
+ this.appState$.dispatch(logoutActions.logout());
+ this.actionsSubject.pipe(ofType(logoutActions.logoutSuccess), takeUntil(this._endSubscriptions$)).subscribe(() => {
+ this.clearStorage();
+ this.removeUser();
+ this.router.navigateByUrl('/loggedout');
+ });
+ }
+
+ public goToOverview(): void {
+ this.router.navigateByUrl('/overview');
+ }
+}
diff --git a/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.html b/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.html
index 41a86e9..c09e7ad 100644
--- a/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.html
+++ b/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.html
@@ -10,28 +10,32 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/ -->
-<form [ngrxFormState]="externalPersonDetailsSandbox.addressDetailsFormState$ | async">
- <h4>{{createOrEditAddressData}}</h4>
+<form [ngrxFormState]="externalPersonDetailsSandbox.addressDetailsFormState$ | async">
+ <h4>{{ createOrEditAddressData }}</h4>
<div>
<!-- type -->
<div class="form-group row">
<label for="addressTypeId" class="col-sm-5 col-form-label">{{ 'Address.AddressType' | translate }}</label>
<div class="col-sm-6">
<select
+ required
type="text"
class="form-control"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['addressTypeId']">
- <option [value]="">{{ 'SelectOption' | translate }}</option> -->
- <option *ngFor="let addressType of addressTypesSandbox.addressTypes$ | async" [value]="addressType.id">{{addressType.type}}</option>
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['addressTypeId']"
+ >
+ <option [value]="null">{{ 'SelectOption' | translate }}</option>
+ -->
+ <option *ngFor="let addressType of addressTypesSandbox.addressTypes$ | async" [value]="addressType.id">{{ addressType.type }}</option>
</select>
</div>
</div>
<!-- MainAddress -->
<div class="form-group row">
- <label for="isMainAddress" class="col-sm-5 col-form-label">{{ 'Address.MainAddress' | translate }}</label>
- <div class="col-sm-6" style="align-self: center;">
- <input *ngIf="!externalPersonDetailsSandbox.existMainAddress || externalPersonDetailsSandbox.isCurrentAddressMainAddress"
+ <label for="isMainAddress" class="col-sm-5 col-form-label">{{ 'Address.MainAddress' | translate }}</label>
+ <div class="col-sm-6" style="align-self: center;">
+ <input
+ *ngIf="!externalPersonDetailsSandbox.existMainAddress || externalPersonDetailsSandbox.isCurrentAddressMainAddress"
type="checkbox"
class="form-check-input"
id="isMainAddress"
@@ -44,13 +48,14 @@
<!-- postCard -->
<div class="form-group row">
<label for="postcode" class="col-sm-5 col-form-label">{{ 'Address.Postcode' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="30"
- class="form-control"
- id="postcode"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['postcode']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="30"
+ class="form-control"
+ id="postcode"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['postcode']"
+ autocomplete="off"
/>
</div>
</div>
@@ -58,13 +63,14 @@
<!-- community -->
<div class="form-group row">
<label for="community" class="col-sm-5 col-form-label">{{ 'Address.Community' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="community"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['community']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="community"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['community']"
+ autocomplete="off"
/>
</div>
</div>
@@ -72,13 +78,14 @@
<!-- community-suffix -->
<div class="form-group row">
<label for="communitySuffix" class="col-sm-5 col-form-label">{{ 'Address.CommunitySuffix' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="communitySuffix"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['communitySuffix']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="communitySuffix"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['communitySuffix']"
+ autocomplete="off"
/>
</div>
</div>
@@ -86,13 +93,14 @@
<!-- street -->
<div class="form-group row">
<label for="street" class="col-sm-5 col-form-label">{{ 'Address.Street' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="street"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['street']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="street"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['street']"
+ autocomplete="off"
/>
</div>
</div>
@@ -100,69 +108,74 @@
<!-- housenumber -->
<div class="form-group row">
<label for="housenumber" class="col-sm-5 col-form-label">{{ 'Address.Housenumber' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="30"
- class="form-control"
- id="housenumber"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['housenumber']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="30"
+ class="form-control"
+ id="housenumber"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['housenumber']"
+ autocomplete="off"
/>
</div>
</div>
- <!-- wgs_84_zone -->
- <div class="form-group row">
+ <!-- wgs_84_zone -->
+ <div class="form-group row">
<label for="wgs84Zone" class="col-sm-5 col-form-label">{{ 'Address.Wgs84Zone' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="wgs84Zone"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['wgs84Zone']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="wgs84Zone"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['wgs84Zone']"
+ autocomplete="off"
/>
</div>
</div>
- <!-- longitude -->
- <div class="form-group row">
+ <!-- longitude -->
+ <div class="form-group row">
<label for="longitude" class="col-sm-5 col-form-label">{{ 'Address.Longitude' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="longitude"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['longitude']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="longitude"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['longitude']"
+ autocomplete="off"
/>
</div>
</div>
- <!-- latitude -->
- <div class="form-group row">
- <label for="latitude" class="col-sm-5 col-form-label">{{ 'Address.Latitude' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="latitude"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['latitude']"
- autocomplete="off"
- />
- </div>
+ <!-- latitude -->
+ <div class="form-group row">
+ <label for="latitude" class="col-sm-5 col-form-label">{{ 'Address.Latitude' | translate }}</label>
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="latitude"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['latitude']"
+ autocomplete="off"
+ />
</div>
+ </div>
- <!-- url_map -->
- <div class="form-group row">
+ <!-- url_map -->
+ <div class="form-group row">
<label for="urlMap" class="col-sm-5 col-form-label">{{ 'Address.UrlMap' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="urlMap"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['urlMap']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="urlMap"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['urlMap']"
+ autocomplete="off"
/>
</div>
</div>
@@ -170,32 +183,25 @@
<!-- note -->
<div class="form-group row">
<label for="note" class="col-sm-5 col-form-label">{{ 'Address.Note' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="note"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['note']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="note"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['note']"
+ autocomplete="off"
/>
</div>
</div>
<!-- buttons -->
- <button
- type="button"
- class="btn btn-primary btn-sm btn-success"
- (click)="externalPersonDetailsSandbox.persistAddress()"
- >
+ <button type="button" class="btn btn-primary btn-sm btn-success" (click)="externalPersonDetailsSandbox.persistAddress()">
{{ 'SaveBtn' | translate }}
</button>
- <button
- type="button"
- class="btn btn-primary btn-sm"
- (click)="externalPersonDetailsSandbox.closeAddressDataDetail()"
- >
+ <button type="button" class="btn btn-primary btn-sm" (click)="externalPersonDetailsSandbox.closeAddressDataDetail()">
{{ 'CancelBtn' | translate }}
</button>
</div>
-</form >
+</form>
diff --git a/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.spec.ts b/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.spec.ts
index c5f3dc9..b81d79a 100644
--- a/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.spec.ts
+++ b/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.spec.ts
@@ -23,11 +23,10 @@
registerAddressEvents() {},
registerExternalPersonEvents() {},
endSubscriptions() {},
- clearAddressData() {},
+ newAddressData() {},
} as any;
- addressTypesSandbox= {};
-
+ addressTypesSandbox = {};
}));
beforeEach(() => {
@@ -38,9 +37,9 @@
expect(component).toBeTruthy();
});
- it('should call registerAddressEvents and clearAddressData onInit', () => {
+ it('should call registerAddressEvents and newAddressData onInit', () => {
const spy1 = spyOn(externalPersonSandbox, 'registerAddressEvents');
- const spy2 = spyOn(externalPersonSandbox, 'clearAddressData');
+ const spy2 = spyOn(externalPersonSandbox, 'newAddressData');
component.ngOnInit();
expect(spy1).toHaveBeenCalled();
expect(spy2).toHaveBeenCalled();
diff --git a/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.ts b/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.ts
index 69bbf6a..5f20d5c 100644
--- a/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.ts
+++ b/src/app/pages/persons/external-person/external-person-details/address-details/address-details.component.ts
@@ -17,19 +17,15 @@
@Component({
selector: 'app-external-person-address-details',
templateUrl: './address-details.component.html',
- styleUrls: ['./address-details.component.scss']
+ styleUrls: ['./address-details.component.scss'],
})
export class ExternalPersonAddressDetailsComponent implements OnInit {
-
@Input() createOrEditAddressData: string;
- constructor(
- public externalPersonDetailsSandbox: ExternalPersonDetailsSandBox,
- public addressTypesSandbox: AddressTypesSandbox
- ) { }
+ constructor(public externalPersonDetailsSandbox: ExternalPersonDetailsSandBox, public addressTypesSandbox: AddressTypesSandbox) {}
ngOnInit() {
this.externalPersonDetailsSandbox.registerAddressEvents();
- this.externalPersonDetailsSandbox.clearAddressData();
+ this.externalPersonDetailsSandbox.newAddressData();
}
}
diff --git a/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.html b/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.html
index c5dbac6..7c3cd2a 100644
--- a/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.html
+++ b/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.html
@@ -10,19 +10,26 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/ -->
-<form [ngrxFormState]="externalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async">
- <h4>{{createOrEditCommunicationsData}}</h4>
+<form [ngrxFormState]="externalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async">
+ <h4>{{ createOrEditCommunicationsData }}</h4>
<div>
<!-- type -->
<div class="form-group row">
<label for="communicationType" class="col-sm-4 col-form-label">{{ 'CommunicationsData.CommunicationType' | translate }}</label>
<div class="col-sm-7">
<select
+ required
type="text"
class="form-control"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['communicationTypeId']">
- <option [value]="">{{ 'SelectOption' | translate }}</option> -->
- <option *ngFor="let communicationType of communicationTypesSandbox.communicationTypes$ | async" [disabled]="communicationType.isDisabled" [value]="communicationType.id">{{communicationType.type}}</option>
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['communicationTypeId']"
+ >
+ <option [value]="null">{{ 'SelectOption' | translate }}</option>
+ <option
+ *ngFor="let communicationType of communicationTypesSandbox.communicationTypes$ | async"
+ [disabled]="communicationType.isDisabled"
+ [value]="communicationType.id"
+ >{{ communicationType.type }}</option
+ >
</select>
</div>
</div>
@@ -30,13 +37,14 @@
<!-- communicationData -->
<div class="form-group row">
<label for="communicationData" class="col-sm-4 col-form-label">{{ 'CommunicationsData.CommunicationData' | translate }}</label>
- <div class="col-sm-7">
- <input type="text"
- maxlength="1024"
- class="form-control"
- id="communicationData"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['communicationData']"
- autocomplete="off"
+ <div class="col-sm-7">
+ <input
+ type="text"
+ maxlength="1024"
+ class="form-control"
+ id="communicationData"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['communicationData']"
+ autocomplete="off"
/>
</div>
</div>
@@ -44,32 +52,25 @@
<!-- note -->
<div class="form-group row">
<label for="note" class="col-sm-4 col-form-label">{{ 'CommunicationsData.Note' | translate }}</label>
- <div class="col-sm-7">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="note"
- [ngrxFormControlState]="((externalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['note']"
- autocomplete="off"
+ <div class="col-sm-7">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="note"
+ [ngrxFormControlState]="((externalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['note']"
+ autocomplete="off"
/>
</div>
</div>
<!-- buttons -->
- <button
- type="button"
- class="btn btn-primary btn-sm btn-success"
- (click)="externalPersonDetailsSandbox.persistCommunicationsData()"
- >
+ <button type="button" class="btn btn-primary btn-sm btn-success" (click)="externalPersonDetailsSandbox.persistCommunicationsData()">
{{ 'SaveBtn' | translate }}
</button>
- <button
- type="button"
- class="btn btn-primary btn-sm"
- (click)="externalPersonDetailsSandbox.closeCommunicationsDataDetail()"
- >
+ <button type="button" class="btn btn-primary btn-sm" (click)="externalPersonDetailsSandbox.closeCommunicationsDataDetail()">
{{ 'CancelBtn' | translate }}
</button>
</div>
-</form >
+</form>
diff --git a/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.spec.ts b/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.spec.ts
index aa4e1d5..5e6a6cb 100644
--- a/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.spec.ts
+++ b/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.spec.ts
@@ -23,11 +23,10 @@
registerCommunicationsDataEvents() {},
registerExternalPersonEvents() {},
endSubscriptions() {},
- clearCommunicationsData() {},
+ newCommunicationsData() {},
} as any;
- communicationTypesSandbox = {
- } as any;
+ communicationTypesSandbox = {} as any;
}));
beforeEach(() => {
@@ -38,9 +37,9 @@
expect(component).toBeTruthy();
});
- it('should call registerCommunicationsDataEvents and clearCommunicationsData onInit', () => {
+ it('should call registerCommunicationsDataEvents and newCommunicationsData onInit', () => {
const spy1 = spyOn(externalPersonSandbox, 'registerCommunicationsDataEvents');
- const spy2 = spyOn(externalPersonSandbox, 'clearCommunicationsData');
+ const spy2 = spyOn(externalPersonSandbox, 'newCommunicationsData');
component.ngOnInit();
expect(spy1).toHaveBeenCalled();
expect(spy2).toHaveBeenCalled();
diff --git a/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.ts b/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.ts
index 1626508..47409b7 100644
--- a/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.ts
+++ b/src/app/pages/persons/external-person/external-person-details/communications-data-details/communications-data-details.component.ts
@@ -17,20 +17,15 @@
@Component({
selector: 'app-external-person-communications-data-details',
templateUrl: './communications-data-details.component.html',
- styleUrls: ['./communications-data-details.component.scss']
+ styleUrls: ['./communications-data-details.component.scss'],
})
export class ExternalPersonCommunicationsDataDetailsComponent implements OnInit {
-
@Input() createOrEditCommunicationsData: string;
- constructor(
- public externalPersonDetailsSandbox: ExternalPersonDetailsSandBox,
- public communicationTypesSandbox: CommunicationTypesSandbox
- ) { }
+ constructor(public externalPersonDetailsSandbox: ExternalPersonDetailsSandBox, public communicationTypesSandbox: CommunicationTypesSandbox) {}
ngOnInit() {
this.externalPersonDetailsSandbox.registerCommunicationsDataEvents();
- this.externalPersonDetailsSandbox.clearCommunicationsData();
+ this.externalPersonDetailsSandbox.newCommunicationsData();
}
-
}
diff --git a/src/app/pages/persons/external-person/external-person-details/external-person-details.sandbox.spec.ts b/src/app/pages/persons/external-person/external-person-details/external-person-details.sandbox.spec.ts
index 094789d..80ddb11 100644
--- a/src/app/pages/persons/external-person/external-person-details/external-person-details.sandbox.spec.ts
+++ b/src/app/pages/persons/external-person/external-person-details/external-person-details.sandbox.spec.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -26,7 +26,7 @@
beforeEach(async(() => {
router = { navigateByUrl() {} } as any;
- appState = { dispatch:()=> {}, pipe: () => of(true), select:()=> of(true) } as any;
+ appState = { dispatch: () => {}, pipe: () => of(true), select: () => of(true) } as any;
actionSubject = { pipe: () => of(true) } as any;
utilService = { displayNotification: () => {} } as any;
modalService = { open() {} } as any;
@@ -43,23 +43,23 @@
it('should call dispatch if load an external person', () => {
const spy = spyOn(appState, 'dispatch');
component.loadExternalPerson('ID');
- expect(spy).toHaveBeenCalledWith( Object({ payload: 'ID', type: externalPersonActions.loadExternalPersonDetail.type }));
+ expect(spy).toHaveBeenCalledWith(Object({ payload: 'ID', type: externalPersonActions.loadExternalPersonDetail.type }));
});
it('should call dispatch if persist an external person', () => {
const spy = spyOn(appState, 'dispatch');
const routerSpy = spyOn(router, 'navigateByUrl');
- const externalPerson = new ExternalPerson;
+ const externalPerson = new ExternalPerson();
externalPerson.lastName = 'test';
- component.externPersonDetailsCurrentFormState = {...component.externPersonDetailsCurrentFormState, isValid: true, value: externalPerson};
+ component.externPersonDetailsCurrentFormState = { ...component.externPersonDetailsCurrentFormState, isValid: true, value: externalPerson };
component.persistExternalPerson();
- expect(spy).toHaveBeenCalledWith( Object({ payload: externalPerson, type: externalPersonActions.persistExternalPersonDetail.type }));
+ expect(spy).toHaveBeenCalledWith(Object({ payload: externalPerson, type: externalPersonActions.persistExternalPersonDetail.type }));
expect(routerSpy).toHaveBeenCalled();
});
it('should call error with displayNotification if form not valid', () => {
const utilSpy = spyOn(utilService, 'displayNotification');
- component.externPersonDetailsCurrentFormState = {...component.externPersonDetailsCurrentFormState, isValid: false};
+ component.externPersonDetailsCurrentFormState = { ...component.externPersonDetailsCurrentFormState, isValid: false };
component.persistExternalPerson();
expect(utilSpy).toHaveBeenCalled();
});
@@ -72,14 +72,16 @@
it('should call dispatch if load an external person addresses', () => {
const spy = spyOn(appState, 'dispatch');
component.loadExternalPersonAddresses('ID');
- expect(spy).toHaveBeenCalledWith( Object({ payload: 'ID', type: externalPersonActions.loadExternalPersonDetailAddresses.type }));
+ expect(spy).toHaveBeenCalledWith(Object({ payload: 'ID', type: externalPersonActions.loadExternalPersonDetailAddresses.type }));
});
it('should call dispatch if load an external person address details', () => {
const spy = spyOn(appState, 'dispatch');
component.externalPersonContactId = 'contactId';
component.loadExternalPersonDetailsAddressDetails('ID');
- expect(spy).toHaveBeenCalledWith( Object({ payload_contactId: 'contactId', payload_addressId: 'ID', type: externalPersonActions.loadExternalPersonDetailAddressDetails.type }));
+ expect(spy).toHaveBeenCalledWith(
+ Object({ payload_contactId: 'contactId', payload_addressId: 'ID', type: externalPersonActions.loadExternalPersonDetailAddressDetails.type })
+ );
});
it('should can register address events and set the addressDetailsCurrentFormState', () => {
@@ -87,15 +89,15 @@
expect(component.addressDetailsCurrentFormState).toBeDefined();
});
- it('should call dispatch if clearExternalPerson', () => {
+ it('should call dispatch if newExternalPerson', () => {
const spy = spyOn(appState, 'dispatch');
- component.clearExternalPerson();
+ component.newExternalPerson();
expect(spy).toHaveBeenCalledTimes(3);
});
it('should call dispatch if clearAddressData', () => {
const spy = spyOn(appState, 'dispatch');
- (component as any).clearAddressData();
+ component.clearAddressData();
expect(spy).toHaveBeenCalledTimes(2);
});
@@ -106,15 +108,15 @@
externalPersonAddress.addressTypeType = 'test';
externalPersonAddress.contactId = 'id';
- component.addressDetailsCurrentFormState = {...component.addressDetailsCurrentFormState, isValid: true, value: externalPersonAddress};
+ component.addressDetailsCurrentFormState = { ...component.addressDetailsCurrentFormState, isValid: true, value: externalPersonAddress };
component.persistAddress();
- expect(spy).toHaveBeenCalledWith( Object({ payload: externalPersonAddress, type: externalPersonActions.persistAddressDetail.type }));
+ expect(spy).toHaveBeenCalledWith(Object({ payload: externalPersonAddress, type: externalPersonActions.persistAddressDetail.type }));
expect(spy1).toHaveBeenCalled();
});
it('should call error with displayNotification if address form not valid', () => {
const utilSpy = spyOn(utilService, 'displayNotification');
- component.addressDetailsCurrentFormState = {...component.addressDetailsCurrentFormState, isValid: false};
+ component.addressDetailsCurrentFormState = { ...component.addressDetailsCurrentFormState, isValid: false };
component.persistAddress();
expect(utilSpy).toHaveBeenCalled();
});
@@ -128,25 +130,28 @@
});
it('should open modal before deleting an address', () => {
- spyOn(component['modalService'], 'open')
- .and.returnValue({componentInstance: {title: ''}, result: {then: () => of(true)}} as any);
- // (component as any)._communicationTypes = [new CommunicationType];
+ spyOn(component['modalService'], 'open').and.returnValue({ componentInstance: { title: '' }, result: { then: () => of(true) } } as any);
component.deleteAddress(new Address());
expect(modalService.open).toHaveBeenCalled();
});
it('should call dispatch if load an external person communications Data', () => {
const spy = spyOn(appState, 'dispatch');
- // (component as any)._communicationTypes = [new CommunicationType];
component.loadCommunicationsData('ID');
- expect(spy).toHaveBeenCalledWith( Object({ payload: 'ID', type: externalPersonActions.loadExternalPersonDetailCommunicationsData.type }));
+ expect(spy).toHaveBeenCalledWith(Object({ payload: 'ID', type: externalPersonActions.loadExternalPersonDetailCommunicationsData.type }));
});
it('should call dispatch if load an external person communicationsData details', () => {
const spy = spyOn(appState, 'dispatch');
- component.externalPersonContactId = 'contactId'
+ component.externalPersonContactId = 'contactId';
component.loadCommunicationsDataDetails('ID');
- expect(spy).toHaveBeenCalledWith( Object({ payload_contactId: 'contactId', payload_communicationsId: 'ID', type: externalPersonActions.loadExternalPersonDetailCommunicationsDataDetails.type }));
+ expect(spy).toHaveBeenCalledWith(
+ Object({
+ payload_contactId: 'contactId',
+ payload_communicationsId: 'ID',
+ type: externalPersonActions.loadExternalPersonDetailCommunicationsDataDetails.type,
+ })
+ );
});
it('should can register communicationsData events and set the communicationsDataDetailsCurrentFormState', () => {
@@ -167,15 +172,19 @@
externalPersonCommunicationsData.communicationTypeType = 'test';
externalPersonCommunicationsData.contactId = 'id';
- component.communicationsDataDetailsCurrentFormState = {...component.communicationsDataDetailsCurrentFormState, isValid: true, value: externalPersonCommunicationsData};
+ component.communicationsDataDetailsCurrentFormState = {
+ ...component.communicationsDataDetailsCurrentFormState,
+ isValid: true,
+ value: externalPersonCommunicationsData,
+ };
component.persistCommunicationsData();
- expect(spy).toHaveBeenCalledWith( Object({ payload: externalPersonCommunicationsData, type: externalPersonActions.persistCommunicationsDataDetail.type }));
+ expect(spy).toHaveBeenCalledWith(Object({ payload: externalPersonCommunicationsData, type: externalPersonActions.persistCommunicationsDataDetail.type }));
expect(spy1).toHaveBeenCalled();
});
it('should call error with displayNotification if communicationsData form not valid', () => {
const utilSpy = spyOn(utilService, 'displayNotification');
- component.communicationsDataDetailsCurrentFormState = {...component.communicationsDataDetailsCurrentFormState, isValid: false};
+ component.communicationsDataDetailsCurrentFormState = { ...component.communicationsDataDetailsCurrentFormState, isValid: false };
component.persistCommunicationsData();
expect(utilSpy).toHaveBeenCalled();
});
@@ -191,9 +200,27 @@
});
it('should open modal before deleting an communicationsData', () => {
- spyOn(component['modalService'], 'open')
- .and.returnValue({componentInstance: {title: ''}, result: {then: () => of(true)}} as any);
- component.deleteCommunicationsData(new CommunicationsData());
+ spyOn(component['modalService'], 'open').and.returnValue({ componentInstance: { title: '' }, result: { then: () => of(true) } } as any);
+ component.deleteCommunicationsData(new CommunicationsData());
expect(modalService.open).toHaveBeenCalled();
});
+
+ it('should call clear and markastouched if newAddressData', () => {
+ const spy = spyOn(appState, 'dispatch');
+ component.newAddressData();
+ expect(spy).toHaveBeenCalledTimes(3);
+ expect(component.isCurrentAddressMainAddress).toBeFalsy();
+ });
+
+ it('should call clear and markastouched if newCommunicationsData', () => {
+ const spy = spyOn(appState, 'dispatch');
+ component.newCommunicationsData();
+ expect(spy).toHaveBeenCalledTimes(3);
+ });
+
+ it('should call dispatch if clearExternalPerson', () => {
+ const spy = spyOn(appState, 'dispatch');
+ component.clearExternalPerson();
+ expect(spy).toHaveBeenCalledTimes(2);
+ });
});
diff --git a/src/app/pages/persons/external-person/external-person-details/external-person-details.sandbox.ts b/src/app/pages/persons/external-person/external-person-details/external-person-details.sandbox.ts
index 88daa73..0f6235f 100644
--- a/src/app/pages/persons/external-person/external-person-details/external-person-details.sandbox.ts
+++ b/src/app/pages/persons/external-person/external-person-details/external-person-details.sandbox.ts
@@ -102,7 +102,7 @@
})
);
this.actionsSubject.pipe(ofType(externalPersonActions.persistExternalPersonDetailSuccess), take(1), takeUntil(this._endSubscriptions$)).subscribe(() => {
- this.clearExternalPerson();
+ this.newExternalPerson();
this.router.navigateByUrl(`/overview`);
});
} else {
@@ -145,10 +145,19 @@
this.isAddressDataDetailViewVisible = false;
}
+ public newExternalPerson(): void {
+ this.clearExternalPerson();
+ this.appState$.dispatch(new MarkAsTouchedAction(externalPersonDetailsFormReducer.FORM_ID));
+ }
+
public clearExternalPerson(): void {
this.appState$.dispatch(new SetValueAction(externalPersonDetailsFormReducer.FORM_ID, externalPersonDetailsFormReducer.INITIAL_STATE.value));
this.appState$.dispatch(new ResetAction(externalPersonDetailsFormReducer.FORM_ID));
- this.appState$.dispatch(new MarkAsTouchedAction(externalPersonDetailsFormReducer.FORM_ID));
+ }
+
+ public newAddressData(): void {
+ this.clearAddressData();
+ this.appState$.dispatch(new MarkAsTouchedAction(externalPersonAddressDetailsFormReducer.FORM_ID));
}
public clearAddressData(): void {
@@ -244,6 +253,11 @@
this.isCommunicationsDataDetailViewVisible = false;
}
+ public newCommunicationsData(): void {
+ this.clearCommunicationsData();
+ this.appState$.dispatch(new MarkAsTouchedAction(externalCommunicationsDataDetailsFormReducer.FORM_ID));
+ }
+
public clearCommunicationsData(): void {
this.appState$.dispatch(
new SetValueAction(externalCommunicationsDataDetailsFormReducer.FORM_ID, externalCommunicationsDataDetailsFormReducer.INITIAL_STATE.value)
diff --git a/src/app/pages/persons/external-person/external-person.resolver.spec.ts b/src/app/pages/persons/external-person/external-person.resolver.spec.ts
index 0ba9c03..4edd190 100644
--- a/src/app/pages/persons/external-person/external-person.resolver.spec.ts
+++ b/src/app/pages/persons/external-person/external-person.resolver.spec.ts
@@ -23,7 +23,7 @@
beforeEach(async(() => {
externalPersonSandbox = {
- clearExternalPerson() {},
+ newExternalPerson() {},
loadExternalPerson() {},
loadExternalPersonAddresses() {},
loadCommunicationsData() {},
@@ -65,8 +65,8 @@
expect(spy2).toHaveBeenCalled();
});
- it('should call clearExternalPerson if create a new external person', () => {
- const spy = spyOn(externalPersonSandbox, 'clearExternalPerson');
+ it('should call newExternalPerson if create a new external person', () => {
+ const spy = spyOn(externalPersonSandbox, 'newExternalPerson');
let ar: any = { params: { contactId: undefined } };
component.resolve(ar);
expect(spy).toHaveBeenCalled();
diff --git a/src/app/pages/persons/external-person/external-person.resolver.ts b/src/app/pages/persons/external-person/external-person.resolver.ts
index 2b81eed..fbe9519 100644
--- a/src/app/pages/persons/external-person/external-person.resolver.ts
+++ b/src/app/pages/persons/external-person/external-person.resolver.ts
@@ -1,6 +1,6 @@
import { AddressTypesSandbox } from './../../admin/address-types/address-types.sandbox';
import { PersonTypesSandbox } from '@pages/admin/person-types/person-types.sandbox';
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -19,27 +19,26 @@
import { CommunicationTypesSandbox } from '@pages/admin/communication-types/communication-types.sandbox';
@Injectable()
-export class ExternalPersonResolver implements Resolve<any>{
-
+export class ExternalPersonResolver implements Resolve<any> {
constructor(
private externalPersonSandbox: ExternalPersonDetailsSandBox,
private salutationsSandbox: SalutationsSandbox,
private communicationTypesSandbox: CommunicationTypesSandbox,
private personTypesSandbox: PersonTypesSandbox,
private addressTypesSandbox: AddressTypesSandbox
- ) { }
+ ) {}
/**
* @param route
*/
public resolve(route: ActivatedRouteSnapshot): void {
const contactId: string = route.params['contactId'];
- if (contactId && (contactId !== 'new')) {
- this.externalPersonSandbox.loadExternalPerson(contactId);
- this.externalPersonSandbox.loadExternalPersonAddresses(contactId);
- this.externalPersonSandbox.loadCommunicationsData(contactId);
+ if (contactId && contactId !== 'new') {
+ this.externalPersonSandbox.loadExternalPerson(contactId);
+ this.externalPersonSandbox.loadExternalPersonAddresses(contactId);
+ this.externalPersonSandbox.loadCommunicationsData(contactId);
} else {
- this.externalPersonSandbox.clearExternalPerson();
+ this.externalPersonSandbox.newExternalPerson();
}
this.salutationsSandbox.loadSalutations();
@@ -49,5 +48,4 @@
this.externalPersonSandbox.isAddressDataDetailViewVisible = false;
this.externalPersonSandbox.isCommunicationsDataDetailViewVisible = false;
}
-
}
diff --git a/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.html b/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.html
index 28271c9..9873424 100644
--- a/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.html
+++ b/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.html
@@ -10,19 +10,22 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/ -->
-<form [ngrxFormState]="internalPersonDetailsSandbox.addressDetailsFormState$ | async">
- <h4>{{createOrEditAddressData}}</h4>
+<form [ngrxFormState]="internalPersonDetailsSandbox.addressDetailsFormState$ | async">
+ <h4>{{ createOrEditAddressData }}</h4>
<div>
<!-- type -->
<div class="form-group row">
<label for="addressTypeId" class="col-sm-5 col-form-label">{{ 'Address.AddressType' | translate }}</label>
<div class="col-sm-6">
<select
+ required
type="text"
class="form-control"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['addressTypeId']">
- <option [value]="">{{ 'SelectOption' | translate }}</option> -->
- <option *ngFor="let addressType of addressTypesSandbox.addressTypes$ | async" [value]="addressType.id">{{addressType.type}}</option>
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['addressTypeId']"
+ >
+ <option [value]="null">{{ 'SelectOption' | translate }}</option>
+ -->
+ <option *ngFor="let addressType of addressTypesSandbox.addressTypes$ | async" [value]="addressType.id">{{ addressType.type }}</option>
</select>
</div>
</div>
@@ -30,12 +33,13 @@
<!-- MainAddress -->
<div class="form-group row">
<label for="isMainAddress" class="col-sm-5 col-form-label">{{ 'Address.MainAddress' | translate }}</label>
- <div class="col-sm-6" style="align-self: center;">
- <input *ngIf="!internalPersonDetailsSandbox.existMainAddress || internalPersonDetailsSandbox.isCurrentAddressMainAddress"
- type="checkbox"
- class="form-check-input"
- id="isMainAddress"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['isMainAddress']"
+ <div class="col-sm-6" style="align-self: center;">
+ <input
+ *ngIf="!internalPersonDetailsSandbox.existMainAddress || internalPersonDetailsSandbox.isCurrentAddressMainAddress"
+ type="checkbox"
+ class="form-check-input"
+ id="isMainAddress"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['isMainAddress']"
/>
<span *ngIf="internalPersonDetailsSandbox.existMainAddress && !internalPersonDetailsSandbox.isCurrentAddressMainAddress">(vorhanden)</span>
</div>
@@ -44,13 +48,14 @@
<!-- postCard -->
<div class="form-group row">
<label for="postcode" class="col-sm-5 col-form-label">{{ 'Address.Postcode' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="30"
- class="form-control"
- id="postcode"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['postcode']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="30"
+ class="form-control"
+ id="postcode"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['postcode']"
+ autocomplete="off"
/>
</div>
</div>
@@ -58,13 +63,14 @@
<!-- community -->
<div class="form-group row">
<label for="community" class="col-sm-5 col-form-label">{{ 'Address.Community' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="community"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['community']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="community"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['community']"
+ autocomplete="off"
/>
</div>
</div>
@@ -72,13 +78,14 @@
<!-- community-suffix -->
<div class="form-group row">
<label for="communitySuffix" class="col-sm-5 col-form-label">{{ 'Address.CommunitySuffix' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="communitySuffix"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['communitySuffix']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="communitySuffix"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['communitySuffix']"
+ autocomplete="off"
/>
</div>
</div>
@@ -86,13 +93,14 @@
<!-- street -->
<div class="form-group row">
<label for="street" class="col-sm-5 col-form-label">{{ 'Address.Street' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="street"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['street']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="street"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['street']"
+ autocomplete="off"
/>
</div>
</div>
@@ -100,69 +108,74 @@
<!-- housenumber -->
<div class="form-group row">
<label for="housenumber" class="col-sm-5 col-form-label">{{ 'Address.Housenumber' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="30"
- class="form-control"
- id="housenumber"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['housenumber']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="30"
+ class="form-control"
+ id="housenumber"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['housenumber']"
+ autocomplete="off"
/>
</div>
</div>
- <!-- wgs_84_zone -->
- <div class="form-group row">
+ <!-- wgs_84_zone -->
+ <div class="form-group row">
<label for="wgs84Zone" class="col-sm-5 col-form-label">{{ 'Address.Wgs84Zone' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="wgs84Zone"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['wgs84Zone']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="wgs84Zone"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['wgs84Zone']"
+ autocomplete="off"
/>
</div>
</div>
- <!-- longitude -->
- <div class="form-group row">
+ <!-- longitude -->
+ <div class="form-group row">
<label for="longitude" class="col-sm-5 col-form-label">{{ 'Address.Longitude' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="longitude"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['longitude']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="longitude"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['longitude']"
+ autocomplete="off"
/>
</div>
</div>
- <!-- latitude -->
- <div class="form-group row">
- <label for="latitude" class="col-sm-5 col-form-label">{{ 'Address.Latitude' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="latitude"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['latitude']"
- autocomplete="off"
- />
- </div>
+ <!-- latitude -->
+ <div class="form-group row">
+ <label for="latitude" class="col-sm-5 col-form-label">{{ 'Address.Latitude' | translate }}</label>
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="latitude"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['latitude']"
+ autocomplete="off"
+ />
</div>
+ </div>
- <!-- url_map -->
- <div class="form-group row">
+ <!-- url_map -->
+ <div class="form-group row">
<label for="urlMap" class="col-sm-5 col-form-label">{{ 'Address.UrlMap' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="urlMap"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['urlMap']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="urlMap"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['urlMap']"
+ autocomplete="off"
/>
</div>
</div>
@@ -170,32 +183,25 @@
<!-- note -->
<div class="form-group row">
<label for="note" class="col-sm-5 col-form-label">{{ 'Address.Note' | translate }}</label>
- <div class="col-sm-6">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="note"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['note']"
- autocomplete="off"
+ <div class="col-sm-6">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="note"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.addressDetailsFormState$ | async)?.controls)['note']"
+ autocomplete="off"
/>
</div>
</div>
<!-- buttons -->
- <button
- type="button"
- class="btn btn-primary btn-sm btn-success"
- (click)="internalPersonDetailsSandbox.persistAddress()"
- >
+ <button type="button" class="btn btn-primary btn-sm btn-success" (click)="internalPersonDetailsSandbox.persistAddress()">
{{ 'SaveBtn' | translate }}
</button>
- <button
- type="button"
- class="btn btn-primary btn-sm"
- (click)="internalPersonDetailsSandbox.closeAddressDataDetail()"
- >
+ <button type="button" class="btn btn-primary btn-sm" (click)="internalPersonDetailsSandbox.closeAddressDataDetail()">
{{ 'CancelBtn' | translate }}
</button>
</div>
-</form >
+</form>
diff --git a/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.spec.ts b/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.spec.ts
index b31efd4..625bd41 100644
--- a/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.spec.ts
+++ b/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.spec.ts
@@ -23,11 +23,10 @@
registerAddressEvents() {},
registerExternalPersonEvents() {},
endSubscriptions() {},
- clearAddressData() {},
+ newAddressData() {},
} as any;
- addressTypesSandbox= {};
-
+ addressTypesSandbox = {};
}));
beforeEach(() => {
@@ -38,9 +37,9 @@
expect(component).toBeTruthy();
});
- it('should call registerAddressEvents and clearAddressData onInit', () => {
+ it('should call registerAddressEvents and newAddressData onInit', () => {
const spy1 = spyOn(internalPersonSandbox, 'registerAddressEvents');
- const spy2 = spyOn(internalPersonSandbox, 'clearAddressData');
+ const spy2 = spyOn(internalPersonSandbox, 'newAddressData');
component.ngOnInit();
expect(spy1).toHaveBeenCalled();
expect(spy2).toHaveBeenCalled();
diff --git a/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.ts b/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.ts
index 6b2f9e7..f8baa61 100644
--- a/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.ts
+++ b/src/app/pages/persons/internal-person/internal-person-details/address-details/address-details.component.ts
@@ -17,20 +17,15 @@
@Component({
selector: 'app-internal-person-address-details',
templateUrl: './address-details.component.html',
- styleUrls: ['./address-details.component.scss']
+ styleUrls: ['./address-details.component.scss'],
})
export class InternalPersonAddressDetailsComponent implements OnInit {
-
@Input() createOrEditAddressData: string;
- constructor(
- public internalPersonDetailsSandbox: InternalPersonDetailsSandBox,
- public addressTypesSandbox: AddressTypesSandbox
- ) { }
+ constructor(public internalPersonDetailsSandbox: InternalPersonDetailsSandBox, public addressTypesSandbox: AddressTypesSandbox) {}
ngOnInit() {
this.internalPersonDetailsSandbox.registerAddressEvents();
- this.internalPersonDetailsSandbox.clearAddressData();
+ this.internalPersonDetailsSandbox.newAddressData();
}
-
}
diff --git a/src/app/pages/persons/internal-person/internal-person-details/communications-data-details/communications-data-details.component.html b/src/app/pages/persons/internal-person/internal-person-details/communications-data-details/communications-data-details.component.html
index 9cde522..ea22554 100644
--- a/src/app/pages/persons/internal-person/internal-person-details/communications-data-details/communications-data-details.component.html
+++ b/src/app/pages/persons/internal-person/internal-person-details/communications-data-details/communications-data-details.component.html
@@ -10,19 +10,26 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/ -->
-<form [ngrxFormState]="internalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async">
- <h4>{{createOrEditCommunicationsData}}</h4>
+<form [ngrxFormState]="internalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async">
+ <h4>{{ createOrEditCommunicationsData }}</h4>
<div>
<!-- type -->
<div class="form-group row">
<label for="communicationType" class="col-sm-4 col-form-label">{{ 'CommunicationsData.CommunicationType' | translate }}</label>
<div class="col-sm-7">
<select
+ required
type="text"
class="form-control"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['communicationTypeId']">
- <option [value]="">{{ 'SelectOption' | translate }}</option> -->
- <option *ngFor="let communicationType of communicationTypesSandbox.communicationTypes$ | async" [disabled]="communicationType.isDisabled" [value]="communicationType.id">{{communicationType.type}}</option>
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['communicationTypeId']"
+ >
+ <option [value]="null">{{ 'SelectOption' | translate }}</option>
+ <option
+ *ngFor="let communicationType of communicationTypesSandbox.communicationTypes$ | async"
+ [disabled]="communicationType.isDisabled"
+ [value]="communicationType.id"
+ >{{ communicationType.type }}</option
+ >
</select>
</div>
</div>
@@ -30,13 +37,14 @@
<!-- communicationData -->
<div class="form-group row">
<label for="communicationData" class="col-sm-4 col-form-label">{{ 'CommunicationsData.CommunicationData' | translate }}</label>
- <div class="col-sm-7">
- <input type="text"
- maxlength="1024"
- class="form-control"
- id="communicationData"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['communicationData']"
- autocomplete="off"
+ <div class="col-sm-7">
+ <input
+ type="text"
+ maxlength="1024"
+ class="form-control"
+ id="communicationData"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['communicationData']"
+ autocomplete="off"
/>
</div>
</div>
@@ -44,32 +52,25 @@
<!-- note -->
<div class="form-group row">
<label for="note" class="col-sm-4 col-form-label">{{ 'CommunicationsData.Note' | translate }}</label>
- <div class="col-sm-7">
- <input type="text"
- maxlength="255"
- class="form-control"
- id="note"
- [ngrxFormControlState]="((internalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['note']"
- autocomplete="off"
+ <div class="col-sm-7">
+ <input
+ type="text"
+ maxlength="255"
+ class="form-control"
+ id="note"
+ [ngrxFormControlState]="((internalPersonDetailsSandbox.communicationsDataDetailsFormState$ | async)?.controls)['note']"
+ autocomplete="off"
/>
</div>
</div>
<!-- buttons -->
- <button
- type="button"
- class="btn btn-primary btn-sm btn-success"
- (click)="internalPersonDetailsSandbox.persistCommunicationsData()"
- >
+ <button type="button" class="btn btn-primary btn-sm btn-success" (click)="internalPersonDetailsSandbox.persistCommunicationsData()">
{{ 'SaveBtn' | translate }}
</button>
- <button
- type="button"
- class="btn btn-primary btn-sm"
- (click)="internalPersonDetailsSandbox.closeCommunicationsDataDetail()"
- >
+ <button type="button" class="btn btn-primary btn-sm" (click)="internalPersonDetailsSandbox.closeCommunicationsDataDetail()">
{{ 'CancelBtn' | translate }}
</button>
</div>
-</form >
+</form>
diff --git a/src/app/pages/persons/internal-person/internal-person-details/communications-data-list/communications-data-list.component.spec.ts b/src/app/pages/persons/internal-person/internal-person-details/communications-data-list/communications-data-list.component.spec.ts
index aea25b6..bda4706 100644
--- a/src/app/pages/persons/internal-person/internal-person-details/communications-data-list/communications-data-list.component.spec.ts
+++ b/src/app/pages/persons/internal-person/internal-person-details/communications-data-list/communications-data-list.component.spec.ts
@@ -24,7 +24,7 @@
registerInternalPersonEvents() {},
endSubscriptions() {},
deleteCommunicationsData() {},
- clearCommunicationsData() {},
+ newCommunicationsData() {},
} as any;
}));
@@ -45,7 +45,7 @@
it('should emit if BusEvents is edit ', () => {
const spy = spyOn(component.internalPersonDetailsId, 'emit');
- const event: any = {type: 'edit', data: {id: 'id'}};
+ const event: any = { type: 'edit', data: { id: 'id' } };
component.gridOptions.context.eventSubject = of(event);
component.ngOnInit();
@@ -54,15 +54,15 @@
it('should deleteCommunicationsData if BusEvents is delete', () => {
const spy = spyOn(internalPersonSandbox, 'deleteCommunicationsData');
- const event: any = {type: 'delete', data: {id: 'id'}};
+ const event: any = { type: 'delete', data: { id: 'id' } };
component.gridOptions.context.eventSubject = of(event);
component.ngOnInit();
expect(spy).toHaveBeenCalled();
});
- it('should clearCommunicationsData and close edit area if callcreateNewCommunicationsDataForm', () => {
- const spy = spyOn(internalPersonSandbox, 'clearCommunicationsData');
+ it('should newCommunicationsData and close edit area if callcreateNewCommunicationsDataForm', () => {
+ const spy = spyOn(internalPersonSandbox, 'newCommunicationsData');
const spyEmit = spyOn(component.createNewInternalPerson, 'emit');
component.createNewCommunicationsDataForm();
@@ -70,4 +70,3 @@
expect(spyEmit).toHaveBeenCalled();
});
});
-
diff --git a/src/app/pages/persons/internal-person/internal-person-details/communications-data-list/communications-data-list.component.ts b/src/app/pages/persons/internal-person/internal-person-details/communications-data-list/communications-data-list.component.ts
index 1cea223..d689713 100644
--- a/src/app/pages/persons/internal-person/internal-person-details/communications-data-list/communications-data-list.component.ts
+++ b/src/app/pages/persons/internal-person/internal-person-details/communications-data-list/communications-data-list.component.ts
@@ -19,16 +19,14 @@
@Component({
selector: 'app-internal-person-communications-data-list',
templateUrl: './communications-data-list.component.html',
- styleUrls: ['./communications-data-list.component.scss']
+ styleUrls: ['./communications-data-list.component.scss'],
})
export class InternalPersonCommunicationsDataListComponent extends BaseList {
-
@Output() internalPersonDetailsId: EventEmitter<string> = new EventEmitter();
@Output() createNewInternalPerson: EventEmitter<string> = new EventEmitter();
public columnDefinition = COMMUNICATIONS_DATA_LIST_COLDEF;
-
constructor(public internalPersonDetailsSandBox: InternalPersonDetailsSandBox) {
super();
}
@@ -36,11 +34,11 @@
ngOnInit() {
this.gridOptions = {
...this.gridOptions,
- localeText: Globals.LOCALE_TEXT
+ localeText: Globals.LOCALE_TEXT,
};
this.gridOptions.context = {
...this.gridOptions.context,
- icons: { edit: true, delete: true }
+ icons: { edit: true, delete: true },
};
this.gridOptions.context.eventSubject.subscribe(event => {
@@ -53,9 +51,8 @@
});
}
- public createNewCommunicationsDataForm(){
- this.internalPersonDetailsSandBox.clearCommunicationsData();
+ public createNewCommunicationsDataForm() {
+ this.internalPersonDetailsSandBox.newCommunicationsData();
this.createNewInternalPerson.emit(null);
}
-
}
diff --git a/src/app/pages/persons/internal-person/internal-person-details/internal-person-details.sandbox.spec.ts b/src/app/pages/persons/internal-person/internal-person-details/internal-person-details.sandbox.spec.ts
index d4a115c..ab24ead 100644
--- a/src/app/pages/persons/internal-person/internal-person-details/internal-person-details.sandbox.spec.ts
+++ b/src/app/pages/persons/internal-person/internal-person-details/internal-person-details.sandbox.spec.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -26,7 +26,7 @@
beforeEach(async(() => {
router = { navigateByUrl() {} } as any;
- appState = { dispatch:()=> {}, pipe: () => of(true), select:()=> of(true) } as any;
+ appState = { dispatch: () => {}, pipe: () => of(true), select: () => of(true) } as any;
actionSubject = { pipe: () => of([]) } as any;
utilService = { displayNotification: () => {} } as any;
modalService = { open() {} } as any;
@@ -43,7 +43,7 @@
it('should call dispatch if load an internal person', () => {
const spy = spyOn(appState, 'dispatch');
component.loadInternalPerson('ID');
- expect(spy).toHaveBeenCalledWith( Object({ payload: 'ID', type: internalPersonActions.loadInternalPersonDetail.type }));
+ expect(spy).toHaveBeenCalledWith(Object({ payload: 'ID', type: internalPersonActions.loadInternalPersonDetail.type }));
});
it('should call dispatch 5 times if persist an existing internal person with unique uid and no userref', () => {
@@ -58,7 +58,7 @@
internalPerson.lastName = 'test';
internalPerson.uid = 'uid';
internalPerson.userRef = undefined;
- component.internalPersonDetailsCurrentFormState = {...component.internalPersonDetailsCurrentFormState, isValid: true, value: internalPerson};
+ component.internalPersonDetailsCurrentFormState = { ...component.internalPersonDetailsCurrentFormState, isValid: true, value: internalPerson };
component.persistInternalPerson();
expect(spy).toHaveBeenCalledTimes(6);
expect(routerSpy).toHaveBeenCalled();
@@ -78,7 +78,7 @@
internalPerson.lastName = 'test';
internalPerson.uid = undefined;
internalPerson.userRef = 'userref';
- component.internalPersonDetailsCurrentFormState = {...component.internalPersonDetailsCurrentFormState, isValid: true, value: internalPerson};
+ component.internalPersonDetailsCurrentFormState = { ...component.internalPersonDetailsCurrentFormState, isValid: true, value: internalPerson };
component.persistInternalPerson();
expect(spy).toHaveBeenCalledTimes(5);
expect(routerSpy).toHaveBeenCalled();
@@ -88,7 +88,7 @@
it('should call error with displayNotification if for not valid', () => {
const utilSpy = spyOn(utilService, 'displayNotification');
- component.internalPersonDetailsCurrentFormState = {...component.internalPersonDetailsCurrentFormState, isValid: false};
+ component.internalPersonDetailsCurrentFormState = { ...component.internalPersonDetailsCurrentFormState, isValid: false };
component.persistInternalPerson();
expect(utilSpy).toHaveBeenCalled();
});
@@ -101,14 +101,20 @@
it('should call dispatch if load an internal person communications Data', () => {
const spy = spyOn(appState, 'dispatch');
component.loadCommunicationsData('ID');
- expect(spy).toHaveBeenCalledWith( Object({ payload: 'ID', type: internalPersonActions.loadInternalPersonDetailCommunicationsData.type }));
+ expect(spy).toHaveBeenCalledWith(Object({ payload: 'ID', type: internalPersonActions.loadInternalPersonDetailCommunicationsData.type }));
});
it('should call dispatch if load an internal person communicationsData details', () => {
const spy = spyOn(appState, 'dispatch');
- component.internalPersonContactId = 'contactId'
+ component.internalPersonContactId = 'contactId';
component.loadCommunicationsDataDetails('ID');
- expect(spy).toHaveBeenCalledWith( Object({ payload_contactId: 'contactId', payload_communicationsId: 'ID', type: internalPersonActions.loadInternalPersonDetailCommunicationsDataDetails.type }));
+ expect(spy).toHaveBeenCalledWith(
+ Object({
+ payload_contactId: 'contactId',
+ payload_communicationsId: 'ID',
+ type: internalPersonActions.loadInternalPersonDetailCommunicationsDataDetails.type,
+ })
+ );
});
it('should can register communicationsData events and set the communicationsDataDetailsCurrentFormState', () => {
@@ -116,9 +122,9 @@
expect(component.communicationsDataDetailsCurrentFormState).toBeDefined();
});
- it('should call dispatch if clearInternalPerson', () => {
+ it('should call dispatch if newInternalPerson', () => {
const spy = spyOn(appState, 'dispatch');
- component.clearInternalPerson();
+ component.newInternalPerson();
expect(spy).toHaveBeenCalledTimes(3);
});
@@ -135,15 +141,19 @@
internalPersonCommunicationsData.communicationTypeType = 'test';
internalPersonCommunicationsData.contactId = 'id';
- component.communicationsDataDetailsCurrentFormState = {...component.communicationsDataDetailsCurrentFormState, isValid: true, value: internalPersonCommunicationsData};
+ component.communicationsDataDetailsCurrentFormState = {
+ ...component.communicationsDataDetailsCurrentFormState,
+ isValid: true,
+ value: internalPersonCommunicationsData,
+ };
component.persistCommunicationsData();
- expect(spy).toHaveBeenCalledWith( Object({ payload: internalPersonCommunicationsData, type: internalPersonActions.persistCommunicationsDataDetail.type }));
+ expect(spy).toHaveBeenCalledWith(Object({ payload: internalPersonCommunicationsData, type: internalPersonActions.persistCommunicationsDataDetail.type }));
expect(spy1).toHaveBeenCalled();
});
it('should call error with displayNotification if communicationsData form not valid', () => {
const utilSpy = spyOn(utilService, 'displayNotification');
- component.communicationsDataDetailsCurrentFormState = {...component.communicationsDataDetailsCurrentFormState, isValid: false};
+ component.communicationsDataDetailsCurrentFormState = { ...component.communicationsDataDetailsCurrentFormState, isValid: false };
component.persistCommunicationsData();
expect(utilSpy).toHaveBeenCalled();
});
@@ -157,23 +167,24 @@
});
it('should open modal before deleting an communicationsData', () => {
- spyOn(component['modalService'], 'open')
- .and.returnValue({componentInstance: {title: ''}, result: {then: () => of(true)}} as any);
- component.deleteCommunicationsData(new CommunicationsData());
+ spyOn(component['modalService'], 'open').and.returnValue({ componentInstance: { title: '' }, result: { then: () => of(true) } } as any);
+ component.deleteCommunicationsData(new CommunicationsData());
expect(modalService.open).toHaveBeenCalled();
});
it('should call dispatch if load an internal person addresses', () => {
const spy = spyOn(appState, 'dispatch');
component.loadInternalPersonAddresses('ID');
- expect(spy).toHaveBeenCalledWith( Object({ payload: 'ID', type: internalPersonActions.loadInternalPersonDetailAddresses.type }));
+ expect(spy).toHaveBeenCalledWith(Object({ payload: 'ID', type: internalPersonActions.loadInternalPersonDetailAddresses.type }));
});
it('should call dispatch if load an internal person address details', () => {
const spy = spyOn(appState, 'dispatch');
component.internalPersonContactId = 'contactId';
component.loadInternalPersonDetailsAddressDetails('ID');
- expect(spy).toHaveBeenCalledWith( Object({ payload_contactId: 'contactId', payload_addressId: 'ID', type: internalPersonActions.loadInternalPersonDetailAddressDetails.type }));
+ expect(spy).toHaveBeenCalledWith(
+ Object({ payload_contactId: 'contactId', payload_addressId: 'ID', type: internalPersonActions.loadInternalPersonDetailAddressDetails.type })
+ );
});
it('should can register address events and set the addressDetailsCurrentFormState', () => {
@@ -181,15 +192,9 @@
expect(component.addressDetailsCurrentFormState).toBeDefined();
});
- it('should call dispatch if clearInternalPerson', () => {
- const spy = spyOn(appState, 'dispatch');
- component.clearInternalPerson();
- expect(spy).toHaveBeenCalledTimes(3);
- });
-
it('should call dispatch if clearAddressData', () => {
const spy = spyOn(appState, 'dispatch');
- (component as any).clearAddressData();
+ component.clearAddressData();
expect(spy).toHaveBeenCalledTimes(2);
});
@@ -200,15 +205,15 @@
internalPersonAddress.addressTypeType = 'test';
internalPersonAddress.contactId = 'id';
- component.addressDetailsCurrentFormState = {...component.addressDetailsCurrentFormState, isValid: true, value: internalPersonAddress};
+ component.addressDetailsCurrentFormState = { ...component.addressDetailsCurrentFormState, isValid: true, value: internalPersonAddress };
component.persistAddress();
- expect(spy).toHaveBeenCalledWith( Object({ payload: internalPersonAddress, type: internalPersonActions.persistAddressDetail.type }));
+ expect(spy).toHaveBeenCalledWith(Object({ payload: internalPersonAddress, type: internalPersonActions.persistAddressDetail.type }));
expect(spy1).toHaveBeenCalled();
});
it('should call error with displayNotification if address form not valid', () => {
const utilSpy = spyOn(utilService, 'displayNotification');
- component.addressDetailsCurrentFormState = {...component.addressDetailsCurrentFormState, isValid: false};
+ component.addressDetailsCurrentFormState = { ...component.addressDetailsCurrentFormState, isValid: false };
component.persistAddress();
expect(utilSpy).toHaveBeenCalled();
});
@@ -220,16 +225,15 @@
expect(spy).toHaveBeenCalled();
expect(component.isAddressDataDetailViewVisible).toBe(false);
});
-
+
it('should open modal before deleting an address', () => {
- spyOn(component['modalService'], 'open')
- .and.returnValue({componentInstance: {title: ''}, result: {then: () => of(true)}} as any);
- component.deleteAddress(new Address());
+ spyOn(component['modalService'], 'open').and.returnValue({ componentInstance: { title: '' }, result: { then: () => of(true) } } as any);
+ component.deleteAddress(new Address());
expect(modalService.open).toHaveBeenCalled();
});
-
+
it('should go in for-loop and set property "existMainAddress"', () => {
- let address: Address = {
+ let address: Address = {
id: '',
contactId: '',
isMainAddress: false,
@@ -245,7 +249,7 @@
latitude: '',
longitude: '',
urlMap: '',
- note: ''
+ note: '',
};
const addresses: Array<Address> = [address];
(component as any)._checkIfMainAddressExist(addresses);
@@ -256,4 +260,23 @@
(component as any)._checkIfMainAddressExist(addresses);
expect(component.existMainAddress).toBeTruthy();
});
+
+ it('should call clear and markastouched if newAddressData', () => {
+ const spy = spyOn(appState, 'dispatch');
+ component.newAddressData();
+ expect(spy).toHaveBeenCalledTimes(3);
+ expect(component.isCurrentAddressMainAddress).toBeFalsy();
+ });
+
+ it('should call clear and markastouched if newCommunicationsData', () => {
+ const spy = spyOn(appState, 'dispatch');
+ component.newCommunicationsData();
+ expect(spy).toHaveBeenCalledTimes(3);
+ });
+
+ it('should call dispatch if clearInternalPerson', () => {
+ const spy = spyOn(appState, 'dispatch');
+ component.clearInternalPerson();
+ expect(spy).toHaveBeenCalledTimes(2);
+ });
});
diff --git a/src/app/pages/persons/internal-person/internal-person-details/internal-person-details.sandbox.ts b/src/app/pages/persons/internal-person/internal-person-details/internal-person-details.sandbox.ts
index 888bd1d..dd2c0dd 100644
--- a/src/app/pages/persons/internal-person/internal-person-details/internal-person-details.sandbox.ts
+++ b/src/app/pages/persons/internal-person/internal-person-details/internal-person-details.sandbox.ts
@@ -164,7 +164,7 @@
});
this.actionsSubject.pipe(ofType(internalPersonActions.persistInternalPersonDetailSuccess), take(1), takeUntil(this._endSubscriptions$)).subscribe(() => {
- this.clearInternalPerson();
+ this.newInternalPerson();
this.router.navigateByUrl(`/overview`);
});
} else {
@@ -207,10 +207,19 @@
this.isAddressDataDetailViewVisible = false;
}
+ public newInternalPerson(): void {
+ this.clearInternalPerson();
+ this.appState$.dispatch(new MarkAsTouchedAction(internalPersonDetailsFormReducer.FORM_ID));
+ }
+
public clearInternalPerson(): void {
this.appState$.dispatch(new SetValueAction(internalPersonDetailsFormReducer.FORM_ID, internalPersonDetailsFormReducer.INITIAL_STATE.value));
this.appState$.dispatch(new ResetAction(internalPersonDetailsFormReducer.FORM_ID));
- this.appState$.dispatch(new MarkAsTouchedAction(internalPersonDetailsFormReducer.FORM_ID));
+ }
+
+ public newAddressData(): void {
+ this.clearAddressData();
+ this.appState$.dispatch(new MarkAsTouchedAction(internalAddressDetailsFormReducer.FORM_ID));
}
public clearAddressData(): void {
@@ -301,6 +310,11 @@
this.isCommunicationsDataDetailViewVisible = false;
}
+ public newCommunicationsData(): void {
+ this.clearCommunicationsData();
+ this.appState$.dispatch(new MarkAsTouchedAction(internalCommunicationsDataDetailsFormReducer.FORM_ID));
+ }
+
public clearCommunicationsData(): void {
this.appState$.dispatch(
new SetValueAction(internalCommunicationsDataDetailsFormReducer.FORM_ID, internalCommunicationsDataDetailsFormReducer.INITIAL_STATE.value)
diff --git a/src/app/pages/persons/internal-person/internal-person.resolver.spec.ts b/src/app/pages/persons/internal-person/internal-person.resolver.spec.ts
index 1f2cb62..569dc36 100644
--- a/src/app/pages/persons/internal-person/internal-person.resolver.spec.ts
+++ b/src/app/pages/persons/internal-person/internal-person.resolver.spec.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -23,26 +23,26 @@
beforeEach(async(() => {
internalPersonSandbox = {
- clearInternalPerson() {},
+ newInternalPerson() {},
loadInternalPerson() {},
loadCommunicationsData() {},
loadInternalPersonAddresses() {},
} as any;
salutationsSandbox = {
- loadSalutations() {}
+ loadSalutations() {},
} as any;
personTypesSandbox = {
- loadPersonTypes() {}
+ loadPersonTypes() {},
} as any;
communicationTypesSandbox = {
- loadCommunicationTypes() {}
+ loadCommunicationTypes() {},
} as any;
addressTypesSandbox = {
- loadAddressTypes() {}
+ loadAddressTypes() {},
} as any;
}));
@@ -56,21 +56,21 @@
it('should call loadInternalPerson if edit a internal person', () => {
const spy = spyOn(internalPersonSandbox, 'loadInternalPerson');
- let ar: any = {params: {contactId: 'ID'}};
+ let ar: any = { params: { contactId: 'ID' } };
component.resolve(ar);
expect(spy).toHaveBeenCalled();
});
it('should call clear if create a new internal person', () => {
- const spy = spyOn(internalPersonSandbox, 'clearInternalPerson');
- let ar: any = {params: {contactId: undefined}};
+ const spy = spyOn(internalPersonSandbox, 'newInternalPerson');
+ let ar: any = { params: { contactId: undefined } };
component.resolve(ar);
expect(spy).toHaveBeenCalled();
});
it('should loadSalutations on resolve', () => {
const spy = spyOn(salutationsSandbox, 'loadSalutations');
- let ar: any = {params: {contactId: undefined}};
+ let ar: any = { params: { contactId: undefined } };
component.resolve(ar);
expect(spy).toHaveBeenCalled();
@@ -78,21 +78,21 @@
it('should loadCommunicationTypes on resolve', () => {
const spy = spyOn(communicationTypesSandbox, 'loadCommunicationTypes');
- let ar: any = {params: {contactId: undefined}};
+ let ar: any = { params: { contactId: undefined } };
component.resolve(ar);
expect(spy).toHaveBeenCalled();
});
it('should set isCommunicationsDataDetailViewVisible true on resolve', () => {
- let ar: any = {params: {contactId: undefined}};
+ let ar: any = { params: { contactId: undefined } };
component.resolve(ar);
expect(internalPersonSandbox.isCommunicationsDataDetailViewVisible).toBeFalsy();
});
it('should set isDetailViewVisible true on resolve', () => {
- let ar: any = {params: {contactId: undefined}};
+ let ar: any = { params: { contactId: undefined } };
component.resolve(ar);
expect(internalPersonSandbox.isDetailViewVisible).toBeFalsy();
@@ -100,7 +100,7 @@
it('should loadPersonTypes on resolve', () => {
const spy = spyOn(personTypesSandbox, 'loadPersonTypes');
- let ar: any = {params: {contactId: undefined}};
+ let ar: any = { params: { contactId: undefined } };
component.resolve(ar);
expect(spy).toHaveBeenCalled();
@@ -108,7 +108,7 @@
it('should loadAddressTypes on resolve', () => {
const spy = spyOn(addressTypesSandbox, 'loadAddressTypes');
- let ar: any = {params: {contactId: undefined}};
+ let ar: any = { params: { contactId: undefined } };
component.resolve(ar);
expect(spy).toHaveBeenCalled();
diff --git a/src/app/pages/persons/internal-person/internal-person.resolver.ts b/src/app/pages/persons/internal-person/internal-person.resolver.ts
index 5899a10..671a81a 100644
--- a/src/app/pages/persons/internal-person/internal-person.resolver.ts
+++ b/src/app/pages/persons/internal-person/internal-person.resolver.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -19,27 +19,26 @@
import { AddressTypesSandbox } from '@pages/admin/address-types/address-types.sandbox';
@Injectable()
-export class InternalPersonResolver implements Resolve<any>{
-
+export class InternalPersonResolver implements Resolve<any> {
constructor(
private internalPersonSandbox: InternalPersonDetailsSandBox,
private salutationsSandbox: SalutationsSandbox,
private communicationTypesSandbox: CommunicationTypesSandbox,
private personTypesSandbox: PersonTypesSandbox,
private addressTypesSandbox: AddressTypesSandbox
- ) { }
+ ) {}
/**
* @param route
*/
public resolve(route: ActivatedRouteSnapshot): void {
const contactId: string = route.params['contactId'];
- if (contactId && (contactId !== 'new')) {
- this.internalPersonSandbox.loadInternalPerson(contactId);
- this.internalPersonSandbox.loadCommunicationsData(contactId);
- this.internalPersonSandbox.loadInternalPersonAddresses(contactId);
+ if (contactId && contactId !== 'new') {
+ this.internalPersonSandbox.loadInternalPerson(contactId);
+ this.internalPersonSandbox.loadCommunicationsData(contactId);
+ this.internalPersonSandbox.loadInternalPersonAddresses(contactId);
} else {
- this.internalPersonSandbox.clearInternalPerson();
+ this.internalPersonSandbox.newInternalPerson();
}
this.salutationsSandbox.loadSalutations();
@@ -48,5 +47,4 @@
this.addressTypesSandbox.loadAddressTypes();
this.internalPersonSandbox.isCommunicationsDataDetailViewVisible = false;
}
-
}
diff --git a/src/app/shared/components/index.ts b/src/app/shared/components/index.ts
index 733c441..10109a4 100644
--- a/src/app/shared/components/index.ts
+++ b/src/app/shared/components/index.ts
@@ -1,5 +1,5 @@
import { ExpandableComponent } from './expandable/expandable.component';
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -28,7 +28,6 @@
import { PageNotFoundComponent } from '@shared/components/pageNotFound/pageNotFound.component';
import { LoadingPlaceholderComponent } from '@shared/components/loadingPlaceholder/loadingPlaceholder.component';
import { VersionInfo } from '@shared/components/version-info/version-info.component';
-
import { AngularFontAwesomeModule } from 'angular-font-awesome';
export const COMPONENTS = [
@@ -44,19 +43,13 @@
SafetyQueryDialogComponent,
ExpandableComponent,
SafetyQueryDialogComponent,
- BoolCellRendererComponent
+ BoolCellRendererComponent,
];
@NgModule({
imports: [RouterModule, AngularFontAwesomeModule, FormsModule, ReactiveFormsModule, CommonModule, TranslateModule, PipesModule],
declarations: COMPONENTS,
exports: COMPONENTS,
- entryComponents: [
- PaginatorComponent,
- ContactTypeCellRendererComponent,
- IconCellRendererComponent,
- SafetyQueryDialogComponent,
- BoolCellRendererComponent
- ],
+ entryComponents: [PaginatorComponent, ContactTypeCellRendererComponent, IconCellRendererComponent, SafetyQueryDialogComponent, BoolCellRendererComponent],
})
export class ComponentsModule {}
diff --git a/src/app/shared/containers/layout/layout.container.html b/src/app/shared/containers/layout/layout.container.html
index 5656268..e126a96 100644
--- a/src/app/shared/containers/layout/layout.container.html
+++ b/src/app/shared/containers/layout/layout.container.html
@@ -10,12 +10,8 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/ -->
-<app-header
-style="position: absolute; left: 0px; right: 0px;"
- (logout)="layoutSandbox.logout()"
- [userName]="(user$ | async)?.name"
-></app-header>
+<app-header style="position: absolute; left: 0px; right: 0px;" [userName]="(user$ | async)?.name"></app-header>
<div class="layout-content">
- <ng-content ></ng-content>
+ <ng-content></ng-content>
</div>
diff --git a/src/app/shared/containers/layout/layout.sandbox.spec.ts b/src/app/shared/containers/layout/layout.sandbox.spec.ts
index e950833..d518ba0 100644
--- a/src/app/shared/containers/layout/layout.sandbox.spec.ts
+++ b/src/app/shared/containers/layout/layout.sandbox.spec.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -14,21 +14,18 @@
import { TranslateService } from '@ngx-translate/core';
import { Store } from '@ngrx/store';
import * as store from '@shared/store';
-import { Router } from '@angular/router';
import { of } from 'rxjs';
describe('LayoutSandbox', () => {
let service: LayoutSandbox = {} as any;
let translateService: TranslateService;
let appState: Store<store.State>;
- let router: Router;
beforeEach(() => {
- appState = { dispatch:()=> {}, pipe: () => of(true), select:()=> of(true) } as any;
- router = { navigateByUrl() {} } as any;
+ appState = { dispatch: () => {}, pipe: () => of(true), select: () => of(true) } as any;
translateService = { addLangs() {}, setDefaultLang() {}, use() {} } as any;
- service = new LayoutSandbox(appState, translateService, router);
+ service = new LayoutSandbox(appState, translateService);
});
it('should create LayoutSandbox service', () => {
@@ -36,20 +33,11 @@
expect(service).toBeDefined();
});
- it('should call clearStorage and removeUser on logout', () => {
- const spy1 = spyOn(service, 'clearStorage');
- const spy2 = spyOn(service, 'removeUser');
- service.logout();
- expect(spy1).toHaveBeenCalled();
- expect(spy2).toHaveBeenCalled();
- });
-
it('should call dispatch and translateService.use on selectLanguage', () => {
- const spy1 = spyOn(appState, 'dispatch');
- const spy2 = spyOn(translateService, 'use');
- service.selectLanguage({});
- expect(spy1).toHaveBeenCalled();
- expect(spy2).toHaveBeenCalled();
- });
-
+ const spy1 = spyOn(appState, 'dispatch');
+ const spy2 = spyOn(translateService, 'use');
+ service.selectLanguage({});
+ expect(spy1).toHaveBeenCalled();
+ expect(spy2).toHaveBeenCalled();
+ });
});
diff --git a/src/app/shared/containers/layout/layout.sandbox.ts b/src/app/shared/containers/layout/layout.sandbox.ts
index c7a5031..6e77cb4 100644
--- a/src/app/shared/containers/layout/layout.sandbox.ts
+++ b/src/app/shared/containers/layout/layout.sandbox.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -11,21 +11,17 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import { Injectable } from '@angular/core';
-import { Router } from '@angular/router';
-import { BaseSandbox } from '@shared/sandbox/base.sandbox';
import { Store } from '@ngrx/store';
import * as store from '@shared/store';
import * as settingsActions from '@shared/store/actions/settings.action';
import { TranslateService } from '@ngx-translate/core';
@Injectable()
-export class LayoutSandbox extends BaseSandbox {
+export class LayoutSandbox {
public selectedLang$ = this.appState$.select(store.getSelectedLanguage);
public availableLanguages$ = this.appState$.select(store.getAvailableLanguages);
- constructor(protected appState$: Store<store.State>, private translateService: TranslateService, private router: Router) {
- super(appState$);
- }
+ constructor(protected appState$: Store<store.State>, private translateService: TranslateService) {}
public selectLanguage(lang: any): void {
this.appState$.dispatch(settingsActions.setLanguage({ payload: lang.code }));
@@ -33,9 +29,4 @@
this.appState$.dispatch(settingsActions.setCulture({ payload: lang.culture }));
this.translateService.use(lang.code);
}
-
- public logout() {
- this.clearStorage();
- this.removeUser();
- }
}
diff --git a/src/app/shared/store/actions/logout/logout.action.ts b/src/app/shared/store/actions/logout/logout.action.ts
new file mode 100644
index 0000000..f3d3909
--- /dev/null
+++ b/src/app/shared/store/actions/logout/logout.action.ts
@@ -0,0 +1,24 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+import { createAction, props } from '@ngrx/store';
+
+export interface ILogoutSuccess {
+ payload: string;
+}
+
+export interface ILogoutFail {
+ payload: string;
+}
+export const logout = createAction('[Logout] Logout');
+export const logoutSuccess = createAction('[Logout] Logout Success', props<ILogoutSuccess>());
+export const logoutFail = createAction('[Logout] Logout Fail', props<ILogoutFail>());
diff --git a/src/app/shared/store/effects/logout/logout.effect.ts b/src/app/shared/store/effects/logout/logout.effect.ts
new file mode 100644
index 0000000..dcff7a2
--- /dev/null
+++ b/src/app/shared/store/effects/logout/logout.effect.ts
@@ -0,0 +1,39 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+import 'rxjs/add/operator/catch';
+import 'rxjs/add/operator/map';
+import 'rxjs/add/operator/switchMap';
+import { Injectable } from '@angular/core';
+import { createEffect, Actions, ofType } from '@ngrx/effects';
+import { of } from 'rxjs/observable/of';
+import * as logoutActions from '@shared/store/actions/logout/logout.action';
+import { catchError, map, switchMap } from 'rxjs/operators';
+import { LogoutApiClient } from '@pages/logout/logout-api-client';
+
+@Injectable()
+export class LogoutEffects {
+ logout$: any = createEffect(() =>
+ this.actions$.pipe(
+ ofType(logoutActions.logout),
+ map(action => action['payload']),
+ switchMap(() => {
+ return this.logoutApiClient.logout().pipe(
+ map(response => logoutActions.logoutSuccess({ payload: response })),
+ catchError(error => of(logoutActions.logoutFail({ payload: error })))
+ );
+ })
+ )
+ );
+
+ constructor(private actions$: Actions, private logoutApiClient: LogoutApiClient) {}
+}
diff --git a/src/app/shared/store/effects/logout/logout.effects.spec.ts b/src/app/shared/store/effects/logout/logout.effects.spec.ts
new file mode 100644
index 0000000..84a2efe
--- /dev/null
+++ b/src/app/shared/store/effects/logout/logout.effects.spec.ts
@@ -0,0 +1,54 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+import { take } from 'rxjs/operators';
+import { Subject, of, throwError } from 'rxjs';
+import * as logoutActions from '@shared/store/actions/logout/logout.action';
+import { LogoutEffects } from '@shared/store/effects/logout/logout.effect';
+import { LogoutApiClient } from '@pages/logout/logout-api-client';
+
+describe('Logout Effects', () => {
+ let effects: LogoutEffects;
+ let actions$: Subject<any>;
+ let apiClient: LogoutApiClient;
+
+ beforeEach(() => {
+ apiClient = {
+ logout() {},
+ } as any;
+ actions$ = new Subject();
+ effects = new LogoutEffects(actions$, apiClient);
+ });
+
+ it('should be truthy', () => {
+ expect(effects).toBeTruthy();
+ });
+
+ it('should equal logoutSuccess after logout', done => {
+ let request = 'test';
+ spyOn(apiClient, 'logout').and.returnValue(of(request));
+ effects.logout$.pipe(take(1)).subscribe(result => {
+ expect(result).toEqual(logoutActions.logoutSuccess({ payload: request }));
+ });
+ done();
+ actions$.next(logoutActions.logout());
+ });
+
+ it('should equal logoutFail after logout Error', done => {
+ spyOn(apiClient, 'logout').and.returnValue(throwError('x'));
+ effects.logout$.pipe(take(1)).subscribe(result => {
+ expect(result).toEqual(logoutActions.logoutFail({ payload: 'x' }));
+ });
+ done();
+ actions$.next(logoutActions.logout());
+ });
+});
diff --git a/src/app/shared/store/reducers/settings.reducer.ts b/src/app/shared/store/reducers/settings.reducer.ts
index 5757bb5..4ce6059 100644
--- a/src/app/shared/store/reducers/settings.reducer.ts
+++ b/src/app/shared/store/reducers/settings.reducer.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -26,8 +26,8 @@
export const INITIAL_STATE: State = {
selectedLanguage: '',
selectedCulture: '',
- availableLanguages: [{ code: 'de', name: 'DE', culture: 'de-DE' }, { code: 'en', name: 'EN', culture: 'en-EN' }],
- user: new User()
+ availableLanguages: [{ code: 'de', name: 'DE', culture: 'de-DE' }],
+ user: new User(),
};
export const settingsReducer = createReducer(