UNPKG

ui5_easy_use

Version:

CLI tool for SAP ui5 and SAPUI5 projects to initialize apps, generate pages, insert form and table components, manage routing, and automate i18n bindings

60 lines (52 loc) 1.81 kB
sap.ui.define([ "${ez5.appName}/${ez5.packgName}/api/OdataV4" ], function (OdataV4) { "use strict"; return BaseController.extend("${ez5.appName}.controller.${ez5.controllerName}", { onInit: function () { this.initialODataV4(); }, // Update this config when the generated controller should call a different entity set. initialODataV4: function () { this.oDatav4 = new OdataV4(this); this.oDataV4Config = this.getODataV4Config(); }, getODataV4Config: function () { return { model: this.getOwnerComponent().getModel(), entitySet: "/EntitySet", filters: [], select: "", expand: null, skip: 0, top: 50 }; }, onGetData_: async function () { const config = this.getODataV4Config(); try { return await this.oDatav4.GET( config.model, config.entitySet, config.filters, config.select, config.expand, config.skip, config.top ); } catch (error) { console.error("Error while fetching OData V4 data:", error); throw error; } }, onSetData_: async function (data = {}) { const config = this.getODataV4Config(); try { return await this.oDatav4.POST(config.model, config.entitySet, { ...data }); } catch (error) { console.error("Error while creating OData V4 data:", error); throw error; } } }); });