| 1 |
import ReactDOM from 'react-dom'; |
| 2 |
import FormControlController from './FormControlController'; |
| 3 |
import FormWidgetController from './FormWidgetController'; |
| 4 |
|
| 5 |
export interface IFormAttributes { |
| 6 |
formId: string; |
| 7 |
formName: string; |
| 8 |
portalId: string; |
| 9 |
} |
| 10 |
|
| 11 |
export default class registerFormWidget { |
| 12 |
widgetContainer: Element; |
| 13 |
attributes: IFormAttributes; |
| 14 |
controlContainer: Element; |
| 15 |
setValue: Function; |
| 16 |
|
| 17 |
constructor(controlContainer: any, widgetContainer: any, setValue: Function) { |
| 18 |
const attributes = widgetContainer.dataset.attributes |
| 19 |
? JSON.parse(widgetContainer.dataset.attributes) |
| 20 |
: {}; |
| 21 |
|
| 22 |
this.widgetContainer = widgetContainer; |
| 23 |
this.controlContainer = controlContainer; |
| 24 |
this.setValue = setValue; |
| 25 |
this.attributes = attributes; |
| 26 |
} |
| 27 |
|
| 28 |
render() { |
| 29 |
ReactDOM.render( |
| 30 |
FormWidgetController(this.attributes, this.setValue)(), |
| 31 |
this.widgetContainer |
| 32 |
); |
| 33 |
|
| 34 |
ReactDOM.render( |
| 35 |
FormControlController(this.attributes, this.setValue)(), |
| 36 |
this.controlContainer |
| 37 |
); |
| 38 |
} |
| 39 |
|
| 40 |
done() { |
| 41 |
ReactDOM.unmountComponentAtNode(this.widgetContainer); |
| 42 |
ReactDOM.unmountComponentAtNode(this.controlContainer); |
| 43 |
} |
| 44 |
} |
| 45 |
|