+
-
-
-
-
+
-
+
diff --git a/dashboard/entity/entities.component.ts b/dashboard/entity/entities.component.ts
index b6600429..afd5968d 100644
--- a/dashboard/entity/entities.component.ts
+++ b/dashboard/entity/entities.component.ts
@@ -1,17 +1,17 @@
-import {Component, ViewChild, OnInit, ElementRef} from '@angular/core';
+import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {HelpContentService} from '../../services/help-content.service';
-import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
+import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {CheckEntity, Entity} from '../../utils/entities/adminTool/entity';
import {Portal} from '../../utils/entities/adminTool/portal';
import {EnvProperties} from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
-import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {UserManagementService} from '../../services/user-management.service';
import {Subscriber} from "rxjs";
import {properties} from "../../../../environments/environment";
import {ConnectHelper} from "../../connect/connectHelper";
+import {AlertModal} from "../../utils/modal/alert";
@Component({
selector: 'entities',
@@ -20,15 +20,16 @@ import {ConnectHelper} from "../../connect/connectHelper";
export class EntitiesComponent implements OnInit {
- @ViewChild('AlertModalSaveEntity') alertModalSaveEntity;
- @ViewChild('AlertModalDeleteEntities') alertModalDeleteEntities;
+ @ViewChild('editModal') editModal: AlertModal;
+ @ViewChild('deleteModal') deleteModal: AlertModal;
+ @ViewChild('relatedPages') relatedPages: AlertModal;
private selectedEntities: string[] = [];
public checkboxes: CheckEntity[] = [];
public entities: Entity[] = [];
- public myForm: FormGroup;
+ public entityForm: FormGroup;
private searchText: RegExp = new RegExp('');
public keyword = '';
@@ -36,8 +37,6 @@ export class EntitiesComponent implements OnInit {
public communities: Portal[] = [];
public portal: string;
- @ViewChild('AlertModalRelatedPages') alertModalRelatedPages;
-
public toggleIds: string[];
public toggleStatus: boolean;
public properties: EnvProperties = properties;
@@ -49,6 +48,7 @@ export class EntitiesComponent implements OnInit {
public isPortalAdministrator = null;
public filterForm: FormGroup;
private subscriptions: any[] = [];
+ private index: number;
constructor(private element: ElementRef, private route: ActivatedRoute,
private _router: Router,
@@ -61,13 +61,6 @@ export class EntitiesComponent implements OnInit {
keyword: [''],
status: ['all', Validators.required]
});
-
- this.myForm = this._fb.group({
- pid: ['', Validators.required],
- name: ['', Validators.required],
- isEnabled: '',
- _id: ''
- });
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
this.filterBySearch(value);
}));
@@ -149,9 +142,10 @@ export class EntitiesComponent implements OnInit {
private deleteEntitiesFromArray(ids: string[]): void {
for (let id of ids) {
- const i = this.checkboxes.findIndex(_ => _.entity._id === id);
- this.checkboxes.splice(i, 1);
+ let i = this.entities.findIndex(_ => _._id == id);
+ this.entities.splice(i, 1);
}
+ this.applyFilter();
}
public confirmDeleteEntity(id: string) {
@@ -173,12 +167,12 @@ export class EntitiesComponent implements OnInit {
this._router.navigate(['/user-info'],
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else {
- this.alertModalDeleteEntities.cancelButton = true;
- this.alertModalDeleteEntities.okButton = true;
- this.alertModalDeleteEntities.alertTitle = 'Delete Confirmation';
- this.alertModalDeleteEntities.message = 'Are you sure you want to delete the selected entity(-ies)?';
- this.alertModalDeleteEntities.okButtonText = 'Yes';
- this.alertModalDeleteEntities.open();
+ this.deleteModal.cancelButton = true;
+ this.deleteModal.okButton = true;
+ this.deleteModal.alertTitle = 'Delete Confirmation';
+ this.deleteModal.message = 'Are you sure you want to delete the selected entity(-ies)?';
+ this.deleteModal.okButtonText = 'Yes';
+ this.deleteModal.open();
}
}
@@ -202,36 +196,37 @@ export class EntitiesComponent implements OnInit {
public editEntity(i: number) {
const entity: Entity = this.checkboxes[i].entity;
- this.myForm = this._fb.group({
- name: [entity.name, Validators.required],
- _id: entity._id,
- pid: [entity.pid, Validators.required],
+ this.index = this.entities.findIndex(value => value._id === entity._id);
+ this.entityForm = this._fb.group({
+ name: this._fb.control(entity.name, Validators.required),
+ _id: this._fb.control(entity._id),
+ pid: this._fb.control(entity.pid, Validators.required)
});
this.modalErrorMessage = '';
- this.entitiesModalOpen(this.alertModalSaveEntity, '', 'Save Changes');
+ this.entitiesModalOpen('Edit Entity', 'Save Changes');
}
public newEntity() {
- this.myForm = this._fb.group({
- pid: ['', Validators.required],
- name: ['', Validators.required],
- isEnabled: '',
- _id: ''
+ this.entityForm = this._fb.group({
+ _id: this._fb.control(null),
+ name: this._fb.control('', Validators.required),
+ pid: this._fb.control('', Validators.required)
});
this.modalErrorMessage = '';
- this.entitiesModalOpen(this.alertModalSaveEntity, '', 'Save');
+ this.entitiesModalOpen('Create Entity', 'Create');
}
- private entitiesModalOpen(modal: any, title: string, yesBtn: string) {
+ private entitiesModalOpen(title: string, yesBtn: string) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'],
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else {
- modal.cancelButton = true;
- modal.okButton = true;
- modal.alertTitle = title;
- modal.okButtonText = yesBtn;
- modal.open();
+ this.editModal.cancelButton = true;
+ this.editModal.okButton = true;
+ this.editModal.okButtonLeft = false;
+ this.editModal.alertTitle = title;
+ this.editModal.okButtonText = yesBtn;
+ this.editModal.open();
}
}
@@ -241,16 +236,16 @@ export class EntitiesComponent implements OnInit {
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else {
this.modalErrorMessage = '';
- if (this.myForm.getRawValue()['_id'].length > 0) {
+ if (this.entityForm.value._id) {
this._helpContentService.updateEntity(
-
this.myForm.value, this.properties.adminToolsAPIURL).subscribe(
+ this.entityForm.value, this.properties.adminToolsAPIURL).subscribe(
entity => {
this.entityUpdatedSuccessfully(entity);
},
error => this.handleUpdateError('System error updating entity', error)
);
} else {
- this._helpContentService.saveEntity(this.myForm.value, this.properties.adminToolsAPIURL).subscribe(
+ this._helpContentService.saveEntity(this.entityForm.value, this.properties.adminToolsAPIURL).subscribe(
entity => {
this.entitySavedSuccessfully(entity);
},
@@ -262,12 +257,14 @@ export class EntitiesComponent implements OnInit {
public entitySavedSuccessfully(entity: Entity) {
- this.checkboxes.push({entity: entity, checked: false});
+ this.entities.push(entity);
+ this.applyFilter();
this.applyCheck(false);
}
public entityUpdatedSuccessfully(entity: Entity) {
- this.checkboxes.find(checkItem => checkItem.entity._id === entity._id).entity = entity;
+ this.entities[this.index] = entity;
+ this.applyFilter();
this.applyCheck(false);
}
@@ -309,7 +306,7 @@ export class EntitiesComponent implements OnInit {
handleUpdateError(message: string, error) {
if (error == null) {
- this.myForm = this._fb.group({
+ this.entityForm = this._fb.group({
pid: ['', Validators.required],
name: ['', Validators.required],
isEnabled: '',
@@ -339,12 +336,12 @@ export class EntitiesComponent implements OnInit {
this._router.navigate(['/user-info'],
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else {
- this.alertModalRelatedPages.cancelButton = true;
- this.alertModalRelatedPages.okButton = true;
- this.alertModalRelatedPages.alertTitle = 'Warning';
- this.alertModalRelatedPages.message = "This action will affect all search pages related to this entity! Pages' status will change to entity's status! Do you want to continue?";
- this.alertModalRelatedPages.okButtonText = 'Yes';
- this.alertModalRelatedPages.open();
+ this.relatedPages.cancelButton = true;
+ this.relatedPages.okButton = true;
+ this.relatedPages.alertTitle = 'Warning';
+ this.relatedPages.message = "This action will affect all search pages related to this entity! Pages' status will change to entity's status! Do you want to continue?";
+ this.relatedPages.okButtonText = 'Yes';
+ this.relatedPages.open();
}
}
diff --git a/dashboard/page/pages.component.html b/dashboard/page/pages.component.html
index ff96afbc..9a3c4add 100644
--- a/dashboard/page/pages.component.html
+++ b/dashboard/page/pages.component.html
@@ -121,15 +121,9 @@
-
-
@@ -137,85 +131,52 @@
-