Appearance
Dropdown Options Integration
This document explains how dropdown options are integrated and synchronized between Application-Frontend and Creative-Engine.
Architecture Overview
The dropdown options integration involves two main components:
- Application-Frontend: Contains the configuration UI for dropdown inputs in
DropdownInputConfiguration.vue - Creative-Engine: Contains the form rendering and dropdown options management in
CreativeFormBlock.vueandDropdownOptionsManager.vue
These components run in separate contexts:
- Application-Frontend runs in the main window with Vue/Vuex store
- Creative-Engine runs inside an iframe with its own DataStore
Communication Flow
From Application-Frontend to Creative-Engine
When dropdown options are updated in
DropdownInputConfiguration.vue, the changes are saved to the Vuex store using theupdateValuemethod from theconfigurationLogicmixin.The updated configuration is loaded into the Creative-Engine iframe when:
- The iframe is initially loaded via
PreviewIframe.vue - The preview is refreshed
- The iframe is initially loaded via
The Creative-Engine loads the configuration data from the JSON payload passed to it and stores it in the reactive
DataStore.creativeSettings.
Within Creative-Engine
CreativeFormBlock.vuerenders form inputs including dropdowns based on data fromformStore.getFormProperties().When in editor mode, dropdown options can be edited using the
DropdownOptionsManager.vuecomponent.When dropdown options are updated in the
DropdownOptionsManager.vue:- Changes are validated locally
- If valid, changes are synced to the form store using the
syncOptionsToInputmethod - The
syncOptionsToInputmethod updates the options directly in the DataStore and forces a re-render
The
updateDropdownOptionsmethod inCreativeFormBlock.vuehandles the update by:- Updating the options in the form properties
- Ensuring the current value is still valid with the new options
- Forcing a re-render by updating the field with its current value
- Emitting an event that can be captured by parent components
Adding New Form Inputs
In editor mode, new form inputs can be added using the UI in
CreativeFormBlock.vue.The
addNewInputmethod:- Generates a unique block name for the new input
- Creates a new input with default properties based on the selected type
- Adds the new input to the form properties
- Updates the form store
Testing
To test dropdown options functionality:
A
testDropdownOptionsmethod has been added toCreativeFormBlock.vuethat allows for programmatic testing of dropdown options updates.This method can be called with an input index and new options array to verify that updates are processed correctly.
Known Limitations
Real-time updates between Application-Frontend and Creative-Engine require a refresh of the preview iframe.
The communication between the two contexts is one-way (Application-Frontend to Creative-Engine) during initial load or refresh.
Future Improvements
Implement two-way communication using postMessage API to allow real-time updates from Creative-Engine back to Application-Frontend.
Add more robust validation and error handling for dropdown options.
Improve the UI for managing dropdown options with features like drag-and-drop reordering.