App.controller.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. sap.ui.define([
  2. "./BaseController",
  3. "sap/ui/model/json/JSONModel"
  4. ], function (BaseController, JSONModel) {
  5. "use strict";
  6. return BaseController.extend("sap.ui.demo.orderbrowser.controller.App", {
  7. onInit : function () {
  8. var oViewModel,
  9. fnSetAppNotBusy,
  10. iOriginalBusyDelay = this.getView().getBusyIndicatorDelay();
  11. oViewModel = new JSONModel({
  12. busy : true,
  13. delay : 0,
  14. layout : "OneColumn",
  15. previousLayout : "",
  16. actionButtonsInfo : {
  17. midColumn : {
  18. fullScreen : false
  19. }
  20. }
  21. });
  22. this.setModel(oViewModel, "appView");
  23. fnSetAppNotBusy = function() {
  24. oViewModel.setProperty("/busy", false);
  25. oViewModel.setProperty("/delay", iOriginalBusyDelay);
  26. };
  27. // since then() has no "reject"-path attach to the MetadataFailed-Event to disable the busy indicator in case of an error
  28. this.getOwnerComponent().getModel().metadataLoaded().then(fnSetAppNotBusy);
  29. this.getOwnerComponent().getModel().attachMetadataFailed(fnSetAppNotBusy);
  30. // apply content density mode to root view
  31. this.getView().addStyleClass(this.getOwnerComponent().getContentDensityClass());
  32. }
  33. });
  34. });