-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathList.controller.js
62 lines (58 loc) · 1.69 KB
/
List.controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
sap.ui.define(
[
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel",
"sap/m/MessageBox",
],
/**
* @param {typeof sap.ui.core.mvc.Controller} Controller
*/
function (Controller, JSONModel, MessageBox) {
"use strict";
return Controller.extend("hogent.flightapp.controller.List", {
onInit: function () {
var oFlight = {
carrID: "",
connID: "",
fldate: null,
};
var oModel = new JSONModel(oFlight);
this.getView().setModel(oModel, "form");
},
handleSavePress: function () {
var oForm = this.getView().getModel("form").getData();
oForm.fldate = new Date(oForm.fldate);
var odatamodel = this.getView().getModel("v2model");
odatamodel.create("/Flights", oForm, {
success: function (data, response) {
MessageBox.success("Data was created successfully");
},
error: function (error) {
MessageBox.error("Error while creating the data");
},
});
},
handleListItemPress: function (oEvent) {
//Get data from click event on table
let sCarrId = oEvent
.getSource()
.getBindingContext()
.getProperty("carrID");
let sConnId = oEvent
.getSource()
.getBindingContext()
.getProperty("connID");
let sFlDate = oEvent
.getSource()
.getBindingContext()
.getProperty("fldate");
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo("Detail", {
carrid: sCarrId,
connid: sConnId,
fldate: sFlDate,
});
},
});
}
);