Skip to content

Commit

Permalink
[front: editLog] role filter
Browse files Browse the repository at this point in the history
  • Loading branch information
t8g committed Aug 31, 2017
1 parent 0080bb4 commit 1deabea
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 29 deletions.
3 changes: 1 addition & 2 deletions client/src/app/isari-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class IsariDataService {

function getLabel(schema, path, lang) {
const item = _get(schema, path);
return item ? item.label[lang] : '';
return item && item.label ? item.label[lang] : '';
}

return Observable.combineLatest([
Expand All @@ -128,7 +128,6 @@ export class IsariDataService {
log._labels = log.diff.map(diff => diff._label);
log.who.roles = log.who.roles.map(role => Object.assign(role, {
_label: roles[role.role].label[lang],
//_lab$: this.getForeignLabel('Organization', role.lab),
}));
return log;
});
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/log-table/log-table.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ thead {
}

td, th {
padding: 5px;
padding: 10px 5px;
display: table-cell;
text-align: left;
vertical-align: middle;
Expand Down Expand Up @@ -86,7 +86,7 @@ td, th {
vertical-align: top;
}

.pagination ul, li, a, md-icon, button {
.pagination ul li a, md-icon, button {
font-size: 16px;
line-height: 36px;
vertical-align:top;
Expand Down
56 changes: 31 additions & 25 deletions client/src/app/log-table/log-table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
<th>{{ 'editLogs.date' | translate }}</th>
<th>
<isari-select
[src]="itemSettings.src"
[stringValue]="itemSettings.stringValue"
[api]="itemSettings.api"
[name]="'itemID'"
[label]="'editLogs.object.' + feature | translate"
[requirement]="false"
[form]="filterForm"></isari-select>
[src]="itemSettings.src"
[stringValue]="itemSettings.stringValue"
[api]="itemSettings.api"
[name]="'itemID'"
[label]="'editLogs.object.' + feature | translate"
[requirement]="false"
[form]="filterForm"></isari-select>
</th>
<th>
<md-select [placeholder]="'editLogs.action' | translate" [formControl]="filterForm.controls['action']" *ngIf="filterForm.controls['action']">
<md-option>{{ 'editLogs.actions.all' | translate }}</md-option>
<md-option>{{ 'editLogs.actions.all' | translate }}</md-option>
<md-option *ngFor="let action of actions" [value]="action">{{ 'editLogs.actions.' + action | translate }}</md-option>
</md-select>
</th>
Expand All @@ -25,24 +25,30 @@
<th style="max-width:25%;border:1px solid #ddd;background:#f2f2f2;">
<div style="display:flex">
<isari-select
style="flex-grow:1;width:33%;"
[src]="whoSettings.src"
[stringValue]="whoSettings.stringValue"
[api]="whoSettings.api"
[name]="'whoID'"
[label]="'editLogs.who' | translate"
[requirement]="false"
[form]="filterForm"></isari-select>
style="flex-grow:1;width:33%;"
[src]="whoSettings.src"
[stringValue]="whoSettings.stringValue"
[api]="whoSettings.api"
[name]="'whoID'"
[label]="'editLogs.who' | translate"
[requirement]="false"
[form]="filterForm"></isari-select>
<isari-select
style="flex-grow:1;width:33%;"
[src]="labSettings.src"
[stringValue]="labSettings.stringValue"
[api]="labSettings.api"
[name]="'isariLab'"
[label]="'editLogs.lab' | translate"
[requirement]="false"
[form]="filterForm"></isari-select>
<div style="flex-grow:1;width:33%;">{{ 'editLogs.role' | translate }}</div>
style="flex-grow:1;width:33%;"
[src]="labSettings.src"
[stringValue]="labSettings.stringValue"
[api]="labSettings.api"
[name]="'isariLab'"
[label]="'editLogs.lab' | translate"
[requirement]="false"
[form]="filterForm"></isari-select>
<md-select *ngIf="filterForm.controls['isariRole']"
style="flex-grow:1;width:33%;align-self:center;"
[placeholder]="'editLogs.role' | translate"
[formControl]="filterForm.controls['isariRole']">
<md-option>{{ 'editLogs.actions.all' | translate }}</md-option>
<md-option *ngFor="let role of roles" [value]="role.value">{{ role.label }}</md-option>
</md-select>
</div>
</th>

Expand Down
8 changes: 8 additions & 0 deletions client/src/app/log-table/log-table.component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Observable } from 'rxjs/Observable';
import { FormControl, FormGroup } from '@angular/forms';
import { IsariDataService } from './../isari-data.service';
import { TranslateService } from 'ng2-translate';
Expand All @@ -14,6 +15,7 @@ export class LogTableComponent implements OnInit {
whoSettings: { api: any, src: any, stringValue: any } = { api: null, src: null, stringValue: null };
itemSettings: { api: any, src: any, stringValue: any } = { api: null, src: null, stringValue: null };
labSettings: { api: any, src: any, stringValue: any } = { api: null, src: null, stringValue: null };
roles: any[];

filterForm: FormGroup;

Expand All @@ -35,6 +37,7 @@ export class LogTableComponent implements OnInit {
'whoID',
'itemID',
'isariLab',
'isariRole',
].forEach(key => {
this.filterForm.addControl(key, new FormControl(this.options[key] || ''));
});
Expand All @@ -58,6 +61,11 @@ export class LogTableComponent implements OnInit {
this.labSettings.src = this.isariDataService.srcForeignBuilder('organizations');
this.labSettings.stringValue = this.isariDataService.getForeignLabel('organizations', this.options.isariLab);

this.isariDataService.getEnum('isariRoles')
.subscribe(roles => this.roles = roles.map(role => Object.assign({}, role, {
label: role.label[this.translate.currentLang]
})));

}

navigatePrev() {
Expand Down
4 changes: 4 additions & 0 deletions client/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ md-dialog-container {
md-dialog-container [md-raised-button].md-primary {
background-color: #E6142D;
}

.md-select-panel {
max-height: none !important;
}

0 comments on commit 1deabea

Please sign in to comment.