Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get tracking view settings #1517

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/common/src/featureServiceHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,33 @@ export function _updateTypeKeywords(itemTemplate: IItemTemplate, createResponse:
return itemTemplate;
}

/**
* Add layer urls from tracking views to the templateDictionary to be used for adlib replacements
*
* @param itemTemplate Item to be created; n.b.: this item is modified
* @param templateDictionary Hash mapping property names to replacement values
* @returns void
* @private
*/
export function _setTrackingViewLayerSettings(itemTemplate: IItemTemplate, templateDictionary: any): void {
const url = itemTemplate.item.url;
const newId = itemTemplate.itemId;
let k;
Object.keys(templateDictionary).some((_k) => {
if (newId === templateDictionary[_k].itemId) {
k = _k;
return true;
}
});

itemTemplate.properties.layers.forEach((l) => {
const id = l.id.toString();
templateDictionary[k][`layer${id}`] = {
url: checkUrlPathTermination(url) + id,
};
});
}

/**
* Create the name mapping object that will allow for all templatized field
* references to be de-templatized.
Expand Down Expand Up @@ -759,6 +786,7 @@ export function addFeatureServiceLayersAndTables(
): Promise<void> {
return new Promise((resolve, reject) => {
if (isTrackingViewTemplate(itemTemplate)) {
_setTrackingViewLayerSettings(itemTemplate, templateDictionary);
resolve(null);
} else {
// Create a hash of various properties that contain field references
Expand Down
25 changes: 21 additions & 4 deletions packages/common/test/featureServiceHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ describe("Module `featureServiceHelpers`: utility functions for feature-service
displayField: "DisplayField",
editFieldsInfo: ["CreateDate"],
subtypeField: "SubtypeField",
subtypes: [{a:"A"}],
subtypes: [{ a: "A" }],
templates: [
{
A: null,
Expand Down Expand Up @@ -654,7 +654,7 @@ describe("Module `featureServiceHelpers`: utility functions for feature-service
],
editFieldsInfo: ["CreateDate"],
subtypeField: "SubtypeField",
subtypes: [{a:"A"}],
subtypes: [{ a: "A" }],
templates: [
{
A: null,
Expand Down Expand Up @@ -3517,25 +3517,42 @@ describe("Module `featureServiceHelpers`: utility functions for feature-service
).toBeRejected();
});

it("should skip tracking view", async () => {
it("should skip tracking view and collect replacement details", async () => {
const expectedUrl: string =
"https://services123.arcgis.com/org1234567890/arcgis/rest/services/ROWPermits_publiccomment/FeatureServer";
const itemId = "aaaaf0ffbdf042adb4ad24124b378d20";
const sourceItemId = "bbbaf0ffbdf042adb4ad24124b378d20";

itemTemplate = templates.getItemTemplate("Feature Service", [], expectedUrl);
itemTemplate.item.typeKeywords = ["Location Tracking View"];
itemTemplate.item.properties = {
trackViewGroup: "grp123",
};
itemTemplate.itemId = itemId;

const templateDictionary = {};
templateDictionary[sourceItemId] = {
itemId,
};

await addFeatureServiceLayersAndTables(
itemTemplate,
{},
templateDictionary,
{
layers: [],
tables: [],
},
MOCK_USER_SESSION,
);

const expectedTemplateDictionary = {
itemId,
layer0: {
url: `${expectedUrl}/0`,
},
};

expect(expectedTemplateDictionary).toEqual(templateDictionary[sourceItemId] as any);
});
});

Expand Down
8 changes: 4 additions & 4 deletions packages/common/test/restHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@ describe("Module `restHelpers`: common REST utility functions shared across pack
contingentValues,
subtypeField: "SubtypeField",
defaultSubtypeCode: "0",
subtypes: [{a: "A"}]
subtypes: [{ a: "A" }],
},
};

Expand Down Expand Up @@ -1976,7 +1976,7 @@ describe("Module `restHelpers`: common REST utility functions shared across pack
url: adminUrl + "0/updateDefinition",
params: {
updateDefinition: {
subtypeField: "SubtypeField"
subtypeField: "SubtypeField",
},
},
args,
Expand All @@ -1985,7 +1985,7 @@ describe("Module `restHelpers`: common REST utility functions shared across pack
url: adminUrl + "0/updateDefinition",
params: {
updateDefinition: {
defaultSubtypeCode: "0"
defaultSubtypeCode: "0",
},
},
args,
Expand All @@ -1994,7 +1994,7 @@ describe("Module `restHelpers`: common REST utility functions shared across pack
url: adminUrl + "0/addToDefinition",
params: {
addToDefinition: {
subtypes: [{a: "A"}]
subtypes: [{ a: "A" }],
},
},
args,
Expand Down
Loading