@bizd/daterange 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +176 -2
- package/dist/resources/bizd/daterange/.library +28 -0
- package/dist/resources/bizd/daterange/DatePeriodPicker-dbg.js +195 -0
- package/dist/resources/bizd/daterange/DatePeriodPicker.js +2 -0
- package/dist/resources/bizd/daterange/DatePeriodPicker.js.map +1 -0
- package/dist/resources/bizd/daterange/DatePeriodPickerEngine-dbg.js +373 -0
- package/dist/resources/bizd/daterange/DatePeriodPickerEngine.js +2 -0
- package/dist/resources/bizd/daterange/DatePeriodPickerEngine.js.map +1 -0
- package/dist/resources/bizd/daterange/library-dbg.js +42 -0
- package/dist/resources/bizd/daterange/library-preload.js +8 -0
- package/dist/resources/bizd/daterange/library-preload.js.map +1 -0
- package/dist/resources/bizd/daterange/library.js +2 -0
- package/dist/resources/bizd/daterange/library.js.map +1 -0
- package/dist/resources/bizd/daterange/manifest.json +61 -0
- package/dist/resources/bizd/daterange/messagebundle.properties +23 -0
- package/dist/resources/bizd/daterange/themes/sap_horizon/library-RTL.css +3 -0
- package/dist/resources/bizd/daterange/themes/sap_horizon/library-parameters.json +1 -0
- package/dist/resources/bizd/daterange/themes/sap_horizon/library.css +3 -0
- package/dist/resources/bizd/daterange/themes/sap_horizon/library.source.less +238 -0
- package/package.json +33 -4
- package/src/bizd/daterange/.library +28 -0
- package/src/bizd/daterange/DatePeriodPicker.js +195 -0
- package/src/bizd/daterange/DatePeriodPickerEngine.js +373 -0
- package/src/bizd/daterange/library.js +42 -0
- package/src/bizd/daterange/messagebundle.properties +23 -0
- package/src/bizd/daterange/themes/sap_horizon/library.source.less +238 -0
- package/ui5.yaml +12 -0
package/README.md
CHANGED
|
@@ -1,3 +1,177 @@
|
|
|
1
|
-
#
|
|
1
|
+
# bizd-daterange
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SAPUI5 date / period picker: **one field** that opens a two-panel popup with quick
|
|
4
|
+
presets (Today, This Week, This Month, … Last Year) on the left and a range calendar on
|
|
5
|
+
the right, plus Clear / Cancel / Apply.
|
|
6
|
+
|
|
7
|
+
UI5 library name: **`bizd.daterange`** · control: **`bizd.daterange.DatePeriodPicker`**
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Use it in a UI5 app
|
|
12
|
+
|
|
13
|
+
### 1. Map the library to the CDN (once per app)
|
|
14
|
+
|
|
15
|
+
In the app's UI5 bootstrap (`index.html`), add `bizd.daterange` to `resourceroots`:
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<script id="sap-ui-bootstrap"
|
|
19
|
+
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
|
|
20
|
+
data-sap-ui-theme="sap_horizon"
|
|
21
|
+
data-sap-ui-resourceroots='{
|
|
22
|
+
"my.app": "./",
|
|
23
|
+
"bizd.daterange": "https://cdn.jsdelivr.net/gh/vanna96/bizd-daterange@1.1.0/dist/resources/bizd/daterange"
|
|
24
|
+
}'
|
|
25
|
+
...></script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The library loads its own JS, CSS and texts from there; no extra `<script>` or `<link>`
|
|
29
|
+
tags. Keep the version in the URL (`@1.1.0` = the git tag) so an update never changes an app
|
|
30
|
+
until you change the URL.
|
|
31
|
+
|
|
32
|
+
> `manifest.json` → `sap.ui5.resourceRoots` only accepts **relative** paths, so an online
|
|
33
|
+
> URL must go in the bootstrap (or `sap.ui.loader.config({ paths: { "bizd/daterange": "<url>" } })`).
|
|
34
|
+
|
|
35
|
+
### 2. Use it in any view
|
|
36
|
+
|
|
37
|
+
```xml
|
|
38
|
+
<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns:m="sap.m" xmlns:dr="bizd.daterange">
|
|
39
|
+
|
|
40
|
+
<m:Label text="Date" design="Bold" labelFor="datePicker"/>
|
|
41
|
+
<dr:DatePeriodPicker id="datePicker"/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 3. Read it in the controller
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
var oPicker = this.byId("datePicker");
|
|
48
|
+
|
|
49
|
+
oPicker.getRange(); // { from: "2026-11-01", to: "2026-11-30" } in valueFormat ("" / "" when empty)
|
|
50
|
+
oPicker.getISORange(); // { from: "2026-11-01", to: "2026-11-30" } always yyyy-MM-dd
|
|
51
|
+
oPicker.isEmpty(); // true → no date chosen (= don't filter by date)
|
|
52
|
+
oPicker.getValue(); // { preset: "THISMONTH", from: Date, to: Date, text: "This Month (…)" }
|
|
53
|
+
|
|
54
|
+
oPicker.setPreset("LASTMONTH");
|
|
55
|
+
oPicker.setRange(new Date(2026, 10, 3), new Date(2026, 10, 9));
|
|
56
|
+
oPicker.clear();
|
|
57
|
+
oPicker.open();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
SAP Business One Service Layer filter example:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
var oISO = this.byId("datePicker").getISORange();
|
|
64
|
+
if (oISO.from) {
|
|
65
|
+
aFilters.push("DocDate ge '" + oISO.from + "' and DocDate le '" + oISO.to + "'");
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### React to changes
|
|
70
|
+
|
|
71
|
+
```xml
|
|
72
|
+
<dr:DatePeriodPicker id="datePicker" change=".onDateChange"/>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
onDateChange: function (oEvent) {
|
|
77
|
+
oEvent.getParameter("from"); // Date | null
|
|
78
|
+
oEvent.getParameter("to"); // Date | null
|
|
79
|
+
oEvent.getParameter("preset"); // "THISMONTH", or "" for a custom range
|
|
80
|
+
oEvent.getParameter("text"); // what the field shows
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`change` fires on Apply, Clear, a chip, and `setPreset` / `setRange` / `clear`.
|
|
85
|
+
|
|
86
|
+
### Properties
|
|
87
|
+
|
|
88
|
+
| Property | Type | Default | Notes |
|
|
89
|
+
|-----------------|----------|----------------------|-------|
|
|
90
|
+
| `width` | CSSSize | `100%` | |
|
|
91
|
+
| `initialPreset` | string | — | Applied on creation, e.g. `THISMONTH`. No `change` event. |
|
|
92
|
+
| `presets` | string[] | all | Presets in the popup. XML: `presets="TODAY,THISWEEK,THISMONTH"` |
|
|
93
|
+
| `displayFormat` | string | `MM/dd/yyyy` | Format shown in the field. |
|
|
94
|
+
| `valueFormat` | string | `yyyy-MM-dd` | Format returned by `getRange()`, e.g. `MM/dd/yyyy`. |
|
|
95
|
+
| `pattern` | string | `MM/dd/yyyy` | Older name for `displayFormat` (1.0.0); still works. |
|
|
96
|
+
| `placeholder` | string | "Any date — pick a period or a date" | |
|
|
97
|
+
| `showChips` | boolean | `false` | Quick chips under the field. |
|
|
98
|
+
| `chipPresets` | string[] | Today, This Week, This Month, Last Month, This Year | With `showChips="true"`. |
|
|
99
|
+
|
|
100
|
+
**Preset keys:** `TODAY`, `YESTERDAY`, `THISWEEK`, `LASTWEEK`, `THISMONTH`, `LASTMONTH`,
|
|
101
|
+
`THISQUARTER`, `LASTQUARTER`, `THISYEAR`, `LASTYEAR` (weeks follow the user's locale).
|
|
102
|
+
|
|
103
|
+
```xml
|
|
104
|
+
<dr:DatePeriodPicker id="postingDate"
|
|
105
|
+
initialPreset="THISMONTH"
|
|
106
|
+
presets="TODAY,THISWEEK,THISMONTH,LASTMONTH,THISYEAR"
|
|
107
|
+
displayFormat="dd/MM/yyyy"/>
|
|
108
|
+
|
|
109
|
+
<!-- Show "10, Jan 2026"; getRange() returns 01/10/2026 -->
|
|
110
|
+
<dr:DatePeriodPicker id="docDate"
|
|
111
|
+
displayFormat="dd, MMM yyyy"
|
|
112
|
+
valueFormat="MM/dd/yyyy"/>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Helpers: `DatePeriodPicker.resolvePreset("LASTMONTH")` → `{ from: Date, to: Date }`,
|
|
116
|
+
`DatePeriodPicker.PRESET_KEYS`.
|
|
117
|
+
|
|
118
|
+
### Requirements
|
|
119
|
+
|
|
120
|
+
SAPUI5 / OpenUI5 **1.120+** with `sap.m` and `sap.ui.unified`, theme **sap_horizon**.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Changelog
|
|
125
|
+
|
|
126
|
+
- **1.1.0**: `displayFormat` and `valueFormat` properties (like `sap.m.DatePicker`).
|
|
127
|
+
`pattern` still works as the older name for `displayFormat`.
|
|
128
|
+
**Changed:** `getRange()` now returns `valueFormat`, default `yyyy-MM-dd`
|
|
129
|
+
(1.0.0 returned the display format). Set `valueFormat="MM/dd/yyyy"` to keep the old output.
|
|
130
|
+
- **1.0.0**: first release.
|
|
131
|
+
|
|
132
|
+
## Develop and release (maintainers)
|
|
133
|
+
|
|
134
|
+
Repository: https://github.com/vanna96/bizd-daterange. jsDelivr serves it straight from
|
|
135
|
+
the git tags: `https://cdn.jsdelivr.net/gh/vanna96/bizd-daterange@<tag>/<path>`.
|
|
136
|
+
The built files in `dist/resources/` are committed on purpose, because jsDelivr serves
|
|
137
|
+
the repository as it is.
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
src/bizd/daterange/
|
|
141
|
+
├── .library library descriptor (build generates manifest.json)
|
|
142
|
+
├── library.js Lib.init
|
|
143
|
+
├── DatePeriodPicker.js the control
|
|
144
|
+
├── DatePeriodPickerEngine.js popup, presets, formatting
|
|
145
|
+
├── messagebundle.properties texts
|
|
146
|
+
└── themes/sap_horizon/library.source.less
|
|
147
|
+
dist/resources/bizd/daterange/ build output (committed; what the CDN serves)
|
|
148
|
+
test/bizd/daterange/DatePeriodPicker.html demo page
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npm install # once: UI5 tooling
|
|
153
|
+
npm start # demo page with live sources
|
|
154
|
+
npm run build # → dist/resources/bizd/daterange (minified + library-preload.js + CSS)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Release a new version
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
npm version patch --no-git-tag-version # 1.0.0 → 1.0.1 (also: minor / major)
|
|
161
|
+
npm run build
|
|
162
|
+
git add -A
|
|
163
|
+
git commit -m "Release 1.0.1"
|
|
164
|
+
git tag 1.0.1
|
|
165
|
+
git push && git push --tags
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
jsDelivr picks up the new tag within minutes:
|
|
169
|
+
`https://cdn.jsdelivr.net/gh/vanna96/bizd-daterange@1.0.1/dist/resources/bizd/daterange/library.js`.
|
|
170
|
+
Then, in each app: change the version in the CDN URL and refresh its offline copy:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
node scripts/sync-app.js ../Biz-Service-App/webapp # or: npm run sync:app
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
> Never move or re-use a released tag: jsDelivr caches tagged versions permanently.
|
|
177
|
+
> Always release a new version number instead.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<library xmlns="http://www.sap.com/sap.ui.library.xsd">
|
|
3
|
+
|
|
4
|
+
<name>bizd.daterange</name>
|
|
5
|
+
<vendor>Bizdimension Co., Ltd.</vendor>
|
|
6
|
+
<version>1.1.0</version>
|
|
7
|
+
|
|
8
|
+
<documentation>SAPUI5 date / period picker (DatePeriodPicker)</documentation>
|
|
9
|
+
|
|
10
|
+
<dependencies>
|
|
11
|
+
<dependency>
|
|
12
|
+
<libraryName>sap.ui.core</libraryName>
|
|
13
|
+
</dependency>
|
|
14
|
+
<dependency>
|
|
15
|
+
<libraryName>sap.m</libraryName>
|
|
16
|
+
</dependency>
|
|
17
|
+
<dependency>
|
|
18
|
+
<libraryName>sap.ui.unified</libraryName>
|
|
19
|
+
</dependency>
|
|
20
|
+
</dependencies>
|
|
21
|
+
|
|
22
|
+
<appData>
|
|
23
|
+
<manifest xmlns="http://www.sap.com/ui5/buildext/manifest">
|
|
24
|
+
<i18n>messagebundle.properties</i18n>
|
|
25
|
+
</manifest>
|
|
26
|
+
</appData>
|
|
27
|
+
|
|
28
|
+
</library>
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bizd.daterange.DatePeriodPicker — date / period filter as one XML tag.
|
|
3
|
+
*
|
|
4
|
+
* A read-only field that opens a two-panel popup: quick presets (Today, This Week,
|
|
5
|
+
* This Month, ... Last Year) on the left, a range calendar on the right, and
|
|
6
|
+
* Clear / Cancel / Apply in the footer. Optional quick chips under the field.
|
|
7
|
+
*
|
|
8
|
+
* ── Usage ────────────────────────────────────────────────────────────────
|
|
9
|
+
* <mvc:View ... xmlns:dr="bizd.daterange">
|
|
10
|
+
* <m:Label text="Date" labelFor="datePicker"/>
|
|
11
|
+
* <dr:DatePeriodPicker id="datePicker"/>
|
|
12
|
+
*
|
|
13
|
+
* var oPicker = this.byId("datePicker");
|
|
14
|
+
* oPicker.getRange(); // { from: "2026-11-01", to: "2026-11-30" } in valueFormat ("" when empty)
|
|
15
|
+
* oPicker.getISORange(); // { from: "2026-11-01", to: "2026-11-30" }
|
|
16
|
+
* oPicker.isEmpty(); // true → no date filter
|
|
17
|
+
* oPicker.clear(); oPicker.setPreset("LASTMONTH"); oPicker.setRange(oFrom, oTo); oPicker.open();
|
|
18
|
+
*
|
|
19
|
+
* <dr:DatePeriodPicker change=".onDateChange"/>
|
|
20
|
+
* onDateChange: function (oEvent) {
|
|
21
|
+
* oEvent.getParameter("from"); oEvent.getParameter("to"); // Date | null
|
|
22
|
+
* oEvent.getParameter("preset"); oEvent.getParameter("text");
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* ── Properties ───────────────────────────────────────────────────────────
|
|
26
|
+
* width CSSSize default "100%"
|
|
27
|
+
* initialPreset string preset applied on creation, e.g. "THISMONTH" (no change event)
|
|
28
|
+
* presets string[] presets offered in the popup, default all (DatePeriodPicker.PRESET_KEYS)
|
|
29
|
+
* displayFormat string format shown in the field, default "MM/dd/yyyy"
|
|
30
|
+
* valueFormat string format returned by getRange(), default "yyyy-MM-dd"
|
|
31
|
+
* e.g. displayFormat="dd, MMM yyyy" valueFormat="MM/dd/yyyy"
|
|
32
|
+
* pattern string older name for displayFormat (still works)
|
|
33
|
+
* placeholder string default "Any date — pick a period or a date"
|
|
34
|
+
* showChips boolean default false — quick chips under the field
|
|
35
|
+
* chipPresets string[] chips shown when showChips="true"
|
|
36
|
+
*
|
|
37
|
+
* In XML, string[] properties take a comma list: presets="TODAY,THISWEEK,THISMONTH"
|
|
38
|
+
* Full guide: README.md of the @bizd/daterange package
|
|
39
|
+
*/
|
|
40
|
+
sap.ui.define([
|
|
41
|
+
"./library",
|
|
42
|
+
"sap/ui/core/Control",
|
|
43
|
+
"sap/ui/core/Lib",
|
|
44
|
+
"sap/m/Input",
|
|
45
|
+
"sap/m/HBox",
|
|
46
|
+
"./DatePeriodPickerEngine"
|
|
47
|
+
], function (library, Control, Lib, Input, HBox, Engine) {
|
|
48
|
+
"use strict";
|
|
49
|
+
|
|
50
|
+
var DatePeriodPicker = Control.extend("bizd.daterange.DatePeriodPicker", {
|
|
51
|
+
metadata: {
|
|
52
|
+
library: "bizd.daterange",
|
|
53
|
+
properties: {
|
|
54
|
+
width: { type: "sap.ui.core.CSSSize", defaultValue: "100%" },
|
|
55
|
+
initialPreset: { type: "string", defaultValue: "" },
|
|
56
|
+
presets: { type: "string[]", defaultValue: null },
|
|
57
|
+
displayFormat: { type: "string", defaultValue: "" },
|
|
58
|
+
valueFormat: { type: "string", defaultValue: "yyyy-MM-dd" },
|
|
59
|
+
pattern: { type: "string", defaultValue: "MM/dd/yyyy" },
|
|
60
|
+
placeholder: { type: "string", defaultValue: "" },
|
|
61
|
+
showChips: { type: "boolean", defaultValue: false },
|
|
62
|
+
chipPresets: { type: "string[]", defaultValue: null }
|
|
63
|
+
},
|
|
64
|
+
aggregations: {
|
|
65
|
+
_input: { type: "sap.m.Input", multiple: false, visibility: "hidden" },
|
|
66
|
+
_chips: { type: "sap.m.HBox", multiple: false, visibility: "hidden" }
|
|
67
|
+
},
|
|
68
|
+
events: {
|
|
69
|
+
/** Fired after every date change (Apply, Clear, chip, setPreset / setRange / clear). */
|
|
70
|
+
change: {
|
|
71
|
+
parameters: {
|
|
72
|
+
preset: { type: "string" },
|
|
73
|
+
from: { type: "object" },
|
|
74
|
+
to: { type: "object" },
|
|
75
|
+
text: { type: "string" }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
renderer: {
|
|
82
|
+
apiVersion: 2,
|
|
83
|
+
render: function (oRm, oControl) {
|
|
84
|
+
oRm.openStart("div", oControl);
|
|
85
|
+
oRm.class("bizDatePeriodPicker");
|
|
86
|
+
oRm.style("width", oControl.getWidth());
|
|
87
|
+
oRm.openEnd();
|
|
88
|
+
oRm.renderControl(oControl.getAggregation("_input"));
|
|
89
|
+
if (oControl.getShowChips()) {
|
|
90
|
+
oRm.renderControl(oControl.getAggregation("_chips"));
|
|
91
|
+
}
|
|
92
|
+
oRm.close("div");
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
init: function () {
|
|
97
|
+
this.setAggregation("_input", new Input(this.getId() + "-input", { width: "100%" }));
|
|
98
|
+
this.setAggregation("_chips", new HBox(this.getId() + "-chips"));
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
// Set up the field before the first render (settings from XML are applied by now)
|
|
102
|
+
onBeforeRendering: function () {
|
|
103
|
+
this._getEngine();
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
exit: function () {
|
|
107
|
+
if (this._oEngine) {
|
|
108
|
+
this._oEngine.destroy();
|
|
109
|
+
this._oEngine = null;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
// A <Label labelFor="..."> on this control points at the inner field
|
|
114
|
+
getIdForLabel: function () {
|
|
115
|
+
return this.getAggregation("_input").getIdForLabel();
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
// ── Public API ────────────────────────────────────────────────────────
|
|
119
|
+
/** @returns {{preset: string, from: Date|null, to: Date|null, text: string}} */
|
|
120
|
+
getValue: function () { return this._getEngine().getValue(); },
|
|
121
|
+
/** @returns {{from: string, to: string}} formatted with valueFormat (default "yyyy-MM-dd"), "" when empty */
|
|
122
|
+
getRange: function () { return this._getEngine().getRange(); },
|
|
123
|
+
/** @returns {{from: string, to: string}} as "yyyy-MM-dd", "" when empty */
|
|
124
|
+
getISORange: function () { return this._getEngine().getISORange(); },
|
|
125
|
+
/** @returns {boolean} true when no date is chosen */
|
|
126
|
+
isEmpty: function () { return this._getEngine().isEmpty(); },
|
|
127
|
+
setPreset: function (sPreset) { this._getEngine().setPreset(sPreset); return this; },
|
|
128
|
+
setRange: function (oFrom, oTo) { this._getEngine().setRange(oFrom, oTo); return this; },
|
|
129
|
+
clear: function () { this._getEngine().clear(); return this; },
|
|
130
|
+
open: function () { this._getEngine().open(); return this; },
|
|
131
|
+
|
|
132
|
+
// ── Settings that shape the popup / chips: rebuild, keep the current date ──
|
|
133
|
+
setPresets: function (a) { return this._setAndRebuild("presets", a); },
|
|
134
|
+
setPattern: function (s) { return this._setAndRebuild("pattern", s); },
|
|
135
|
+
setDisplayFormat: function (s) { return this._setAndRebuild("displayFormat", s); },
|
|
136
|
+
setValueFormat: function (s) { return this._setAndRebuild("valueFormat", s); },
|
|
137
|
+
setShowChips: function (b) { return this._setAndRebuild("showChips", !!b); },
|
|
138
|
+
setChipPresets: function (a) { return this._setAndRebuild("chipPresets", a); },
|
|
139
|
+
setPlaceholder: function (s) {
|
|
140
|
+
this.setProperty("placeholder", s, true);
|
|
141
|
+
this.getAggregation("_input").setPlaceholder(
|
|
142
|
+
s || Lib.getResourceBundleFor("bizd.daterange").getText("DPP_PLACEHOLDER"));
|
|
143
|
+
return this;
|
|
144
|
+
},
|
|
145
|
+
setInitialPreset: function (s) {
|
|
146
|
+
this.setProperty("initialPreset", s, true);
|
|
147
|
+
if (this._oEngine && s && this._oEngine.isEmpty()) {
|
|
148
|
+
this._oEngine.setPreset(s, true);
|
|
149
|
+
}
|
|
150
|
+
return this;
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
_setAndRebuild: function (sName, vValue) {
|
|
154
|
+
// showChips changes the DOM → re-render; the others only rebuild the popup
|
|
155
|
+
this.setProperty(sName, vValue, sName !== "showChips");
|
|
156
|
+
if (this._oEngine) {
|
|
157
|
+
var oValue = this._oEngine.getValue();
|
|
158
|
+
this._oEngine.destroy();
|
|
159
|
+
this._oEngine = null;
|
|
160
|
+
this._getEngine(oValue.from ? oValue : null);
|
|
161
|
+
}
|
|
162
|
+
return this;
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
_getEngine: function (oKeepValue) {
|
|
166
|
+
if (this._oEngine) return this._oEngine;
|
|
167
|
+
|
|
168
|
+
var oInitial = oKeepValue
|
|
169
|
+
? (oKeepValue.preset ? { preset: oKeepValue.preset } : { from: oKeepValue.from, to: oKeepValue.to })
|
|
170
|
+
: (this.getInitialPreset() ? { preset: this.getInitialPreset() } : null);
|
|
171
|
+
|
|
172
|
+
this._oEngine = Engine.create({
|
|
173
|
+
input: this.getAggregation("_input"),
|
|
174
|
+
chips: this.getShowChips() ? this.getAggregation("_chips") : null,
|
|
175
|
+
presets: this.getPresets() || undefined,
|
|
176
|
+
chipPresets: this.getChipPresets() || undefined,
|
|
177
|
+
pattern: this.getPattern(),
|
|
178
|
+
displayFormat: this.getDisplayFormat() || undefined,
|
|
179
|
+
valueFormat: this.getValueFormat() || undefined,
|
|
180
|
+
placeholder: this.getPlaceholder() || undefined,
|
|
181
|
+
value: oInitial,
|
|
182
|
+
change: function (oValue) { this.fireChange(oValue); }.bind(this)
|
|
183
|
+
});
|
|
184
|
+
return this._oEngine;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
/** First and last day of a preset, e.g. DatePeriodPicker.resolvePreset("THISMONTH") → { from, to } */
|
|
189
|
+
DatePeriodPicker.resolvePreset = Engine.resolvePreset;
|
|
190
|
+
|
|
191
|
+
/** All preset keys: TODAY, YESTERDAY, THISWEEK, LASTWEEK, THISMONTH, LASTMONTH, THISQUARTER, LASTQUARTER, THISYEAR, LASTYEAR */
|
|
192
|
+
DatePeriodPicker.PRESET_KEYS = Engine.PRESET_KEYS;
|
|
193
|
+
|
|
194
|
+
return DatePeriodPicker;
|
|
195
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
sap.ui.define(["./library","sap/ui/core/Control","sap/ui/core/Lib","sap/m/Input","sap/m/HBox","./DatePeriodPickerEngine"],function(e,t,i,n,s,r){"use strict";var a=t.extend("bizd.daterange.DatePeriodPicker",{metadata:{library:"bizd.daterange",properties:{width:{type:"sap.ui.core.CSSSize",defaultValue:"100%"},initialPreset:{type:"string",defaultValue:""},presets:{type:"string[]",defaultValue:null},displayFormat:{type:"string",defaultValue:""},valueFormat:{type:"string",defaultValue:"yyyy-MM-dd"},pattern:{type:"string",defaultValue:"MM/dd/yyyy"},placeholder:{type:"string",defaultValue:""},showChips:{type:"boolean",defaultValue:false},chipPresets:{type:"string[]",defaultValue:null}},aggregations:{_input:{type:"sap.m.Input",multiple:false,visibility:"hidden"},_chips:{type:"sap.m.HBox",multiple:false,visibility:"hidden"}},events:{change:{parameters:{preset:{type:"string"},from:{type:"object"},to:{type:"object"},text:{type:"string"}}}}},renderer:{apiVersion:2,render:function(e,t){e.openStart("div",t);e.class("bizDatePeriodPicker");e.style("width",t.getWidth());e.openEnd();e.renderControl(t.getAggregation("_input"));if(t.getShowChips()){e.renderControl(t.getAggregation("_chips"))}e.close("div")}},init:function(){this.setAggregation("_input",new n(this.getId()+"-input",{width:"100%"}));this.setAggregation("_chips",new s(this.getId()+"-chips"))},onBeforeRendering:function(){this._getEngine()},exit:function(){if(this._oEngine){this._oEngine.destroy();this._oEngine=null}},getIdForLabel:function(){return this.getAggregation("_input").getIdForLabel()},getValue:function(){return this._getEngine().getValue()},getRange:function(){return this._getEngine().getRange()},getISORange:function(){return this._getEngine().getISORange()},isEmpty:function(){return this._getEngine().isEmpty()},setPreset:function(e){this._getEngine().setPreset(e);return this},setRange:function(e,t){this._getEngine().setRange(e,t);return this},clear:function(){this._getEngine().clear();return this},open:function(){this._getEngine().open();return this},setPresets:function(e){return this._setAndRebuild("presets",e)},setPattern:function(e){return this._setAndRebuild("pattern",e)},setDisplayFormat:function(e){return this._setAndRebuild("displayFormat",e)},setValueFormat:function(e){return this._setAndRebuild("valueFormat",e)},setShowChips:function(e){return this._setAndRebuild("showChips",!!e)},setChipPresets:function(e){return this._setAndRebuild("chipPresets",e)},setPlaceholder:function(e){this.setProperty("placeholder",e,true);this.getAggregation("_input").setPlaceholder(e||i.getResourceBundleFor("bizd.daterange").getText("DPP_PLACEHOLDER"));return this},setInitialPreset:function(e){this.setProperty("initialPreset",e,true);if(this._oEngine&&e&&this._oEngine.isEmpty()){this._oEngine.setPreset(e,true)}return this},_setAndRebuild:function(e,t){this.setProperty(e,t,e!=="showChips");if(this._oEngine){var i=this._oEngine.getValue();this._oEngine.destroy();this._oEngine=null;this._getEngine(i.from?i:null)}return this},_getEngine:function(e){if(this._oEngine)return this._oEngine;var t=e?e.preset?{preset:e.preset}:{from:e.from,to:e.to}:this.getInitialPreset()?{preset:this.getInitialPreset()}:null;this._oEngine=r.create({input:this.getAggregation("_input"),chips:this.getShowChips()?this.getAggregation("_chips"):null,presets:this.getPresets()||undefined,chipPresets:this.getChipPresets()||undefined,pattern:this.getPattern(),displayFormat:this.getDisplayFormat()||undefined,valueFormat:this.getValueFormat()||undefined,placeholder:this.getPlaceholder()||undefined,value:t,change:function(e){this.fireChange(e)}.bind(this)});return this._oEngine}});a.resolvePreset=r.resolvePreset;a.PRESET_KEYS=r.PRESET_KEYS;return a});
|
|
2
|
+
//# sourceMappingURL=DatePeriodPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePeriodPicker.js","names":["sap","ui","define","library","Control","Lib","Input","HBox","Engine","DatePeriodPicker","extend","metadata","properties","width","type","defaultValue","initialPreset","presets","displayFormat","valueFormat","pattern","placeholder","showChips","chipPresets","aggregations","_input","multiple","visibility","_chips","events","change","parameters","preset","from","to","text","renderer","apiVersion","render","oRm","oControl","openStart","class","style","getWidth","openEnd","renderControl","getAggregation","getShowChips","close","init","this","setAggregation","getId","onBeforeRendering","_getEngine","exit","_oEngine","destroy","getIdForLabel","getValue","getRange","getISORange","isEmpty","setPreset","sPreset","setRange","oFrom","oTo","clear","open","setPresets","a","_setAndRebuild","setPattern","s","setDisplayFormat","setValueFormat","setShowChips","b","setChipPresets","setPlaceholder","setProperty","getResourceBundleFor","getText","setInitialPreset","sName","vValue","oValue","oKeepValue","oInitial","getInitialPreset","create","input","chips","getPresets","undefined","getChipPresets","getPattern","getDisplayFormat","getValueFormat","getPlaceholder","value","fireChange","bind","resolvePreset","PRESET_KEYS"],"sources":["DatePeriodPicker-dbg.js"],"mappings":"AAuCAA,IAAIC,GAAGC,OAAO,CACV,YACA,sBACA,kBACA,cACA,aACA,4BACD,SAAUC,EAASC,EAASC,EAAKC,EAAOC,EAAMC,GAC7C,aAEA,IAAIC,EAAmBL,EAAQM,OAAO,kCAAmC,CACrEC,SAAU,CACNR,QAAS,iBACTS,WAAY,CACRC,MAAe,CAAEC,KAAM,sBAAuBC,aAAc,QAC5DC,cAAe,CAAEF,KAAM,SAAYC,aAAc,IACjDE,QAAe,CAAEH,KAAM,WAAYC,aAAc,MACjDG,cAAe,CAAEJ,KAAM,SAAYC,aAAc,IACjDI,YAAe,CAAEL,KAAM,SAAYC,aAAc,cACjDK,QAAe,CAAEN,KAAM,SAAYC,aAAc,cACjDM,YAAe,CAAEP,KAAM,SAAYC,aAAc,IACjDO,UAAe,CAAER,KAAM,UAAYC,aAAc,OACjDQ,YAAe,CAAET,KAAM,WAAYC,aAAc,OAErDS,aAAc,CACVC,OAAQ,CAAEX,KAAM,c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