Merge pull request #1062 from Alfresco/dev-valbano-1044

Dev valbano 1044
This commit is contained in:
Mario Romano
2016-11-11 11:11:26 +00:00
committed by GitHub
7 changed files with 177 additions and 59 deletions

View File

@@ -85,9 +85,9 @@ export class AnalyticsService {
getProcessStatusValues(): Observable<any> {
let paramOptions: ParameterValueModel[] = [];
paramOptions.push(new ParameterValueModel({id: 'All', name: 'All'}));
paramOptions.push(new ParameterValueModel({id: 'Active', name: 'Active'}));
paramOptions.push(new ParameterValueModel({id: 'Complete', name: 'Complete'}));
paramOptions.push(new ParameterValueModel({ id: 'All', name: 'All' }));
paramOptions.push(new ParameterValueModel({ id: 'Active', name: 'Active' }));
paramOptions.push(new ParameterValueModel({ id: 'Complete', name: 'Complete' }));
return Observable.create(observer => {
observer.next(paramOptions);
@@ -98,11 +98,11 @@ export class AnalyticsService {
getDateIntervalValues(): Observable<any> {
let paramOptions: ParameterValueModel[] = [];
paramOptions.push(new ParameterValueModel({id: 'byHour', name: 'By hour'}));
paramOptions.push(new ParameterValueModel({id: 'byDay', name: 'By day'}));
paramOptions.push(new ParameterValueModel({id: 'byWeek', name: 'By week'}));
paramOptions.push(new ParameterValueModel({id: 'byMonth', name: 'By month'}));
paramOptions.push(new ParameterValueModel({id: 'byYear', name: 'By year'}));
paramOptions.push(new ParameterValueModel({ id: 'byHour', name: 'By hour' }));
paramOptions.push(new ParameterValueModel({ id: 'byDay', name: 'By day' }));
paramOptions.push(new ParameterValueModel({ id: 'byWeek', name: 'By week' }));
paramOptions.push(new ParameterValueModel({ id: 'byMonth', name: 'By month' }));
paramOptions.push(new ParameterValueModel({ id: 'byYear', name: 'By year' }));
return Observable.create(observer => {
observer.next(paramOptions);
@@ -113,9 +113,9 @@ export class AnalyticsService {
getMetricValues(): Observable<any> {
let paramOptions: ParameterValueModel[] = [];
paramOptions.push(new ParameterValueModel({id: 'totalCount', name: 'Number of times a step is executed'}));
paramOptions.push(new ParameterValueModel({id: 'totalTime', name: 'Total time spent in a process step'}));
paramOptions.push(new ParameterValueModel({id: 'avgTime', name: 'Average time spent in a process step'}));
paramOptions.push(new ParameterValueModel({ id: 'totalCount', name: 'Number of times a step is executed' }));
paramOptions.push(new ParameterValueModel({ id: 'totalTime', name: 'Total time spent in a process step' }));
paramOptions.push(new ParameterValueModel({ id: 'avgTime', name: 'Average time spent in a process step' }));
return Observable.create(observer => {
observer.next(paramOptions);
@@ -171,7 +171,7 @@ export class AnalyticsService {
let paramOptions: ParameterValueModel[] = [];
let body = res.json();
body.forEach((opt) => {
paramOptions.push(new ParameterValueModel({id: opt, name: opt}));
paramOptions.push(new ParameterValueModel({ id: opt, name: opt }));
});
return paramOptions;
}).catch(this.handleError);
@@ -185,7 +185,7 @@ export class AnalyticsService {
getReportsByParams(reportId: number, paramsQuery: any): Observable<any> {
let url = `${this.alfrescoSettingsService.getBPMApiBaseUrl()}/app/rest/reporting/report-params/${reportId}`;
let body = JSON.stringify(paramsQuery);
let body = paramsQuery ? JSON.stringify(paramsQuery) : {};
let options = this.getRequestOptions();
return this.http
.post(url, body, options)
@@ -233,7 +233,7 @@ export class AnalyticsService {
public getRequestOptions(param?: any): RequestOptions {
let headers = this.getHeaders();
return new RequestOptions({headers: headers, withCredentials: true, search: param});
return new RequestOptions({ headers: headers, withCredentials: true, search: param });
}
private handleError(error: Response) {

View File

@@ -34,7 +34,7 @@ export class FormModel {
readonly name: string;
readonly taskId: string;
readonly taskName: string = FormModel.UNSET_TASK_NAME;
readonly processDefinitionId: string;
private _isValid: boolean = true;
get isValid(): boolean {
@@ -72,6 +72,7 @@ export class FormModel {
this.name = json.name;
this.taskId = json.taskId;
this.taskName = json.taskName || json.name || FormModel.UNSET_TASK_NAME;
this.processDefinitionId = json.processDefinitionId;
let tabCache: FormWidgetModelCache<TabModel> = {};

View File

@@ -34,25 +34,52 @@ export class DropdownWidget extends WidgetComponent implements OnInit {
ngOnInit() {
if (this.field && this.field.restUrl) {
this.formService
.getRestFieldValues(
this.field.form.taskId,
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
);
if (this.field.form.processDefinitionId) {
this.getValuesByProcessDefinitionId();
} else {
this.getValuesByTaskId();
}
}
}
getValuesByTaskId() {
this.formService
.getRestFieldValues(
this.field.form.taskId,
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
);
}
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) {
console.error(error);
}

View File

@@ -39,20 +39,11 @@ export class DropdownEditorComponent extends CellEditorComponent implements OnIn
let field = this.table.field;
if (field) {
if (this.column.optionType === 'rest') {
this.formService
.getRestFieldValuesColumn(
field.form.taskId,
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);
},
err => this.handleError(err)
);
if (this.table.form && 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);
@@ -60,6 +51,40 @@ export class DropdownEditorComponent extends CellEditorComponent implements OnIn
}
}
getValuesByTaskId(field) {
this.formService
.getRestFieldValuesColumn(
field.form.taskId,
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);
},
err => this.handleError(err)
);
}
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);
},
err => this.handleError(err)
);
}
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
let value: any = (<HTMLInputElement>event.target).value;
value = column.options.find(opt => opt.name === value);

View File

@@ -34,21 +34,44 @@ export class RadioButtonsWidget extends WidgetComponent implements OnInit {
ngOnInit() {
if (this.field && this.field.restUrl) {
this.formService
.getRestFieldValues(
this.field.form.taskId,
this.field.id
)
.subscribe(
(result: FormFieldOption[]) => {
this.field.options = result || [];
this.field.updateForm();
},
this.handleError
);
if (this.field.form.processDefinitionId) {
this.getOptionsByProcessDefinitionId();
} else {
this.getOptionsByTaskId();
}
}
}
getOptionsByTaskId() {
this.formService
.getRestFieldValues(
this.field.form.taskId,
this.field.id
)
.subscribe(
(result: FormFieldOption[]) => {
this.field.options = result || [];
this.field.updateForm();
},
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) {
this.field.value = optionSelected;
this.checkVisibility(this.field);

View File

@@ -38,6 +38,14 @@ export class TypeaheadWidget extends WidgetComponent implements OnInit {
}
ngOnInit() {
if (this.field.form.processDefinitionId) {
this.getValuesByProcessDefinitionId();
} else {
this.getValuesByTaskId();
}
}
getValuesByTaskId() {
this.formService
.getRestFieldValues(
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[] {
let val = this.value.toLocaleLowerCase();
return this.field.options.filter(item => {

View File

@@ -143,7 +143,7 @@ export class FormService {
* @returns {Observable<any>}
*/
saveTaskForm(taskId: string, formValues: FormValues): Observable<any> {
let body = JSON.stringify({values: formValues});
let body = JSON.stringify({ values: formValues });
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.saveTaskForm(taskId, body))
.catch(this.handleError);
@@ -157,7 +157,7 @@ export class FormService {
* @returns {Observable<any>}
*/
completeTaskForm(taskId: string, formValues: FormValues, outcome?: string): Observable<any> {
let data: any = {values: formValues};
let data: any = { values: formValues };
if (outcome) {
data.outcome = outcome;
}
@@ -223,6 +223,16 @@ export class FormService {
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> {
let alfrescoApi = this.apiService.getInstance();
return Observable.fromPromise(alfrescoApi.activiti.taskApi.getRestFieldValuesColumn(taskId, field, column));