fiveapples 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/fiveapples +7 -0
- data/lib/config5.ru +31 -0
- data/lib/fiveapples.db3 +0 -0
- data/lib/fiveapples.rb +46 -0
- data/lib/model.rb +58 -0
- data/lib/ui5/Component.js +41 -0
- data/lib/ui5/controller/BreederList.controller.js +68 -0
- data/lib/ui5/controller/Breeder_Create.controller.js +82 -0
- data/lib/ui5/controller/Breeder_Detail.controller.js +89 -0
- data/lib/ui5/controller/CultivarList.controller.js +46 -0
- data/lib/ui5/controller/Cultivar_Create.controller.js +100 -0
- data/lib/ui5/controller/Cultivar_Detail.controller.js +204 -0
- data/lib/ui5/controller/FiveApplesApp.controller.js +62 -0
- data/lib/ui5/controller/MCultivarList.controller.js +96 -0
- data/lib/ui5/controller/MenuList.controller.js +28 -0
- data/lib/ui5/controller/NotFound.controller.js +9 -0
- data/lib/ui5/controller/ParentageList.controller.js +71 -0
- data/lib/ui5/controller/Parentage_Create.controller.js +134 -0
- data/lib/ui5/controller/Parentage_Detail.controller.js +116 -0
- data/lib/ui5/controller/VibertBaseController.js +40 -0
- data/lib/ui5/i18n/i18n.properties +7 -0
- data/lib/ui5/index.html +33 -0
- data/lib/ui5/manifest.json +194 -0
- data/lib/ui5/model/formatter.js +1 -0
- data/lib/ui5/model/models.js +19 -0
- data/lib/ui5/view/BreederList.view.xml +50 -0
- data/lib/ui5/view/BreederOptio.fragment.xml +21 -0
- data/lib/ui5/view/Breeder_Create.view.xml +26 -0
- data/lib/ui5/view/Breeder_Detail.view.xml +53 -0
- data/lib/ui5/view/CultivarList.view.xml +58 -0
- data/lib/ui5/view/CultivarOptio.fragment.xml +23 -0
- data/lib/ui5/view/Cultivar_Create.view.xml +33 -0
- data/lib/ui5/view/Cultivar_Detail.view.xml +93 -0
- data/lib/ui5/view/FiveApplesApp.view.xml +9 -0
- data/lib/ui5/view/MCultivarList.view.xml +43 -0
- data/lib/ui5/view/MenuList.view.xml +18 -0
- data/lib/ui5/view/NotFound.view.xml +9 -0
- data/lib/ui5/view/ParentageList.view.xml +64 -0
- data/lib/ui5/view/Parentage_Create.view.xml +26 -0
- data/lib/ui5/view/Parentage_Detail.view.xml +51 -0
- metadata +128 -0
@@ -0,0 +1,204 @@
|
|
1
|
+
sap.ui.define([
|
2
|
+
'jquery.sap.global',
|
3
|
+
"sap/ui/core/mvc/Controller",
|
4
|
+
"sap/m/MessageToast",
|
5
|
+
"sap/ui/commons/Dialog",
|
6
|
+
"sap/ui/core/routing/History"
|
7
|
+
], function (jQuery, Controller, MessageToast, Dialog, History) {
|
8
|
+
"use strict";
|
9
|
+
return Controller.extend("vibert.controller.Cultivar_Detail", {
|
10
|
+
onInit: function () {
|
11
|
+
this._oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
12
|
+
this._oRouter.getRoute("cultivar_detail").attachPatternMatched(this._onDetailMatched, this);
|
13
|
+
|
14
|
+
},
|
15
|
+
|
16
|
+
_onDetailMatched : function (oEvent) {
|
17
|
+
this._sObjectID = oEvent.getParameter("arguments").id ;
|
18
|
+
var sObjectPath = "/cultivar(" + this._sObjectID + ")" ;
|
19
|
+
this._sObjectPath = sObjectPath;
|
20
|
+
|
21
|
+
var oView = this.getView();
|
22
|
+
// var oModel = sap.ui.getCore().getModel();
|
23
|
+
// oView.setModel(oModel);
|
24
|
+
oView.bindElement({ path: sObjectPath});
|
25
|
+
var oModel = oView.getModel();
|
26
|
+
|
27
|
+
},
|
28
|
+
_onBindingChange : function (oEvent) {
|
29
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
30
|
+
},
|
31
|
+
onCreatePress: function (evt) {
|
32
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
33
|
+
oRouter.navTo( "cultivar_create" );
|
34
|
+
},
|
35
|
+
|
36
|
+
onDeletePress: function (evt) {
|
37
|
+
var oView = this.getView();
|
38
|
+
var oModel = oView.getModel();
|
39
|
+
|
40
|
+
var mParms = {};
|
41
|
+
|
42
|
+
var oDeleteDialog = new sap.ui.commons.Dialog();
|
43
|
+
oDeleteDialog.setTitle("Delete Cultivar");
|
44
|
+
var oText = new sap.ui.commons.TextView({text: "Are you sure to delete this Cultivar?"});
|
45
|
+
var _that = this;
|
46
|
+
oDeleteDialog.addContent(oText);
|
47
|
+
oDeleteDialog.addButton(
|
48
|
+
new sap.ui.commons.Button({
|
49
|
+
text: "Confirm",
|
50
|
+
press:function(){
|
51
|
+
var mParms = {};
|
52
|
+
// mParms.merge = true;
|
53
|
+
|
54
|
+
mParms.success = function(data, response){
|
55
|
+
|
56
|
+
oDeleteDialog.close();
|
57
|
+
_that._oRouter.navTo( "cultivarList" );
|
58
|
+
oModel.refresh();
|
59
|
+
};
|
60
|
+
mParms.error = function(error){
|
61
|
+
oDeleteDialog.close();
|
62
|
+
MessageToast.show("Delete failed"); } ;
|
63
|
+
var sMsg;
|
64
|
+
sMsg = oView.getBindingContext();
|
65
|
+
mParms.context = sMsg;
|
66
|
+
oModel.remove("",mParms);
|
67
|
+
|
68
|
+
}
|
69
|
+
})
|
70
|
+
|
71
|
+
);
|
72
|
+
oDeleteDialog.open();
|
73
|
+
},
|
74
|
+
onSave: function() {
|
75
|
+
var oView = this.getView();
|
76
|
+
var oModel = oView.getModel();
|
77
|
+
var sPath = this._sObjectPath;
|
78
|
+
var mParms = {};
|
79
|
+
var oEntry = {};
|
80
|
+
|
81
|
+
var oData = oModel.getData(sPath);
|
82
|
+
|
83
|
+
oEntry.name = this.byId('name').getValue();
|
84
|
+
oEntry.year = this.byId('year').getValue();
|
85
|
+
oEntry.breeder_id = this.byId('breeder_id').getValue();
|
86
|
+
|
87
|
+
function onSuccessHandler(){
|
88
|
+
oModel.refresh();
|
89
|
+
oModel.updateBindings();
|
90
|
+
MessageToast.show("Update success");
|
91
|
+
}
|
92
|
+
function onErrorHandler(){ MessageToast.show("Update failed"); }
|
93
|
+
|
94
|
+
|
95
|
+
mParms.success = onSuccessHandler;
|
96
|
+
mParms.error = onErrorHandler;
|
97
|
+
mParms.merge = false;
|
98
|
+
oModel.setTokenHandlingEnabled(true);
|
99
|
+
oModel.updateSecurityToken();
|
100
|
+
oModel.update( this._sObjectPath, oEntry, mParms );
|
101
|
+
|
102
|
+
},
|
103
|
+
onCreateParentForPress : function() {
|
104
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
105
|
+
oRouter.navTo( "parent_create_for", {cultivar_id: this._sObjectID} );
|
106
|
+
|
107
|
+
},
|
108
|
+
handleBreederPress : function () {
|
109
|
+
var sBreeder_ID = this.byId('breeder_ID').getValue();
|
110
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
111
|
+
oRouter.navTo( "breeder_detail", {ID: sBreeder_ID } );
|
112
|
+
},
|
113
|
+
|
114
|
+
onCheck: function() {
|
115
|
+
var oView = this.getView();
|
116
|
+
var oModel = oView.getModel();
|
117
|
+
var sPath = this._sObjectPath;
|
118
|
+
var oData = oModel.getData(sPath);
|
119
|
+
console.log("Model data:", oData);
|
120
|
+
console.log("Model has pending changes:", oModel.hasPendingChanges());
|
121
|
+
console.log("Pending changes:",
|
122
|
+
oModel.getPendingChanges()); },
|
123
|
+
|
124
|
+
onNavBack: function () {
|
125
|
+
var oHistory = History.getInstance();
|
126
|
+
var sPreviousHash = oHistory.getPreviousHash();
|
127
|
+
|
128
|
+
|
129
|
+
if (sPreviousHash !== undefined) {
|
130
|
+
window.history.go(-1);
|
131
|
+
} else {
|
132
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
133
|
+
oRouter.navTo("cultivarList", true);
|
134
|
+
}
|
135
|
+
},
|
136
|
+
onParentSelectionChange : function () {
|
137
|
+
var oTable = this.byId("parent_table");
|
138
|
+
var iIndex = oTable.getSelectedIndex();
|
139
|
+
|
140
|
+
var oCtxt = oTable.getContextByIndex(iIndex);
|
141
|
+
var sToPageParID = oCtxt.getProperty("parent_id") ;
|
142
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
143
|
+
oRouter.navTo( "cultivar_detail", {id: sToPageParID } );
|
144
|
+
|
145
|
+
},
|
146
|
+
|
147
|
+
onFiliiSelectionChange : function () {
|
148
|
+
var oTable = this.byId("child_table");
|
149
|
+
var iIndex = oTable.getSelectedIndex();
|
150
|
+
|
151
|
+
var oCtxt = oTable.getContextByIndex(iIndex);
|
152
|
+
var sToPageParID = oCtxt.getProperty("cultivar_id") ;
|
153
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
154
|
+
oRouter.navTo( "cultivar_detail", {id: sToPageParID} );
|
155
|
+
|
156
|
+
}, // Warning: alot of dupl. code with the "cultivar create" controlller
|
157
|
+
inputId : "",
|
158
|
+
inputDescrId: "",
|
159
|
+
onBreederCreatePress: function (evt) {
|
160
|
+
|
161
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
162
|
+
oRouter.navTo( "breeder_create" );
|
163
|
+
|
164
|
+
},
|
165
|
+
onBreederIDValueHelp : function (oEvent) {
|
166
|
+
|
167
|
+
this.inputId = oEvent.getSource().getId();
|
168
|
+
this.inputDescrId = this.inputId + "_descr";
|
169
|
+
|
170
|
+
// create value help dialog
|
171
|
+
if (!this._valueHelpDialog) {
|
172
|
+
this._valueHelpDialog = sap.ui.xmlfragment(
|
173
|
+
"vibert.view.BreederOptio", this );
|
174
|
+
|
175
|
+
this.getView().addDependent(this._valueHelpDialog);
|
176
|
+
}
|
177
|
+
|
178
|
+
this._valueHelpDialog.open( '' );
|
179
|
+
},
|
180
|
+
|
181
|
+
_handleValueHelpSearch : function (evt) {
|
182
|
+
var sValue = evt.getParameter("value");
|
183
|
+
var oFilter = new Filter( "name",
|
184
|
+
sap.ui.model.FilterOperator.Contains, sValue
|
185
|
+
);
|
186
|
+
evt.getSource().getBinding("items").filter([oFilter]);
|
187
|
+
},
|
188
|
+
|
189
|
+
_handleValueHelpClose : function (evt) {
|
190
|
+
var oSelectedItem = evt.getParameter("selectedItem");
|
191
|
+
if (oSelectedItem) {
|
192
|
+
var IDInput = this.getView().byId(this.inputId);
|
193
|
+
IDInput.setValue(oSelectedItem.getDescription());
|
194
|
+
|
195
|
+
var oText = this.getView().byId(this.inputDescrId);
|
196
|
+
oText.setText(oSelectedItem.getTitle());
|
197
|
+
|
198
|
+
}
|
199
|
+
evt.getSource().getBinding("items").filter([]);
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
});
|
204
|
+
});
|
@@ -0,0 +1,62 @@
|
|
1
|
+
sap.ui.define([
|
2
|
+
'jquery.sap.global',
|
3
|
+
'sap/m/MessageToast',
|
4
|
+
'sap/ui/core/Fragment',
|
5
|
+
'sap/ui/core/mvc/Controller',
|
6
|
+
'sap/ui/model/Filter',
|
7
|
+
'sap/ui/model/odata/ODataModel'
|
8
|
+
], function(jQuery, MessageToast, Fragment, Controller, Filter, ODataModel) {
|
9
|
+
"use strict";
|
10
|
+
|
11
|
+
var CController = Controller.extend("vibert.controller.FiveApplesApp", {
|
12
|
+
|
13
|
+
|
14
|
+
onOrientationChange: function(oEvent) {
|
15
|
+
var bLandscapeOrientation = oEvent.getParameter("landscape"),
|
16
|
+
sMsg = "Orientation now is: " + (bLandscapeOrientation ? "Landscape" : "Portrait");
|
17
|
+
MessageToast.show(sMsg, {duration: 5000});
|
18
|
+
},
|
19
|
+
|
20
|
+
onPressNavToDetail : function(oEvent) {
|
21
|
+
this.getSplitAppObj().to(this.createId("detailDetail"));
|
22
|
+
},
|
23
|
+
|
24
|
+
onPressDetailBack : function() {
|
25
|
+
this.getSplitAppObj().backDetail();
|
26
|
+
},
|
27
|
+
|
28
|
+
onPressMasterBack : function() {
|
29
|
+
this.getSplitAppObj().backMaster();
|
30
|
+
},
|
31
|
+
|
32
|
+
onPressGoToMaster : function() {
|
33
|
+
this.getSplitAppObj().toMaster(this.createId("master"));
|
34
|
+
},
|
35
|
+
|
36
|
+
onListItemPress : function(oEvent) {
|
37
|
+
var sToPageId = oEvent.getParameter("listItem").getCustomData()[0].getValue();
|
38
|
+
|
39
|
+
this.getSplitAppObj().toDetail(this.createId(sToPageId));
|
40
|
+
},
|
41
|
+
|
42
|
+
onPressModeBtn : function(oEvent) {
|
43
|
+
var sSplitAppMode = oEvent.getSource().getSelectedButton().getCustomData()[0].getValue();
|
44
|
+
|
45
|
+
this.getSplitAppObj().setMode(sSplitAppMode);
|
46
|
+
MessageToast.show("Split Container mode is changed to: " + sSplitAppMode, {duration: 5000});
|
47
|
+
},
|
48
|
+
|
49
|
+
getSplitAppObj : function() {
|
50
|
+
var result = this.byId("FiveApplesApp");
|
51
|
+
if (!result) {
|
52
|
+
jQuery.sap.log.info("FiveApplesApp object can't be found");
|
53
|
+
}
|
54
|
+
return result;
|
55
|
+
}
|
56
|
+
|
57
|
+
});
|
58
|
+
|
59
|
+
|
60
|
+
return CController;
|
61
|
+
|
62
|
+
});
|
@@ -0,0 +1,96 @@
|
|
1
|
+
sap.ui.define(["sap/ui/core/mvc/Controller",
|
2
|
+
"sap/m/MessageToast",
|
3
|
+
"sap/ui/model/odata/ODataModel",
|
4
|
+
"sap/ui/commons/Dialog",
|
5
|
+
"sap/ui/model/resource/ResourceModel"],
|
6
|
+
function (Controller, MessageToast, ODataModel, Dialog, ResourceModel) {
|
7
|
+
"use strict";
|
8
|
+
return Controller.extend("vibert.controller.MCultivarList", {
|
9
|
+
|
10
|
+
typusMap : {},
|
11
|
+
|
12
|
+
onInit : function() {
|
13
|
+
|
14
|
+
},
|
15
|
+
|
16
|
+
onCreatePress: function (evt) {
|
17
|
+
var oCreateDialog = new Dialog();
|
18
|
+
var oModel = this.getView().getModel();
|
19
|
+
function onCreateSuccessHandler(){
|
20
|
+
oCreateDialog.close(); oModel.refresh(); }
|
21
|
+
|
22
|
+
function onCreateErrorHandler(){
|
23
|
+
oCreateDialog.close(); MessageToast.show("Create failed");
|
24
|
+
}
|
25
|
+
|
26
|
+
oCreateDialog.setTitle("Create Cultivar");
|
27
|
+
var oSimpleForm = new sap.ui.layout.form.SimpleForm({
|
28
|
+
maxContainerCols: 2,
|
29
|
+
content:[
|
30
|
+
new sap.ui.core.Title({text:"New cultivar"}),
|
31
|
+
new sap.ui.commons.Label({text:"name"}),
|
32
|
+
new sap.ui.commons.TextField({value:""}) ]
|
33
|
+
});
|
34
|
+
oCreateDialog.addContent(oSimpleForm);
|
35
|
+
oCreateDialog.addButton(
|
36
|
+
new sap.ui.commons.Button({
|
37
|
+
text: "Submit",
|
38
|
+
press: function() {
|
39
|
+
var content = oSimpleForm.getContent();
|
40
|
+
var oEntry = {};
|
41
|
+
oEntry.name = content[2].getValue();
|
42
|
+
oModel.create('/cultivar', oEntry, {success: onCreateSuccessHandler, error: onCreateErrorHandler});
|
43
|
+
}
|
44
|
+
})
|
45
|
+
);
|
46
|
+
oCreateDialog.open();
|
47
|
+
|
48
|
+
},
|
49
|
+
|
50
|
+
handlePress : function(oEvent) {
|
51
|
+
var oItem=oEvent.getSource();
|
52
|
+
var ctx = oItem.getBindingContext();
|
53
|
+
var sToPageId = oItem.getBindingContext().getProperty("id") ;
|
54
|
+
|
55
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
56
|
+
// MessageToast.show("'press' event fired! navTo cultivar_detail -->"+sToPageId);
|
57
|
+
oRouter.navTo( "cultivar_detail" , { id: sToPageId });
|
58
|
+
},
|
59
|
+
|
60
|
+
onDeletePress: function (evt) {
|
61
|
+
var oTable = this.getView().byId("m_cultivar_table");
|
62
|
+
var oModel = this.getView().getModel();
|
63
|
+
var iIndex = oTable.getSelectedIndex();
|
64
|
+
|
65
|
+
var oDeleteDialog = new sap.ui.commons.Dialog();
|
66
|
+
oDeleteDialog.setTitle("Delete Cultivar");
|
67
|
+
var oText = new sap.ui.commons.TextView({text: "Are you sure to delete this Cultivar?"});
|
68
|
+
oDeleteDialog.addContent(oText);
|
69
|
+
oDeleteDialog.addButton(
|
70
|
+
new sap.ui.commons.Button({
|
71
|
+
text: "Confirm",
|
72
|
+
press:function(){
|
73
|
+
var mParms = {};
|
74
|
+
|
75
|
+
|
76
|
+
mParms.success = function(data, response){
|
77
|
+
oModel.refresh(); oDeleteDialog.close(); };
|
78
|
+
mParms.error = function(error){
|
79
|
+
oDeleteDialog.close(); MessageToast.show("Delete failed"); } ;
|
80
|
+
var sMsg;
|
81
|
+
if (iIndex < 0) {
|
82
|
+
sMsg = "no item selected";
|
83
|
+
} else {
|
84
|
+
|
85
|
+
sMsg = oTable.getContextByIndex(iIndex);
|
86
|
+
mParms.context = sMsg;
|
87
|
+
oModel.remove("",mParms); }
|
88
|
+
}
|
89
|
+
})
|
90
|
+
);
|
91
|
+
oDeleteDialog.open();
|
92
|
+
}
|
93
|
+
});
|
94
|
+
});
|
95
|
+
|
96
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
sap.ui.define([
|
2
|
+
'jquery.sap.global',
|
3
|
+
'sap/m/MessageToast',
|
4
|
+
'sap/ui/core/Fragment',
|
5
|
+
'sap/ui/core/mvc/Controller',
|
6
|
+
'sap/ui/model/Filter',
|
7
|
+
'sap/ui/model/odata/ODataModel'
|
8
|
+
], function(jQuery, MessageToast, Fragment, Controller, Filter, ODataModel) {
|
9
|
+
"use strict";
|
10
|
+
|
11
|
+
var CController = Controller.extend("vibert.controller.MenuList", {
|
12
|
+
|
13
|
+
onListItemPress: function(oEvent) {
|
14
|
+
// also possible:
|
15
|
+
// var oRouter = this.getOwnerComponent().getRouterFor(this);
|
16
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
17
|
+
var oItem = oEvent.getSource();
|
18
|
+
var sToPageId = oEvent.getParameter("listItem").getCustomData()[0].getValue();
|
19
|
+
oRouter.navTo( sToPageId );
|
20
|
+
}
|
21
|
+
}
|
22
|
+
);
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
return CController;
|
27
|
+
|
28
|
+
});
|
@@ -0,0 +1,71 @@
|
|
1
|
+
sap.ui.define(["sap/ui/core/mvc/Controller",
|
2
|
+
"sap/m/MessageToast",
|
3
|
+
"sap/ui/model/odata/ODataModel",
|
4
|
+
"sap/ui/commons/Dialog",
|
5
|
+
"sap/ui/model/resource/ResourceModel",
|
6
|
+
"./VibertBaseController"],
|
7
|
+
function (Controller, MessageToast, ODataModel, Dialog, ResourceModel, VibertBaseController) {
|
8
|
+
"use strict";
|
9
|
+
return VibertBaseController.extend("vibert.controller.ParentageList", {
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
onCreatePress: function (evt) {
|
14
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
15
|
+
oRouter.navTo( "parentage_create" );
|
16
|
+
},
|
17
|
+
onSelectionChange: function (evt) {
|
18
|
+
var oTable = this.getView().byId("parentage_table");
|
19
|
+
var iIndex = oTable.getSelectedIndex();
|
20
|
+
|
21
|
+
var oCtxt = oTable.getContextByIndex(iIndex);
|
22
|
+
var sToPageRID = oCtxt.getProperty("cultivar_id") ;
|
23
|
+
var sToPagePtID = oCtxt.getProperty("ptype_id") ;
|
24
|
+
var sToPageParID = oCtxt.getProperty("parent_id") ;
|
25
|
+
|
26
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
27
|
+
// MessageToast.show(" navTo parens_detail -->"+sToPageId);
|
28
|
+
oRouter.navTo( "parentage_detail", {cultivar_id: sToPageRID , ptype_id: sToPagePtID, parent_id: sToPageParID} );
|
29
|
+
},
|
30
|
+
|
31
|
+
//onDisplayPress: function (evt) {
|
32
|
+
//// was same as onSelectionChange now
|
33
|
+
//} ,
|
34
|
+
onDeletePress: function (evt) {
|
35
|
+
var oTable = this.getView().byId("parentage_table");
|
36
|
+
var oModel = this.getView().getModel();
|
37
|
+
var iIndex = oTable.getSelectedIndex();
|
38
|
+
var mParms = {};
|
39
|
+
|
40
|
+
var oDeleteDialog = new sap.ui.commons.Dialog();
|
41
|
+
oDeleteDialog.setTitle("Delete Parentage");
|
42
|
+
var oText = new sap.ui.commons.TextView({text: "Are you sure to delete this Parentage?"});
|
43
|
+
oDeleteDialog.addContent(oText);
|
44
|
+
oDeleteDialog.addButton(
|
45
|
+
new sap.ui.commons.Button({
|
46
|
+
text: "Confirm",
|
47
|
+
press:function(){
|
48
|
+
var mParms = {};
|
49
|
+
mParms.merge = true;
|
50
|
+
|
51
|
+
mParms.success = function(data, response){
|
52
|
+
oModel.refresh(); oDeleteDialog.close(); };
|
53
|
+
mParms.error = function(error){
|
54
|
+
oDeleteDialog.close(); MessageToast.show("Delete failed"); } ;
|
55
|
+
var sMsg;
|
56
|
+
if (iIndex < 0) {
|
57
|
+
sMsg = "no item selected";
|
58
|
+
} else {
|
59
|
+
|
60
|
+
sMsg = oTable.getContextByIndex(iIndex);
|
61
|
+
mParms.context = sMsg;
|
62
|
+
oModel.remove("",mParms); }
|
63
|
+
}
|
64
|
+
})
|
65
|
+
);
|
66
|
+
oDeleteDialog.open();
|
67
|
+
}
|
68
|
+
});
|
69
|
+
});
|
70
|
+
|
71
|
+
|
@@ -0,0 +1,134 @@
|
|
1
|
+
sap.ui.define([
|
2
|
+
"sap/ui/core/mvc/Controller",
|
3
|
+
"sap/m/MessageToast",
|
4
|
+
'sap/ui/core/Fragment',
|
5
|
+
'sap/ui/model/Filter',
|
6
|
+
"sap/ui/model/odata/ODataModel",
|
7
|
+
"sap/ui/core/routing/History",
|
8
|
+
"./VibertBaseController"
|
9
|
+
], function (Controller, MessageToast, Fragment, Filter, ODataModel, History, VibertBaseController) {
|
10
|
+
"use strict";
|
11
|
+
return VibertBaseController.extend("vibert.controller.Parentage_Create", {
|
12
|
+
_attachDetailMatched: function () {
|
13
|
+
this._oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
14
|
+
this._oRouter.getRoute("parentage_create_for").attachPatternMatched(this._onDetailMatched, this);
|
15
|
+
},
|
16
|
+
_onDetailMatched : function (oEvent) {
|
17
|
+
var oObject = oEvent.getParameter("arguments");
|
18
|
+
var sCultivarID = oObject.cultivar_ID ;
|
19
|
+
var sObjPath = "/cultivar(" + sCultivarID + ")" ;
|
20
|
+
var sAttribPath = "/cultivar(" + sCultivarID + ")/name" ;
|
21
|
+
|
22
|
+
var oView = this.getView();
|
23
|
+
|
24
|
+
var oModel = this.getView().getModel();
|
25
|
+
var oRIDtxt = this.byId("cultivar_ID_descr");
|
26
|
+
|
27
|
+
function onSuccessHandler(){
|
28
|
+
var sRtxt = oModel.getProperty(sAttribPath);
|
29
|
+
oRIDtxt.setText(sRtxt);
|
30
|
+
}
|
31
|
+
function onErrorHandler(){
|
32
|
+
MessageToast.show("Read failed"); }
|
33
|
+
|
34
|
+
oModel.read(sObjPath, {success: onSuccessHandler, error: onErrorHandler } );
|
35
|
+
|
36
|
+
var oRID = this.byId("cultivar_ID");
|
37
|
+
oRID.setValue(sCultivarID);
|
38
|
+
//
|
39
|
+
// twoway bindingmode has to be set from start on creation of the Model,
|
40
|
+
// otherwise it does not wotk apparently
|
41
|
+
// BindingMode: "TwoWay"});
|
42
|
+
|
43
|
+
},
|
44
|
+
_onBindingChange : function (oEvent) {
|
45
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
46
|
+
// No data for the binding
|
47
|
+
//if (!this.getView().getBindingContext()) {
|
48
|
+
// oRouter.navTo("notFound");
|
49
|
+
//}
|
50
|
+
},
|
51
|
+
onCreate: function() {
|
52
|
+
|
53
|
+
var myForm = sap.ui.getCore().byId("parentage_create_form");
|
54
|
+
var sObjectPath = "/parentage" ;
|
55
|
+
var oView = this.getView() ;
|
56
|
+
var oModel = oView.getModel();
|
57
|
+
|
58
|
+
var oEntry = {};
|
59
|
+
|
60
|
+
var _that = this;
|
61
|
+
oEntry.cultivar_ID = this.byId('cultivar_ID').getValue();
|
62
|
+
oEntry.ptype_ID = this.byId('ptype_ID').getValue();
|
63
|
+
oEntry.parent_ID = this.byId('parent_ID').getValue();
|
64
|
+
|
65
|
+
function onSuccessHandler(){
|
66
|
+
oModel.refresh();
|
67
|
+
_that.byId('cultivar_ID').setValue("");
|
68
|
+
_that.byId('ptype_ID').setValue("");
|
69
|
+
_that.byId('parent_ID').setValue("");
|
70
|
+
MessageToast.show("Create success");
|
71
|
+
_that.onNavBack();
|
72
|
+
|
73
|
+
}
|
74
|
+
function onErrorHandler(){
|
75
|
+
MessageToast.show("Create failed"); }
|
76
|
+
|
77
|
+
oModel.create( sObjectPath, oEntry, {success: onSuccessHandler, error: onErrorHandler } );
|
78
|
+
|
79
|
+
},
|
80
|
+
|
81
|
+
onNavBack: function () {
|
82
|
+
var oHistory = History.getInstance();
|
83
|
+
var sPreviousHash = oHistory.getPreviousHash();
|
84
|
+
|
85
|
+
|
86
|
+
if (sPreviousHash !== undefined) {
|
87
|
+
window.history.go(-1);
|
88
|
+
} else {
|
89
|
+
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
|
90
|
+
oRouter.navTo("ParensList", true);
|
91
|
+
}
|
92
|
+
},
|
93
|
+
inputId : "",
|
94
|
+
inputDescrId: "",
|
95
|
+
|
96
|
+
onIDValueHelp : function (oEvent) {
|
97
|
+
|
98
|
+
this.inputId = oEvent.getSource().getId();
|
99
|
+
this.inputDescrId = this.inputId + "_descr";
|
100
|
+
|
101
|
+
// create value help dialog
|
102
|
+
if (!this._valueHelpDialog) {
|
103
|
+
this._valueHelpDialog = sap.ui.xmlfragment(
|
104
|
+
"vibert.view.CultivarOptio", this );
|
105
|
+
|
106
|
+
this.getView().addDependent(this._valueHelpDialog);
|
107
|
+
}
|
108
|
+
|
109
|
+
this._valueHelpDialog.open( '' );
|
110
|
+
},
|
111
|
+
|
112
|
+
_handleValueHelpSearch : function (evt) {
|
113
|
+
var sValue = evt.getParameter("value");
|
114
|
+
var oFilter = new Filter( "name",
|
115
|
+
sap.ui.model.FilterOperator.Contains, sValue
|
116
|
+
);
|
117
|
+
evt.getSource().getBinding("items").filter([oFilter]);
|
118
|
+
},
|
119
|
+
|
120
|
+
_handleValueHelpClose : function (evt) {
|
121
|
+
var oSelectedItem = evt.getParameter("selectedItem");
|
122
|
+
if (oSelectedItem) {
|
123
|
+
var IDInput = this.getView().byId(this.inputId);
|
124
|
+
IDInput.setValue(oSelectedItem.getDescription());
|
125
|
+
|
126
|
+
var oText = this.getView().byId(this.inputDescrId);
|
127
|
+
oText.setText(oSelectedItem.getTitle());
|
128
|
+
|
129
|
+
}
|
130
|
+
evt.getSource().getBinding("items").filter([]);
|
131
|
+
|
132
|
+
}
|
133
|
+
});
|
134
|
+
});
|