-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from Esri/c/136998-change-method-signatures-t…
…o-accept-ids-instead-of-models 136998 - Adjust method signatures to accept ids instead of models
- Loading branch information
Showing
20 changed files
with
172 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
|
||
export * from "./utils"; | ||
export * from "./items"; | ||
export * from "./sharing"; | ||
export * from "./utils"; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
|
||
import { IRequestOptions } from "@esri/arcgis-rest-request"; | ||
import { getItem } from "@esri/arcgis-rest-portal"; | ||
import { IModel, IGetSurveyModelsResponse } from "@esri/hub-common"; | ||
import { getInputFeatureServiceModel } from "./get-input-feature-service-model"; | ||
import { getSourceFeatureServiceModelFromFieldworker } from "./get-source-feature-service-model-from-fieldworker"; | ||
import { getStakeholderModel } from "./get-stakeholder-model"; | ||
import { isFieldworkerView } from "../utils/is-fieldworker-view"; | ||
|
||
/** | ||
* Builds a dictionary of Survey items for the given Form model | ||
* @param {string} formId The Form ID of the survey | ||
* @param {IRequestOptions} requestOptions The request options | ||
* @returns {Promise<IGetSurveyModelsResponse>} | ||
*/ | ||
export const getSurveyModels = ( | ||
formId: string, | ||
requestOptions: IRequestOptions | ||
): Promise<IGetSurveyModelsResponse> => { | ||
let fieldworker: IModel; | ||
let stakeholder: IModel; | ||
|
||
return getItem(formId, requestOptions) | ||
.then((item) => { | ||
const promises: Array<Promise<IModel>> = [ | ||
// the primary input will be the fieldworker (if it exists), otherwise | ||
// the source feature service. | ||
getInputFeatureServiceModel( | ||
formId, | ||
requestOptions | ||
), | ||
getStakeholderModel( | ||
formId, | ||
requestOptions | ||
) | ||
]; | ||
|
||
return Promise.all(promises) | ||
.then(([featureServiceOrFieldworkerModelResult, stakeholderResult]) => { | ||
stakeholder = stakeholderResult; | ||
|
||
if (isFieldworkerView(featureServiceOrFieldworkerModelResult.item)) { | ||
fieldworker = featureServiceOrFieldworkerModelResult; | ||
// if the primary input is the fieldworker, fetch | ||
// the source feature service | ||
return getSourceFeatureServiceModelFromFieldworker( | ||
fieldworker.item.id, | ||
requestOptions | ||
); | ||
} else { | ||
return featureServiceOrFieldworkerModelResult; | ||
} | ||
}) | ||
.then((featureService) => { | ||
return { | ||
form: { item }, | ||
featureService, | ||
fieldworker, | ||
stakeholder | ||
}; | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from "./get-input-feature-service-model"; | ||
export * from "./get-source-feature-service-model-from-fieldworker"; | ||
export * from "./get-stakeholder-model"; | ||
export * from "./get-survey-models"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...g/get-input-feature-service-model.test.ts → ...s/get-input-feature-service-model.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...re-service-model-from-fieldworker.test.ts → ...re-service-model-from-fieldworker.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.