This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor module dependency anasys
- Loading branch information
Showing
6 changed files
with
183 additions
and
25 deletions.
There are no files selected for viewing
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,72 @@ | ||
import UIComponent from "sap/ui/core/UIComponent"; | ||
import JSONModel from "sap/ui/model/json/JSONModel"; | ||
import * as Device from "sap/ui/Device"; | ||
import { createHelloDialog } from "./fragments/HelloDialog"; | ||
import { manifest } from "./manifest"; | ||
import Dialog from "sap/m/Dialog"; | ||
import BindingMode from "sap/ui/model/BindingMode"; | ||
import View from "sap/ui/core/mvc/View"; | ||
import Controller from "sap/ui/core/mvc/Controller"; | ||
|
||
export default class Component extends UIComponent { | ||
|
||
private metadata = { | ||
manifest | ||
} | ||
|
||
private _dialog: Dialog | ||
|
||
init() { | ||
super.init(this, arguments); | ||
// set data model | ||
var oData = { | ||
recipient: { | ||
name: "World" | ||
} | ||
}; | ||
var oModel = new JSONModel(oData); | ||
this.setModel(oModel); | ||
|
||
// set device model | ||
var oDeviceModel = new JSONModel(Device); | ||
oDeviceModel.setDefaultBindingMode(BindingMode.OneWay); | ||
this.setModel(oDeviceModel, "device"); | ||
|
||
// create the views based on the url/hash | ||
this.getRouter().initialize(); | ||
|
||
} | ||
|
||
openHelloDialog() { | ||
const oView = this.getAggregation("rootControl") as View; | ||
// create dialog lazily | ||
if (!this._dialog) { | ||
var oFragmentController = { | ||
onCloseDialog: () => { | ||
this._dialog.close(); | ||
} | ||
}; | ||
// create dialog via fragment factory | ||
this._dialog = createHelloDialog(oFragmentController); | ||
// connect dialog to the root view of this component (models, lifecycle) | ||
oView.addDependent(this._dialog); | ||
// forward compact/cozy style into dialog | ||
jQuery.sap.syncStyleClass(((oView.getController() as Controller).getOwnerComponent() as Component).getContentDensityClass(), oView, this._dialog); | ||
} | ||
this._dialog.open(); | ||
} | ||
|
||
private _sContentDensityClass: string | ||
|
||
getContentDensityClass() { | ||
if (!this._sContentDensityClass) { | ||
if (!sap.ui.Device.support.touch) { | ||
this._sContentDensityClass = "sapUiSizeCompact"; | ||
} else { | ||
this._sContentDensityClass = "sapUiSizeCozy"; | ||
} | ||
} | ||
return this._sContentDensityClass; | ||
} | ||
|
||
} |
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,28 @@ | ||
sap.ui.define("ui5/wt/ts/model/formatter", [], function () { | ||
var _default = {}; | ||
|
||
var createFormatter = function createFormatter(oView) { | ||
return { | ||
statusText: function statusText(sStatus) { | ||
var oResourceBundle = oView.getModel("i18n").getResourceBundle(); | ||
|
||
switch (sStatus) { | ||
case "A": | ||
return oResourceBundle.getText("invoiceStatusA"); | ||
|
||
case "B": | ||
return oResourceBundle.getText("invoiceStatusB"); | ||
|
||
case "C": | ||
return oResourceBundle.getText("invoiceStatusC"); | ||
|
||
default: | ||
return oResourceBundle.getText("invoiceStatusA"); | ||
} | ||
} | ||
}; | ||
}; | ||
|
||
_default.createFormatter = createFormatter; | ||
return _default; | ||
}) |
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