{"version":3,"sources":["webpack:///./node_modules/@abaco/activities-module/src/modules/activities-module/api/IrrigationApi.ts","webpack:///./node_modules/@abaco/activities-module/src/modules/activities-module/models/Utils.ts"],"names":["IrrigationApi","http","rootPath","this","paging","filter","get","params","offset","count","toUpperCase","undefined","res","data","plot_id","action_id","editedIrrigation","put","toHA","pkCuaa","protocol_id","execution_id","newirrigation","post","pk_cuaa","campaign","delete","activity_id","status","object","keys","forEach","key","path","split","lastKey","splice","length","join","ref","reduce","accum","k","console","warn","val","toHAList","list","r","toPercentage","perc","Math","floor"],"mappings":"2OAKqBA,E,WAKjB,WAAYC,EAAkBC,GAAgB,uBAC1CC,KAAKF,KAAOA,EACZE,KAAKD,SAAWA,E,kHAGb,WAAyBE,EAAsBC,GAA/C,uGACeF,KAAKF,KAAKK,IAAV,UAAiBH,KAAKD,SAAtB,wCAAsE,CACpFK,OAAQ,CACJC,OAAQJ,EAAOI,OACfC,MAAOL,EAAOK,MACdJ,OAAQA,EAAS,4BAAH,OAA+BA,EAAOK,oBAAkBC,KAL3E,cACGC,EADH,yBASIA,EAAIC,MATR,gD,iJAYA,WAAqBC,EAAiBC,EAAmBC,GAAzD,uGACeb,KAAKF,KAAKgB,IAAV,UAAiBd,KAAKD,SAAtB,2BAAiDY,EAAjD,uBAAuEC,EAAvE,eAA+FC,GAD9G,cACGJ,EADH,OAEHM,eAAKN,EAAIC,KAAM,CAAC,iBAFb,kBAGID,EAAIC,MAHR,gD,2JAMA,WAA6BM,EAAgBC,EAAqBL,EAAmBC,GAArF,uGACeb,KAAKF,KAAKgB,IAAV,UAAiBd,KAAKD,SAAtB,kCAAwDiB,EAAxD,iCAAuFC,EAAvF,uBAAiHL,EAAjH,eAAyIC,GADxJ,cACGJ,EADH,yBAEIA,EAAIC,MAFR,gD,0JAKA,WAA0BC,EAAiBO,EAAsBC,GAAjE,uGACenB,KAAKF,KAAKsB,KAAV,UAAkBpB,KAAKD,SAAvB,2BAAkDY,EAAlD,oBAAqEO,EAArE,e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O","file":"js/chunk-6211610e.63469a4d.js","sourcesContent":["import { HTTPClient } from '@abaco/web-common/src/HTTP';\nimport { PagedResults, PagingParams } from '@abaco/web-common/src/Paging';\nimport { IrrigationType, IrrigationOut, Irrigation, CompleteIrrigation, Activity } from \"../models/Irrigation\";\nimport { toHA } from '../models/Utils';\n\nexport default class IrrigationApi {\n\n private http: HTTPClient;\n private rootPath: string;\n\n constructor(http: HTTPClient, rootPath: string) {\n this.http = http;\n this.rootPath = rootPath\n }\n\n public async getIrrigationTypes(paging: PagingParams, filter: string | null): Promise> {\n const res = await this.http.get(`${this.rootPath}/v1/plots/dictionary_irrigation_type`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n filter: filter ? `^ds_irrigation_type like ${filter.toUpperCase()}` : undefined\n }\n })\n\n return res.data;\n }\n\n public async editIrrigation(plot_id: number, action_id: number, editedIrrigation: IrrigationOut): Promise {\n const res = await this.http.put(`${this.rootPath}/v1/plots/plots/${plot_id}/activities/${action_id}/irrigation`, editedIrrigation);\n toHA(res.data, [\"area_covered\"]);\n return res.data;\n }\n\n public async editProtocolIrrigation(pkCuaa: number, protocol_id: number, action_id: number, editedIrrigation: Partial): Promise {\n const res = await this.http.put(`${this.rootPath}/v1/protocols/subjects/${pkCuaa}/dictionary_protocols/${protocol_id}/activities/${action_id}/irrigation`, editedIrrigation);\n return res.data;\n }\n\n public async addActionIrrigation(plot_id: number, execution_id: number, newirrigation: IrrigationOut): Promise {\n const res = await this.http.post(`${this.rootPath}/v1/plots/plots/${plot_id}/actions/${execution_id}/irrigation`, newirrigation);\n return res.data;\n }\n\n public async deleteActionIrrigation(pk_cuaa: number, campaign: number, execution_id: number, action_id: number): Promise {\n const res = await this.http.delete(`${this.rootPath}/v1/plots/subjects/${pk_cuaa}/${campaign}/actions/${execution_id}/irrigation/${action_id}`);\n return res.data;\n }\n\n public async getIrrigations(pk_cuaa: number, campaign: number, plot_id: number): Promise {\n\n const res = await this.http.get(\n `/sitiagri-rest-api/api_basic/v1/plots/dashboard/subjects/${pk_cuaa}/campaigns/${campaign}/irrigations`,\n {\n params: {\n plot_id\n }\n }\n );\n\n return res.data\n\n }\n\n public async getNewIrrigationInfo(pk_cuaa: number): Promise\n {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/dashboard/subjects/${pk_cuaa}/irrigation_activity`)\n\n return res.data\n }\n\n public async deletePlannedIrrigation(plot_id: number, activity_id: number): Promise\n {\n const res = await this.http.delete(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/activities/${activity_id}`)\n\n return res.status\n }\n}\n","import { GenOrUse } from \"./Product\";\nimport { TranslateResult } from \"vue-i18n\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function toHA(object: { [key: string]: any }, keys: string[]) {\n keys.forEach((key) => {\n const path = key.split(\".\");\n const lastKey = path.splice(path.length - 1, 1).join(\"\");\n const ref = path.reduce((accum, k) => accum ? accum[k] : accum, object);\n if (ref === undefined) {\n console.warn(`Invalid path to object, ${key} points to undefined `);\n } else if (ref !== null) {\n // Ignore null objects\n const val = ref[lastKey];\n ref[lastKey] = val / 10000;\n }\n });\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function toHAList(list: {[key: string]: any}[], keys: string[]): void {\n if(!list){\n return;\n }\n list.forEach(r => toHA(r, keys));\n}\n\nexport function toPercentage(perc: number): string{\n // due to 0.56 * 100 gives 0.5655000001, damn javascript!\n return (Math.floor(perc * 10000) / 100) + \"%\";\n}\n\nexport interface SummaryStep{\n component: string;\n isVisible?: boolean;\n type?: GenOrUse[];\n}\n\nexport interface SelectionStep {\n component: string;\n isDisabled: boolean;\n title: string | TranslateResult;\n optional?: boolean;\n canNavigateToWarehouse?: boolean;\n}\n\n"],"sourceRoot":""}