-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
957f2f8
commit d51cce5
Showing
12 changed files
with
167 additions
and
172 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Initialize the options for the select input by formatting the default and variable values array. | ||
* @param {Array} variables - Array of plugin variables values. | ||
* @param {Array} defaultValues - Array of attribute default values. | ||
* @returns {Array} Array of objects representing the default and variable values. | ||
*/ | ||
export function initSelectOptions(variables, defaultValues) { | ||
const categories = [...new Set(variables.map(({ category }) => category))]; | ||
const children = categories.map((category) => ({ | ||
type: 'category', | ||
name: category, | ||
children: variables | ||
.filter((variable) => variable.category === category) | ||
.map((variable) => ({ | ||
type: 'item', | ||
name: variable.name, | ||
value: variable.value !== null ? variable.value : variable.defaultValue, | ||
formattedName: variable.formattedName, | ||
})), | ||
})); | ||
|
||
return [{ | ||
type: 'category', | ||
name: 'plugin.component.attribute.selectInput.defaultValue', | ||
children: defaultValues.map((value) => ({ | ||
type: 'item', | ||
value, | ||
})), | ||
}, { | ||
type: 'category', | ||
name: 'plugin.component.attribute.selectInput.variables', | ||
children, | ||
}]; | ||
} |
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
Oops, something went wrong.