Enabled dynamic options to use CategoryValue type. SQL MIAA deploy now up to parity with Portal. (#18279)

* Removed extra backup policy field in MIAA deploy. Re-ordered fields in MIAA deploy for parity.

* Enabled dynamic options to work with categoryvalue type objects.

* Removed defaultValue CategoryValue typing, fixed some type checks.

* Added a clarifying comment to setModelValues and removed unnecessary type from defaultValue

* Removed CategoryValue from selection

* Undo parenthesis for single type
This commit is contained in:
Candice Ye
2022-02-11 11:19:30 -08:00
committed by GitHub
parent 56f72e33b1
commit 85cfde7421
5 changed files with 70 additions and 77 deletions

View File

@@ -438,7 +438,7 @@ async function hookUpDynamicOptions(context: WizardPageContext): Promise<void> {
const updateOptions = async () => {
const currentValue = await targetComponent.getValue();
if (field.dynamicOptions && field.options && fieldComponent && fieldComponent.setOptions) {
const targetValueFound = field.dynamicOptions.alternates.find(item => item.selection === currentValue);
let targetValueFound = field.dynamicOptions.alternates.find(item => item.selection === currentValue);
if (targetValueFound) {
fieldComponent.setOptions(<OptionsInfo>{
values: targetValueFound.alternateValues,
@@ -1646,7 +1646,12 @@ export function getPasswordMismatchMessage(fieldName: string): string {
export async function setModelValues(inputComponents: InputComponents, model: Model): Promise<void> {
await Promise.all(Object.keys(inputComponents).map(async key => {
const value = await inputComponents[key].getValue();
model.setPropertyValue(key, value);
// Check if value is of type CategoryValue. If so, we need to get the name from the CategoryValue object.
if (typeof (value) === 'object') {
model.setPropertyValue(key, value.name);
} else {
model.setPropertyValue(key, value);
}
}));
}