mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
Added fix for #1044
This commit is contained in:
parent
8195c00c74
commit
38b61a4f64
@ -34,7 +34,7 @@ export class FormModel {
|
|||||||
readonly name: string;
|
readonly name: string;
|
||||||
readonly taskId: string;
|
readonly taskId: string;
|
||||||
readonly taskName: string = FormModel.UNSET_TASK_NAME;
|
readonly taskName: string = FormModel.UNSET_TASK_NAME;
|
||||||
|
readonly processDefinitionId: string;
|
||||||
private _isValid: boolean = true;
|
private _isValid: boolean = true;
|
||||||
|
|
||||||
get isValid(): boolean {
|
get isValid(): boolean {
|
||||||
@ -72,6 +72,7 @@ export class FormModel {
|
|||||||
this.name = json.name;
|
this.name = json.name;
|
||||||
this.taskId = json.taskId;
|
this.taskId = json.taskId;
|
||||||
this.taskName = json.taskName || json.name || FormModel.UNSET_TASK_NAME;
|
this.taskName = json.taskName || json.name || FormModel.UNSET_TASK_NAME;
|
||||||
|
this.processDefinitionId = json.processDefinitionId;
|
||||||
|
|
||||||
let tabCache: FormWidgetModelCache<TabModel> = {};
|
let tabCache: FormWidgetModelCache<TabModel> = {};
|
||||||
|
|
||||||
|
@ -34,6 +34,15 @@ export class DropdownWidget extends WidgetComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.field && this.field.restUrl) {
|
if (this.field && this.field.restUrl) {
|
||||||
|
if (this.field.form.processDefinitionId) {
|
||||||
|
this.getValuesByProcessDefinitionId();
|
||||||
|
} else {
|
||||||
|
this.getValuesByTaskId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getValuesByTaskId() {
|
||||||
this.formService
|
this.formService
|
||||||
.getRestFieldValues(
|
.getRestFieldValues(
|
||||||
this.field.form.taskId,
|
this.field.form.taskId,
|
||||||
@ -51,6 +60,24 @@ export class DropdownWidget extends WidgetComponent implements OnInit {
|
|||||||
this.handleError
|
this.handleError
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getValuesByProcessDefinitionId() {
|
||||||
|
this.formService
|
||||||
|
.getRestFieldValuesByProcessId(
|
||||||
|
this.field.form.processDefinitionId,
|
||||||
|
this.field.id
|
||||||
|
)
|
||||||
|
.subscribe(
|
||||||
|
(result: FormFieldOption[]) => {
|
||||||
|
let options = [];
|
||||||
|
if (this.field.emptyOption) {
|
||||||
|
options.push(this.field.emptyOption);
|
||||||
|
}
|
||||||
|
this.field.options = options.concat((result || []));
|
||||||
|
this.field.updateForm();
|
||||||
|
},
|
||||||
|
this.handleError
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleError(error: any) {
|
handleError(error: any) {
|
||||||
|
@ -39,6 +39,19 @@ export class DropdownEditorComponent extends CellEditorComponent implements OnIn
|
|||||||
let field = this.table.field;
|
let field = this.table.field;
|
||||||
if (field) {
|
if (field) {
|
||||||
if (this.column.optionType === 'rest') {
|
if (this.column.optionType === 'rest') {
|
||||||
|
if (this.table.form.processDefinitionId) {
|
||||||
|
this.getValuesByProcessDefinitionId(field);
|
||||||
|
} else {
|
||||||
|
this.getValuesByTaskId(field);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.options = this.column.options || [];
|
||||||
|
this.value = this.table.getCellValue(this.row, this.column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getValuesByTaskId(field) {
|
||||||
this.formService
|
this.formService
|
||||||
.getRestFieldValuesColumn(
|
.getRestFieldValuesColumn(
|
||||||
field.form.taskId,
|
field.form.taskId,
|
||||||
@ -53,11 +66,23 @@ export class DropdownEditorComponent extends CellEditorComponent implements OnIn
|
|||||||
},
|
},
|
||||||
err => this.handleError(err)
|
err => this.handleError(err)
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
this.options = this.column.options || [];
|
|
||||||
|
getValuesByProcessDefinitionId(field) {
|
||||||
|
this.formService
|
||||||
|
.getRestFieldValuesColumnByProcessId(
|
||||||
|
field.form.processDefinitionId,
|
||||||
|
field.id,
|
||||||
|
this.column.id
|
||||||
|
)
|
||||||
|
.subscribe(
|
||||||
|
(result: DynamicTableColumnOption[]) => {
|
||||||
|
this.column.options = result || [];
|
||||||
|
this.options = this.column.options;
|
||||||
this.value = this.table.getCellValue(this.row, this.column);
|
this.value = this.table.getCellValue(this.row, this.column);
|
||||||
}
|
},
|
||||||
}
|
err => this.handleError(err)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
||||||
|
@ -34,6 +34,15 @@ export class RadioButtonsWidget extends WidgetComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.field && this.field.restUrl) {
|
if (this.field && this.field.restUrl) {
|
||||||
|
if (this.field.form.processDefinitionId) {
|
||||||
|
this.getOptionsByProcessDefinitionId();
|
||||||
|
} else {
|
||||||
|
this.getOptionsByTaskId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getOptionsByTaskId() {
|
||||||
this.formService
|
this.formService
|
||||||
.getRestFieldValues(
|
.getRestFieldValues(
|
||||||
this.field.form.taskId,
|
this.field.form.taskId,
|
||||||
@ -47,6 +56,20 @@ export class RadioButtonsWidget extends WidgetComponent implements OnInit {
|
|||||||
this.handleError
|
this.handleError
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getOptionsByProcessDefinitionId() {
|
||||||
|
this.formService
|
||||||
|
.getRestFieldValuesByProcessId(
|
||||||
|
this.field.form.processDefinitionId,
|
||||||
|
this.field.id
|
||||||
|
)
|
||||||
|
.subscribe(
|
||||||
|
(result: FormFieldOption[]) => {
|
||||||
|
this.field.options = result || [];
|
||||||
|
this.field.updateForm();
|
||||||
|
},
|
||||||
|
this.handleError
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onOptionClick(optionSelected: any) {
|
onOptionClick(optionSelected: any) {
|
||||||
|
@ -38,6 +38,14 @@ export class TypeaheadWidget extends WidgetComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
if (this.field.form.processDefinitionId) {
|
||||||
|
this.getValuesByProcessDefinitionId();
|
||||||
|
} else {
|
||||||
|
this.getValuesByTaskId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getValuesByTaskId() {
|
||||||
this.formService
|
this.formService
|
||||||
.getRestFieldValues(
|
.getRestFieldValues(
|
||||||
this.field.form.taskId,
|
this.field.form.taskId,
|
||||||
@ -61,6 +69,30 @@ export class TypeaheadWidget extends WidgetComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getValuesByProcessDefinitionId() {
|
||||||
|
this.formService
|
||||||
|
.getRestFieldValuesByProcessId(
|
||||||
|
this.field.form.processDefinitionId,
|
||||||
|
this.field.id
|
||||||
|
)
|
||||||
|
.subscribe(
|
||||||
|
(result: FormFieldOption[]) => {
|
||||||
|
let options = result || [];
|
||||||
|
this.field.options = options;
|
||||||
|
this.field.updateForm();
|
||||||
|
|
||||||
|
let fieldValue = this.field.value;
|
||||||
|
if (fieldValue) {
|
||||||
|
let toSelect = options.find(item => item.id === fieldValue);
|
||||||
|
if (toSelect) {
|
||||||
|
this.value = toSelect.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
this.handleError
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
getOptions(): FormFieldOption[] {
|
getOptions(): FormFieldOption[] {
|
||||||
let val = this.value.toLocaleLowerCase();
|
let val = this.value.toLocaleLowerCase();
|
||||||
return this.field.options.filter(item => {
|
return this.field.options.filter(item => {
|
||||||
|
@ -223,6 +223,16 @@ export class FormService {
|
|||||||
return Observable.fromPromise(alfrescoApi.activiti.taskApi.getRestFieldValues(taskId, field));
|
return Observable.fromPromise(alfrescoApi.activiti.taskApi.getRestFieldValues(taskId, field));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRestFieldValuesByProcessId(processDefinitionId: string, field: string): Observable<any> {
|
||||||
|
let alfrescoApi = this.apiService.getInstance();
|
||||||
|
return Observable.fromPromise(alfrescoApi.activiti.processApi.getRestFieldValues(processDefinitionId, field));
|
||||||
|
}
|
||||||
|
|
||||||
|
getRestFieldValuesColumnByProcessId(processDefinitionId: string, field: string, column?: string): Observable<any> {
|
||||||
|
let alfrescoApi = this.apiService.getInstance();
|
||||||
|
return Observable.fromPromise(alfrescoApi.activiti.processApi.getRestTableFieldValues(processDefinitionId, field, column));
|
||||||
|
}
|
||||||
|
|
||||||
getRestFieldValuesColumn(taskId: string, field: string, column?: string): Observable<any> {
|
getRestFieldValuesColumn(taskId: string, field: string, column?: string): Observable<any> {
|
||||||
let alfrescoApi = this.apiService.getInstance();
|
let alfrescoApi = this.apiService.getInstance();
|
||||||
return Observable.fromPromise(alfrescoApi.activiti.taskApi.getRestFieldValuesColumn(taskId, field, column));
|
return Observable.fromPromise(alfrescoApi.activiti.taskApi.getRestFieldValuesColumn(taskId, field, column));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user