[ACA-4198] fix appVersion init for multiple versions (#6785)

* fix appVersion init for multiple versions

* fix test
This commit is contained in:
Denys Vuika 2021-03-06 14:42:41 +00:00 committed by GitHub
parent e21b777a3c
commit e7e8fe5cb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 5 deletions

View File

@ -29,9 +29,11 @@
placeholder="{{processFilterProperty.label | translate}}"
[formControlName]="processFilterProperty.key"
[attr.data-automation-id]="'adf-cloud-edit-process-property-' + processFilterProperty.key">
<mat-option *ngFor="let propertyOption of processFilterProperty.options" [value]="propertyOption.value" [attr.data-automation-id]="'adf-cloud-edit-process-property-options-' + processFilterProperty.key">
{{ propertyOption.label | translate }}
</mat-option>
<mat-option
*ngFor="let propertyOption of processFilterProperty.options"
[value]="propertyOption.value"
[attr.data-automation-id]="'adf-cloud-edit-process-property-options-' + processFilterProperty.key"
>{{ propertyOption.label | translate }}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex="23%" *ngIf="processFilterProperty.type === 'multi-select'" [attr.data-automation-id]="processFilterProperty.key">

View File

@ -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 { ProcessFilterCloudModel } from './process-filter-cloud.model';
describe('ProcessFilterCloudModel', () => {
it('should use appVersion from the provided object', () => {
const model = new ProcessFilterCloudModel({ appVersion: 1 });
expect(model.appVersion).toBe(1);
});
it('should use appVersionMultiple if provided', () => {
const model = new ProcessFilterCloudModel({ appVersionMultiple: [1, 2] });
expect(model.appVersion).toEqual([1, 2]);
});
it('should use appVersionMultiple over the appVersion if both provided', () => {
const model = new ProcessFilterCloudModel({ appVersion: 1, appVersionMultiple: [1, 2] });
expect(model.appVersion).toEqual([1, 2]);
});
});

View File

@ -60,7 +60,12 @@ export class ProcessFilterCloudModel {
this.icon = obj.icon || null;
this.index = obj.index || null;
this.appName = obj.appName || obj.appName === '' ? obj.appName : null;
this.appVersion = obj.appVersion ? obj.appVersion : (obj.appVersionMultiple instanceof Array ? obj.appVersionMultiple : null);
this.appVersion = obj.appVersion || null;
if (obj.appVersionMultiple && Array.isArray(obj.appVersionMultiple) && obj.appVersionMultiple.length > 0) {
this.appVersion = obj.appVersionMultiple;
}
this.processInstanceId = obj.processInstanceId || null;
this.processName = obj.processName || null;
this.initiator = obj.initiator || null;