Uploaded image for project: 'Nuxeo Elements'
  1. Nuxeo Elements
  2. ELEMENTS-863

Observer fires when it should not

    XMLWordPrintable

    Details

    • Type: Question
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.0, 3.0.0
    • Fix Version/s: 2.4.6, 3.0.0
    • Component/s: Actions
    • Backlog priority:
      600
    • Sprint:
      nxGang Sprint 11.1.5, nxGang Sprint 11.1.8
    • Story Points:
      2

      Description

      Studio-side

      1. create a custom document type named documentTypeA
      2. create a custom document type named documentTypeB
      3. in Designer generate the forms
      4. 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>
        
        
      5. 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>
        
        
      6. save the project

      Server-side

      1. create a workspace
      2. open google inspector
      3. in google inspector click the console tab
      4. in google inspector clear the console logs
      5. in webui click the + sign and select documentTypeA
      6. observe the console logs show observer type A
      7. close the form and observe another line showing observer type A
      8. click the + sign and select documentTypeB
      9. observe the console logs show observer type A and observer type B
      10. close the form and observe another line showing observer type B
      11. click the + sign and select documentTypeB again
      12. 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)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 2 hours, 30 minutes
                  1d 2h 30m