@vnejs/plugins.feature.date 0.1.1 → 0.1.3
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/modules/date.js +5 -3
- package/package.json +1 -1
package/modules/date.js
CHANGED
|
@@ -7,13 +7,13 @@ export class DateModule extends Module {
|
|
|
7
7
|
this.on(this.EVENTS.DATE.SET, this.onDateSet);
|
|
8
8
|
this.on(this.EVENTS.DATE.ADD, this.onDateAdd);
|
|
9
9
|
|
|
10
|
-
this.on(this.EVENTS.STATE.SET, this.
|
|
10
|
+
this.on(this.EVENTS.STATE.SET, this.onStateSet);
|
|
11
11
|
this.on(this.EVENTS.STATE.CLEAR, this.setDefaultState);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.
|
|
14
|
+
init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
onLineExec = async ({ line = "" } = {}) => {
|
|
17
17
|
const [action, ...values] = line.split(" ");
|
|
18
18
|
|
|
19
19
|
const days = Number(values[0] || 0) || 0;
|
|
@@ -34,6 +34,8 @@ export class DateModule extends Module {
|
|
|
34
34
|
onDateSet = ({ days = 0, months = 0, years = 0 } = {}) => this.changeDate(days + 1, months, years);
|
|
35
35
|
onDateAdd = ({ days = 0, months = 0, years = 0 } = {}) => this.changeDate(this.state.days + days, this.state.months + months, this.state.years + years);
|
|
36
36
|
|
|
37
|
+
onStateSet = async ({ [this.name]: state } = {}) => this.setState(await this.emitOne(this.EVENTS.VENDORS.CLONE, state));
|
|
38
|
+
|
|
37
39
|
changeDate = (days = 0, months = 0, years = 0) => {
|
|
38
40
|
const w = new Date();
|
|
39
41
|
w.setDate(days);
|