Uploaded image for project: 'Community Dashboard Framework'
  1. Community Dashboard Framework
  2. CDF-713

As a user, I'd like to be able to easily change the datasource used by a component in the preExec function.

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Closed
    • Severity: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.0.0 GA, 6.1-16.08.18
    • Component/s: None
    • Labels:
      None
    • Story Points:
      0
    • Notice:
      When an issue is open, the "Fix Version/s" field conveys a target, not necessarily a commitment. When an issue is closed, the "Fix Version/s" field conveys the version that the issue was fixed in.
    • Sprint:
      No idea what we are doing

      Description

      At the moment, a query used by a component is retrieved, for the triggerQuery lifecycle, in a callback passed to .execute by the .beginQuery function. (see attached file).
      This callback will run after .preExec, but the query definition parameters are part of the callback's scope, so to be able to use a different query, we need to use the exact same objects that were passed to beginQuery.
      Some dashboard implementations work by replacing definitions objects in .preExec, which breaks the ability to override the query.

      Suggestion:
      Allow triggerQuery to receive either a getter function, or the queryDefinition object.
      This will allow queryDefinition to escape the scope "trap" it is currently in, and so replacing queryDefinition entirely will be possible.
      Go trough all the components which use the triggerQuery lifecycle, and change them to provide a getter instead of the queryDefinition.

      //implementation suggestion
      triggerQuery: function(queryDef, callback, queryOptions) {
            this.beginQuery(
              _.isFunction(queryDef) ? queryDef() : queryDef, 
              function(data) {
                callback(data);
                this.endExec();
              },
              queryOptions);
          }
      

      Success Criteria:

      • A dashboard developer should be able to change the datasource used by a component, in the preExecution function, in 3 different ways:
        • this.queryDefinition.dataSource = "otherDatasource";
        • this.queryDefinition = $.extend( this.queryDefinition , { dataSource: "otherDatasource", ... });
        • this.queryDefinition = $.extend( {}, this.queryDefinition , { dataSource: "otherDatasource", ... });
      • All of these strategies must work.
      • Ideally, attach a sample using the 3 strategies.
      • Update the triggerQuery Documentation

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                gneto Gonçalo Neto
              • Votes:
                5 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: