Tangerine-Community / Tangerine

Digitize your offline data collection. Create your Forms online with Tangerine Editor, conduct them offline with the Tangerine Android App. All results you collect can be exported as a CSV file, easy for processing in a spreadsheet. Tangerine has been used in over 1 million assessments and surveys in over 60 countries and in 100 languages.
http://www.tangerinecentral.org/
GNU General Public License v3.0
50 stars 29 forks source link

Feature - Unified namespacing for Tangerine functions #2198

Open chrisekelley opened 4 years ago

chrisekelley commented 4 years ago

We are beginning to implement a global namespace - $ - for Tangerine helper functions. In order to reduce potential confusion with Jquery '$', how about using the 'T' namespace for Tangy functions?

Additionally, Can we organize all Tangerine functions in this namespace like this:

chrisekelley commented 4 years ago

This is how it's shaping up. In app.component, the following will be iitialized:

    //  Expose helpers inside T:
    window['T'] = {
      "form": {
        Get: Get
      },
      "user": this.userService
    }

In case, event, and issue related parts, case will be added to T:

this.window['T']['case'] = this.caseService

So far, I'm still keeping other places where instances of caseService are exposed to window so as to not cause bugs in any scripts:

this.window.caseService = this.caseService
chrisekelley commented 4 years ago

Should we split up these properties? For example, having T.form.helpers, T.form.service, T.user.service, T.case.service, etc? Is it going to be awkward to use ${T.form.helpers.Get('fieldName')} ?

    window['T'] = {
      "form": { 
         "helpers : {
            Get: Get
          }
         "service : this.formService 
        },
      "user": {
       "service" : this.userService
        }
    }
chrisekelley commented 4 years ago

There is a new doc on using this new T namespace in docs/editor/case-module/custom-case-reports.md