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
This commit is contained in:
parent
527f3744cb
commit
f778369838
|
@ -1,97 +0,0 @@
|
||||||
<div id="entities">
|
|
||||||
<div id="content">
|
|
||||||
<div class="menubar fixed">
|
|
||||||
<div class="sidebar-toggler visible-xs">
|
|
||||||
<i class="ion-navicon"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="entity-title">Entities</div>
|
|
||||||
<form target="BSFormPanel_Admin_1" class="search">
|
|
||||||
<input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Search entities (name)..." type="text"/>
|
|
||||||
<input class="btn" type="submit">
|
|
||||||
</form>
|
|
||||||
<a (click)="showModal()" class="btn btn-success pull-right"><i></i> New Entity </a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content-wrapper" id="contentWrapper">
|
|
||||||
<div>
|
|
||||||
<div class="contentPanel">
|
|
||||||
<div class="uk-alert-danger" uk-alert style="display: none;" aria-hidden="true">
|
|
||||||
<span></span><span></span><span></span></div>
|
|
||||||
<div class="uk-alert-success" uk-alert style="display: none;" aria-hidden="true">
|
|
||||||
<span></span><span></span><span></span></div>
|
|
||||||
<div class="uk-alert" uk-alert style="display: none;" aria-hidden="true"><span></span><span></span><span></span></div>
|
|
||||||
<div>
|
|
||||||
<div class="gwt-HTML">
|
|
||||||
<div class="row users-list">
|
|
||||||
<div class="col-md-12">
|
|
||||||
|
|
||||||
<div class="filters marginBottom20">
|
|
||||||
<div class="links form-group form-inline">
|
|
||||||
<div class="gwt-Label filterLabel">Filter by community:</div>
|
|
||||||
<select class="input-xxlarge form-control" (change)="filterByCommunity($event)">
|
|
||||||
<!--option value="">-- none selected --</option-->
|
|
||||||
<option *ngFor="let community of communities" value="{{community._id}}">{{community.name}}</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row headers">
|
|
||||||
<div class="col-sm-1 header select-users"><input id="allEntityCheckbox" type="checkbox" (change)="toggleCheckBoxes($event)">
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-5 header hidden-xs"><label><a href="#">Name</a></label></div>
|
|
||||||
<div class="col-sm-5 header hidden-xs"><label><a href="#">State</a></label></div>
|
|
||||||
<div class="col-sm-1 header hidden-xs"><label><a href="#">Actions</a></label></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<template [ngIf]="entitiesCheckboxes && entitiesCheckboxes.length>0">
|
|
||||||
<div *ngFor="let check of entitiesCheckboxes; let i=index" class="row user">
|
|
||||||
<div class="col-sm-1 avatar"><input id="{{check.entity._id}}" class="checkBox" type="checkbox"
|
|
||||||
name="entitiescb[]" value="{{check.entity._id}}" [(ngModel)]="check.checked">
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-5">
|
|
||||||
<div class="name" href="#">{{check.entity.name}}</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-5">
|
|
||||||
<div *ngIf="check.entity.isEnabled" class="activated" >
|
|
||||||
<input (click)="toggleEntity(false,[check.entity._id])" class="deactivate" src="imgs/check-icon.png" title="Disable" width="20" type="image" height="20">
|
|
||||||
</div>
|
|
||||||
<div *ngIf="!check.entity.isEnabled" class="deactivated" >
|
|
||||||
<input (click)="toggleEntity(true,[check.entity._id])" class="deactivate" src="imgs/x-icon.png" title="Enable" width="20" type="image" height="20">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-1">
|
|
||||||
<div class="actions" href="#">
|
|
||||||
<input title="Edit" src="imgs/icn_edit.png" class="edit" type="image" (click)="editEntity(i)">
|
|
||||||
<input title="Delete" src="imgs/icn_trash.png" class="delete" type="image" (click)="confirmDeleteEntity(check.entity._id)">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div *ngIf="entitiesCheckboxes.length==0" class="col-md-12">
|
|
||||||
<div class="uk-alert-warning" uk-alert>No entities found</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<modal-form #saveModal [saveText]="'Save'" [titleText]="'Add a new Entity'" [formGroup]="formGroup" [type]="'entity'"
|
|
||||||
[isModalShown]="isModalShown" (emmitObject)="entitySavedSuccessfully($event)" (emmitError)="handleError($event)"
|
|
||||||
[selectedCommunityId]="selectedCommunityId">
|
|
||||||
<entity-form [group]="formGroup"></entity-form>
|
|
||||||
</modal-form>
|
|
||||||
|
|
||||||
<modal-form #updateModal [saveText]="'Update'" [titleText]="'Update Entity'" [formGroup]="formGroup" [type]="'entity'"
|
|
||||||
[isModalShown]="isModalShown" (emmitObject)="entityUpdatedSuccessfully($event)" (emmitError)="handleError($event)"
|
|
||||||
[selectedCommunityId]="selectedCommunityId">
|
|
||||||
<entity-form [group]="formGroup"></entity-form>
|
|
||||||
</modal-form>
|
|
||||||
|
|
||||||
<delete-confirmation-dialog #deleteConfirmationModal [isModalShown]="isModalShown" (emmitObject)="confirmedDeleteEntities($event)">
|
|
||||||
Are you sure you want to delete the selected entity(-ies)?
|
|
||||||
</delete-confirmation-dialog>
|
|
|
@ -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(<CheckEntity>{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(<CheckEntity>{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(<CheckEntity>{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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue