-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"use strict"; | ||
|
||
sap.ui.define(["sap/ui/core/UIComponent", "./model/models", "sap/ui/Device"], function (UIComponent, __models, Device) { | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj; | ||
} | ||
const models = _interopRequireDefault(__models); | ||
/** | ||
* @namespace com.myorg.myapp | ||
*/ | ||
const Component = UIComponent.extend("com.myorg.myapp.Component", { | ||
metadata: { | ||
manifest: "json" | ||
}, | ||
init: function _init() { | ||
// call the base component's init function | ||
UIComponent.prototype.init.call(this); | ||
|
||
// create the device model | ||
this.setModel(models.createDeviceModel(), "device"); | ||
|
||
// create the views based on the url/hash | ||
this.getRouter().initialize(); | ||
}, | ||
getContentDensityClass: function _getContentDensityClass() { | ||
if (this.contentDensityClass === undefined) { | ||
// check whether FLP has already set the content density class; do nothing in this case | ||
if (document.body.classList.contains("sapUiSizeCozy") || document.body.classList.contains("sapUiSizeCompact")) { | ||
this.contentDensityClass = ""; | ||
} else if (!Device.support.touch) { | ||
// apply "compact" mode if touch is not supported | ||
this.contentDensityClass = "sapUiSizeCompact"; | ||
} else { | ||
// "cozy" in case of touch support; default for most sap.m controls, but needed for desktop-first controls like sap.ui.table.Table | ||
this.contentDensityClass = "sapUiSizeCozy"; | ||
} | ||
} | ||
return this.contentDensityClass; | ||
} | ||
}); | ||
return Component; | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use strict"; | ||
|
||
sap.ui.define(["./BaseController"], function (__BaseController) { | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj; | ||
} | ||
const BaseController = _interopRequireDefault(__BaseController); | ||
/** | ||
* @namespace com.myorg.myapp.controller | ||
*/ | ||
const App = BaseController.extend("com.myorg.myapp.controller.App", { | ||
onInit: function _onInit() { | ||
// apply content density mode to root view | ||
this.getView().addStyleClass(this.getOwnerComponent().getContentDensityClass()); | ||
} | ||
}); | ||
return App; | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use strict"; | ||
|
||
sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/UIComponent", "sap/ui/core/routing/History"], function (Controller, UIComponent, History) { | ||
/** | ||
* @namespace com.myorg.myapp.controller | ||
*/ | ||
const BaseController = Controller.extend("com.myorg.myapp.controller.BaseController", { | ||
getOwnerComponent: function _getOwnerComponent() { | ||
return Controller.prototype.getOwnerComponent.call(this); | ||
}, | ||
getRouter: function _getRouter() { | ||
return UIComponent.getRouterFor(this); | ||
}, | ||
getResourceBundle: function _getResourceBundle() { | ||
const oModel = this.getOwnerComponent().getModel("i18n"); | ||
return oModel.getResourceBundle(); | ||
}, | ||
getModel: function _getModel(sName) { | ||
return this.getView().getModel(sName); | ||
}, | ||
setModel: function _setModel(oModel, sName) { | ||
this.getView().setModel(oModel, sName); | ||
return this; | ||
}, | ||
navTo: function _navTo(sName, oParameters, bReplace) { | ||
this.getRouter().navTo(sName, oParameters, undefined, bReplace); | ||
}, | ||
onNavBack: function _onNavBack() { | ||
const sPreviousHash = History.getInstance().getPreviousHash(); | ||
if (sPreviousHash !== undefined) { | ||
window.history.go(-1); | ||
} else { | ||
this.getRouter().navTo("main", {}, undefined, true); | ||
} | ||
} | ||
}); | ||
return BaseController; | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
sap.ui.define(["sap/m/MessageBox", "./BaseController"], function (MessageBox, __BaseController) { | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj; | ||
} | ||
const BaseController = _interopRequireDefault(__BaseController); | ||
/** | ||
* @namespace com.myorg.myapp.controller | ||
*/ | ||
const Main = BaseController.extend("com.myorg.myapp.controller.Main", { | ||
sayHello: function _sayHello() { | ||
MessageBox.show("Hello World!"); | ||
} | ||
}); | ||
return Main; | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.