-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AAE-21392 Fix dropdown cloud widget style
- Loading branch information
1 parent
219f239
commit 7b61ec4
Showing
7 changed files
with
112 additions
and
14 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...es-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud-placeholder.pipe.spec.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,32 @@ | ||
/*! | ||
* @license | ||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. | ||
* | ||
* 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 { DropdownCloudPlaceholderPipe } from "./dropdown-cloud-placeholder.pipe"; | ||
import { DEFAULT_OPTION } from "./dropdown-cloud.widget"; | ||
import { optionsMock, optionsMockWithDefaultOption } from './dropdown-cloud.mock'; | ||
|
||
describe('DropdownCloudPlaceholderPipe', () => { | ||
const pipe = new DropdownCloudPlaceholderPipe(); | ||
|
||
it('should set default option if it exists', () => { | ||
expect(pipe.transform(optionsMockWithDefaultOption)).toBe(DEFAULT_OPTION.name); | ||
}); | ||
|
||
it('should not set default option if it does not exist', () => { | ||
expect(pipe.transform(optionsMock)).toBe(undefined); | ||
}); | ||
}); |
35 changes: 35 additions & 0 deletions
35
...ervices-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud-placeholder.pipe.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,35 @@ | ||
/*! | ||
* @license | ||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. | ||
* | ||
* 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 { FormFieldOption } from '@alfresco/adf-core'; | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DEFAULT_OPTION } from './dropdown-cloud.widget'; | ||
|
||
@Pipe({ | ||
name: 'dropdownCloudPlaceholder' | ||
}) | ||
export class DropdownCloudPlaceholderPipe implements PipeTransform { | ||
|
||
private getDefaultOption(options: FormFieldOption[]): FormFieldOption { | ||
return options.find((option: FormFieldOption) => option.id === DEFAULT_OPTION.id); | ||
} | ||
|
||
transform(options: FormFieldOption[]): string { | ||
return this.getDefaultOption(options)?.name; | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.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,37 @@ | ||
/*! | ||
* @license | ||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. | ||
* | ||
* 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 { FormFieldOption } from '@alfresco/adf-core'; | ||
|
||
export const optionsMock: FormFieldOption[] = [ | ||
{ | ||
id: 'option-01', | ||
name: 'Option 01' | ||
}, | ||
{ | ||
id: 'option-02', | ||
name: 'Option 02' | ||
}, | ||
]; | ||
|
||
export const optionsMockWithDefaultOption: FormFieldOption[] = [ | ||
{ | ||
id: 'empty', | ||
name: 'Choose one...' | ||
}, | ||
...optionsMock | ||
]; |
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
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