AddData Widget Modifications

398
15
Jump to solution
12-04-2017 01:17 PM
JamesCrandall
MVP Frequent Contributor

Problem: The AddData widget does not filter out ESRI Premium Content from its search results and publicly shared WAB apps will have many non-organizational account users.  The WAB refreshes if attempting to add ESRI premium content (after signing in) and is a very confusing user experience.

Question: Is there an easy way to filter out ESRI Premium Content from the AddData widget search results?

We're interested in an interim quick solution that we can implement to our WAB apps we build with WAB Developer and would like to alter the AddData widget as described above.  In the longer term, an enhancement request will be made to fix this issue as it seems to be a design flaw in general.  There should not be interruptions to the logical flow and is quite confusing to the user.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

James,

  This change should do it:

      buildQueryParams: function(task) {
        var qRequired = null;
        if (typeof this.qRequiredFilter === "string" && this.qRequiredFilter.length > 0) {
          qRequired = this.qRequiredFilter;
        }
        var params = {
          q: qRequired,
          canSortByRelevance: false
        };
        array.forEach(this.getComponents(), function(component) {
          component.appendQueryParams(params, task);
        });
        if(params.q.indexOf("orgid") === -1 && params.q.indexOf("owner") === -1){
          var portal = this.searchContext.portal;

          if(!portal.haveSignIn()){
            var q = "(-\"Requires Subscription\")";
            if (params.q !== null && params.q.length > 0) {
              params.q += " AND " + q;
            } else {
              params.q = q;
            }
          }
        }
        delete params.canSortByRelevance;
        if (params.q === null && typeof this.qDefaultFilter === "string" &&
          this.qDefaultFilter.length > 0) {
          params.q = this.qDefaultFilter;
        }
        return params;
      },

View solution in original post

15 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

James,

   I am having a hard time verifying it working but see if this works for you (since you know what was returning for you) widgets\AddData\search\SearchPane.js line 29:

define(["dojo/_base/declare",
    "dojo/_base/lang",
    "dojo/_base/array",
    "dojo/on",
    "dojo/dom-class",
    "dijit/_WidgetBase",
    "dijit/_TemplatedMixin",
    "dijit/_WidgetsInTemplateMixin",
    "dojo/text!./templates/SearchPane.html",
    "dojo/i18n!../nls/strings",
    "./SearchBox",
    "./BBoxOption",
    "./ScopeOptions",
    "./TypeOptions",
    "./SortOptions",
    "./ResultsPane",
    "./Paging",
    "./ResultCount"
  ],
  function(declare, lang, array, on, domClass, _WidgetBase, _TemplatedMixin,
    _WidgetsInTemplateMixin, template, i18n) {

    return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {

      i18n: i18n,
      templateString: template,

      qDefaultFilter: null,
      qRequiredFilter: "tags:(* NOT 'premium content')",
      searchOnStart: true,
JamesCrandall
MVP Frequent Contributor

Much appreciated, Robert -- I'll dig into this today and give it a go.

0 Kudos
JamesCrandall
MVP Frequent Contributor

Robert -- that definitely had an affect.  However, it filters out all "My Organization" content if signed in.  I think the most desired solution is to filter out ESRI premium content from the "ArcGIS Online" drop-down, but if the user is signed in then do not apply any filter.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

James,

  Hmm. Strange the filter is set for item tagged with "Premium content" to not show. So I am not sure why your content would be filtered out when signed in. So are you saying you only want to apply the filter when the "ArcGIS Online" source is selected and the user is Not signed in?

0 Kudos
JamesCrandall
MVP Frequent Contributor

So are you saying you only want to apply the filter when the "ArcGIS Online" source is selected and the user is Not signed in?

Yes, that sounds like what we'd want to see.  If we have a public WAB deployed to our domain then no login is required if the app is opened and no ESRI premium content should be listed in any search result at all because it will automatically redirect to the sign in.  This is very disruptive to the user experience -- it should prompt the user to ask if they'd like to sign in and offer the opportunity to cancel so that the WAB does not refresh and the session content lost.

However, we can have all internal resources point to the WAB with url parameters so that it opens at the org sign-in rather than open as a public user.  This forces the user to sign in first -- this way any AddData search results should then contain all public content, content shared with the organization and ESRI premium content would be fine to add and there will not be any refresh because the user is already signed into the org.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

James,

   OK, here is what I came up with.

SearchPane.js (remove the change from the previous post and make this change):

      buildQueryParams: function(task) {
        var qRequired = null;
        if (typeof this.qRequiredFilter === "string" && this.qRequiredFilter.length > 0) {
          qRequired = this.qRequiredFilter;
        }
        var params = {
          q: qRequired,
          canSortByRelevance: false
        };
        array.forEach(this.getComponents(), function(component) {
          component.appendQueryParams(params, task);
        });
        if(params.q.indexOf("orgid") === -1 && params.q.indexOf("owner") === -1){
          var portal = this.searchContext.portal;
          if(!portal.haveSignIn()){
            var q = "(tags:(* NOT 'premium content'))";
            if (params.q !== null && params.q.length > 0) {
              params.q += " AND " + q;
            } else {
              params.q = q;
            }
          }
        }
        delete params.canSortByRelevance;
        if (params.q === null && typeof this.qDefaultFilter === "string" &&
          this.qDefaultFilter.length > 0) {
          params.q = this.qDefaultFilter;
        }
        return params;
      },
JamesCrandall
MVP Frequent Contributor

Thank you.  Does this have to be added in any particular location within SearchPane.js or other call to buildQueryParams?

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

James,

  Sorry for not making it clear that is a replacement buildQueryParams function (so replace your current buildQueryParams function with this one).

JamesCrandall
MVP Frequent Contributor

Got it.  Thanks a million.

0 Kudos