GeezerVison is showing github.com — Added everything for Step 3: Adding the Price Formatter · wridgeu/UI5-testing@ea435e8
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: webapp/model/formatter.js +18-3Lines changed: 18 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,8 +14,23 @@ sap.ui.define([], function () { |
14 | 14 | } |
15 | 15 | return parseFloat(sValue).toFixed(2); |
16 | 16 | }, |
17 | | - priceState: function (){ |
18 | | - |
19 | | - } |
| 17 | + /** |
| 18 | + * Defines a value state based on the price |
| 19 | + * |
| 20 | + * @public |
| 21 | + * @param {number} iPrice the price of a post |
| 22 | + * @returns {string} sValue the state for the price |
| 23 | + */ |
| 24 | + priceState: function (iPrice) { |
| 25 | + if (iPrice < 50) { |
| 26 | + return "Success"; |
| 27 | + } else if (iPrice >= 50 && iPrice < 250) { |
| 28 | + return "None"; |
| 29 | + } else if (iPrice >= 250 && iPrice < 2000) { |
| 30 | + return "Warning"; |
| 31 | + } else { |
| 32 | + return "Error"; |
| 33 | + } |
| 34 | + }, |
20 | 35 | }; |
21 | 36 | }); |
Collapse file
Copy file name to clipboardExpand all lines: webapp/view/Worklist.view.xml +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
32 | 32 | <cells> |
33 | 33 | <ObjectIdentifier title="{Title}"/> |
34 | 34 | <Text text="{Category}"/> |
35 | | - <ObjectNumber number="{ |
36 | | - path: 'Price', |
37 | | - formatter: '.formatter.numberUnit' |
38 | | - }" unit="{Currency}" /> |
| 35 | + <ObjectNumber number="{path: 'Price',formatter: '.formatter.numberUnit'}" |
| 36 | + state="{path: 'Price',formatter: '.formatter.priceState'}" |
| 37 | + unit="{Currency}" /> |
39 | 38 | </cells> |
40 | 39 | </ColumnListItem> |
41 | 40 | </items> |
|