Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:sciencespo/isari into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgirard committed Aug 31, 2017
2 parents f03101f + dd04148 commit 81e58d8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
2 changes: 1 addition & 1 deletion client/src/app/isari-list/isari-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<isari-chart [feature]="feature" [data]="filteredData"></isari-chart>
</md-card> -->
<md-card>
<md-toolbar [color]="primary">
<md-toolbar>

<span>{{ feature | translate }}</span>
&nbsp;
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/isari-list/isari-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class IsariListComponent implements OnInit {
private storageService: StorageService,
private route: ActivatedRoute,
private isariDataService: IsariDataService,
private translate: TranslateService,
public translate: TranslateService,
private titleService: Title,
private dialog: MdDialog) {}

Expand Down
17 changes: 15 additions & 2 deletions client/src/app/log-table/log-table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@
<th>{{ 'editLogs.date' | translate }}</th>
<th>{{ 'editLogs.object' | translate }}</th>
<th>
<md-select [placeholder]="'editLogs.action' | translate" [formControl]="filters.action">
<md-select [placeholder]="'editLogs.action' | translate" [formControl]="filterForm.controls['action']" *ngIf="filterForm.controls['action']">
<md-option *ngFor="let action of actions" [value]="action.value">{{ 'editLogs.actions.' + action.label | translate }}</md-option>
</md-select>
</th>

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

<th>{{ 'editLogs.role' | translate }}</th>
Expand Down Expand Up @@ -50,3 +60,6 @@
<li><a md-button (click)="navigateNext()"><md-icon>navigate_next</md-icon></a>
</ul>
</div>

<!-- remove me style WTF ??? -->
<md-input placeholder="Company (disabled)" disabled value="Google"></md-input>
37 changes: 22 additions & 15 deletions client/src/app/log-table/log-table.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FormControl } from '@angular/forms';
import { FormControl, FormGroup } from '@angular/forms';
import { IsariDataService } from './../isari-data.service';
import { TranslateService } from 'ng2-translate';
import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core';
import { Component, Input, OnInit, Output, EventEmitter, OnChanges } from '@angular/core';

@Component({
selector: 'isari-log-table',
Expand All @@ -10,31 +10,44 @@ import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core';
})
export class LogTableComponent implements OnInit {

filters = {};
actions = [
{ 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 };

filterForm: FormGroup;

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

constructor(
private translate: TranslateService
private translate: TranslateService,
private isariDataService: IsariDataService
) {}

ngOnInit() {
this.filterForm = new FormGroup({});
[
'action'
'action',
'whoID',
].forEach(key => {
this.filters[key] = new FormControl(this.options[key] || '');
this.filters[key].valueChanges.subscribe(this.changeFilter('action'));
this.filterForm.addControl(key, new FormControl(this.options[key] || ''));
});

this.filterForm.valueChanges.subscribe(values => {
this.onOptionsChange.emit(Object.assign({}, this.options, values));
});

// 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);
}

navigatePrev() {
Expand All @@ -46,14 +59,8 @@ export class LogTableComponent implements OnInit {
this.emitChange('skip', this.options.skip + this.options.limit);
}

private changeFilter(key) {
return value => this.emitChange(key, value);
}

private emitChange(key, value) {
this.onOptionsChange.emit(Object.assign(this.options, {
[key]: value
}));
this.onOptionsChange.emit(Object.assign(this.options, { [key]: value }));
}

}

0 comments on commit 81e58d8

Please sign in to comment.