Studio-side
- create a custom document type named documentTypeA
- create a custom document type named documentTypeB
- in Designer generate the forms
- in creation form of document A paste the following:
<!-- `nuxeo-documenttypea-create-layout` @group Nuxeo UI @element nuxeo-documenttypea-create-layout --> <dom-module id="nuxeo-documenttypea-create-layout"> <template> <style> *[role=widget] { padding: 5px; } </style> <nuxeo-input role="widget" value="{{document.properties.dc:title}}" label="Title" type="text"></nuxeo-input> <nuxeo-input role="widget" value="{{document.properties.dc:description}}" label="Description" type="text"></nuxeo-input> </template> <script> Polymer({ is: 'nuxeo-documenttypea-create-layout', behaviors: [Nuxeo.LayoutBehavior], properties: { /** * @doctype documentTypeA */ document: { type: Object, observer: '_observeDocA' }, }, _observeDocA: function() { console.log("observer type A") } }); </script> </dom-module>
- in creation form of document B paste the following:
<!-- `nuxeo-documenttypeb-create-layout` @group Nuxeo UI @element nuxeo-documenttypeb-create-layout --> <dom-module id="nuxeo-documenttypeb-create-layout"> <template> <style> *[role=widget] { padding: 5px; } </style> <nuxeo-input role="widget" value="{{document.properties.dc:title}}" label="Title" type="text"></nuxeo-input> <nuxeo-input role="widget" value="{{document.properties.dc:description}}" label="Description" type="text"></nuxeo-input> </template> <script> Polymer({ is: 'nuxeo-documenttypeb-create-layout', behaviors: [Nuxeo.LayoutBehavior], properties: { /** * @doctype documentTypeB */ document: { type: Object, observer: '_observeDocB' }, }, _observeDocB: function() { console.log("observer type B") } }); </script> </dom-module>
- save the project
Server-side
- create a workspace
- open google inspector
- in google inspector click the console tab
- in google inspector clear the console logs
- in webui click the + sign and select documentTypeA
- observe the console logs show observer type A
- close the form and observe another line showing observer type A
- click the + sign and select documentTypeB
- observe the console logs show observer type A and observer type B
- close the form and observe another line showing observer type B
- click the + sign and select documentTypeB again
- observe the console logs show observer type B and observer type B (see consoleLogs.png)
Expected behavior: the observer should be triggered only once when opening the form and only the right one (observerDocA for type A and observerDocB for type B)