How to rewrite super.data() in AMD

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bandtank
    Active Community Member
    • Mar 2017
    • 385

    How to rewrite super.data() in AMD

    I am following the directions shown here to modify the date type. The original view has this code:
    Code:
    data() {
      const data = super.data();​
    That syntax only works in ES6, which is not valid for customizations in the custom folder. AMD must be used. How do I rewrite that statement in AMD?

    Code:
    SyntaxError: 'super' keyword unexpected here (at date.js?r=1723651316:132:20)
        at new Function (<anonymous>)
        at Object._execute (loader.js:311:17)
        at Object._handleResponseText (loader.js:964:22)
        at loader.js:925:30​
  • yuri
    Member
    • Mar 2014
    • 8624

    #2
    It should work if you use ES6 classes (rather than the 'extend' method).
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • yuri
      Member
      • Mar 2014
      • 8624

      #3
      Code:
      define(['views/fields/base'], Dep => {
          return class extends Dep {
              data() {
                 return {
                     ...super.data(),
                     newKey: 'value',
                 };
              }
          }​​
      });
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • bandtank
        Active Community Member
        • Mar 2017
        • 385

        #4
        Thank you. That worked.

        Comment

        Working...