Skip to content

Commit

Permalink
[front: editLog] itemID filter
Browse files Browse the repository at this point in the history
  • Loading branch information
t8g committed Aug 31, 2017
1 parent f610b81 commit 0bc1fc1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 39 deletions.
2 changes: 1 addition & 1 deletion client/src/app/isari-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export class IsariDataService {
return Observable.of([]);
}

const url = `${this.dataUrl}/${mongoSchema2Api[feature]}/${values.join(',')}/string`;
const url = `${this.dataUrl}/${mongoSchema2Api[feature] || feature}/${values.join(',')}/string`;
return this.http.get(url, this.getHttpOptions())
.map(response => response.json());
// .map(item => item.value);
Expand Down
9 changes: 3 additions & 6 deletions client/src/app/log-table/log-table.component.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
table {
width: 100%;
display: table;
margin-top: 1em;
}

table {
Expand All @@ -14,10 +15,6 @@ th {
font-family: Roboto, "Helvetica Neue", sans-serif;
}

table tbody tr {
cursor: pointer;
}

table.bordered > thead > tr,
table.bordered > tbody > tr {
border-bottom: 1px solid #d0d0d0;
Expand All @@ -36,7 +33,7 @@ table.striped > tbody > tr > td {
vertical-align: top;
}

table.striped > tbody > tr > td > p {
table.striped > tbody > tr > td p {
margin: 0;
}

Expand All @@ -54,7 +51,7 @@ thead {
}

td, th {
padding: 15px 5px;
padding: 5px;
display: table-cell;
text-align: left;
vertical-align: middle;
Expand Down
62 changes: 40 additions & 22 deletions client/src/app/log-table/log-table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,41 @@
<thead>
<tr>
<th>{{ 'editLogs.date' | translate }}</th>
<th>{{ 'editLogs.object.' + feature | 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>
</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 *ngFor="let action of actions" [value]="action">{{ 'editLogs.actions.' + action | translate }}</md-option>
</md-select>
</th>

<th>
<isari-select
[src]="field.src"
[stringValue]="field.stringValue"
[api]="field.api"
[name]="'whoID'"
[label]="'editLogs.who' | translate"
[requirement]="false"
[form]="filterForm"></isari-select>
<th>{{ 'editLogs.fields' | translate }}</th>

<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>
<div style="flex-grow:1;width:33%;">{{ 'editLogs.lab' | translate }}</div>
<div style="flex-grow:1;width:33%;">{{ 'editLogs.role' | translate }}</div>
</div>
</th>
<th>{{ 'editLogs.lab' | translate }}</th>

<th>{{ 'editLogs.role' | translate }}</th>
<th>{{ 'editLogs.fields' | translate }}</th>
</tr>
</thead>

Expand All @@ -36,19 +49,24 @@
</td>
<td>{{ 'editLogs.actions.' + log.action | translate }}</td>

<td>{{ log.who.name }}</td>
<td>
<p *ngFor="let role of log.who.roles">
<a [routerLink]="['/organizations', { outlets: { editor: role.lab } }]" queryParamsHandling="preserve" *ngIf="labs && role.lab">{{ labs[role.lab]?.value }}</a>
</p>
<p *ngFor="let label of log._labels">{{ label.join(' : ') }}</p>
</td>

<td>
<p *ngFor="let role of log.who.roles">{{ role._label }}</p>
</td>
<td>
<p *ngFor="let label of log._labels">{{ label.join(' : ') }}</p>
<td style="border-left:1px solid #ddd;">
<div style="display:flex">
<div style="flex-grow:1;width:33%;">{{ log.who.name }}</div>
<div style="flex-grow:1;width:33%;">
<p *ngFor="let role of log.who.roles">
<a [routerLink]="['/organizations', { outlets: { editor: role.lab } }]" queryParamsHandling="preserve" *ngIf="labs && role.lab">{{ labs[role.lab]?.value }}</a>
</p>
</div>
<div style="flex-grow:1;width:33%;">
<p *ngFor="let role of log.who.roles">{{ role._label }}</p>
</div>
</div>
</td>

</tr>
</tbody>

Expand Down
22 changes: 12 additions & 10 deletions client/src/app/log-table/log-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@ import { Component, Input, OnInit, Output, EventEmitter, OnChanges } from '@angu
export class LogTableComponent implements OnInit {

actions = ['create', 'update', 'delete'];
// { value: '', label: 'all' },
// { value: 'create', label: 'create' },
// { value: 'update', label: 'update' },
// { value: 'delete', label: 'delete' }
// ];
field: { api: any, src: any, stringValue: any } = { api: null, src: null, stringValue: null };
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 };

filterForm: FormGroup;

@Input() logs: any[];
@Input() labs: any[];
@Input() feature: string;
@Input() options: { id?: string, skip?: number, limit?: number, action?: string, whoID: string };
@Input() options: { itemID?: string, skip?: number, limit?: number, action?: string, whoID: string };
@Output() onOptionsChange = new EventEmitter();

constructor(
Expand All @@ -36,6 +32,7 @@ export class LogTableComponent implements OnInit {
[
'action',
'whoID',
'itemID',
].forEach(key => {
this.filterForm.addControl(key, new FormControl(this.options[key] || ''));
});
Expand All @@ -45,9 +42,14 @@ export class LogTableComponent implements OnInit {
});

// people autocomplete (whoID)
this.field.api = this.isariDataService.getSchemaApi('people');
this.field.src = this.isariDataService.srcForeignBuilder('people');
this.field.stringValue = this.isariDataService.getForeignLabel('People', this.options.whoID);
this.whoSettings.api = this.isariDataService.getSchemaApi('people');
this.whoSettings.src = this.isariDataService.srcForeignBuilder('people');
this.whoSettings.stringValue = this.isariDataService.getForeignLabel('People', this.options.whoID);

// item autocomplete (itemID)
this.itemSettings.api = this.isariDataService.getSchemaApi(this.feature);
this.itemSettings.src = this.isariDataService.srcForeignBuilder(this.feature);
this.itemSettings.stringValue = this.isariDataService.getForeignLabel(this.feature, this.options.itemID);
}

navigatePrev() {
Expand Down

0 comments on commit 0bc1fc1

Please sign in to comment.