Fix project role displaying issue

This commit is contained in:
Steven Zou 2017-06-15 18:17:00 +08:00
parent 2a0fdc4ed2
commit ce19ba2889
3 changed files with 25 additions and 17 deletions

View File

@ -28,12 +28,20 @@ import { State } from 'clarity-angular';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ListProjectComponent {
_filterType: string = ProjectTypes[0];
@Input() projects: Project[];
@Input() filteredType: string;
@Input()
get filteredType(): string {
return this._filterType;
}
set filteredType(value: string) {
if (value && value.trim() !== "") {
this._filterType = value;
}
}
@Output() paginate = new EventEmitter<State>();
@Output() toggle = new EventEmitter<Project>();
@Output() delete = new EventEmitter<Project>();
@ -49,7 +57,7 @@ export class ListProjectComponent {
}
get showRoleInfo(): boolean {
return this.filteredType === ProjectTypes[0];
return this.filteredType !== ProjectTypes[2];
}
public get isSystemAdmin(): boolean {

View File

@ -14,9 +14,9 @@
<div class="option-right">
<div class="select" style="float: left;">
<select (change)="doFilterProjects($event)">
<option value="-1" [selected]="currentFilteredType === -1">{{projectTypes[0] | translate}}</option>
<option value="0">{{projectTypes[1] | translate}}</option>
<option value="1">{{projectTypes[2] | translate}}</option>
<option value="0" [selected]="currentFilteredType === 0">{{projectTypes[0] | translate}}</option>
<option value="1">{{projectTypes[1] | translate}}</option>
<option value="2">{{projectTypes[2] | translate}}</option>
</select>
</div>
<grid-filter filterPlaceholder='{{"PROJECT.FILTER_PLACEHOLDER" | translate}}' (filter)="doSearchProjects($event)" [currentValue]="projectName"></grid-filter>

View File

@ -56,7 +56,7 @@ export class ProjectComponent implements OnInit, OnDestroy {
@ViewChild(ListProjectComponent)
listProject: ListProjectComponent;
currentFilteredType: number = -1;//all projects
currentFilteredType: number = 0;//all projects
projectName: string = "";
subscription: Subscription;
@ -146,10 +146,10 @@ export class ProjectComponent implements OnInit, OnDestroy {
doSearchProjects(projectName: string): void {
this.projectName = projectName;
if (projectName === "") {
if (this.currentFilteredType === -1) {
if (this.currentFilteredType === 0) {
this.getProjects();
} else {
this.getProjects(projectName, this.currentFilteredType);
this.getProjects(projectName, this.currentFilteredType - 1);
}
} else {
this.getProjects(projectName);
@ -160,10 +160,10 @@ export class ProjectComponent implements OnInit, OnDestroy {
if ($event && $event.target && $event.target["value"]) {
this.projectName = "";
this.currentFilteredType = +$event.target["value"];
if (this.currentFilteredType === -1) {
if (this.currentFilteredType === 0) {
this.getProjects();
} else {
this.getProjects("", this.currentFilteredType);
this.getProjects("", this.currentFilteredType - 1);
}
}
}
@ -177,7 +177,7 @@ export class ProjectComponent implements OnInit, OnDestroy {
response => {
this.messageHandlerService.showSuccess('PROJECT.TOGGLED_SUCCESS');
this.statisticHandler.refresh();
this.getProjects("", this.currentFilteredType);
this.getProjects("", this.currentFilteredType - 1);
},
error => this.messageHandlerService.handleError(error)
);
@ -197,7 +197,7 @@ export class ProjectComponent implements OnInit, OnDestroy {
}
refresh(): void {
this.currentFilteredType = -1;
this.currentFilteredType = 0;
this.retrieve();
this.statisticHandler.refresh();
}