This commit is contained in:
Martin Rojas Miguel Angel 2018-07-10 11:54:56 +02:00
parent 3968bd4f54
commit 93765b20c3
4 changed files with 45 additions and 72 deletions

View File

@ -1,18 +1,15 @@
<div class="list-group-search">
<div class="row">
<div *ngIf="filterTypeIsWorkbasket(); else tasktype">
<div class="dropdown col-xs-2">
<button class="btn btn-default" data-toggle="dropdown" type="button" id="dropdownMenufilter"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="true">
<button class="btn btn-default" data-toggle="dropdown" type="button" id="dropdownMenufilter" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="true">
<taskana-icon-type [type]="filter.filterParams?.type" class="vertical-align"></taskana-icon-type>
</button>
<ul class="dropdown-menu dropdown-menu-users" role="menu">
<li>
<a *ngFor="let type of allTypes | mapValues" type="button" (click)="selectType(type.key); search()"
data-toggle="tooltip"
[title]="type.value">
<a *ngFor="let type of allTypes | mapValues" type="button" (click)="selectType(type.key); search()" data-toggle="tooltip"
[title]="type.value">
<taskana-icon-type class="vertical-align" [type]='type.key' [text]="type.value"></taskana-icon-type>
</a>
</li>
@ -20,29 +17,25 @@
</div>
<div class="col-xs-4">
<input type="text" [(ngModel)]="filter.filterParams.name" (keyup.enter)="search()" class="form-control"
id="display-name-filter" placeholder="Filter name">
<input type="text" [(ngModel)]="filter.filterParams.name" (keyup.enter)="search()" class="form-control" id="display-name-filter"
placeholder="Filter name">
</div>
<div class="col-xs-4">
<input type="text" [(ngModel)]="filter.filterParams.key" (keyup.enter)="search()" class="form-control"
id="display-key-filter" placeholder="Filter key">
<input type="text" [(ngModel)]="filter.filterParams.key" (keyup.enter)="search()" class="form-control" id="display-key-filter"
placeholder="Filter key">
</div>
</div>
<ng-template #tasktype>
<div class="col-xs-2">
</div>
<div class="col-xs-8">
<input type="text" [(ngModel)]="filter.filterParams.name" (keyup.enter)="search()" class="form-control"
id="display-name-filter" placeholder="Filter name">
<input type="text" [(ngModel)]="filter.filterParams.name" (keyup.enter)="search()" class="form-control" id="display-name-filter"
placeholder="Filter name">
</div>
</ng-template>
<button (click)="clear(); search()" type="button"
class="btn btn-default glyphicon glyphicon-ban-circle blue pull-right margin-right"
data-toggle="tooltip" title="Clear">
<button (click)="clear(); search()" type="button" class="btn btn-default glyphicon glyphicon-ban-circle blue pull-right margin-right"
data-toggle="tooltip" title="Clear">
</button>
</div>
@ -53,25 +46,21 @@
</div>
<div class="col-xs-8">
<div *ngIf="checkUppercaseFilterType(filterType); else normalFilter">
<input type="text" [(ngModel)]="filter.filterParams[filterType]"
(ngModelChange)="filter.filterParams[filterType] = $event.toLocaleUpperCase()"
(keyup.enter)="search()"
class="form-control" id="display-{{filterType}}-filter" placeholder="Filter {{filterType}}">
<input type="text" [(ngModel)]="filter.filterParams[filterType]" (ngModelChange)="filter.filterParams[filterType] = $event.toLocaleUpperCase()"
(keyup.enter)="search()" class="form-control" id="display-{{filterType}}-filter" placeholder="Filter {{filterType}}">
</div>
<ng-template #normalFilter>
<input type="text" [(ngModel)]="filter.filterParams[filterType]"
(keyup.enter)="search()"
class="form-control" id="display-{{filterType}}-filter" placeholder="Filter {{filterType}}">
<input type="text" [(ngModel)]="filter.filterParams[filterType]" (keyup.enter)="search()" class="form-control" id="display-{{filterType}}-filter"
placeholder="Filter {{filterType}}">
</ng-template>
</div>
<div *ngIf="filterType === lastFilterKey" class="pull-right">
<button (click)="search()" type="button"
class="btn btn-default glyphicon glyphicon-search blue pull-right margin-right"
data-toggle="tooltip" title="Search">
<button (click)="search()" type="button" class="btn btn-default glyphicon glyphicon-search blue pull-right margin-right"
data-toggle="tooltip" title="Search">
</button>
</div>
</div>
</li>
</div>
</div>
</div>

View File

@ -1,14 +1,13 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {FormsModule} from '@angular/forms';
import {AngularSvgIconModule} from 'angular-svg-icon';
import {HttpClientModule} from '@angular/common/http';
import {HttpModule} from '@angular/http';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { AngularSvgIconModule } from 'angular-svg-icon';
import { HttpClientModule } from '@angular/common/http';
import { HttpModule } from '@angular/http';
import {FilterModel} from 'app/models/filter';
import {IconTypeComponent} from '../../administration/components/type-icon/icon-type.component';
import {FilterComponent} from './filter.component';
import {MapValuesPipe} from 'app/shared/pipes/mapValues/map-values.pipe';
import {configureTests} from 'app/app.test.configuration';
import { IconTypeComponent } from '../../administration/components/type-icon/icon-type.component';
import { FilterComponent } from './filter.component';
import { MapValuesPipe } from 'app/shared/pipes/mapValues/map-values.pipe';
import { configureTests } from 'app/app.test.configuration';
describe('FilterComponent', () => {
let component: FilterComponent,
@ -26,31 +25,31 @@ describe('FilterComponent', () => {
configureTests(configure).then(testBed => {
fixture = TestBed.createComponent(FilterComponent);
component = fixture.componentInstance;
component.filter = new FilterModel({
component.filterParams = {
name: 'someName', owner: 'someOwner', description: 'someDescription',
key: 'someKey', type: 'PERSONAL'
});
};
debugElement = fixture.debugElement.nativeElement;
fixture.detectChanges();
done();
});
});
afterEach((done) => {
afterEach(() => {
document.body.removeChild(debugElement);
});
it('should create', (done) => {
it('should create', () => {
expect(component).toBeTruthy();
});
it('should create a component', (done) => {
it('should create a component', () => {
expect(debugElement.querySelector('#some-id')).toBeNull();
fixture.detectChanges();
expect(debugElement.querySelector('#some-id')).toBeDefined();
});
it('should have filter by: name, description, key, owner and type defined', (done) => {
it('should have filter by: name, description, key, owner and type defined', () => {
expect(debugElement.querySelector('#display-name-filter')).toBeDefined();
expect(debugElement.querySelector('#display-description-filter')).toBeDefined();
expect(debugElement.querySelector('#display-key-filter')).toBeDefined();
@ -58,11 +57,12 @@ describe('FilterComponent', () => {
expect(debugElement.querySelector('#display-type-filter')).toBeDefined();
});
it('should be able to clear all fields after pressing clear button', (done) => {
component.filter = new FilterModel({
it('should be able to clear all fields after pressing clear button', () => {
component.filterParams = {
name: 'someName', owner: 'someOwner', description: 'someDescription',
key: 'someKey', type: 'PERSONAL'
});
};
fixture.detectChanges();
debugElement.querySelector('[title="Clear"]').click();
expect(component.filter.filterParams.name).toBe('');
expect(component.filter.filterParams.description).toBe('');
@ -71,20 +71,4 @@ describe('FilterComponent', () => {
expect(component.filter.filterParams.key).toBe('');
});
it('should be able to select a type and return it based on a number', (done) => {
expect(component).toBeTruthy();
});
it('should be able to emit a filter after clicking on search button', (done) => {
component.filter = new FilterModel({
name: 'someName', owner: 'someOwner', description: 'someDescription',
key: 'someKey', type: 'PERSONAL'
});
component.performFilter.subscribe(filter => {
expect(filter.name).toBe('someName');
done();
});
debugElement.querySelector('[title="Search"]').click();
});
});

View File

@ -1,4 +1,4 @@
import {AfterContentInit, Component, EventEmitter, Input, Output} from '@angular/core';
import {AfterContentInit, Component, EventEmitter, Input, Output, OnInit} from '@angular/core';
import {ICONTYPES} from 'app/models/type';
import {FilterModel} from 'app/models/filter';
import {TaskanaType} from 'app/models/taskana-type';
@ -8,7 +8,8 @@ import {TaskanaType} from 'app/models/taskana-type';
templateUrl: './filter.component.html',
styleUrls: ['./filter.component.scss']
})
export class FilterComponent implements AfterContentInit {
export class FilterComponent implements OnInit {
@Input() allTypes: Map<string, string>;
@Input() filterParams: any;
@ -25,7 +26,7 @@ export class FilterComponent implements AfterContentInit {
constructor() {
}
ngAfterContentInit(): void {
ngOnInit(): void {
this.initializeFilterModel();
if (this.filterParams) {
this.filterParamKeys = Object.keys(this.filterParams);
@ -67,7 +68,7 @@ export class FilterComponent implements AfterContentInit {
getUnusedKeys(): string[] {
const unusedKeys = [];
for (const key of this.filterParamKeys) {
if (['name', 'key'].indexOf(key) < 0) {
if (['name', 'key', 'type'].indexOf(key) < 0) {
unusedKeys.push(key);
}
}

View File

@ -16,6 +16,8 @@ import { TaskanaTreeComponent } from 'app/shared/tree/tree.component';
import { TypeAheadComponent } from 'app/shared/type-ahead/type-ahead.component';
import { SortComponent } from './sort/sort.component';
import { RemoveConfirmationComponent } from 'app/shared/remove-confirmation/remove-confirmation.component';
import { FilterComponent } from 'app/shared/filter/filter.component';
import { IconTypeComponent } from 'app/administration/components/type-icon/icon-type.component';
/**
* Pipes
@ -32,9 +34,6 @@ import { MapToIterable } from './pipes/mapToIterable/mapToIterable';
*/
import { HttpClientInterceptor } from './services/httpClientInterceptor/http-client-interceptor.service';
import { AccessIdsService } from './services/access-ids/access-ids.service';
import {SortComponent} from 'app/shared/sort/sort.component';
import {FilterComponent} from 'app/shared/filter/filter.component';
import {IconTypeComponent} from 'app/administration/components/type-icon/icon-type.component';
import { FormsValidatorService } from './services/forms/forms-validator.service';