From f77836983887db7945b214ea724343f918f052b4 Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Thu, 11 Jan 2018 12:06:04 +0000 Subject: [PATCH] Deleting unused files helpcontent/selectEntities.component git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@50281 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../helpcontent/selectEntities.component.html | 97 ---------- .../helpcontent/selectEntities.component.ts | 180 ------------------ 2 files changed, 277 deletions(-) delete mode 100644 app/pages/helpcontent/selectEntities.component.html delete mode 100644 app/pages/helpcontent/selectEntities.component.ts diff --git a/app/pages/helpcontent/selectEntities.component.html b/app/pages/helpcontent/selectEntities.component.html deleted file mode 100644 index bf41291..0000000 --- a/app/pages/helpcontent/selectEntities.component.html +++ /dev/null @@ -1,97 +0,0 @@ -
-
- - -
-
-
- - - -
-
-
-
- -
- -
- -
-
-
- - - -
- - -
-
No entities found
-
-
-
-
-
-
-
-
-
-
- - - - - - - - - - Are you sure you want to delete the selected entity(-ies)? - diff --git a/app/pages/helpcontent/selectEntities.component.ts b/app/pages/helpcontent/selectEntities.component.ts deleted file mode 100644 index aca4dd6..0000000 --- a/app/pages/helpcontent/selectEntities.component.ts +++ /dev/null @@ -1,180 +0,0 @@ -import { Component, ViewChild, OnInit } from '@angular/core'; -import { HelpContentService } from "../../services/help-content.service"; -import { FormGroup } from "@angular/forms"; -import { ModalFormComponent } from "../modal-form.component"; -import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component"; -import { EntityFormComponent } from "./entity-form.component"; -import { CheckEntity, Entity } from "../../domain/entity"; -import { Community } from "../../domain/community"; - -@Component({ - selector: 'selectEntities', - templateUrl: './selectEntities.component.html', -}) - -export class SelectEntitiesComponent implements OnInit { - - // @ViewChild(ModalFormComponent) - @ViewChild('saveModal') - public modal:ModalFormComponent; - - @ViewChild('updateModal') - public updateModal:ModalFormComponent; - - @ViewChild('deleteConfirmationModal') - public deleteConfirmationModal : DeleteConfirmationDialogComponent; - - @ViewChild(EntityFormComponent) - public formComponent : EntityFormComponent; - - public entitiesCheckboxes : CheckEntity[] = []; - - public entities : Entity[] = []; - - public errorMessage: string; - - public formGroup : FormGroup; - - private searchText : RegExp = new RegExp(''); - - public communities: Community[] = []; - - public selectedCommunityId: string; - - ngOnInit() { - this.getCommunities(); - - this.formGroup = this.formComponent.form; - } - - constructor(private _helpContentService: HelpContentService) {} - - getCommunities() { - let self = this; - this._helpContentService.getCommunities().subscribe( - communities => { - self.communities = communities; - self.getEntities(self.communities[0]._id); - self.selectedCommunityId = self.communities[0]._id; - }, - error => this.handleError('System error retrieving communities', error)); - } - - getEntities(community_id: string) { - let self = this; - this._helpContentService.getCommunityEntities(community_id).subscribe( - entities => { - self.entities = entities; - self.entitiesCheckboxes = []; - - entities.forEach(_ => { - self.entitiesCheckboxes.push({entity : _, checked : false}); - }); - }, - error => this.handleError('System error retrieving entities', error)); - } - - public showModal():void { - this.modal.showModal(); - } - - public toggleCheckBoxes(event) { - this.entitiesCheckboxes.forEach(_ => _.checked = event.target.checked); - } - - public applyCheck(flag : boolean) { - console.info("applyCheck "+flag); - this.entitiesCheckboxes.forEach(_ => _.checked = flag); - } - - public getSelectedEntities() : string[] { - return this.entitiesCheckboxes.filter(entity => entity.checked == true).map(checkedEntity => checkedEntity.entity).map(res => res._id); - } - - private deleteEntitiesFromArray(ids : string[]) : void { - for(let id of ids) { - let i = this.entitiesCheckboxes.findIndex(_ => _.entity._id == id); - this.entitiesCheckboxes.splice(i, 1); - } - } - - public confirmDeleteEntity(id : string) { - this.deleteConfirmationModal.ids = [id]; - this.deleteConfirmationModal.showModal(); - } - - public confirmDeleteSelectedEntities() { - this.deleteConfirmationModal.ids = this.getSelectedEntities(); - this.deleteConfirmationModal.showModal(); - } - - public confirmedDeleteEntities(ids : string[]) { - this._helpContentService.deleteEntities(ids).subscribe( - _ => this.deleteEntitiesFromArray(ids), - error => this.handleError('System error deleting the selected entities', error) - ); - } - - public editEntity(i : number) { - let entity : Entity = this.entitiesCheckboxes[i].entity; - this.formGroup.patchValue(entity); - this.updateModal.showModal(); - } - - public entitySavedSuccessfully(entity: Entity) { - this.entitiesCheckboxes.push({entity : entity, checked : false}); - this.applyCheck(false); - } - - public entityUpdatedSuccessfully(entity : Entity) { - this.entitiesCheckboxes.find(checkItem => checkItem.entity._id==entity._id).entity = entity; - this.applyCheck(false); - } - - public filterBySearch(text : string) { - this.searchText = new RegExp(text,'i'); - this.applyFilter(); - } - - public applyFilter() { - this.entitiesCheckboxes = []; - this.entities.filter(item => this.filterEntities(item)).forEach( - _ => this.entitiesCheckboxes.push({entity: _, checked: false}) - ); - } - - public filterEntities(entity : Entity) : boolean { - let textFlag = this.searchText.toString() == '' || (entity.name).match(this.searchText) != null; - return textFlag; - } - - handleError(message: string, error) { - if(error == null) { - this.formComponent.reset(); - } - this.errorMessage = message + ' (Server responded: ' + error + ')'; - } - - - - public filterByCommunity(event: any) { - this.selectedCommunityId = event.target.value; - this.applyCommunityFilter(this.selectedCommunityId); - } - - public applyCommunityFilter(community_id: string) { - this.getEntities(community_id); - } - - public toggleEntity(status : boolean, id : string) { - this._helpContentService.toggleEntity(this.selectedCommunityId,id,status).subscribe( - () => { - let i = this.entitiesCheckboxes.findIndex(_ => _.entity._id == id); - this.entitiesCheckboxes[i].entity.isEnabled=status; - this.applyCheck(false); - }, - error => this.handleError('System error changing the status of the selected entity(-ies)', error) - ); - } - - }