{"version":3,"sources":["webpack:///./node_modules/@abaco/treatment-register-module/src/modules/treatment-register-module/api/IrrigationApi.ts","webpack:///./node_modules/@abaco/treatment-register-module/src/modules/treatment-register-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","irrigationType","curIrrigation","records","length","object","keys","forEach","key","path","split","lastKey","splice","join","ref","reduce","accum","k","console","warn","val","toPercentage","perc","Math","floor"],"mappings":"0OAKqBA,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,eAAgGC,GAD/G,cACGV,EADH,yBAEIA,EAAIC,MAFR,gD,2JAKA,WAA6BW,EAAiBC,EAAkBJ,EAAsBN,GAAtF,uGACeZ,KAAKF,KAAKyB,OAAV,UAAoBvB,KAAKD,SAAzB,8BAAuDsB,EAAvD,YAAkEC,EAAlE,oBAAsFJ,EAAtF,uBAAiHN,IADhI,cACGH,EADH,yBAEIA,EAAIC,MAFR,gD,iKAKA,WAAiCc,GAAjC,yGACexB,KAAKF,KAAKK,IAAV,UAAiBH,KAAKD,SAAtB,wCAAsE,CACpFK,OAAQ,CACJF,OAAQ,gCAAF,OAAkCsB,MAH7C,cACGf,EADH,OASCgB,EADAhB,GAAOA,EAAIC,MAAQD,EAAIC,KAAKgB,SAAWjB,EAAIC,KAAKgB,QAAQC,OAAS,EACjDlB,EAAIC,KAAKgB,QAAQ,GAEjB,GAXjB,kBAaID,GAbJ,gD,8OC7CL,SAAUV,EAAKa,EAAgCC,GACjDA,EAAKC,SAAQ,SAACC,GACV,IAAMC,EAAOD,EAAIE,MAAM,KACjBC,EAAUF,EAAKG,OAAOH,EAAKL,OAAS,EAAG,GAAGS,KAAK,IAC/CC,EAAML,EAAKM,QAAO,SAACC,EAAOC,GAAR,OAAcD,EAAQA,EAAMC,GAAKD,IAAOX,GAChE,QAAYpB,IAAR6B,EACAI,QAAQC,KAAR,kCAAwCX,EAAxC,+BACG,GAAY,OAARM,EAAc,CAErB,IAAMM,EAAMN,EAAIH,GAChBG,EAAIH,GAAWS,EAAM,QAa3B,SAAUC,EAAaC,GAEzB,OAAQC,KAAKC,MAAa,IAAPF,GAAgB,IAAO","file":"js/chunk-3f29ce62.af247af8.js","sourcesContent":["import { HTTPClient } from '@abaco/web-common/src/HTTP';\nimport { PagedResults, PagingParams } from '@abaco/web-common/src/Paging';\nimport { IrrigationType, IrrigationOut, Irrigation } 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 getSpecificIrrigationTypes(irrigationType: string): Promise {\n const res = await this.http.get(`${this.rootPath}/v1/plots/dictionary_irrigation_type`, {\n params: {\n filter: `^irrigation_type_s_code like ${irrigationType}`\n }\n })\n\n let curIrrigation: IrrigationType;\n if( res && res.data && res.data.records && res.data.records.length > 0){\n curIrrigation = res.data.records[0];\n }else{\n curIrrigation = {} as IrrigationType;\n }\n return curIrrigation;\n }\n\n}\n","import { 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\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":""}