forked from enviPath/enviPy
[Feature] Attach AdditionalInformation to Nodes (#428)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#428
This commit is contained in:
@ -186,6 +186,40 @@ window.AdditionalInformationApi = {
|
||||
return this._handleResponse(response, "createItem");
|
||||
},
|
||||
|
||||
/**
|
||||
* Create new additional information and attach it to an object.
|
||||
|
||||
* @param {string} modelName - Name/type of the additional information model
|
||||
* @param {Object} data - Data for the new item
|
||||
* @param {string} attachObjectUrl - UUID of the object this data should be attached to
|
||||
* @param {string} scenarioUuid - UUID of the scenario
|
||||
* @returns {Promise<{status: string, uuid: string}>}
|
||||
*/
|
||||
async createItemOnNonScenarioObject(modelName, data, attachObjectUrl, scenarioUuid) {
|
||||
const sanitizedData = this.sanitizePayload(data);
|
||||
this._log("createItemOnNonScenarioObject", { modelName, data: sanitizedData, attachObjectUrl, scenarioUuid });
|
||||
|
||||
sanitizedData.attach_obj_url = attachObjectUrl;
|
||||
if (scenarioUuid) {
|
||||
sanitizedData.scenario_uuid = scenarioUuid;
|
||||
}
|
||||
|
||||
|
||||
// Normalize model name to lowercase
|
||||
const normalizedName = modelName.toLowerCase();
|
||||
|
||||
const response = await fetch(
|
||||
`/api/v1/information/${normalizedName}/`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: this._buildHeaders(),
|
||||
body: JSON.stringify(sanitizedData),
|
||||
},
|
||||
);
|
||||
|
||||
return this._handleResponse(response, "createItemOnNonScenarioObject");
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete additional information from a scenario
|
||||
* @param {string} scenarioUuid - UUID of the scenario
|
||||
|
||||
Reference in New Issue
Block a user