Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4739

Improve pdfviewer component by making each promise level override-accessible

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Done
    • Affects Version/s: 9.0.0
    • Fix Version/s: 9.5.1
    • Component/s: Components
    • Security Level: Jimmy
    • Labels:
    • gh.sprint.customfield.default.name:
      ZK 9.5.1 S1

      Description

      Current state

      The pdfviewer component contains inline lambdas used in promises.

      This makes overrides very difficult / impossible without replacing the whole JS file due to the code being unreachable in client.

      Ex: zkex/pdfviewer/Pdfviewer.ts

      _getPage(pageNum) has a structure such as:

       

      _getPage(pageNum: number, pdfFirstRender = false) {
                      ...
      		return this._pdf.getPage(pageNum).then(page => {
                              ...
      			return page.render({...})
      				.promise
      				.then(() => page.getTextContent({}))
      				.then(textContent => {
                              ...
      

       

      Desired state

      Instead of using inline promises, the promise could access a function defined at class level.
      ex:

      _getPage(pageNum: number, pdfFirstRender = false) {
                      ...
      		return this._pdf.getPage(pageNum).then(promiseGetPageAfterPdfGetPage);
      
      //end of instance-level function, start of class-level functions
      },{ 
          promiseGetPageAfterPdfGetPage: function (page) {
              ...
              return page.render({...})
      				.promise
      				.then(promiseGetPageGetTextContent)
          },
          promiseGetPageGetTextContent: function(){
              ...
          }
      
      }
      

       
      etc.

      This would allow developers to set overrides granularly without having to replace the whole JS file.

      Workaround

      Compile and replace the whole pdfviewer.tf source by the updated replacement. 

        Attachments

          Activity

            People

            Assignee:
            rudyhuang rudyhuang
            Reporter:
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 4 hours
                4h
                Remaining:
                Time Spent - 2 hours Remaining Estimate - 2 hours
                2h
                Logged:
                Time Spent - 2 hours Remaining Estimate - 2 hours
                2h