How to use the @esri/solution-common.getProp function in @esri/solution-common

To help you get started, we’ve selected a few @esri/solution-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Esri / solution.js / packages / simple-types / src / dashboard.ts View on Github external
export function _getDatasourceInfo(
  obj: any,
  datasourceInfos: common.IDatasourceInfo[]
): any {
  let info: any;
  // the datasource will have an id property when it's referencing a map layer
  // the fields collection will already be defined
  const id: string =
    common.getProp(obj, "dataSource.id") || common.getProp(obj, "targetId");
  if (id) {
    const dashboardLayerId: string = id.split("#")[1];
    if (
      !datasourceInfos.some(di => {
        info = di.ids.indexOf(dashboardLayerId) > -1 ? di : info;
        return di.ids.indexOf(dashboardLayerId) > -1;
      })
    ) {
      // in some cases the id will not contain a layer name...it will have the dashboard id for another widget
      // in that case lookup the datasource from referenced widget
      const dashboardWidgetId: string = id.split("#")[0];
      datasourceInfos.some(di => {
        const references: string[] = di.references || [];
        const hasRef: boolean = references.indexOf(dashboardWidgetId) > -1;
        info = hasRef ? di : info;
        return hasRef;
github Esri / solution.js / packages / simple-types / src / dashboard.ts View on Github external
})
    ) {
      // in some cases the id will not contain a layer name...it will have the dashboard id for another widget
      // in that case lookup the datasource from referenced widget
      const dashboardWidgetId: string = id.split("#")[0];
      datasourceInfos.some(di => {
        const references: string[] = di.references || [];
        const hasRef: boolean = references.indexOf(dashboardWidgetId) > -1;
        info = hasRef ? di : info;
        return hasRef;
      });
    }
  } else {
    // otherwise match the itemId and the layerId to get the correct fields and path
    const itemId: any = common.cleanLayerBasedItemId(
      common.getProp(obj, "dataSource.itemId")
    );
    const layerId: any = common.cleanLayerId(
      common.getProp(obj, "dataSource.layerId")
    );
    if (itemId) {
      datasourceInfos.some(di => {
        const matches: boolean = itemId === di.itemId && layerId === di.layerId;
        info = matches ? di : info;
        return matches;
      });
    }
  }
  return info;
}
github Esri / solution.js / packages / simple-types / src / webmap.ts View on Github external
export function _templatizeProperty(
  solutionTemplate: common.IItemTemplate,
  datasourceInfos: common.IDatasourceInfo[],
  path: string
): void {
  const objs: any[] = common.getProp(solutionTemplate, path);
  if (objs) {
    common.setProp(solutionTemplate, path, _templatize(objs, datasourceInfos));
  }
}
github Esri / solution.js / packages / simple-types / src / workforce.ts View on Github external
const templatizeUrlTemplate = function(item: any) {
    let ids: string[];
    if (common.getProp(item, "urlTemplate")) {
      ids = item.urlTemplate.match(/itemID=[0-9A-F]{32}/gim) || [];
      ids.forEach(id => {
        id = id.replace("itemID=", "");
        item.urlTemplate = item.urlTemplate.replace(
          id,
          common.templatizeTerm(id, id, ".itemId")
        );
      });
    }
  };
github Esri / solution.js / packages / creator / src / createItemTemplate.ts View on Github external
layersAndTables.forEach(obj => {
        if (!common.hasDatasource(datasourceInfos, t.itemId, obj.id)) {
          datasourceInfos.push({
            itemId: t.itemId,
            layerId: obj.id,
            fields: obj.fields,
            basePath: t.itemId + ".layer" + obj.id + ".fields",
            url: common.getProp(t, "item.url"),
            ids: [],
            relationships: obj.relationships || [],
            adminLayerInfo: obj.adminLayerInfo || {}
          });
        }
      });
    }
github Esri / solution.js / packages / simple-types / src / webmappingapplication.ts View on Github external
serviceResponses.forEach(serviceResponse => {
            if (common.getProp(serviceResponse, "serviceItemId")) {
              const serviceTemplate: string =
                "{{" +
                serviceResponse.serviceItemId +
                (serviceResponse.hasOwnProperty("id")
                  ? ".layer" + serviceResponse.id
                  : "") +
                ".url}}";
              objString = replaceUrl(
                objString,
                requestUrls[i],
                serviceTemplate
              );
            }
            i++;
          });
          resolve(objString);
github Esri / solution.js / packages / simple-types / src / workforce.ts View on Github external
user => {
        _updateDispatchers(
          common.getProp(newlyCreatedItem, "data.dispatchers"),
          user.username || "",
          user.fullName || "",
          destinationAuthentication
        ).then(
          results => {
            resolve({ success: results });
          },
          e => reject(common.fail(e))
        );
      },
      e => reject(common.fail(e))
github Esri / solution.js / packages / simple-types / src / webmappingapplication.ts View on Github external
paths.forEach(path => {
    const url: string = common.getProp(itemTemplate, path);
    if (url) {
      const subString: string = url.substring(
        url.indexOf("/", url.indexOf("//") + 2)
      );
      common.setProp(
        itemTemplate,
        path,
        subString !== url ? base + subString : base
      );
    }
  });
}