Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [AAE-5953] solved rebase conflict :wq * [AAE-5953] solved rebase conflict * [AAE-5953] added stories for missing app and task id * [AAE-5953] hide readOnly control * [AAE-5953] added form cloud service interface * [AAE-5953] fixed lint errors * [AAE-5953] migrated stories and mocks * [AAE-5953] migrated task cloud service mock * [AAE-5953] migrated task cloud service mock * [AAE-5953] improved syntax * [AAE-5953] removed redundant mock * [AAE-5953] refactored and moved mocks * [AAE-5953] refactor modules import * [AAE-5953] fixed translation key issue * [AAE-5953] refactor module imports * [AAE-5953] rrefactored few mock task details props * [AAE-5953] moved new story module to testing folder * [AAE-5953] fixed mock task assignee
- Loading branch information
Showing
9 changed files
with
296 additions
and
19 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
lib/process-services-cloud/src/lib/form/mocks/form-cloud.service.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/*! | ||
* @license | ||
* Copyright 2019 Alfresco Software, Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { FormModel, FormValues } from '@alfresco/adf-core'; | ||
import { UploadApi } from '@alfresco/js-api'; | ||
import { Observable, of } from 'rxjs'; | ||
import { map, switchMap } from 'rxjs/operators'; | ||
import { FormContent } from '../../services/form-fields.interfaces'; | ||
import { TaskDetailsCloudModel } from '../../task/public-api'; | ||
import { taskDetailsContainer } from '../../task/task-header/mocks/task-details-cloud.mock'; | ||
import { fakeCloudForm } from '../mocks/cloud-form.mock'; | ||
import { TaskVariableCloud } from '../models/task-variable-cloud.model'; | ||
import { FormCloudInterface } from '../services/form-cloud.interface'; | ||
|
||
export class FormCloudServiceMock implements FormCloudInterface { | ||
|
||
uploadApi: UploadApi; | ||
|
||
getTaskForm(appName: string, taskId: string, version?: number): Observable<any> { | ||
return this.getTask(appName, taskId).pipe( | ||
switchMap((task) => { | ||
return this.getForm(appName, task.formKey, version).pipe( | ||
map((form: FormContent) => { | ||
const flattenForm = { | ||
...form.formRepresentation, | ||
...form.formRepresentation.formDefinition, | ||
taskId: task.id, | ||
taskName: task.name, | ||
processDefinitionId: task.processDefinitionId, | ||
processInstanceId: task.processInstanceId | ||
}; | ||
delete flattenForm.formDefinition; | ||
return flattenForm; | ||
}) | ||
); | ||
}) | ||
); | ||
} | ||
|
||
getTask(_appName: string, taskId: string): Observable<TaskDetailsCloudModel> { | ||
return of(taskDetailsContainer[taskId]); | ||
} | ||
|
||
getForm(_appName: string, _formKey: string, _version?: number): Observable<FormContent> { | ||
return of(fakeCloudForm); | ||
} | ||
|
||
getTaskVariables(_appName: string, _taskId: string): Observable<TaskVariableCloud[]> { | ||
return of([new TaskVariableCloud({ name: 'name1', value: 5, type: 'text', id: '52' })]); | ||
} | ||
|
||
saveTaskForm( | ||
_appName: string, | ||
taskId: string, | ||
_processInstanceId: string, | ||
_formId: string, | ||
_values: FormValues | ||
): Observable<TaskDetailsCloudModel> { | ||
return of(taskDetailsContainer[taskId]); | ||
} | ||
|
||
completeTaskForm( | ||
_appName: string, | ||
taskId: string, | ||
_processInstanceId: string, | ||
_formId: string, | ||
_formValues: FormValues, | ||
_outcome: string, | ||
_version: number | ||
): Observable<TaskDetailsCloudModel> { | ||
return of(taskDetailsContainer[taskId]); | ||
} | ||
|
||
createTemporaryRawRelatedContent(_file: any, _nodeId: string, _contentHost: string): Observable<any> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
getDropDownJsonData(_url: string): Observable<any> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
parseForm(_json: any, _data?: TaskVariableCloud[], _readOnly: boolean = false): FormModel { | ||
throw new Error('Method not implemented.'); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
lib/process-services-cloud/src/lib/form/services/form-cloud.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/*! | ||
* @license | ||
* Copyright 2019 Alfresco Software, Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { UploadApi } from '@alfresco/js-api'; | ||
import { FormModel, FormValues } from '@alfresco/adf-core'; | ||
import { TaskDetailsCloudModel } from '../../task/start-task/models/task-details-cloud.model'; | ||
import { TaskVariableCloud } from '../models/task-variable-cloud.model'; | ||
import { FormContent } from '../../services/form-fields.interfaces'; | ||
import { Observable } from 'rxjs'; | ||
|
||
export interface FormCloudInterface { | ||
|
||
uploadApi: UploadApi; | ||
|
||
getTaskForm(appName: string, taskId: string, version?: number): Observable<any>; | ||
saveTaskForm(appName: string, taskId: string, processInstanceId: string, formId: string, values: FormValues): Observable<TaskDetailsCloudModel>; | ||
createTemporaryRawRelatedContent(file: any, nodeId: string, contentHost: string): Observable<any>; | ||
completeTaskForm(appName: string, taskId: string, processInstanceId: string, formId: string, formValues: FormValues, outcome: string, version: number): Observable<TaskDetailsCloudModel>; | ||
getTask(appName: string, taskId: string): Observable<TaskDetailsCloudModel>; | ||
getTaskVariables(appName: string, taskId: string): Observable<TaskVariableCloud[]>; | ||
getForm(appName: string, formKey: string, version?: number): Observable<FormContent>; | ||
getDropDownJsonData(url: string): Observable<any>; | ||
parseForm(json: any, data?: TaskVariableCloud[], readOnly?: boolean): FormModel; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...ess-services-cloud/src/lib/task/task-form/components/task-form-cloud.component.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/*! | ||
* @license | ||
* Copyright 2019 Alfresco Software, Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Meta, moduleMetadata, Story } from '@storybook/angular'; | ||
import { FormCloudService } from '../../../form/public-api'; | ||
import { TaskCloudService } from '../../services/task-cloud.service'; | ||
import { TaskFormModule } from '../task-form.module'; | ||
import { TaskFormCloudComponent } from './task-form-cloud.component'; | ||
import { TaskCloudServiceMock } from '../../mock/task-cloud.service.mock'; | ||
import { FormCloudServiceMock } from '../../../form/mocks/form-cloud.service.mock'; | ||
import { ProcessServicesCloudStoryModule } from '../../../testing/process-services-cloud-story.module'; | ||
|
||
export default { | ||
component: TaskFormCloudComponent, | ||
title: 'Process Services Cloud/Components/Task Form', | ||
decorators: [ | ||
moduleMetadata({ | ||
imports: [ProcessServicesCloudStoryModule, TaskFormModule], | ||
providers: [ | ||
{ provide: TaskCloudService, useClass: TaskCloudServiceMock }, | ||
{ provide: FormCloudService, useClass: FormCloudServiceMock } | ||
] | ||
}) | ||
], | ||
argTypes: { | ||
appName: { table: { disable: true } }, | ||
taskId: { table: { disable: true } }, | ||
readOnly: { table: { disable: true } } | ||
} | ||
} as Meta; | ||
|
||
const template: Story<TaskFormCloudComponent> = (args: TaskFormCloudComponent) => ({ | ||
props: args | ||
}); | ||
|
||
export const primary = template.bind({}); | ||
primary.args = { | ||
appName: 'app', | ||
readOnly: false, | ||
showCancelButton: true, | ||
showCompleteButton: true, | ||
showRefreshButton: false, | ||
showTitle: true, | ||
showValidationIcon: true, | ||
taskId: 'mock-task-with-form' | ||
}; | ||
|
||
export const readOnly = template.bind({}); | ||
readOnly.args = { | ||
...primary.args, | ||
readOnly: true | ||
}; | ||
|
||
export const showRefreshButton = template.bind({}); | ||
showRefreshButton.args = { | ||
...primary.args, | ||
showRefreshButton: true | ||
}; | ||
|
||
export const hideValidationIcon = template.bind({}); | ||
hideValidationIcon.args = { | ||
...primary.args, | ||
showValidationIcon: false | ||
}; | ||
|
||
export const invalidOrMissingApp = template.bind({}); | ||
invalidOrMissingApp.args = { | ||
...primary.args, | ||
appName: undefined | ||
}; | ||
|
||
export const invalidOrMissingTaskId = template.bind({}); | ||
invalidOrMissingTaskId.args = { | ||
...primary.args, | ||
taskId: undefined | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
lib/process-services-cloud/src/lib/testing/process-services-cloud-story.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*! | ||
* @license | ||
* Copyright 2019 Alfresco Software, Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { NgModule } from '@angular/core'; | ||
import { CoreModule, TRANSLATION_PROVIDER } from '@alfresco/adf-core'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
TranslateModule.forRoot(), | ||
CoreModule.forRoot(), | ||
BrowserAnimationsModule | ||
], | ||
providers: [ | ||
{ | ||
provide: TRANSLATION_PROVIDER, | ||
multi: true, | ||
useValue: { | ||
name: 'adf-process-services-cloud', | ||
source: 'assets/adf-process-services-cloud' | ||
} | ||
} | ||
] | ||
}) | ||
export class ProcessServicesCloudStoryModule { } |