How to use the @esri/solution-common.templatizeTerm 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
obj.datasets.forEach((dataset: IDashboardDataset) => {
    // when the datasource has an itemId is an external datasource
    const itemId: string = common.getProp(dataset, "dataSource.itemId");
    if (itemId) {
      if (itemTemplate.dependencies.indexOf(itemId) < 0) {
        itemTemplate.dependencies.push(itemId);
      }
      const layerId: number = common.getProp(dataset, "dataSource.layerId");
      dataset.dataSource.itemId = common.templatizeTerm(
        itemId,
        itemId,
        layerId !== undefined ? ".layer" + layerId + ".itemId" : ".itemId"
      );
      if (layerId !== undefined) {
        dataset.dataSource.layerId = common.templatizeTerm(
          itemId,
          itemId,
          ".layer" + layerId + ".layerId"
        );
      }
    }
  });
}
github Esri / solution.js / packages / simple-types / src / workforce.ts View on Github external
keyProperties.forEach(p => {
    if (common.getProp(data, p)) {
      if (common.getProp(data[p], "serviceItemId")) {
        // templatize properties with id and url
        const id: string = data[p].serviceItemId;
        let serviceItemIdSuffix: string = ".itemId";

        if (common.getProp(data[p], "url")) {
          const layerId = data[p].url.substr(
            (data[p].url as string).lastIndexOf("/") + 1
          );
          data[p].url = common.templatizeTerm(
            id,
            id,
            ".layer" + layerId + ".url"
          );
          serviceItemIdSuffix = ".layer" + layerId + serviceItemIdSuffix;
        }
        data[p].serviceItemId = common.templatizeTerm(
          id,
          id,
          serviceItemIdSuffix
        );
      } else {
        // templatize simple id properties
        data[p] = common.templatizeTerm(data[p], data[p], ".itemId");
      }
    }
github Esri / solution.js / packages / simple-types / src / dashboard.ts View on Github external
obj.datasets.forEach((dataset: IDashboardDataset) => {
    // when the datasource has an itemId is an external datasource
    const itemId: string = common.getProp(dataset, "dataSource.itemId");
    if (itemId) {
      if (itemTemplate.dependencies.indexOf(itemId) < 0) {
        itemTemplate.dependencies.push(itemId);
      }
      const layerId: number = common.getProp(dataset, "dataSource.layerId");
      dataset.dataSource.itemId = common.templatizeTerm(
        itemId,
        itemId,
        layerId !== undefined ? ".layer" + layerId + ".itemId" : ".itemId"
      );
      if (layerId !== undefined) {
        dataset.dataSource.layerId = common.templatizeTerm(
          itemId,
          itemId,
          ".layer" + layerId + ".layerId"
        );
      }
    }
  });
}
github Esri / solution.js / packages / group / src / group.ts View on Github external
return new Promise((resolve, reject) => {
    // Init template
    const itemTemplate: common.IItemTemplate = common.createInitializedGroupTemplate(
      itemInfo
    );
    itemTemplate.estimatedDeploymentCostFactor = 2; // minimal set is starting, creating, done|failed

    // Templatize item info property values
    itemTemplate.item.id = common.templatizeTerm(
      itemTemplate.item.id,
      itemTemplate.item.id,
      ".itemId"
    );

    // Get the group's items--its dependencies
    common.getGroupContents(itemInfo.id, authentication).then(
      groupContents => {
        itemTemplate.type = "Group";
        itemTemplate.dependencies = groupContents;
        common.getGroup(itemInfo.id, authentication).then(
          groupResponse => {
            groupResponse.id = itemTemplate.item.id;
            itemTemplate.item = groupResponse;

            // Request resources
github Esri / solution.js / packages / simple-types / src / workforce.ts View on Github external
// templatize properties with id and url
        const id: string = data[p].serviceItemId;
        let serviceItemIdSuffix: string = ".itemId";

        if (common.getProp(data[p], "url")) {
          const layerId = data[p].url.substr(
            (data[p].url as string).lastIndexOf("/") + 1
          );
          data[p].url = common.templatizeTerm(
            id,
            id,
            ".layer" + layerId + ".url"
          );
          serviceItemIdSuffix = ".layer" + layerId + serviceItemIdSuffix;
        }
        data[p].serviceItemId = common.templatizeTerm(
          id,
          id,
          serviceItemIdSuffix
        );
      } else {
        // templatize simple id properties
        data[p] = common.templatizeTerm(data[p], data[p], ".itemId");
      }
    }
  });
github Esri / solution.js / packages / simple-types / src / webmappingapplication.ts View on Github external
paths.forEach(path => {
    const id: any = common.getProp(itemTemplate, path);
    common.setProp(
      itemTemplate,
      path,
      common.templatizeTerm(id, id, ".itemId")
    );
  });
}
github Esri / solution.js / packages / simple-types / src / dashboard.ts View on Github external
objs.forEach(obj => {
        if (obj.type === "mapWidget") {
          if (itemTemplate.dependencies.indexOf(obj.itemId) < 0) {
            itemTemplate.dependencies.push(obj.itemId);
          }
          obj.itemId = common.templatizeTerm(obj.itemId, obj.itemId, ".itemId");
        }
        if (Array.isArray(obj.datasets)) {
          _getDatasourceDependencies(obj, itemTemplate);
        }
      });
    }
github Esri / solution.js / packages / simple-types / src / webmap.ts View on Github external
const layerId = layer.url.substr(
        (layer.url as string).lastIndexOf("/") + 1
      );
      const hashId: any =
        Object.keys(urlHash).indexOf(layer.url) > -1
          ? urlHash[layer.url]
          : undefined;
      const itemId: string = layer.itemId ? layer.itemId : hashId;
      if (itemId) {
        layer.url = common.templatizeTerm(
          itemId,
          itemId,
          ".layer" + layerId + ".url"
        );
        if (layer.itemId) {
          layer.itemId = common.templatizeTerm(
            itemId,
            itemId,
            ".layer" + layerId + ".itemId"
          );
        }
      }
    }
  });
}
github Esri / solution.js / packages / simple-types / src / workforce.ts View on Github external
ids.forEach(id => {
        id = id.replace("itemID=", "");
        item.urlTemplate = item.urlTemplate.replace(
          id,
          common.templatizeTerm(id, id, ".itemId")
        );
      });
    }
github Esri / solution.js / packages / simple-types / src / webmap.ts View on Github external
layerList.forEach((layer: any) => {
    if (layer.url) {
      const layerId = layer.url.substr(
        (layer.url as string).lastIndexOf("/") + 1
      );
      const hashId: any =
        Object.keys(urlHash).indexOf(layer.url) > -1
          ? urlHash[layer.url]
          : undefined;
      const itemId: string = layer.itemId ? layer.itemId : hashId;
      if (itemId) {
        layer.url = common.templatizeTerm(
          itemId,
          itemId,
          ".layer" + layerId + ".url"
        );
        if (layer.itemId) {
          layer.itemId = common.templatizeTerm(
            itemId,
            itemId,
            ".layer" + layerId + ".itemId"
          );
        }
      }
    }
  });
}