mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
Support for rest dropdown fields (dynamic table)
This commit is contained in:
parent
36dd42b62d
commit
3b898959ee
@ -51,7 +51,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="editMode">
|
||||
<div *ngIf="editMode" class="mdl-shadow--2dp">
|
||||
<div class="mdl-grid" *ngFor="let column of content.columns">
|
||||
<div class="mdl-cell mdl-cell--6-col" [ngSwitch]="column.type">
|
||||
<div *ngSwitchCase="'Dropdown'">
|
||||
|
@ -29,4 +29,8 @@ export abstract class CellEditorComponent {
|
||||
@Input()
|
||||
column: DynamicTableColumn;
|
||||
|
||||
protected handleError(error: any) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
<label [attr.for]="column.id">{{column.name}}</label>
|
||||
<div>
|
||||
<select
|
||||
[value]="table.getCellValue(row, column)"
|
||||
[value]="value"
|
||||
class="dropdown-editor__select"
|
||||
(change)="onValueChanged(row, column, $event)">
|
||||
<option></option>
|
||||
<option *ngFor="let opt of column.options" [value]="opt.name">{{opt.name}}</option>
|
||||
<option *ngFor="let opt of options" [value]="opt.name">{{opt.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -15,9 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { CellEditorComponent } from './../cell.editor';
|
||||
import { DynamicTableRow, DynamicTableColumn } from './../../../core/index';
|
||||
import { DynamicTableRow, DynamicTableColumn, DynamicTableColumnOption } from './../../../core/index';
|
||||
import { FormService } from './../../../../../services/form.service';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
@ -25,7 +26,36 @@ import { DynamicTableRow, DynamicTableColumn } from './../../../core/index';
|
||||
templateUrl: './dropdown.editor.html',
|
||||
styleUrls: ['./dropdown.editor.css']
|
||||
})
|
||||
export class DropdownEditorComponent extends CellEditorComponent {
|
||||
export class DropdownEditorComponent extends CellEditorComponent implements OnInit {
|
||||
|
||||
value: any;
|
||||
options: DynamicTableColumnOption[] = [];
|
||||
|
||||
constructor(private formService: FormService) {
|
||||
super();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.value = this.table.getCellValue(this.row, this.column);
|
||||
this.options = this.column.options || [];
|
||||
|
||||
let field = this.table.field;
|
||||
if (field && field.restUrl) {
|
||||
this.formService
|
||||
.getRestFieldValuesColumn(
|
||||
field.form.taskId,
|
||||
field.id,
|
||||
this.column.id
|
||||
)
|
||||
.subscribe(
|
||||
(result: DynamicTableColumnOption[]) => {
|
||||
this.column.options = result || [];
|
||||
this.options = this.column.options;
|
||||
},
|
||||
err => this.handleError(err)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: Event) {
|
||||
let value: any = (<HTMLInputElement>event.srcElement).value;
|
||||
@ -33,4 +63,5 @@ export class DropdownEditorComponent extends CellEditorComponent {
|
||||
row.value[column.id] = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -208,7 +208,12 @@ export class FormService {
|
||||
|
||||
getRestFieldValues(taskId: string, field: string): Observable<any> {
|
||||
let alfrescoApi = this.apiService.getInstance();
|
||||
return Observable.fromPromise(alfrescoApi.activiti.taskFormsApi.getRestFieldValues(taskId, field));
|
||||
return Observable.fromPromise(alfrescoApi.activiti.taskApi.getRestFieldValues(taskId, field));
|
||||
}
|
||||
|
||||
getRestFieldValuesColumn(taskId: string, field: string, column?: string): Observable<any> {
|
||||
let alfrescoApi = this.apiService.getInstance();
|
||||
return Observable.fromPromise(alfrescoApi.activiti.taskApi.getRestFieldValuesColumn(taskId, field, column));
|
||||
}
|
||||
|
||||
// TODO: uses private webApp api
|
||||
|
Loading…
x
Reference in New Issue
Block a user