-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
103 additions
and
60 deletions.
There are no files selected for viewing
133 changes: 73 additions & 60 deletions
133
examples/ui5-js-app/webapp/controller/Main.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,81 @@ | ||
sap.ui.define(['test/Sample/controller/BaseController', 'sap/m/MessageToast', 'sap/ui/model/json/JSONModel'], function ( | ||
Controller, | ||
MessageToast, | ||
JSONModel | ||
) { | ||
'use strict'; | ||
sap.ui.define( | ||
[ | ||
"test/Sample/controller/BaseController", | ||
"sap/m/MessageToast", | ||
"sap/ui/model/json/JSONModel", | ||
"sap/ui/core/Fragment" | ||
], | ||
(Controller, MessageToast, JSONModel, Fragment) => { | ||
return Controller.extend("test.Sample.controller.Main", { | ||
onInit() { | ||
this.getOwnerComponent().getModel().read("/Customers('TRAIH')") | ||
|
||
return Controller.extend('test.Sample.controller.Main', { | ||
onInit: function () { | ||
this.getOwnerComponent().getModel().read("/Customers('TRAIH')"); | ||
|
||
const jData = { | ||
inputValue: 'test Input Value !!!', | ||
buttonText: "Don't press me !!! -> binded", | ||
checkbox: false, | ||
barcode: '' | ||
}; | ||
const jData = { | ||
inputValue: "test Input Value !!!", | ||
buttonText: "Don't press me !!! -> binded", | ||
checkbox: false, | ||
barcode: "" | ||
} | ||
|
||
let testModel = new JSONModel(jData); | ||
this.getView().setModel(testModel, 'testModel'); | ||
}, | ||
let testModel = new JSONModel(jData) | ||
this.getView().setModel(testModel, "testModel") | ||
}, | ||
|
||
navFwd: function () { | ||
return this.getOwnerComponent().getRouter().navTo('RouteOther'); | ||
}, | ||
navFwd() { | ||
return this.getOwnerComponent().getRouter().navTo("RouteOther") | ||
}, | ||
|
||
onPress: function (oEvent) { | ||
MessageToast.show(`${oEvent.getSource().getId()} pressed`); | ||
}, | ||
onBoo: function (oEvent) { | ||
MessageToast.show(`👻`); | ||
}, | ||
onPress(oEvent) { | ||
MessageToast.show(`${oEvent.getSource().getId()} pressed`) | ||
}, | ||
onBoo(oEvent) { | ||
MessageToast.show(`👻`) | ||
}, | ||
|
||
onTest: function (oEvent) { | ||
this.onBoo(oEvent); | ||
}, | ||
onSelect: function (oEvent) { | ||
const selectedProperty = oEvent.getSource().getProperty('selected'); | ||
const selectedParameter = oEvent.getParameter('selected'); | ||
MessageToast.show(`selectedProperty: ${selectedProperty} selectedParameter: ${selectedParameter}`); | ||
}, | ||
scanBarcode: function (oEvent) { | ||
var _self = this; | ||
cordova.plugins.barcodeScanner.scan( | ||
function (result) { | ||
onTest(oEvent) { | ||
this.onBoo(oEvent) | ||
}, | ||
onSelect(oEvent) { | ||
const selectedProperty = oEvent.getSource().getProperty("selected") | ||
const selectedParameter = oEvent.getParameter("selected") | ||
MessageToast.show(`selectedProperty: ${selectedProperty} selectedParameter: ${selectedParameter}`) | ||
}, | ||
scanBarcode(oEvent) { | ||
var _self = this | ||
cordova.plugins.barcodeScanner.scan( | ||
function (result) { | ||
// update in model | ||
_self.getView().getModel("testModel").setProperty("/barcode", result.scanCode) | ||
|
||
// update in model | ||
_self.getView().getModel('testModel').setProperty('/barcode', result.scanCode); | ||
MessageToast.show( | ||
"We got a barcode\n" + | ||
"Result: " + | ||
result.scanCode + | ||
"\n" + | ||
"Format: " + | ||
result.format + | ||
"\n" + | ||
"Cancelled: " + | ||
result.cancelled | ||
) | ||
}, | ||
function (error) { | ||
MessageToast.show("Scanning failed: " + error) | ||
} | ||
) | ||
}, | ||
|
||
MessageToast.show( | ||
'We got a barcode\n' + | ||
'Result: ' + | ||
result.scanCode + | ||
'\n' + | ||
'Format: ' + | ||
result.format + | ||
'\n' + | ||
'Cancelled: ' + | ||
result.cancelled | ||
); | ||
}, | ||
function (error) { | ||
MessageToast.show('Scanning failed: ' + error); | ||
async openDialog() { | ||
if (!this.dialog) { | ||
this.dialog = await Fragment.load({ name: "test.Sample.view.Dialog", controller: this }) | ||
this.dialog.setModel(this.getView().getModel("i18n"), "i18n") | ||
} | ||
); | ||
} | ||
}); | ||
}); | ||
this.dialog.open() | ||
}, | ||
|
||
close() { | ||
this.dialog.close() | ||
} | ||
}) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<core:FragmentDefinition xmlns="sap.m" | ||
xmlns:core="sap.ui.core"> | ||
<Dialog id="Dialog" | ||
title="{i18n>dialog.title}" | ||
type="Message"> | ||
<content> | ||
<Text text="{i18n>dialog.text}" /> | ||
</content> | ||
<endButton> | ||
<Button text="{i18n>dialog.close}" | ||
press="close"></Button> | ||
</endButton> | ||
|
||
</Dialog> | ||
</core:FragmentDefinition> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters