"use strict";sap.ui.define(["./BaseController","sap/ui/model/json/JSONModel","sap/m/MessageBox"],function(e,t,o){"use strict";function n(e){return e&&e.__esModule&&typeof e.default!=="undefined"?e.default:e}const s=n(e);const a=s.extend("com.optrabot.ui.controller.TradeTemplateList",{onInit:function e(){this.oView=this.getView();this.oRouter=this.getOwnerComponent().getRouter();this.oViewModel=new t({TemplateCollection:[]});this.oView.setModel(this.oViewModel,"tradetemplates");this.loadTemplates()},loadTemplates:async function e(){try{const e=this.getOwnerComponent().getModel("global");const t=e.getProperty("/backendBaseUrl");const o=await fetch(`${t}/api/templates/`);if(!o.ok){throw new Error("Failed to fetch templates")}const n=await o.json();this.oViewModel.setProperty("/TemplateCollection",n)}catch(e){o.error("Failed to load templates: "+e.message)}},onAdd:function e(){this.showFunctionNotImplementedMessage()},onTemplatePress:function e(t){var o=this.oView.getParent().getParent();o.setLayout("TwoColumnsMidExpanded");var n=t.getSource().getBindingContext("tradetemplates").getPath();var s=n.split("/").slice(-1).pop();console.log("Template name: "+s);this.oRouter.navTo("template",{layout:"TwoColumnsMidExpanded",template:s})}});return a});
//# sourceMappingURL=TradeTemplateList.controller.js.map