@iobroker/adapter-react-v5 7.0.2 → 7.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/Components/404.d.ts +3 -2
- package/Components/404.js +3 -2
- package/Components/ColorPicker.d.ts +22 -8
- package/Components/ColorPicker.js +34 -17
- package/Components/ComplexCron.js +24 -24
- package/Components/CopyToClipboard.d.ts +10 -1
- package/Components/CopyToClipboard.js +17 -8
- package/Components/CustomModal.d.ts +1 -1
- package/Components/CustomModal.js +8 -8
- package/Components/FileBrowser.d.ts +11 -11
- package/Components/FileBrowser.js +135 -152
- package/Components/FileViewer.js +34 -23
- package/Components/Icon.d.ts +16 -2
- package/Components/Icon.js +19 -8
- package/Components/IconPicker.js +10 -14
- package/Components/IconSelector.d.ts +1 -1
- package/Components/IconSelector.js +64 -74
- package/Components/Image.d.ts +8 -4
- package/Components/Image.js +13 -32
- package/Components/Loader.d.ts +2 -2
- package/Components/Loader.js +21 -18
- package/Components/Loaders/MV.d.ts +6 -1
- package/Components/Loaders/MV.js +23 -7
- package/Components/Loaders/PT.d.ts +7 -2
- package/Components/Loaders/PT.js +20 -7
- package/Components/Loaders/Vendor.d.ts +2 -2
- package/Components/Loaders/Vendor.js +15 -7
- package/Components/Logo.js +16 -18
- package/Components/MDUtils.d.ts +1 -1
- package/Components/MDUtils.js +8 -4
- package/Components/ObjectBrowser.d.ts +40 -39
- package/Components/ObjectBrowser.js +550 -435
- package/Components/Router.d.ts +1 -3
- package/Components/Router.js +3 -1
- package/Components/SaveCloseButtons.d.ts +3 -3
- package/Components/SaveCloseButtons.js +3 -3
- package/Components/Schedule.d.ts +15 -15
- package/Components/Schedule.js +177 -154
- package/Components/SelectWithIcon.d.ts +2 -2
- package/Components/SelectWithIcon.js +45 -34
- package/Components/SimpleCron/index.js +83 -43
- package/Components/TabContainer.js +2 -2
- package/Components/TabContent.js +1 -1
- package/Components/TabHeader.js +1 -1
- package/Components/TableResize.d.ts +2 -2
- package/Components/TableResize.js +5 -5
- package/Components/TextWithIcon.d.ts +1 -1
- package/Components/TextWithIcon.js +10 -8
- package/Components/ToggleThemeMenu.d.ts +2 -2
- package/Components/ToggleThemeMenu.js +3 -3
- package/Components/TreeTable.d.ts +18 -18
- package/Components/TreeTable.js +76 -72
- package/Components/UploadImage.d.ts +2 -2
- package/Components/UploadImage.js +25 -21
- package/Components/Utils.d.ts +42 -22
- package/Components/Utils.js +66 -65
- package/Components/withWidth.d.ts +2 -2
- package/Components/withWidth.js +10 -6
- package/Dialogs/ComplexCron.d.ts +2 -2
- package/Dialogs/ComplexCron.js +3 -3
- package/Dialogs/Confirm.d.ts +4 -4
- package/Dialogs/Confirm.js +18 -8
- package/Dialogs/Cron.d.ts +3 -3
- package/Dialogs/Cron.js +21 -17
- package/Dialogs/Error.d.ts +3 -3
- package/Dialogs/Error.js +6 -4
- package/Dialogs/Message.d.ts +3 -3
- package/Dialogs/Message.js +6 -4
- package/Dialogs/SelectFile.d.ts +4 -4
- package/Dialogs/SelectFile.js +6 -4
- package/Dialogs/SelectID.d.ts +12 -10
- package/Dialogs/SelectID.js +12 -8
- package/Dialogs/SimpleCron.d.ts +2 -2
- package/Dialogs/SimpleCron.js +2 -2
- package/Dialogs/TextInput.d.ts +2 -2
- package/Dialogs/TextInput.js +3 -3
- package/GenericApp.d.ts +19 -13
- package/GenericApp.js +128 -85
- package/LegacyConnection.d.ts +240 -248
- package/LegacyConnection.js +500 -525
- package/README.md +1234 -1170
- package/Theme.d.ts +1 -1
- package/Theme.js +9 -12
- package/assets/devices.json +1 -0
- package/assets/rooms.json +1 -0
- package/craco-module-federation.js +3 -12
- package/i18n/de.json +434 -434
- package/i18n/en.json +434 -434
- package/i18n/es.json +434 -434
- package/i18n/fr.json +434 -434
- package/i18n/it.json +434 -434
- package/i18n/nl.json +434 -434
- package/i18n/pl.json +434 -434
- package/i18n/pt.json +434 -434
- package/i18n/ru.json +434 -434
- package/i18n/uk.json +434 -434
- package/i18n/zh-cn.json +434 -434
- package/i18n.d.ts +26 -19
- package/i18n.js +28 -22
- package/icons/IconAdapter.js +2 -2
- package/icons/IconAlias.js +2 -2
- package/icons/IconChannel.js +2 -2
- package/icons/IconClearFilter.js +2 -2
- package/icons/IconClosed.js +2 -2
- package/icons/IconCopy.js +2 -2
- package/icons/IconDevice.js +2 -2
- package/icons/IconDocument.js +2 -2
- package/icons/IconDocumentReadOnly.js +2 -2
- package/icons/IconExpert.js +2 -2
- package/icons/IconFx.js +2 -2
- package/icons/IconInstance.js +2 -2
- package/icons/IconLogout.js +2 -2
- package/icons/IconNoIcon.js +2 -2
- package/icons/IconOpen.d.ts +2 -2
- package/icons/IconOpen.js +2 -2
- package/icons/IconProps.d.ts +4 -3
- package/icons/IconState.d.ts +2 -2
- package/icons/IconState.js +2 -2
- package/index.css +3 -2
- package/package.json +1 -1
- package/src/Components/404.tsx +32 -31
- package/src/Components/ColorPicker.tsx +142 -114
- package/src/Components/ComplexCron.tsx +174 -137
- package/src/Components/CopyToClipboard.tsx +22 -9
- package/src/Components/CustomModal.tsx +76 -69
- package/src/Components/FileBrowser.tsx +959 -852
- package/src/Components/FileViewer.tsx +146 -127
- package/src/Components/Icon.tsx +80 -52
- package/src/Components/IconPicker.tsx +83 -67
- package/src/Components/IconSelector.tsx +159 -141
- package/src/Components/Image.tsx +43 -26
- package/src/Components/Loader.tsx +56 -32
- package/src/Components/Logo.tsx +62 -52
- package/src/Components/MDUtils.tsx +10 -6
- package/src/Components/ObjectBrowser.tsx +3198 -2478
- package/src/Components/Router.tsx +11 -11
- package/src/Components/SaveCloseButtons.tsx +43 -39
- package/src/Components/Schedule.tsx +1091 -853
- package/src/Components/SelectWithIcon.tsx +135 -93
- package/src/Components/TabContainer.tsx +21 -19
- package/src/Components/TabContent.tsx +13 -12
- package/src/Components/TabHeader.tsx +10 -9
- package/src/Components/TableResize.tsx +52 -37
- package/src/Components/TextWithIcon.tsx +30 -19
- package/src/Components/ToggleThemeMenu.tsx +31 -13
- package/src/Components/TreeTable.tsx +468 -385
- package/src/Components/UploadImage.tsx +153 -121
- package/src/Components/Utils.tsx +135 -127
- package/src/Components/loader.css +40 -31
- package/src/Components/withWidth.tsx +23 -12
- package/src/Connection.tsx +1 -3
- package/src/Dialogs/ComplexCron.tsx +55 -61
- package/src/Dialogs/Confirm.tsx +88 -65
- package/src/Dialogs/Cron.tsx +122 -112
- package/src/Dialogs/Error.tsx +37 -42
- package/src/Dialogs/Message.tsx +39 -37
- package/src/Dialogs/SelectFile.tsx +95 -85
- package/src/Dialogs/SelectID.tsx +141 -129
- package/src/Dialogs/SimpleCron.tsx +44 -44
- package/src/Dialogs/TextInput.tsx +60 -68
- package/src/GenericApp.tsx +342 -242
- package/src/LegacyConnection.tsx +972 -842
- package/src/Prompt.tsx +3 -1
- package/src/Theme.tsx +19 -26
- package/src/icons/IconAdapter.tsx +16 -14
- package/src/icons/IconAlias.tsx +16 -14
- package/src/icons/IconChannel.tsx +55 -16
- package/src/icons/IconClearFilter.tsx +17 -15
- package/src/icons/IconClosed.tsx +16 -11
- package/src/icons/IconCopy.tsx +16 -11
- package/src/icons/IconDevice.tsx +121 -22
- package/src/icons/IconDocument.tsx +16 -11
- package/src/icons/IconDocumentReadOnly.tsx +21 -12
- package/src/icons/IconExpert.tsx +20 -12
- package/src/icons/IconFx.tsx +16 -14
- package/src/icons/IconInstance.tsx +16 -14
- package/src/icons/IconLogout.tsx +20 -18
- package/src/icons/IconNoIcon.tsx +16 -14
- package/src/icons/IconOpen.tsx +17 -12
- package/src/icons/IconProps.tsx +4 -3
- package/src/icons/IconState.tsx +34 -13
- package/src/index.css +3 -2
- package/tasks.js +91 -0
- package/types.d.ts +141 -0
- package/Components/Loaders/PT.css +0 -109
- package/Components/Loaders/Vendor.css +0 -13
- package/Components/loader.css +0 -222
- package/Components/types.d.ts +0 -82
- package/assets/devices/Alarm Systems.svg +0 -19
- package/assets/devices/Amplifier.svg +0 -22
- package/assets/devices/Awnings.svg +0 -5
- package/assets/devices/Battery Status.svg +0 -5
- package/assets/devices/Ceiling Spotlights.svg +0 -16
- package/assets/devices/Chandelier.svg +0 -7
- package/assets/devices/Climate.svg +0 -12
- package/assets/devices/Coffee Makers.svg +0 -6
- package/assets/devices/Cold Water.svg +0 -31
- package/assets/devices/Computer.svg +0 -21
- package/assets/devices/Consumption.svg +0 -8
- package/assets/devices/Curtains.svg +0 -43
- package/assets/devices/Dishwashers.svg +0 -12
- package/assets/devices/Doors.svg +0 -6
- package/assets/devices/Doorstep.svg +0 -35
- package/assets/devices/Dryer.svg +0 -14
- package/assets/devices/Fan.svg +0 -20
- package/assets/devices/Floor Lamps.svg +0 -5
- package/assets/devices/Garage Doors.svg +0 -9
- package/assets/devices/Gates.svg +0 -32
- package/assets/devices/Hairdryer.svg +0 -23
- package/assets/devices/Handle.svg +0 -6
- package/assets/devices/Hanging Lamps.svg +0 -9
- package/assets/devices/Heater.svg +0 -44
- package/assets/devices/Hoods.svg +0 -12
- package/assets/devices/Hot Water.svg +0 -10
- package/assets/devices/Humidity.svg +0 -41
- package/assets/devices/Iron.svg +0 -5
- package/assets/devices/Irrigation.svg +0 -23
- package/assets/devices/Led Strip.svg +0 -31
- package/assets/devices/Light.svg +0 -30
- package/assets/devices/Lightings.svg +0 -46
- package/assets/devices/Lock.svg +0 -19
- package/assets/devices/Louvre.svg +0 -7
- package/assets/devices/Mowing Machine.svg +0 -9
- package/assets/devices/Music.svg +0 -13
- package/assets/devices/Outdoor Blinds.svg +0 -7
- package/assets/devices/People.svg +0 -19
- package/assets/devices/Pool.svg +0 -8
- package/assets/devices/Power Consumption.svg +0 -13
- package/assets/devices/Printer.svg +0 -10
- package/assets/devices/Pump.svg +0 -10
- package/assets/devices/Receiver.svg +0 -19
- package/assets/devices/Sconces.svg +0 -10
- package/assets/devices/Security.svg +0 -34
- package/assets/devices/Shading.svg +0 -5
- package/assets/devices/Shutters.svg +0 -11
- package/assets/devices/SmokeDetector.svg +0 -13
- package/assets/devices/Sockets.svg +0 -13
- package/assets/devices/Speaker.svg +0 -35
- package/assets/devices/Stove.svg +0 -12
- package/assets/devices/Table Lamps.svg +0 -12
- package/assets/devices/Temperature Sensors.svg +0 -28
- package/assets/devices/Tv.svg +0 -8
- package/assets/devices/Vacuum Cleaner.svg +0 -16
- package/assets/devices/Ventilation.svg +0 -12
- package/assets/devices/Washing Machines.svg +0 -16
- package/assets/devices/Water Consumption.svg +0 -6
- package/assets/devices/Water Heater.svg +0 -8
- package/assets/devices/Water.svg +0 -40
- package/assets/devices/Weather.svg +0 -28
- package/assets/devices/Window.svg +0 -8
- package/assets/rooms/Anteroom.svg +0 -53
- package/assets/rooms/Attic.svg +0 -21
- package/assets/rooms/Balcony.svg +0 -13
- package/assets/rooms/Barn.svg +0 -6
- package/assets/rooms/Basement.svg +0 -5
- package/assets/rooms/Bathroom.svg +0 -38
- package/assets/rooms/Bedroom.svg +0 -5
- package/assets/rooms/Boiler Room.svg +0 -13
- package/assets/rooms/Carport.svg +0 -17
- package/assets/rooms/Cellar.svg +0 -89
- package/assets/rooms/Chamber.svg +0 -9
- package/assets/rooms/Corridor.svg +0 -53
- package/assets/rooms/Dining Area.svg +0 -37
- package/assets/rooms/Dining Room.svg +0 -37
- package/assets/rooms/Dining.svg +0 -37
- package/assets/rooms/Dressing Room.svg +0 -5
- package/assets/rooms/Driveway.svg +0 -15
- package/assets/rooms/Entrance.svg +0 -44
- package/assets/rooms/Equipment Room.svg +0 -15
- package/assets/rooms/Front Yard.svg +0 -64
- package/assets/rooms/Gallery.svg +0 -14
- package/assets/rooms/Garage.svg +0 -20
- package/assets/rooms/Garden.svg +0 -13
- package/assets/rooms/Ground Floor.svg +0 -95
- package/assets/rooms/Guest Bathroom.svg +0 -33
- package/assets/rooms/Guest Room.svg +0 -5
- package/assets/rooms/Gym.svg +0 -5
- package/assets/rooms/Hall.svg +0 -19
- package/assets/rooms/Home Theater.svg +0 -8
- package/assets/rooms/Kitchen.svg +0 -18
- package/assets/rooms/Laundry Room.svg +0 -12
- package/assets/rooms/Living Area.svg +0 -11
- package/assets/rooms/Living Room.svg +0 -10
- package/assets/rooms/Locker Room.svg +0 -17
- package/assets/rooms/Nursery.svg +0 -5
- package/assets/rooms/Office.svg +0 -8
- package/assets/rooms/Outdoors.svg +0 -7
- package/assets/rooms/Playroom.svg +0 -6
- package/assets/rooms/Pool.svg +0 -8
- package/assets/rooms/Rear Wall.svg +0 -30
- package/assets/rooms/Second Floor.svg +0 -95
- package/assets/rooms/Shed.svg +0 -16
- package/assets/rooms/Sleeping Area.svg +0 -22
- package/assets/rooms/Stairway.svg +0 -5
- package/assets/rooms/Stairwell.svg +0 -15
- package/assets/rooms/Storeroom.svg +0 -5
- package/assets/rooms/Summer House.svg +0 -27
- package/assets/rooms/Swimming Pool.svg +0 -21
- package/assets/rooms/Terrace.svg +0 -7
- package/assets/rooms/Toilet.svg +0 -10
- package/assets/rooms/Upstairs.svg +0 -6
- package/assets/rooms/Wardrobe.svg +0 -60
- package/assets/rooms/Washroom.svg +0 -20
- package/assets/rooms/Wc.svg +0 -10
- package/assets/rooms/Windscreen.svg +0 -60
- package/assets/rooms/Workshop.svg +0 -23
- package/assets/rooms/Workspace.svg +0 -8
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Input,
|
|
5
|
-
Radio,
|
|
6
|
-
FormControlLabel,
|
|
7
|
-
FormGroup,
|
|
8
|
-
Checkbox,
|
|
9
|
-
MenuItem,
|
|
10
|
-
Select,
|
|
11
|
-
TextField, Box,
|
|
12
|
-
} from '@mui/material';
|
|
1
|
+
import React, { Component, type JSX } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Input, Radio, FormControlLabel, FormGroup, Checkbox, MenuItem, Select, TextField, Box } from '@mui/material';
|
|
13
4
|
|
|
14
5
|
import I18n from '../i18n';
|
|
15
|
-
import { IobTheme } from '../types';
|
|
6
|
+
import type { IobTheme } from '../types';
|
|
16
7
|
import Utils from './Utils';
|
|
17
8
|
|
|
18
9
|
const styles: Record<string, any> = {
|
|
@@ -72,9 +63,7 @@ const styles: Record<string, any> = {
|
|
|
72
63
|
inputSmallCheck: {
|
|
73
64
|
padding: 0,
|
|
74
65
|
},
|
|
75
|
-
rowOnce: {
|
|
76
|
-
|
|
77
|
-
},
|
|
66
|
+
rowOnce: {},
|
|
78
67
|
rowDays: (theme: IobTheme) => ({
|
|
79
68
|
background: theme.palette.mode !== 'dark' ? '#ddeaff' : '#4b5057',
|
|
80
69
|
}),
|
|
@@ -109,16 +98,7 @@ const styles: Record<string, any> = {
|
|
|
109
98
|
}),
|
|
110
99
|
};
|
|
111
100
|
|
|
112
|
-
const WEEKDAYS = [
|
|
113
|
-
'Sunday',
|
|
114
|
-
'Monday',
|
|
115
|
-
'Tuesday',
|
|
116
|
-
'Wednesday',
|
|
117
|
-
'Thursday',
|
|
118
|
-
'Friday',
|
|
119
|
-
'Saturday',
|
|
120
|
-
'Sunday',
|
|
121
|
-
];
|
|
101
|
+
const WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
|
|
122
102
|
const MONTHS = [
|
|
123
103
|
'January',
|
|
124
104
|
'February',
|
|
@@ -281,14 +261,14 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
281
261
|
if (this.props.schedule && typeof this.props.schedule === 'string' && this.props.schedule[0] === '{') {
|
|
282
262
|
try {
|
|
283
263
|
schedule = JSON.parse(this.props.schedule);
|
|
284
|
-
} catch
|
|
264
|
+
} catch {
|
|
285
265
|
// ignore
|
|
286
266
|
}
|
|
287
267
|
} else if (typeof this.props.schedule === 'object') {
|
|
288
268
|
schedule = this.props.schedule;
|
|
289
269
|
}
|
|
290
270
|
|
|
291
|
-
if (
|
|
271
|
+
if (!schedule || !Object.keys(schedule).length) {
|
|
292
272
|
setTimeout(() => this.onChange(this.state.schedule, true), 200);
|
|
293
273
|
schedule = DEFAULT;
|
|
294
274
|
}
|
|
@@ -305,12 +285,11 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
305
285
|
};
|
|
306
286
|
|
|
307
287
|
if (JSON.stringify(schedule) !== this.props.schedule) {
|
|
308
|
-
setTimeout(() =>
|
|
309
|
-
this.props.onChange && this.props.onChange(JSON.stringify(schedule)), 100);
|
|
288
|
+
setTimeout(() => this.props.onChange && this.props.onChange(JSON.stringify(schedule)), 100);
|
|
310
289
|
}
|
|
311
290
|
}
|
|
312
291
|
|
|
313
|
-
onChange(schedule: ScheduleConfig, force?: boolean) {
|
|
292
|
+
onChange(schedule: ScheduleConfig, force?: boolean): void {
|
|
314
293
|
const isDiff = JSON.stringify(schedule) !== JSON.stringify(this.state.schedule);
|
|
315
294
|
if (force || isDiff) {
|
|
316
295
|
isDiff && this.setState({ schedule, desc: Schedule.state2text(schedule) });
|
|
@@ -366,7 +345,12 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
366
345
|
if (!copy.valid.to) {
|
|
367
346
|
delete copy.valid.to;
|
|
368
347
|
}
|
|
369
|
-
if (
|
|
348
|
+
if (
|
|
349
|
+
copy.period.days === 1 ||
|
|
350
|
+
copy.period.weeks === 1 ||
|
|
351
|
+
copy.period.months === 1 ||
|
|
352
|
+
copy.period.years === 1
|
|
353
|
+
) {
|
|
370
354
|
const from = Schedule.string2date(copy.valid.from);
|
|
371
355
|
const today = new Date();
|
|
372
356
|
today.setHours(0);
|
|
@@ -390,7 +374,7 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
390
374
|
if (typeof schedule === 'string') {
|
|
391
375
|
try {
|
|
392
376
|
schedule = JSON.parse(schedule) as ScheduleConfig;
|
|
393
|
-
} catch
|
|
377
|
+
} catch {
|
|
394
378
|
return '';
|
|
395
379
|
}
|
|
396
380
|
}
|
|
@@ -420,7 +404,14 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
420
404
|
if (daysOfWeek.length === 2 && daysOfWeek[0] === 0 && daysOfWeek[1] === 6) {
|
|
421
405
|
// on weekends
|
|
422
406
|
desc.push(I18n.t('sch_desc_onWeekends'));
|
|
423
|
-
} else if (
|
|
407
|
+
} else if (
|
|
408
|
+
daysOfWeek.length === 5 &&
|
|
409
|
+
daysOfWeek[0] === 1 &&
|
|
410
|
+
daysOfWeek[1] === 2 &&
|
|
411
|
+
daysOfWeek[2] === 3 &&
|
|
412
|
+
daysOfWeek[3] === 4 &&
|
|
413
|
+
daysOfWeek[4] === 5
|
|
414
|
+
) {
|
|
424
415
|
// on workdays
|
|
425
416
|
desc.push(I18n.t('sch_desc_onWorkdays'));
|
|
426
417
|
} else {
|
|
@@ -455,7 +446,14 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
455
446
|
if (daysOfWeek.length === 2 && daysOfWeek[0] === 0 && daysOfWeek[1] === 6) {
|
|
456
447
|
// on weekends
|
|
457
448
|
desc.push(I18n.t('sch_desc_onWeekends'));
|
|
458
|
-
} else if (
|
|
449
|
+
} else if (
|
|
450
|
+
daysOfWeek.length === 5 &&
|
|
451
|
+
daysOfWeek[0] === 1 &&
|
|
452
|
+
daysOfWeek[1] === 2 &&
|
|
453
|
+
daysOfWeek[2] === 3 &&
|
|
454
|
+
daysOfWeek[3] === 4 &&
|
|
455
|
+
daysOfWeek[4] === 5
|
|
456
|
+
) {
|
|
459
457
|
// on workdays
|
|
460
458
|
desc.push(I18n.t('sch_desc_onWorkdays'));
|
|
461
459
|
} else {
|
|
@@ -523,11 +521,15 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
523
521
|
} else {
|
|
524
522
|
desc.push(I18n.t('sch_desc_everyNYears', schedule.period.years.toString()));
|
|
525
523
|
}
|
|
526
|
-
desc.push(
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
524
|
+
desc.push(
|
|
525
|
+
I18n.t(
|
|
526
|
+
'sch_desc_onDate',
|
|
527
|
+
schedule.period.yearDate.toString(),
|
|
528
|
+
schedule.period.yearMonth
|
|
529
|
+
? I18n.t(MONTHS[schedule.period.yearMonth - 1])
|
|
530
|
+
: I18n.t('sch_desc_everyMonth'),
|
|
531
|
+
),
|
|
532
|
+
);
|
|
531
533
|
}
|
|
532
534
|
|
|
533
535
|
// time
|
|
@@ -556,8 +558,12 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
556
558
|
desc.push(I18n.t('sch_desc_everyNHours', schedule.time.interval.toString()));
|
|
557
559
|
}
|
|
558
560
|
|
|
559
|
-
const start =
|
|
560
|
-
|
|
561
|
+
const start =
|
|
562
|
+
ASTRO.indexOf(schedule.time.start) !== -1
|
|
563
|
+
? I18n.t(`sch_astro_${schedule.time.start}`)
|
|
564
|
+
: schedule.time.start;
|
|
565
|
+
const end =
|
|
566
|
+
ASTRO.indexOf(schedule.time.end) !== -1 ? I18n.t(`sch_astro_${schedule.time.end}`) : schedule.time.end;
|
|
561
567
|
if (start !== '00:00' || (end !== '24:00' && end !== '23:59')) {
|
|
562
568
|
// from HH:mm to HH:mm
|
|
563
569
|
desc.push(I18n.t('sch_desc_intervalFromTo', start, end));
|
|
@@ -580,7 +586,7 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
580
586
|
return desc.join(' ');
|
|
581
587
|
}
|
|
582
588
|
|
|
583
|
-
getTimePeriodElements() {
|
|
589
|
+
getTimePeriodElements(): JSX.Element {
|
|
584
590
|
const schedule = this.state.schedule;
|
|
585
591
|
let wholeDay = false;
|
|
586
592
|
let day = false;
|
|
@@ -597,272 +603,344 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
597
603
|
fromTo = false;
|
|
598
604
|
}
|
|
599
605
|
|
|
600
|
-
return
|
|
601
|
-
<div
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
this.onChange(_schedule);
|
|
610
|
-
}}
|
|
611
|
-
/>}
|
|
612
|
-
label={I18n.t('sch_intervalTime')}
|
|
613
|
-
/>
|
|
614
|
-
</div>
|
|
615
|
-
<div style={styles.settingsDiv}>
|
|
616
|
-
<div style={styles.settingsDiv}>
|
|
617
|
-
{!schedule.time.exactTime && <div>
|
|
618
|
-
<div>
|
|
619
|
-
<FormControlLabel
|
|
620
|
-
control={<Radio
|
|
621
|
-
style={styles.inputRadio}
|
|
622
|
-
checked={!!fromTo}
|
|
623
|
-
onClick={() => {
|
|
624
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
625
|
-
_schedule.time.start = '00:00';
|
|
626
|
-
_schedule.time.end = '23:59';
|
|
627
|
-
this.onChange(_schedule);
|
|
628
|
-
}}
|
|
629
|
-
/>}
|
|
630
|
-
label={!fromTo ? I18n.t('sch_fromTo') : ''}
|
|
631
|
-
/>
|
|
632
|
-
{fromTo && [
|
|
633
|
-
<TextField
|
|
634
|
-
variant="standard"
|
|
635
|
-
style={{ ...styles.inputTime, marginRight: 10 }}
|
|
636
|
-
key="exactTimeFrom"
|
|
637
|
-
type="time"
|
|
638
|
-
value={this.state.schedule.time.start}
|
|
639
|
-
// InputProps={{inputComponent: TextTime}}
|
|
640
|
-
onChange={e => {
|
|
641
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
642
|
-
_schedule.time.start = e.target.value;
|
|
643
|
-
this.onChange(_schedule);
|
|
644
|
-
}}
|
|
645
|
-
InputLabelProps={{ shrink: true }}
|
|
646
|
-
label={I18n.t('sch_from')}
|
|
647
|
-
margin="normal"
|
|
648
|
-
/>,
|
|
649
|
-
<TextField
|
|
650
|
-
variant="standard"
|
|
651
|
-
style={styles.inputTime}
|
|
652
|
-
key="exactTimeTo"
|
|
653
|
-
type="time"
|
|
654
|
-
value={this.state.schedule.time.end}
|
|
655
|
-
// InputProps={{inputComponent: TextTime}}
|
|
656
|
-
onChange={e => {
|
|
657
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
658
|
-
_schedule.time.end = e.target.value;
|
|
659
|
-
this.onChange(_schedule);
|
|
660
|
-
}}
|
|
661
|
-
InputLabelProps={{ shrink: true }}
|
|
662
|
-
label={I18n.t('sch_to')}
|
|
663
|
-
margin="normal"
|
|
664
|
-
/>,
|
|
665
|
-
]}
|
|
666
|
-
</div>
|
|
667
|
-
</div>}
|
|
668
|
-
|
|
669
|
-
{!schedule.time.exactTime && <div>
|
|
670
|
-
<FormControlLabel
|
|
671
|
-
control={<Radio
|
|
672
|
-
style={styles.inputRadio}
|
|
673
|
-
checked={!!wholeDay}
|
|
674
|
-
onClick={() => {
|
|
675
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
676
|
-
_schedule.time.start = '00:00';
|
|
677
|
-
_schedule.time.end = '24:00';
|
|
678
|
-
this.onChange(_schedule);
|
|
679
|
-
}}
|
|
680
|
-
/>}
|
|
681
|
-
label={I18n.t('sch_wholeDay')}
|
|
682
|
-
/>
|
|
683
|
-
</div>}
|
|
684
|
-
|
|
685
|
-
{!schedule.time.exactTime && <div>
|
|
686
|
-
<FormControlLabel
|
|
687
|
-
control={<Radio
|
|
688
|
-
style={styles.inputRadio}
|
|
689
|
-
checked={!!day}
|
|
690
|
-
onClick={() => {
|
|
691
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
692
|
-
_schedule.time.start = 'sunrise';
|
|
693
|
-
_schedule.time.end = 'sunset';
|
|
694
|
-
this.onChange(_schedule);
|
|
695
|
-
}}
|
|
696
|
-
/>}
|
|
697
|
-
label={I18n.t('sch_astroDay')}
|
|
698
|
-
/>
|
|
699
|
-
</div>}
|
|
700
|
-
|
|
701
|
-
{!schedule.time.exactTime && <div>
|
|
702
|
-
<FormControlLabel
|
|
703
|
-
control={<Radio
|
|
606
|
+
return (
|
|
607
|
+
<div
|
|
608
|
+
key="timePeriod"
|
|
609
|
+
style={styles.rowDiv}
|
|
610
|
+
>
|
|
611
|
+
<div style={styles.modeDiv}>
|
|
612
|
+
<FormControlLabel
|
|
613
|
+
control={
|
|
614
|
+
<Radio
|
|
704
615
|
style={styles.inputRadio}
|
|
705
|
-
checked={
|
|
616
|
+
checked={!schedule.time.exactTime}
|
|
706
617
|
onClick={() => {
|
|
707
618
|
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
708
|
-
_schedule.time.
|
|
709
|
-
_schedule.time.end = 'sunrise';
|
|
619
|
+
_schedule.time.exactTime = false;
|
|
710
620
|
this.onChange(_schedule);
|
|
711
621
|
}}
|
|
712
|
-
/>
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
622
|
+
/>
|
|
623
|
+
}
|
|
624
|
+
label={I18n.t('sch_intervalTime')}
|
|
625
|
+
/>
|
|
626
|
+
</div>
|
|
627
|
+
<div style={styles.settingsDiv}>
|
|
628
|
+
<div style={styles.settingsDiv}>
|
|
629
|
+
{!schedule.time.exactTime && (
|
|
630
|
+
<div>
|
|
631
|
+
<div>
|
|
632
|
+
<FormControlLabel
|
|
633
|
+
control={
|
|
634
|
+
<Radio
|
|
635
|
+
style={styles.inputRadio}
|
|
636
|
+
checked={!!fromTo}
|
|
637
|
+
onClick={() => {
|
|
638
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
639
|
+
_schedule.time.start = '00:00';
|
|
640
|
+
_schedule.time.end = '23:59';
|
|
641
|
+
this.onChange(_schedule);
|
|
642
|
+
}}
|
|
643
|
+
/>
|
|
644
|
+
}
|
|
645
|
+
label={!fromTo ? I18n.t('sch_fromTo') : ''}
|
|
646
|
+
/>
|
|
647
|
+
{fromTo && [
|
|
648
|
+
<TextField
|
|
649
|
+
variant="standard"
|
|
650
|
+
style={{ ...styles.inputTime, marginRight: 10 }}
|
|
651
|
+
key="exactTimeFrom"
|
|
652
|
+
type="time"
|
|
653
|
+
value={this.state.schedule.time.start}
|
|
654
|
+
// InputProps={{inputComponent: TextTime}}
|
|
655
|
+
onChange={e => {
|
|
656
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
657
|
+
_schedule.time.start = e.target.value;
|
|
658
|
+
this.onChange(_schedule);
|
|
659
|
+
}}
|
|
660
|
+
slotProps={{
|
|
661
|
+
inputLabel: { shrink: true },
|
|
662
|
+
}}
|
|
663
|
+
label={I18n.t('sch_from')}
|
|
664
|
+
margin="normal"
|
|
665
|
+
/>,
|
|
666
|
+
<TextField
|
|
667
|
+
variant="standard"
|
|
668
|
+
style={styles.inputTime}
|
|
669
|
+
key="exactTimeTo"
|
|
670
|
+
type="time"
|
|
671
|
+
value={this.state.schedule.time.end}
|
|
672
|
+
// InputProps={{inputComponent: TextTime}}
|
|
673
|
+
onChange={e => {
|
|
674
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
675
|
+
_schedule.time.end = e.target.value;
|
|
676
|
+
this.onChange(_schedule);
|
|
677
|
+
}}
|
|
678
|
+
slotProps={{
|
|
679
|
+
inputLabel: { shrink: true },
|
|
680
|
+
}}
|
|
681
|
+
label={I18n.t('sch_to')}
|
|
682
|
+
margin="normal"
|
|
683
|
+
/>,
|
|
684
|
+
]}
|
|
685
|
+
</div>
|
|
686
|
+
</div>
|
|
687
|
+
)}
|
|
688
|
+
|
|
689
|
+
{!schedule.time.exactTime && (
|
|
690
|
+
<div>
|
|
691
|
+
<FormControlLabel
|
|
692
|
+
control={
|
|
693
|
+
<Radio
|
|
694
|
+
style={styles.inputRadio}
|
|
695
|
+
checked={!!wholeDay}
|
|
696
|
+
onClick={() => {
|
|
697
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
698
|
+
_schedule.time.start = '00:00';
|
|
699
|
+
_schedule.time.end = '24:00';
|
|
700
|
+
this.onChange(_schedule);
|
|
701
|
+
}}
|
|
702
|
+
/>
|
|
703
|
+
}
|
|
704
|
+
label={I18n.t('sch_wholeDay')}
|
|
705
|
+
/>
|
|
706
|
+
</div>
|
|
707
|
+
)}
|
|
708
|
+
|
|
709
|
+
{!schedule.time.exactTime && (
|
|
710
|
+
<div>
|
|
711
|
+
<FormControlLabel
|
|
712
|
+
control={
|
|
713
|
+
<Radio
|
|
714
|
+
style={styles.inputRadio}
|
|
715
|
+
checked={!!day}
|
|
716
|
+
onClick={() => {
|
|
717
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
718
|
+
_schedule.time.start = 'sunrise';
|
|
719
|
+
_schedule.time.end = 'sunset';
|
|
720
|
+
this.onChange(_schedule);
|
|
721
|
+
}}
|
|
722
|
+
/>
|
|
723
|
+
}
|
|
724
|
+
label={I18n.t('sch_astroDay')}
|
|
725
|
+
/>
|
|
726
|
+
</div>
|
|
727
|
+
)}
|
|
728
|
+
|
|
729
|
+
{!schedule.time.exactTime && (
|
|
730
|
+
<div>
|
|
731
|
+
<FormControlLabel
|
|
732
|
+
control={
|
|
733
|
+
<Radio
|
|
734
|
+
style={styles.inputRadio}
|
|
735
|
+
checked={!!night}
|
|
736
|
+
onClick={() => {
|
|
737
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
738
|
+
_schedule.time.start = 'sunset';
|
|
739
|
+
_schedule.time.end = 'sunrise';
|
|
740
|
+
this.onChange(_schedule);
|
|
741
|
+
}}
|
|
742
|
+
/>
|
|
743
|
+
}
|
|
744
|
+
label={I18n.t('sch_astroNight')}
|
|
745
|
+
/>
|
|
746
|
+
</div>
|
|
747
|
+
)}
|
|
748
|
+
</div>
|
|
749
|
+
{!schedule.time.exactTime && this.getPeriodSettingsMinutes()}
|
|
716
750
|
</div>
|
|
717
|
-
{!schedule.time.exactTime && this.getPeriodSettingsMinutes()}
|
|
718
751
|
</div>
|
|
719
|
-
|
|
752
|
+
);
|
|
720
753
|
}
|
|
721
754
|
|
|
722
|
-
getTimeExactElements() {
|
|
755
|
+
getTimeExactElements(): JSX.Element {
|
|
723
756
|
const isAstro = ASTRO.includes(this.state.schedule.time.start);
|
|
724
757
|
|
|
725
|
-
return
|
|
726
|
-
<div
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
758
|
+
return (
|
|
759
|
+
<div
|
|
760
|
+
key="timeExact"
|
|
761
|
+
style={styles.rowDiv}
|
|
762
|
+
>
|
|
763
|
+
<div style={styles.modeDiv}>
|
|
764
|
+
<FormControlLabel
|
|
765
|
+
control={
|
|
766
|
+
<Radio
|
|
767
|
+
style={styles.inputRadio}
|
|
768
|
+
checked={!!this.state.schedule.time.exactTime}
|
|
769
|
+
onClick={() => {
|
|
770
|
+
const schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
771
|
+
schedule.time.exactTime = true;
|
|
772
|
+
this.onChange(schedule);
|
|
773
|
+
}}
|
|
774
|
+
/>
|
|
775
|
+
}
|
|
776
|
+
label={I18n.t('sch_exactTime')}
|
|
777
|
+
/>
|
|
778
|
+
</div>
|
|
779
|
+
{this.state.schedule.time.exactTime && (
|
|
780
|
+
<Select
|
|
781
|
+
variant="standard"
|
|
782
|
+
value={isAstro ? this.state.schedule.time.start : '00:00'}
|
|
783
|
+
onChange={e => {
|
|
784
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
785
|
+
_schedule.time.start = e.target.value;
|
|
786
|
+
this.onChange(_schedule);
|
|
735
787
|
}}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
788
|
+
>
|
|
789
|
+
<MenuItem
|
|
790
|
+
key="specific"
|
|
791
|
+
value="00:00"
|
|
792
|
+
>
|
|
793
|
+
{I18n.t('sch_specificTime')}
|
|
794
|
+
</MenuItem>
|
|
795
|
+
{ASTRO.map(event => (
|
|
796
|
+
<MenuItem
|
|
797
|
+
key={event}
|
|
798
|
+
value={event}
|
|
799
|
+
>
|
|
800
|
+
{I18n.t(`sch_astro_${event}`)}
|
|
801
|
+
</MenuItem>
|
|
802
|
+
))}
|
|
803
|
+
</Select>
|
|
804
|
+
)}
|
|
805
|
+
{this.state.schedule.time.exactTime && !isAstro && (
|
|
806
|
+
<div style={styles.settingsDiv}>
|
|
807
|
+
<TextField
|
|
808
|
+
variant="standard"
|
|
809
|
+
style={styles.inputTime}
|
|
810
|
+
key="exactTimeValue"
|
|
811
|
+
value={this.state.schedule.time.start}
|
|
812
|
+
type="time"
|
|
813
|
+
// inputComponent={TextTime}
|
|
814
|
+
onChange={e => {
|
|
815
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
816
|
+
_schedule.time.start = e.target.value;
|
|
817
|
+
this.onChange(_schedule);
|
|
818
|
+
}}
|
|
819
|
+
InputLabelProps={{ shrink: true }}
|
|
820
|
+
margin="normal"
|
|
821
|
+
/>
|
|
822
|
+
</div>
|
|
823
|
+
)}
|
|
739
824
|
</div>
|
|
740
|
-
|
|
741
|
-
variant="standard"
|
|
742
|
-
value={isAstro ? this.state.schedule.time.start : '00:00'}
|
|
743
|
-
onChange={e => {
|
|
744
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
745
|
-
_schedule.time.start = e.target.value;
|
|
746
|
-
this.onChange(_schedule);
|
|
747
|
-
}}
|
|
748
|
-
>
|
|
749
|
-
<MenuItem key="specific" value="00:00">{I18n.t('sch_specificTime')}</MenuItem>
|
|
750
|
-
{ASTRO.map(event => <MenuItem key={event} value={event}>{I18n.t(`sch_astro_${event}`)}</MenuItem>)}
|
|
751
|
-
</Select>}
|
|
752
|
-
{this.state.schedule.time.exactTime && !isAstro &&
|
|
753
|
-
<div style={styles.settingsDiv}>
|
|
754
|
-
<TextField
|
|
755
|
-
variant="standard"
|
|
756
|
-
style={styles.inputTime}
|
|
757
|
-
key="exactTimeValue"
|
|
758
|
-
value={this.state.schedule.time.start}
|
|
759
|
-
type="time"
|
|
760
|
-
// inputComponent={TextTime}
|
|
761
|
-
onChange={e => {
|
|
762
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
763
|
-
_schedule.time.start = e.target.value;
|
|
764
|
-
this.onChange(_schedule);
|
|
765
|
-
}}
|
|
766
|
-
InputLabelProps={{ shrink: true }}
|
|
767
|
-
margin="normal"
|
|
768
|
-
/>
|
|
769
|
-
</div>}
|
|
770
|
-
</div>;
|
|
825
|
+
);
|
|
771
826
|
}
|
|
772
827
|
|
|
773
|
-
static getDivider() {
|
|
828
|
+
static getDivider(): JSX.Element {
|
|
774
829
|
return <hr style={styles.hr} />;
|
|
775
830
|
}
|
|
776
831
|
|
|
777
|
-
getPeriodModes() {
|
|
832
|
+
getPeriodModes(): JSX.Element[] {
|
|
778
833
|
const schedule = this.state.schedule;
|
|
779
|
-
const isOnce =
|
|
834
|
+
const isOnce =
|
|
835
|
+
!schedule.period.dows &&
|
|
836
|
+
!schedule.period.months &&
|
|
837
|
+
!schedule.period.dates &&
|
|
838
|
+
!schedule.period.years &&
|
|
839
|
+
!schedule.period.days &&
|
|
840
|
+
!schedule.period.weeks;
|
|
780
841
|
if (isOnce && !schedule.period.once) {
|
|
781
842
|
schedule.period.once = Schedule.now2string(true);
|
|
782
843
|
}
|
|
783
844
|
|
|
784
845
|
return [
|
|
785
846
|
// ----- once ---
|
|
786
|
-
<div
|
|
847
|
+
<div
|
|
848
|
+
key="once"
|
|
849
|
+
style={{ ...styles.rowDiv, ...styles.rowOnce }}
|
|
850
|
+
>
|
|
787
851
|
<div style={styles.modeDiv}>
|
|
788
852
|
<FormControlLabel
|
|
789
|
-
control={
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
853
|
+
control={
|
|
854
|
+
<Radio
|
|
855
|
+
style={styles.inputRadio}
|
|
856
|
+
checked={!!isOnce}
|
|
857
|
+
onClick={() => {
|
|
858
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
859
|
+
_schedule.period.once = _schedule.period.once || Schedule.now2string(true);
|
|
860
|
+
_schedule.period.dows = '';
|
|
861
|
+
_schedule.period.months = '';
|
|
862
|
+
_schedule.period.dates = '';
|
|
863
|
+
_schedule.period.years = 0;
|
|
864
|
+
_schedule.period.yearDate = 0;
|
|
865
|
+
_schedule.period.yearMonth = 0;
|
|
866
|
+
_schedule.period.weeks = 0;
|
|
867
|
+
_schedule.period.days = 0;
|
|
868
|
+
this.onChange(_schedule);
|
|
869
|
+
}}
|
|
870
|
+
/>
|
|
871
|
+
}
|
|
806
872
|
label={I18n.t('sch_periodOnce')}
|
|
807
873
|
/>
|
|
808
874
|
</div>
|
|
809
|
-
{isOnce &&
|
|
810
|
-
<
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
if (this.refOnce.current) {
|
|
823
|
-
this.refOnce.current.style.background = '#ff000030';
|
|
824
|
-
}
|
|
825
|
-
this.timerOnce = setTimeout(value => {
|
|
875
|
+
{isOnce && (
|
|
876
|
+
<div style={styles.settingsDiv}>
|
|
877
|
+
<TextField
|
|
878
|
+
variant="standard"
|
|
879
|
+
style={styles.inputDate}
|
|
880
|
+
type="date"
|
|
881
|
+
ref={this.refOnce}
|
|
882
|
+
key="exactDateAt"
|
|
883
|
+
defaultValue={string2USdate(schedule.period.once)}
|
|
884
|
+
// InputProps={{inputComponent: TextTime}}
|
|
885
|
+
onChange={e => {
|
|
886
|
+
this.timerOnce && clearTimeout(this.timerOnce);
|
|
826
887
|
this.timerOnce = null;
|
|
888
|
+
|
|
827
889
|
if (this.refOnce.current) {
|
|
828
|
-
this.refOnce.current.style.background = '';
|
|
829
|
-
}
|
|
830
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
831
|
-
const date = Schedule.string2date(value);
|
|
832
|
-
if (date.toString() !== 'Invalid Date') {
|
|
833
|
-
_schedule.period.once = `${padding(date.getDate())}.${padding(date.getMonth() + 1)}.${date.getFullYear()}`;
|
|
834
|
-
this.onChange(_schedule);
|
|
890
|
+
this.refOnce.current.style.background = '#ff000030';
|
|
835
891
|
}
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
892
|
+
this.timerOnce = setTimeout(
|
|
893
|
+
value => {
|
|
894
|
+
this.timerOnce = null;
|
|
895
|
+
if (this.refOnce.current) {
|
|
896
|
+
this.refOnce.current.style.background = '';
|
|
897
|
+
}
|
|
898
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
899
|
+
const date = Schedule.string2date(value);
|
|
900
|
+
if (date.toString() !== 'Invalid Date') {
|
|
901
|
+
_schedule.period.once = `${padding(date.getDate())}.${padding(date.getMonth() + 1)}.${date.getFullYear()}`;
|
|
902
|
+
this.onChange(_schedule);
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
1500,
|
|
906
|
+
e.target.value,
|
|
907
|
+
);
|
|
908
|
+
}}
|
|
909
|
+
InputLabelProps={{ shrink: true }}
|
|
910
|
+
label={I18n.t('sch_at')}
|
|
911
|
+
margin="normal"
|
|
912
|
+
/>
|
|
913
|
+
</div>
|
|
914
|
+
)}
|
|
843
915
|
</div>,
|
|
844
916
|
|
|
845
917
|
// ----- days ---
|
|
846
|
-
<Box
|
|
918
|
+
<Box
|
|
919
|
+
component="div"
|
|
920
|
+
key="days"
|
|
921
|
+
sx={Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowDays)}
|
|
922
|
+
>
|
|
847
923
|
<div style={styles.modeDiv}>
|
|
848
924
|
<FormControlLabel
|
|
849
|
-
control={
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
925
|
+
control={
|
|
926
|
+
<Radio
|
|
927
|
+
style={styles.inputRadio}
|
|
928
|
+
checked={!!schedule.period.days}
|
|
929
|
+
onClick={() => {
|
|
930
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
931
|
+
_schedule.period.days = 1;
|
|
932
|
+
_schedule.period.dows = '';
|
|
933
|
+
_schedule.period.months = '';
|
|
934
|
+
_schedule.period.dates = '';
|
|
935
|
+
_schedule.period.years = 0;
|
|
936
|
+
_schedule.period.yearDate = 0;
|
|
937
|
+
_schedule.period.yearMonth = 0;
|
|
938
|
+
_schedule.period.weeks = 0;
|
|
939
|
+
_schedule.period.once = '';
|
|
940
|
+
this.onChange(_schedule);
|
|
941
|
+
}}
|
|
942
|
+
/>
|
|
943
|
+
}
|
|
866
944
|
label={I18n.t('sch_periodDaily')}
|
|
867
945
|
/>
|
|
868
946
|
</div>
|
|
@@ -890,224 +968,284 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
890
968
|
</div>,
|
|
891
969
|
*/
|
|
892
970
|
// ----- weeks ---
|
|
893
|
-
<Box
|
|
971
|
+
<Box
|
|
972
|
+
component="div"
|
|
973
|
+
key="weeks"
|
|
974
|
+
sx={Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowDows)}
|
|
975
|
+
>
|
|
894
976
|
<div style={styles.modeDiv}>
|
|
895
977
|
<FormControlLabel
|
|
896
|
-
control={
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
978
|
+
control={
|
|
979
|
+
<Radio
|
|
980
|
+
style={styles.inputRadio}
|
|
981
|
+
checked={!!schedule.period.weeks}
|
|
982
|
+
onClick={() => {
|
|
983
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
984
|
+
_schedule.period.weeks = schedule.period.weeks ? 0 : 1;
|
|
985
|
+
_schedule.period.dows = schedule.period.dows || '[0]';
|
|
986
|
+
_schedule.period.months = '';
|
|
987
|
+
_schedule.period.dates = '';
|
|
988
|
+
_schedule.period.years = 0;
|
|
989
|
+
_schedule.period.yearDate = 0;
|
|
990
|
+
_schedule.period.yearMonth = 0;
|
|
991
|
+
_schedule.period.days = 0;
|
|
992
|
+
_schedule.period.once = '';
|
|
993
|
+
this.onChange(_schedule);
|
|
994
|
+
}}
|
|
995
|
+
/>
|
|
996
|
+
}
|
|
913
997
|
label={I18n.t('sch_periodWeekly')}
|
|
914
998
|
/>
|
|
915
999
|
</div>
|
|
916
|
-
<Box
|
|
1000
|
+
<Box
|
|
1001
|
+
component="div"
|
|
1002
|
+
style={styles.settingsDiv}
|
|
1003
|
+
>
|
|
917
1004
|
<div style={styles.settingsDiv}>{this.getPeriodSettingsWeekly()}</div>
|
|
918
|
-
<Box
|
|
1005
|
+
<Box
|
|
1006
|
+
component="div"
|
|
1007
|
+
sx={Utils.getStyle(this.props.theme, styles.settingsDiv, styles.rowDowsDows)}
|
|
1008
|
+
>
|
|
919
1009
|
{this.state.schedule.period.weeks ? this.getPeriodSettingsWeekdays() : null}
|
|
920
1010
|
</Box>
|
|
921
1011
|
</Box>
|
|
922
1012
|
</Box>,
|
|
923
1013
|
|
|
924
1014
|
// ----- months ---
|
|
925
|
-
<Box
|
|
1015
|
+
<Box
|
|
1016
|
+
component="div"
|
|
1017
|
+
key="months"
|
|
1018
|
+
sx={Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowMonths)}
|
|
1019
|
+
>
|
|
926
1020
|
<div style={styles.modeDiv}>
|
|
927
1021
|
<FormControlLabel
|
|
928
|
-
control={
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
1022
|
+
control={
|
|
1023
|
+
<Radio
|
|
1024
|
+
style={styles.inputRadio}
|
|
1025
|
+
checked={!!schedule.period.months}
|
|
1026
|
+
onClick={() => {
|
|
1027
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1028
|
+
_schedule.period.months = 1;
|
|
1029
|
+
_schedule.period.dows = '';
|
|
1030
|
+
_schedule.period.dates = '';
|
|
1031
|
+
_schedule.period.years = 0;
|
|
1032
|
+
_schedule.period.yearDate = 0;
|
|
1033
|
+
_schedule.period.yearMonth = 0;
|
|
1034
|
+
_schedule.period.weeks = 0;
|
|
1035
|
+
_schedule.period.days = 0;
|
|
1036
|
+
_schedule.period.once = '';
|
|
1037
|
+
this.onChange(_schedule);
|
|
1038
|
+
}}
|
|
1039
|
+
/>
|
|
1040
|
+
}
|
|
945
1041
|
label={I18n.t('sch_periodMonthly')}
|
|
946
1042
|
/>
|
|
947
1043
|
</div>
|
|
948
1044
|
<div style={styles.settingsDiv}>
|
|
949
1045
|
{this.getPeriodSettingsMonthly()}
|
|
950
|
-
{schedule.period.months ?
|
|
951
|
-
<Box
|
|
952
|
-
<
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1046
|
+
{schedule.period.months ? (
|
|
1047
|
+
<Box>
|
|
1048
|
+
<Box
|
|
1049
|
+
component="div"
|
|
1050
|
+
sx={Utils.getStyle(this.props.theme, styles.settingsDiv, styles.rowMonthsDates)}
|
|
1051
|
+
>
|
|
1052
|
+
<FormControlLabel
|
|
1053
|
+
control={
|
|
1054
|
+
<Checkbox
|
|
1055
|
+
style={styles.inputRadio}
|
|
1056
|
+
checked={!!schedule.period.dates}
|
|
1057
|
+
onClick={() => {
|
|
1058
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1059
|
+
_schedule.period.months = _schedule.period.months || 1;
|
|
1060
|
+
const dates = [];
|
|
1061
|
+
for (let i = 1; i <= 31; i++) {
|
|
1062
|
+
dates.push(i);
|
|
1063
|
+
}
|
|
1064
|
+
_schedule.period.dates =
|
|
1065
|
+
_schedule.period.dates || JSON.stringify(dates);
|
|
1066
|
+
_schedule.period.dows = '';
|
|
1067
|
+
_schedule.period.years = 0;
|
|
1068
|
+
_schedule.period.yearDate = 0;
|
|
1069
|
+
_schedule.period.yearMonth = 0;
|
|
1070
|
+
_schedule.period.weeks = 0;
|
|
1071
|
+
_schedule.period.days = 0;
|
|
1072
|
+
_schedule.period.once = '';
|
|
1073
|
+
|
|
1074
|
+
this.onChange(_schedule);
|
|
1075
|
+
}}
|
|
1076
|
+
/>
|
|
1077
|
+
}
|
|
1078
|
+
label={I18n.t('sch_periodDates')}
|
|
1079
|
+
/>
|
|
1080
|
+
</Box>
|
|
1081
|
+
<Box
|
|
1082
|
+
component="div"
|
|
1083
|
+
sx={Utils.getStyle(this.props.theme, styles.settingsDiv, styles.rowMonthsDates)}
|
|
1084
|
+
>
|
|
1085
|
+
{this.getPeriodSettingsDates()}
|
|
1086
|
+
</Box>
|
|
980
1087
|
</Box>
|
|
981
|
-
|
|
1088
|
+
) : null}
|
|
982
1089
|
</div>
|
|
983
1090
|
</Box>,
|
|
984
1091
|
|
|
985
1092
|
// ----- years ---
|
|
986
|
-
<Box
|
|
1093
|
+
<Box
|
|
1094
|
+
component="div"
|
|
1095
|
+
key="years"
|
|
1096
|
+
sx={Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowYears)}
|
|
1097
|
+
>
|
|
987
1098
|
<div style={styles.modeDiv}>
|
|
988
1099
|
<FormControlLabel
|
|
989
|
-
control={
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1100
|
+
control={
|
|
1101
|
+
<Radio
|
|
1102
|
+
style={styles.inputRadio}
|
|
1103
|
+
checked={!!schedule.period.years}
|
|
1104
|
+
onClick={() => {
|
|
1105
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1106
|
+
_schedule.period.years = 1;
|
|
1107
|
+
_schedule.period.yearDate = 1;
|
|
1108
|
+
_schedule.period.yearMonth = 1;
|
|
1109
|
+
_schedule.period.dows = '';
|
|
1110
|
+
_schedule.period.months = 0;
|
|
1111
|
+
_schedule.period.dates = '';
|
|
1112
|
+
_schedule.period.weeks = 0;
|
|
1113
|
+
_schedule.period.days = 0;
|
|
1114
|
+
_schedule.period.once = '';
|
|
1115
|
+
this.onChange(_schedule);
|
|
1116
|
+
}}
|
|
1117
|
+
/>
|
|
1118
|
+
}
|
|
1006
1119
|
label={I18n.t('sch_periodYearly')}
|
|
1007
1120
|
/>
|
|
1008
1121
|
</div>
|
|
1009
1122
|
<div style={styles.settingsDiv}>
|
|
1010
1123
|
<div style={styles.settingsDiv}>{this.getPeriodSettingsYearly()}</div>
|
|
1011
|
-
{!!schedule.period.years &&
|
|
1012
|
-
<
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1124
|
+
{!!schedule.period.years && (
|
|
1125
|
+
<div style={styles.settingsDiv}>
|
|
1126
|
+
<span>{I18n.t('sch_on')}</span>
|
|
1127
|
+
<Input
|
|
1128
|
+
key="input"
|
|
1129
|
+
value={this.state.schedule.period.yearDate}
|
|
1130
|
+
style={styles.inputEvery}
|
|
1131
|
+
type="number"
|
|
1132
|
+
inputProps={{ min: 1, max: 31 }}
|
|
1133
|
+
onChange={e => {
|
|
1134
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1135
|
+
_schedule.period.yearDate = parseInt(e.target.value, 10);
|
|
1136
|
+
if (_schedule.period.yearDate < 1) {
|
|
1137
|
+
_schedule.period.yearDate = 31;
|
|
1138
|
+
}
|
|
1139
|
+
if (_schedule.period.yearDate > 31) {
|
|
1140
|
+
_schedule.period.yearDate = 1;
|
|
1141
|
+
}
|
|
1142
|
+
this.onChange(_schedule);
|
|
1143
|
+
}}
|
|
1144
|
+
/>
|
|
1145
|
+
<Select
|
|
1146
|
+
variant="standard"
|
|
1147
|
+
value={schedule.period.yearMonth}
|
|
1148
|
+
onChange={e => {
|
|
1149
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1150
|
+
_schedule.period.yearMonth = e.target.value;
|
|
1151
|
+
this.onChange(_schedule);
|
|
1152
|
+
}}
|
|
1153
|
+
>
|
|
1154
|
+
<MenuItem
|
|
1155
|
+
key="every"
|
|
1156
|
+
value={0}
|
|
1157
|
+
>
|
|
1158
|
+
{I18n.t('sch_yearEveryMonth')}
|
|
1159
|
+
</MenuItem>
|
|
1160
|
+
{MONTHS.map((month, i) => (
|
|
1161
|
+
<MenuItem
|
|
1162
|
+
key={month}
|
|
1163
|
+
value={i + 1}
|
|
1164
|
+
>
|
|
1165
|
+
{I18n.t(month)}
|
|
1166
|
+
</MenuItem>
|
|
1167
|
+
))}
|
|
1168
|
+
</Select>
|
|
1169
|
+
</div>
|
|
1170
|
+
)}
|
|
1040
1171
|
</div>
|
|
1041
1172
|
</Box>,
|
|
1042
1173
|
];
|
|
1043
1174
|
}
|
|
1044
1175
|
|
|
1045
|
-
getPeriodSettingsMinutes() {
|
|
1046
|
-
return
|
|
1047
|
-
<
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1176
|
+
getPeriodSettingsMinutes(): JSX.Element {
|
|
1177
|
+
return (
|
|
1178
|
+
<div style={{ display: 'inline-block' }}>
|
|
1179
|
+
<label>{I18n.t('sch_every')}</label>
|
|
1180
|
+
<Input
|
|
1181
|
+
value={this.state.schedule.time.interval}
|
|
1182
|
+
style={{ ...styles.inputEvery, verticalAlign: 'bottom' }}
|
|
1183
|
+
type="number"
|
|
1184
|
+
inputProps={{ min: 1 }}
|
|
1185
|
+
onChange={e => {
|
|
1186
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1187
|
+
_schedule.time.interval = parseInt(e.target.value, 10);
|
|
1188
|
+
this.onChange(_schedule);
|
|
1189
|
+
}}
|
|
1190
|
+
/>
|
|
1191
|
+
<Select
|
|
1192
|
+
variant="standard"
|
|
1193
|
+
value={this.state.schedule.time.mode}
|
|
1194
|
+
onChange={e => {
|
|
1195
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1196
|
+
_schedule.time.mode = e.target.value;
|
|
1197
|
+
this.onChange(_schedule);
|
|
1198
|
+
}}
|
|
1199
|
+
>
|
|
1200
|
+
<MenuItem value={PERIODS.minutes}>{I18n.t('sch_periodMinutes')}</MenuItem>
|
|
1201
|
+
<MenuItem value={PERIODS.hours}>{I18n.t('sch_periodHours')}</MenuItem>
|
|
1202
|
+
</Select>
|
|
1203
|
+
</div>
|
|
1204
|
+
);
|
|
1072
1205
|
}
|
|
1073
1206
|
|
|
1074
|
-
getPeriodSettingsWeekdays() {
|
|
1207
|
+
getPeriodSettingsWeekdays(): JSX.Element[] {
|
|
1075
1208
|
// || this.state.schedule.period.dows === '[1, 2, 3, 4, 5]' || this.state.schedule.period.dows === '[0, 6]'
|
|
1076
1209
|
const schedule = this.state.schedule;
|
|
1077
|
-
const isSpecific =
|
|
1210
|
+
const isSpecific =
|
|
1211
|
+
schedule.period.dows && schedule.period.dows !== '[1, 2, 3, 4, 5]' && schedule.period.dows !== '[0, 6]';
|
|
1078
1212
|
return [
|
|
1079
1213
|
<div key="workdays">
|
|
1080
1214
|
<FormControlLabel
|
|
1081
|
-
control={
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
_schedule.period.days
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1215
|
+
control={
|
|
1216
|
+
<Radio
|
|
1217
|
+
style={styles.inputRadio}
|
|
1218
|
+
checked={schedule.period.dows === '[1, 2, 3, 4, 5]'}
|
|
1219
|
+
onClick={() => {
|
|
1220
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1221
|
+
_schedule.period.dows = '[1, 2, 3, 4, 5]';
|
|
1222
|
+
if (_schedule.period.days) {
|
|
1223
|
+
_schedule.period.days = 1;
|
|
1224
|
+
}
|
|
1225
|
+
this.onChange(_schedule);
|
|
1226
|
+
}}
|
|
1227
|
+
/>
|
|
1228
|
+
}
|
|
1093
1229
|
label={I18n.t('sch_periodWorkdays')}
|
|
1094
1230
|
/>
|
|
1095
1231
|
</div>,
|
|
1096
1232
|
|
|
1097
1233
|
<div key="weekend">
|
|
1098
1234
|
<FormControlLabel
|
|
1099
|
-
control={
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
_schedule.period.days
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1235
|
+
control={
|
|
1236
|
+
<Radio
|
|
1237
|
+
style={styles.inputRadio}
|
|
1238
|
+
checked={schedule.period.dows === '[0, 6]'}
|
|
1239
|
+
onClick={() => {
|
|
1240
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1241
|
+
_schedule.period.dows = '[0, 6]';
|
|
1242
|
+
if (_schedule.period.days) {
|
|
1243
|
+
_schedule.period.days = 1;
|
|
1244
|
+
}
|
|
1245
|
+
this.onChange(_schedule);
|
|
1246
|
+
}}
|
|
1247
|
+
/>
|
|
1248
|
+
}
|
|
1111
1249
|
label={I18n.t('sch_periodWeekend')}
|
|
1112
1250
|
/>
|
|
1113
1251
|
</div>,
|
|
@@ -1118,58 +1256,67 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
1118
1256
|
>
|
|
1119
1257
|
<FormControlLabel
|
|
1120
1258
|
style={{ verticalAlign: 'top' }}
|
|
1121
|
-
control={
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
_schedule.period.days
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1259
|
+
control={
|
|
1260
|
+
<Radio
|
|
1261
|
+
style={styles.inputRadio}
|
|
1262
|
+
checked={!!isSpecific}
|
|
1263
|
+
onClick={() => {
|
|
1264
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1265
|
+
_schedule.period.dows = '[0, 1, 2, 3, 4, 5, 6]';
|
|
1266
|
+
if (_schedule.period.days) {
|
|
1267
|
+
_schedule.period.days = 1;
|
|
1268
|
+
}
|
|
1269
|
+
this.onChange(_schedule);
|
|
1270
|
+
}}
|
|
1271
|
+
/>
|
|
1272
|
+
}
|
|
1133
1273
|
label={I18n.t('sch_periodWeekdays')}
|
|
1134
1274
|
/>
|
|
1135
|
-
{isSpecific && (schedule.period.days === 1 || schedule.period.weeks) &&
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1275
|
+
{isSpecific && (schedule.period.days === 1 || schedule.period.weeks) && (
|
|
1276
|
+
<FormGroup
|
|
1277
|
+
row
|
|
1278
|
+
style={{ ...styles.inputGroup, width: 150 }}
|
|
1279
|
+
>
|
|
1280
|
+
{[1, 2, 3, 4, 5, 6, 0].map(i => (
|
|
1281
|
+
<FormControlLabel
|
|
1282
|
+
key={`specific_${i}`}
|
|
1283
|
+
style={styles.inputGroupElement}
|
|
1284
|
+
control={
|
|
1285
|
+
<Checkbox
|
|
1286
|
+
style={styles.inputSmallCheck}
|
|
1287
|
+
checked={schedule.period.dows.includes(i.toString())}
|
|
1288
|
+
onChange={e => {
|
|
1289
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1290
|
+
let daysOfWeek: number[];
|
|
1291
|
+
try {
|
|
1292
|
+
daysOfWeek = JSON.parse(_schedule.period.dows);
|
|
1293
|
+
} catch {
|
|
1294
|
+
daysOfWeek = [];
|
|
1295
|
+
}
|
|
1296
|
+
if (e.target.checked && !daysOfWeek.includes(i)) {
|
|
1297
|
+
daysOfWeek.push(i);
|
|
1298
|
+
} else if (!e.target.checked && daysOfWeek.includes(i)) {
|
|
1299
|
+
daysOfWeek.splice(daysOfWeek.indexOf(i), 1);
|
|
1300
|
+
}
|
|
1301
|
+
daysOfWeek.sort((a: number, b: number) => a - b);
|
|
1302
|
+
_schedule.period.dows = JSON.stringify(daysOfWeek);
|
|
1303
|
+
if (_schedule.period.days) {
|
|
1304
|
+
_schedule.period.days = 1;
|
|
1305
|
+
}
|
|
1306
|
+
this.onChange(_schedule);
|
|
1307
|
+
}}
|
|
1308
|
+
/>
|
|
1309
|
+
}
|
|
1310
|
+
label={I18n.t(WEEKDAYS[i])}
|
|
1311
|
+
/>
|
|
1312
|
+
))}
|
|
1313
|
+
</FormGroup>
|
|
1314
|
+
)}
|
|
1168
1315
|
</div>,
|
|
1169
1316
|
];
|
|
1170
1317
|
}
|
|
1171
1318
|
|
|
1172
|
-
getPeriodSettingsDaily() {
|
|
1319
|
+
getPeriodSettingsDaily(): JSX.Element[] | null {
|
|
1173
1320
|
if (!this.state.schedule.period.days) {
|
|
1174
1321
|
return null;
|
|
1175
1322
|
}
|
|
@@ -1177,31 +1324,35 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
1177
1324
|
return [
|
|
1178
1325
|
<div key="every_day">
|
|
1179
1326
|
<FormControlLabel
|
|
1180
|
-
control={
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1327
|
+
control={
|
|
1328
|
+
<Radio
|
|
1329
|
+
style={styles.inputRadio}
|
|
1330
|
+
checked={schedule.period.days === 1 && !schedule.period.dows}
|
|
1331
|
+
onClick={() => {
|
|
1332
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1333
|
+
_schedule.period.days = 1;
|
|
1334
|
+
_schedule.period.dows = '';
|
|
1335
|
+
this.onChange(_schedule);
|
|
1336
|
+
}}
|
|
1337
|
+
/>
|
|
1338
|
+
}
|
|
1190
1339
|
label={I18n.t('sch_periodEveryDay')}
|
|
1191
1340
|
/>
|
|
1192
1341
|
</div>,
|
|
1193
1342
|
<div key="everyN_day">
|
|
1194
1343
|
<FormControlLabel
|
|
1195
|
-
control={
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1344
|
+
control={
|
|
1345
|
+
<Radio
|
|
1346
|
+
style={styles.inputRadio}
|
|
1347
|
+
checked={schedule.period.days > 1}
|
|
1348
|
+
onClick={() => {
|
|
1349
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1350
|
+
_schedule.period.days = 2;
|
|
1351
|
+
_schedule.period.dows = '';
|
|
1352
|
+
this.onChange(_schedule);
|
|
1353
|
+
}}
|
|
1354
|
+
/>
|
|
1355
|
+
}
|
|
1205
1356
|
label={I18n.t('sch_periodEvery')}
|
|
1206
1357
|
/>
|
|
1207
1358
|
{schedule.period.days > 1 && [
|
|
@@ -1218,44 +1369,56 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
1218
1369
|
this.onChange(_schedule);
|
|
1219
1370
|
}}
|
|
1220
1371
|
/>,
|
|
1221
|
-
<span
|
|
1372
|
+
<span
|
|
1373
|
+
key="span"
|
|
1374
|
+
style={{ paddingRight: 10 }}
|
|
1375
|
+
>
|
|
1376
|
+
{I18n.t('sch_periodDay')}
|
|
1377
|
+
</span>,
|
|
1222
1378
|
]}
|
|
1223
1379
|
</div>,
|
|
1224
1380
|
];
|
|
1225
1381
|
}
|
|
1226
1382
|
|
|
1227
|
-
getPeriodSettingsWeekly() {
|
|
1383
|
+
getPeriodSettingsWeekly(): JSX.Element[] | null {
|
|
1228
1384
|
if (!this.state.schedule.period.weeks) {
|
|
1229
1385
|
return null;
|
|
1230
1386
|
}
|
|
1231
1387
|
const schedule = this.state.schedule;
|
|
1232
1388
|
return [
|
|
1233
|
-
<div
|
|
1389
|
+
<div
|
|
1390
|
+
key="radios"
|
|
1391
|
+
style={{ display: 'inline-block', verticalAlign: 'top' }}
|
|
1392
|
+
>
|
|
1234
1393
|
<div>
|
|
1235
1394
|
<FormControlLabel
|
|
1236
|
-
control={
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1395
|
+
control={
|
|
1396
|
+
<Radio
|
|
1397
|
+
style={styles.inputRadio}
|
|
1398
|
+
checked={schedule.period.weeks === 1}
|
|
1399
|
+
onClick={() => {
|
|
1400
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1401
|
+
_schedule.period.weeks = 1;
|
|
1402
|
+
this.onChange(_schedule);
|
|
1403
|
+
}}
|
|
1404
|
+
/>
|
|
1405
|
+
}
|
|
1245
1406
|
label={I18n.t('sch_periodEveryWeek')}
|
|
1246
1407
|
/>
|
|
1247
1408
|
</div>
|
|
1248
1409
|
<div>
|
|
1249
1410
|
<FormControlLabel
|
|
1250
|
-
control={
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1411
|
+
control={
|
|
1412
|
+
<Radio
|
|
1413
|
+
style={styles.inputRadio}
|
|
1414
|
+
checked={schedule.period.weeks > 1}
|
|
1415
|
+
onClick={() => {
|
|
1416
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1417
|
+
_schedule.period.weeks = 2;
|
|
1418
|
+
this.onChange(_schedule);
|
|
1419
|
+
}}
|
|
1420
|
+
/>
|
|
1421
|
+
}
|
|
1259
1422
|
label={I18n.t('sch_periodEvery')}
|
|
1260
1423
|
/>
|
|
1261
1424
|
{schedule.period.weeks > 1 && [
|
|
@@ -1278,7 +1441,7 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
1278
1441
|
];
|
|
1279
1442
|
}
|
|
1280
1443
|
|
|
1281
|
-
getPeriodSettingsDates() {
|
|
1444
|
+
getPeriodSettingsDates(): JSX.Element | null {
|
|
1282
1445
|
if (!this.state.schedule.period.dates) {
|
|
1283
1446
|
return null;
|
|
1284
1447
|
}
|
|
@@ -1291,103 +1454,128 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
1291
1454
|
|
|
1292
1455
|
const parsedDates = JSON.parse(schedule.period.dates);
|
|
1293
1456
|
|
|
1294
|
-
return
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1457
|
+
return (
|
|
1458
|
+
<FormGroup
|
|
1459
|
+
row
|
|
1460
|
+
style={{ ...styles.inputGroup, maxWidth: 620 }}
|
|
1461
|
+
>
|
|
1462
|
+
<FormControlLabel
|
|
1463
|
+
style={styles.inputDateDay}
|
|
1464
|
+
control={
|
|
1465
|
+
<Checkbox
|
|
1466
|
+
style={styles.inputDateDayCheck}
|
|
1467
|
+
checked={parsedDates.length === 31}
|
|
1468
|
+
onChange={() => {
|
|
1469
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1470
|
+
const _dates = [];
|
|
1471
|
+
for (let i = 1; i <= 31; i++) {
|
|
1472
|
+
_dates.push(i);
|
|
1473
|
+
}
|
|
1474
|
+
_schedule.period.dates = JSON.stringify(_dates);
|
|
1475
|
+
this.onChange(_schedule);
|
|
1476
|
+
}}
|
|
1477
|
+
/>
|
|
1478
|
+
}
|
|
1479
|
+
label={I18n.t('sch_all')}
|
|
1480
|
+
/>
|
|
1481
|
+
<FormControlLabel
|
|
1482
|
+
style={styles.inputDateDay}
|
|
1483
|
+
control={
|
|
1484
|
+
<Checkbox
|
|
1485
|
+
style={styles.inputDateDayCheck}
|
|
1486
|
+
checked={!parsedDates.length}
|
|
1487
|
+
onChange={() => {
|
|
1488
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1489
|
+
_schedule.period.dates = '[]';
|
|
1490
|
+
this.onChange(_schedule);
|
|
1491
|
+
}}
|
|
1492
|
+
/>
|
|
1493
|
+
}
|
|
1494
|
+
label={I18n.t('sch_no_one')}
|
|
1495
|
+
/>
|
|
1496
|
+
{parsedDates.length !== 31 && !!parsedDates.length && (
|
|
1497
|
+
<FormControlLabel
|
|
1498
|
+
style={styles.inputDateDay}
|
|
1499
|
+
control={
|
|
1500
|
+
<Checkbox
|
|
1501
|
+
style={styles.inputDateDayCheck}
|
|
1502
|
+
checked={false}
|
|
1503
|
+
onChange={() => {
|
|
1504
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1505
|
+
const result = [];
|
|
1506
|
+
const _parsedDates = JSON.parse(_schedule.period.dates);
|
|
1507
|
+
for (let i = 1; i <= 31; i++) {
|
|
1508
|
+
if (!_parsedDates.includes(i)) {
|
|
1509
|
+
result.push(i);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
result.sort((a, b) => a - b);
|
|
1513
|
+
_schedule.period.dates = JSON.stringify(result);
|
|
1514
|
+
this.onChange(_schedule);
|
|
1515
|
+
}}
|
|
1516
|
+
/>
|
|
1308
1517
|
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
/>
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
label={I18n.t('sch_no_one')}
|
|
1327
|
-
/>
|
|
1328
|
-
{parsedDates.length !== 31 && !!parsedDates.length &&
|
|
1329
|
-
<FormControlLabel
|
|
1330
|
-
style={styles.inputDateDay}
|
|
1331
|
-
control={<Checkbox
|
|
1332
|
-
style={styles.inputDateDayCheck}
|
|
1333
|
-
checked={false}
|
|
1334
|
-
onChange={() => {
|
|
1335
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1336
|
-
const result = [];
|
|
1337
|
-
const _parsedDates = JSON.parse(_schedule.period.dates);
|
|
1338
|
-
for (let i = 1; i <= 31; i++) {
|
|
1339
|
-
if (!_parsedDates.includes(i)) {
|
|
1340
|
-
result.push(i);
|
|
1341
|
-
}
|
|
1518
|
+
label={I18n.t('sch_invert')}
|
|
1519
|
+
/>
|
|
1520
|
+
)}
|
|
1521
|
+
<div />
|
|
1522
|
+
{dates.map(i => (
|
|
1523
|
+
<FormControlLabel
|
|
1524
|
+
key={`date_${i}`}
|
|
1525
|
+
style={
|
|
1526
|
+
!i
|
|
1527
|
+
? {
|
|
1528
|
+
...styles.inputDateDay,
|
|
1529
|
+
opacity: 0,
|
|
1530
|
+
cursor: 'default',
|
|
1531
|
+
userSelect: 'none',
|
|
1532
|
+
pointerEvents: 'none',
|
|
1533
|
+
}
|
|
1534
|
+
: styles.inputDateDay
|
|
1342
1535
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
<span key="0" style={{ opacity: 0 }}>0</span>,
|
|
1384
|
-
<span key="num">{i}</span>,
|
|
1385
|
-
] : i}
|
|
1386
|
-
/>)}
|
|
1387
|
-
</FormGroup>;
|
|
1536
|
+
control={
|
|
1537
|
+
<Checkbox
|
|
1538
|
+
style={styles.inputDateDayCheck}
|
|
1539
|
+
checked={JSON.parse(schedule.period.dates).includes(i)}
|
|
1540
|
+
onChange={e => {
|
|
1541
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1542
|
+
let _dates;
|
|
1543
|
+
try {
|
|
1544
|
+
_dates = JSON.parse(_schedule.period.dates);
|
|
1545
|
+
} catch {
|
|
1546
|
+
_dates = [];
|
|
1547
|
+
}
|
|
1548
|
+
if (e.target.checked && !_dates.includes(i)) {
|
|
1549
|
+
_dates.push(i);
|
|
1550
|
+
} else if (!e.target.checked && _dates.includes(i)) {
|
|
1551
|
+
_dates.splice(_dates.indexOf(i), 1);
|
|
1552
|
+
}
|
|
1553
|
+
_dates.sort((a: number, b: number) => a - b);
|
|
1554
|
+
_schedule.period.dates = JSON.stringify(_dates);
|
|
1555
|
+
this.onChange(_schedule);
|
|
1556
|
+
}}
|
|
1557
|
+
/>
|
|
1558
|
+
}
|
|
1559
|
+
label={
|
|
1560
|
+
i < 10
|
|
1561
|
+
? [
|
|
1562
|
+
<span
|
|
1563
|
+
key="0"
|
|
1564
|
+
style={{ opacity: 0 }}
|
|
1565
|
+
>
|
|
1566
|
+
0
|
|
1567
|
+
</span>,
|
|
1568
|
+
<span key="num">{i}</span>,
|
|
1569
|
+
]
|
|
1570
|
+
: i
|
|
1571
|
+
}
|
|
1572
|
+
/>
|
|
1573
|
+
))}
|
|
1574
|
+
</FormGroup>
|
|
1575
|
+
);
|
|
1388
1576
|
}
|
|
1389
1577
|
|
|
1390
|
-
getPeriodSettingsMonthly() {
|
|
1578
|
+
getPeriodSettingsMonthly(): JSX.Element[] | null {
|
|
1391
1579
|
if (!this.state.schedule.period.months) {
|
|
1392
1580
|
return null;
|
|
1393
1581
|
}
|
|
@@ -1397,152 +1585,180 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
1397
1585
|
return [
|
|
1398
1586
|
<div key="every">
|
|
1399
1587
|
<FormControlLabel
|
|
1400
|
-
control={
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1588
|
+
control={
|
|
1589
|
+
<Radio
|
|
1590
|
+
style={styles.inputRadio}
|
|
1591
|
+
checked={typeof schedule.period.months === 'number' && schedule.period.months === 1}
|
|
1592
|
+
onClick={() => {
|
|
1593
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1594
|
+
_schedule.period.months = 1;
|
|
1595
|
+
this.onChange(schedule);
|
|
1596
|
+
}}
|
|
1597
|
+
/>
|
|
1598
|
+
}
|
|
1409
1599
|
label={I18n.t('sch_periodEveryMonth')}
|
|
1410
1600
|
/>
|
|
1411
1601
|
</div>,
|
|
1412
1602
|
<div key="everyN">
|
|
1413
1603
|
<FormControlLabel
|
|
1414
|
-
control={
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1604
|
+
control={
|
|
1605
|
+
<Radio
|
|
1606
|
+
style={styles.inputRadio}
|
|
1607
|
+
checked={typeof schedule.period.months === 'number' && schedule.period.months > 1}
|
|
1608
|
+
onClick={() => {
|
|
1609
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1610
|
+
_schedule.period.months = 2;
|
|
1611
|
+
this.onChange(_schedule);
|
|
1612
|
+
}}
|
|
1613
|
+
/>
|
|
1614
|
+
}
|
|
1423
1615
|
label={I18n.t('sch_periodEvery')}
|
|
1424
1616
|
/>
|
|
1425
|
-
{typeof schedule.period.months === 'number' &&
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
_schedule.period.months = parseInt(e.target.value, 10);
|
|
1435
|
-
if (_schedule.period.months < 1) _schedule.period.months = 1;
|
|
1436
|
-
this.onChange(_schedule);
|
|
1437
|
-
}}
|
|
1438
|
-
/>,
|
|
1439
|
-
<span key="text">{I18n.t('sch_periodMonth')}</span>,
|
|
1440
|
-
]}
|
|
1441
|
-
</div>,
|
|
1442
|
-
<div key="specific" style={{ verticalAlign: 'top' }}>
|
|
1443
|
-
<FormControlLabel
|
|
1444
|
-
style={{ verticalAlign: 'top' }}
|
|
1445
|
-
control={<Radio
|
|
1446
|
-
style={styles.inputRadio}
|
|
1447
|
-
checked={typeof schedule.period.months === 'string'}
|
|
1448
|
-
onClick={() => {
|
|
1449
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1450
|
-
_schedule.period.months = '[1,2,3,4,5,6,7,8,9,10,11,12]';
|
|
1451
|
-
this.onChange(_schedule);
|
|
1452
|
-
}}
|
|
1453
|
-
/>}
|
|
1454
|
-
label={I18n.t('sch_periodSpecificMonths')}
|
|
1455
|
-
/>
|
|
1456
|
-
{typeof schedule.period.months === 'string' &&
|
|
1457
|
-
<FormGroup
|
|
1458
|
-
row
|
|
1459
|
-
style={styles.inputGroup}
|
|
1460
|
-
>
|
|
1461
|
-
<FormControlLabel
|
|
1462
|
-
style={styles.inputDateDay}
|
|
1463
|
-
control={<Checkbox
|
|
1464
|
-
style={styles.inputDateDayCheck}
|
|
1465
|
-
checked={parsedMonths.length === 12}
|
|
1466
|
-
onChange={() => {
|
|
1617
|
+
{typeof schedule.period.months === 'number' &&
|
|
1618
|
+
schedule.period.months > 1 && [
|
|
1619
|
+
<Input
|
|
1620
|
+
key="input"
|
|
1621
|
+
value={schedule.period.months}
|
|
1622
|
+
style={styles.inputEvery}
|
|
1623
|
+
type="number"
|
|
1624
|
+
inputProps={{ min: 2 }}
|
|
1625
|
+
onChange={e => {
|
|
1467
1626
|
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
months
|
|
1627
|
+
_schedule.period.months = parseInt(e.target.value, 10);
|
|
1628
|
+
if (_schedule.period.months < 1) {
|
|
1629
|
+
_schedule.period.months = 1;
|
|
1471
1630
|
}
|
|
1472
|
-
_schedule.period.months = JSON.stringify(months);
|
|
1473
1631
|
this.onChange(_schedule);
|
|
1474
1632
|
}}
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1633
|
+
/>,
|
|
1634
|
+
<span key="text">{I18n.t('sch_periodMonth')}</span>,
|
|
1635
|
+
]}
|
|
1636
|
+
</div>,
|
|
1637
|
+
<div
|
|
1638
|
+
key="specific"
|
|
1639
|
+
style={{ verticalAlign: 'top' }}
|
|
1640
|
+
>
|
|
1641
|
+
<FormControlLabel
|
|
1642
|
+
style={{ verticalAlign: 'top' }}
|
|
1643
|
+
control={
|
|
1644
|
+
<Radio
|
|
1645
|
+
style={styles.inputRadio}
|
|
1646
|
+
checked={typeof schedule.period.months === 'string'}
|
|
1647
|
+
onClick={() => {
|
|
1484
1648
|
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1485
|
-
_schedule.period.months = '[]';
|
|
1649
|
+
_schedule.period.months = '[1,2,3,4,5,6,7,8,9,10,11,12]';
|
|
1486
1650
|
this.onChange(_schedule);
|
|
1487
1651
|
}}
|
|
1488
|
-
/>
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1652
|
+
/>
|
|
1653
|
+
}
|
|
1654
|
+
label={I18n.t('sch_periodSpecificMonths')}
|
|
1655
|
+
/>
|
|
1656
|
+
{typeof schedule.period.months === 'string' && (
|
|
1657
|
+
<FormGroup
|
|
1658
|
+
row
|
|
1659
|
+
style={styles.inputGroup}
|
|
1660
|
+
>
|
|
1492
1661
|
<FormControlLabel
|
|
1493
1662
|
style={styles.inputDateDay}
|
|
1494
|
-
control={
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
result.push(i);
|
|
1663
|
+
control={
|
|
1664
|
+
<Checkbox
|
|
1665
|
+
style={styles.inputDateDayCheck}
|
|
1666
|
+
checked={parsedMonths.length === 12}
|
|
1667
|
+
onChange={() => {
|
|
1668
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1669
|
+
const months = [];
|
|
1670
|
+
for (let i = 1; i <= 12; i++) {
|
|
1671
|
+
months.push(i);
|
|
1504
1672
|
}
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
/>}
|
|
1513
|
-
<div />
|
|
1514
|
-
{MONTHS.map((month, i) =>
|
|
1673
|
+
_schedule.period.months = JSON.stringify(months);
|
|
1674
|
+
this.onChange(_schedule);
|
|
1675
|
+
}}
|
|
1676
|
+
/>
|
|
1677
|
+
}
|
|
1678
|
+
label={I18n.t('sch_all')}
|
|
1679
|
+
/>
|
|
1515
1680
|
<FormControlLabel
|
|
1516
|
-
style={styles.
|
|
1517
|
-
control={
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1681
|
+
style={styles.inputDateDay}
|
|
1682
|
+
control={
|
|
1683
|
+
<Checkbox
|
|
1684
|
+
style={styles.inputDateDayCheck}
|
|
1685
|
+
checked={!parsedMonths.length}
|
|
1686
|
+
onChange={() => {
|
|
1687
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1688
|
+
_schedule.period.months = '[]';
|
|
1689
|
+
this.onChange(_schedule);
|
|
1690
|
+
}}
|
|
1691
|
+
/>
|
|
1692
|
+
}
|
|
1693
|
+
label={I18n.t('sch_no_one')}
|
|
1694
|
+
/>
|
|
1695
|
+
{parsedMonths.length !== 12 && !!parsedMonths.length && (
|
|
1696
|
+
<FormControlLabel
|
|
1697
|
+
style={styles.inputDateDay}
|
|
1698
|
+
control={
|
|
1699
|
+
<Checkbox
|
|
1700
|
+
style={styles.inputDateDayCheck}
|
|
1701
|
+
checked={false}
|
|
1702
|
+
onChange={() => {
|
|
1703
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1704
|
+
const result = [];
|
|
1705
|
+
const _parsedMonths = JSON.parse(_schedule.period.months);
|
|
1706
|
+
for (let i = 1; i <= 12; i++) {
|
|
1707
|
+
if (!_parsedMonths.includes(i)) {
|
|
1708
|
+
result.push(i);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
result.sort((a, b) => a - b);
|
|
1712
|
+
_schedule.period.months = JSON.stringify(result);
|
|
1713
|
+
this.onChange(_schedule);
|
|
1714
|
+
}}
|
|
1715
|
+
/>
|
|
1716
|
+
}
|
|
1717
|
+
label={I18n.t('sch_invert')}
|
|
1718
|
+
/>
|
|
1719
|
+
)}
|
|
1720
|
+
<div />
|
|
1721
|
+
{MONTHS.map((month, i) => (
|
|
1722
|
+
<FormControlLabel
|
|
1723
|
+
key={`month_${i}`}
|
|
1724
|
+
style={styles.inputGroupElement}
|
|
1725
|
+
control={
|
|
1726
|
+
<Checkbox
|
|
1727
|
+
style={styles.inputSmallCheck}
|
|
1728
|
+
checked={
|
|
1729
|
+
typeof schedule.period.months === 'string'
|
|
1730
|
+
? JSON.parse(schedule.period.months).includes(i + 1)
|
|
1731
|
+
: schedule.period.months === i
|
|
1732
|
+
}
|
|
1733
|
+
onChange={e => {
|
|
1734
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1735
|
+
let months;
|
|
1736
|
+
try {
|
|
1737
|
+
months = JSON.parse(_schedule.period.months);
|
|
1738
|
+
} catch {
|
|
1739
|
+
months = [];
|
|
1740
|
+
}
|
|
1741
|
+
if (e.target.checked && !months.includes(i + 1)) {
|
|
1742
|
+
months.push(i + 1);
|
|
1743
|
+
} else if (!e.target.checked && months.includes(i + 1)) {
|
|
1744
|
+
months.splice(months.indexOf(i + 1), 1);
|
|
1745
|
+
}
|
|
1746
|
+
months.sort((a: number, b: number) => a - b);
|
|
1747
|
+
_schedule.period.months = JSON.stringify(months);
|
|
1748
|
+
this.onChange(_schedule);
|
|
1749
|
+
}}
|
|
1750
|
+
/>
|
|
1751
|
+
}
|
|
1752
|
+
label={I18n.t(month)}
|
|
1753
|
+
/>
|
|
1754
|
+
))}
|
|
1755
|
+
</FormGroup>
|
|
1756
|
+
)}
|
|
1541
1757
|
</div>,
|
|
1542
1758
|
];
|
|
1543
1759
|
}
|
|
1544
1760
|
|
|
1545
|
-
getPeriodSettingsYearly() {
|
|
1761
|
+
getPeriodSettingsYearly(): JSX.Element[] | null {
|
|
1546
1762
|
if (!this.state.schedule.period.years) {
|
|
1547
1763
|
return null;
|
|
1548
1764
|
}
|
|
@@ -1550,29 +1766,33 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
1550
1766
|
return [
|
|
1551
1767
|
<div key="year">
|
|
1552
1768
|
<FormControlLabel
|
|
1553
|
-
control={
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1769
|
+
control={
|
|
1770
|
+
<Radio
|
|
1771
|
+
style={styles.inputRadio}
|
|
1772
|
+
checked={schedule.period.years === 1}
|
|
1773
|
+
onClick={() => {
|
|
1774
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1775
|
+
_schedule.period.years = 1;
|
|
1776
|
+
this.onChange(_schedule);
|
|
1777
|
+
}}
|
|
1778
|
+
/>
|
|
1779
|
+
}
|
|
1562
1780
|
label={I18n.t('sch_periodEveryYear')}
|
|
1563
1781
|
/>
|
|
1564
1782
|
</div>,
|
|
1565
1783
|
<div key="every">
|
|
1566
1784
|
<FormControlLabel
|
|
1567
|
-
control={
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1785
|
+
control={
|
|
1786
|
+
<Radio
|
|
1787
|
+
style={styles.inputRadio}
|
|
1788
|
+
checked={schedule.period.years > 1}
|
|
1789
|
+
onClick={() => {
|
|
1790
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1791
|
+
_schedule.period.years = 2;
|
|
1792
|
+
this.onChange(_schedule);
|
|
1793
|
+
}}
|
|
1794
|
+
/>
|
|
1795
|
+
}
|
|
1576
1796
|
label={I18n.t('sch_periodEvery')}
|
|
1577
1797
|
/>
|
|
1578
1798
|
{schedule.period.years > 1 && [
|
|
@@ -1585,7 +1805,9 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
1585
1805
|
onChange={e => {
|
|
1586
1806
|
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1587
1807
|
_schedule.period.years = parseInt(e.target.value, 10);
|
|
1588
|
-
if (_schedule.period.years < 1)
|
|
1808
|
+
if (_schedule.period.years < 1) {
|
|
1809
|
+
_schedule.period.years = 1;
|
|
1810
|
+
}
|
|
1589
1811
|
this.onChange(_schedule);
|
|
1590
1812
|
}}
|
|
1591
1813
|
/>,
|
|
@@ -1618,106 +1840,122 @@ class Schedule extends Component<ScheduleProps, ScheduleState> {
|
|
|
1618
1840
|
return new Date(parseInt(parts[2], 10), parseInt(parts[1], 10) - 1, parseInt(parts[0], 10));
|
|
1619
1841
|
}
|
|
1620
1842
|
|
|
1621
|
-
getValidSettings() {
|
|
1843
|
+
getValidSettings(): JSX.Element {
|
|
1622
1844
|
const schedule = this.state.schedule;
|
|
1623
1845
|
// ----- from ---
|
|
1624
|
-
return
|
|
1625
|
-
<div style={
|
|
1626
|
-
<
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
<
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
if (this.refFrom.current) {
|
|
1642
|
-
this.refFrom.current.style.background = '#ff000030';
|
|
1643
|
-
}
|
|
1846
|
+
return (
|
|
1847
|
+
<div style={styles.rowDiv}>
|
|
1848
|
+
<div style={{ ...styles.modeDiv, verticalAlign: 'middle' }}>
|
|
1849
|
+
<span style={{ fontWeight: 'bold', paddingRight: 10 }}>{I18n.t('sch_valid')}</span>
|
|
1850
|
+
<span>{I18n.t('sch_validFrom')}</span>
|
|
1851
|
+
</div>
|
|
1852
|
+
<div style={styles.settingsDiv}>
|
|
1853
|
+
<TextField
|
|
1854
|
+
variant="standard"
|
|
1855
|
+
style={{ ...styles.inputDate, marginRight: 10 }}
|
|
1856
|
+
key="exactTimeFrom"
|
|
1857
|
+
inputRef={this.refFrom}
|
|
1858
|
+
defaultValue={string2USdate(schedule.valid.from)}
|
|
1859
|
+
type="date"
|
|
1860
|
+
// inputComponent={TextDate}
|
|
1861
|
+
onChange={e => {
|
|
1862
|
+
this.timerFrom && clearTimeout(this.timerFrom);
|
|
1644
1863
|
|
|
1645
|
-
this.timerFrom = setTimeout(value => {
|
|
1646
|
-
this.timerFrom = null;
|
|
1647
1864
|
if (this.refFrom.current) {
|
|
1648
|
-
this.refFrom.current.style.background = '';
|
|
1649
|
-
}
|
|
1650
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1651
|
-
const date = Schedule.string2date(value);
|
|
1652
|
-
if (date.toString() !== 'Invalid Date') {
|
|
1653
|
-
_schedule.valid.from = `${padding(date.getDate())}.${padding(date.getMonth() + 1)}.${date.getFullYear()}`;
|
|
1654
|
-
this.onChange(_schedule);
|
|
1865
|
+
this.refFrom.current.style.background = '#ff000030';
|
|
1655
1866
|
}
|
|
1656
|
-
}, 1500, e.target.value);
|
|
1657
|
-
}}
|
|
1658
|
-
InputLabelProps={{ shrink: true }}
|
|
1659
|
-
margin="normal"
|
|
1660
|
-
/>
|
|
1661
|
-
<FormControlLabel
|
|
1662
|
-
control={<Checkbox
|
|
1663
|
-
style={styles.inputRadio}
|
|
1664
|
-
checked={!!schedule.valid.to}
|
|
1665
|
-
onClick={() => {
|
|
1666
|
-
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1667
|
-
_schedule.valid.to = _schedule.valid.to ? '' : Schedule.now2string(true);
|
|
1668
|
-
this.onChange(_schedule);
|
|
1669
|
-
}}
|
|
1670
|
-
/>}
|
|
1671
|
-
label={I18n.t('sch_validTo')}
|
|
1672
|
-
/>
|
|
1673
|
-
{!!schedule.valid.to && <TextField
|
|
1674
|
-
variant="standard"
|
|
1675
|
-
inputRef={this.refTo}
|
|
1676
|
-
style={{ ...styles.inputDate, marginRight: 10 }}
|
|
1677
|
-
key="exactTimeFrom"
|
|
1678
|
-
type="date"
|
|
1679
|
-
defaultValue={string2USdate(schedule.valid.to)}
|
|
1680
|
-
// inputComponent={TextDate}
|
|
1681
|
-
onChange={e => {
|
|
1682
|
-
this.timerTo && clearTimeout(this.timerTo);
|
|
1683
1867
|
|
|
1684
|
-
|
|
1685
|
-
|
|
1868
|
+
this.timerFrom = setTimeout(
|
|
1869
|
+
value => {
|
|
1870
|
+
this.timerFrom = null;
|
|
1871
|
+
if (this.refFrom.current) {
|
|
1872
|
+
this.refFrom.current.style.background = '';
|
|
1873
|
+
}
|
|
1874
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1875
|
+
const date = Schedule.string2date(value);
|
|
1876
|
+
if (date.toString() !== 'Invalid Date') {
|
|
1877
|
+
_schedule.valid.from = `${padding(date.getDate())}.${padding(date.getMonth() + 1)}.${date.getFullYear()}`;
|
|
1878
|
+
this.onChange(_schedule);
|
|
1879
|
+
}
|
|
1880
|
+
},
|
|
1881
|
+
1500,
|
|
1882
|
+
e.target.value,
|
|
1883
|
+
);
|
|
1884
|
+
}}
|
|
1885
|
+
InputLabelProps={{ shrink: true }}
|
|
1886
|
+
margin="normal"
|
|
1887
|
+
/>
|
|
1888
|
+
<FormControlLabel
|
|
1889
|
+
control={
|
|
1890
|
+
<Checkbox
|
|
1891
|
+
style={styles.inputRadio}
|
|
1892
|
+
checked={!!schedule.valid.to}
|
|
1893
|
+
onClick={() => {
|
|
1894
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1895
|
+
_schedule.valid.to = _schedule.valid.to ? '' : Schedule.now2string(true);
|
|
1896
|
+
this.onChange(_schedule);
|
|
1897
|
+
}}
|
|
1898
|
+
/>
|
|
1686
1899
|
}
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1900
|
+
label={I18n.t('sch_validTo')}
|
|
1901
|
+
/>
|
|
1902
|
+
{!!schedule.valid.to && (
|
|
1903
|
+
<TextField
|
|
1904
|
+
variant="standard"
|
|
1905
|
+
inputRef={this.refTo}
|
|
1906
|
+
style={{ ...styles.inputDate, marginRight: 10 }}
|
|
1907
|
+
key="exactTimeFrom"
|
|
1908
|
+
type="date"
|
|
1909
|
+
defaultValue={string2USdate(schedule.valid.to)}
|
|
1910
|
+
// inputComponent={TextDate}
|
|
1911
|
+
onChange={e => {
|
|
1912
|
+
this.timerTo && clearTimeout(this.timerTo);
|
|
1913
|
+
|
|
1914
|
+
if (this.refTo.current) {
|
|
1915
|
+
this.refTo.current.style.background = '#ff000030';
|
|
1916
|
+
}
|
|
1917
|
+
this.timerTo = setTimeout(
|
|
1918
|
+
value => {
|
|
1919
|
+
this.timerTo = null;
|
|
1920
|
+
if (this.refTo.current) {
|
|
1921
|
+
this.refTo.current.style.background = '';
|
|
1922
|
+
}
|
|
1923
|
+
const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
|
|
1924
|
+
const date = Schedule.string2date(value);
|
|
1925
|
+
if (date.toString() !== 'Invalid Date') {
|
|
1926
|
+
_schedule.valid.to = `${padding(date.getDate())}.${padding(date.getMonth() + 1)}.${date.getFullYear()}`;
|
|
1927
|
+
this.onChange(_schedule);
|
|
1928
|
+
}
|
|
1929
|
+
},
|
|
1930
|
+
1500,
|
|
1931
|
+
e.target.value,
|
|
1932
|
+
);
|
|
1933
|
+
}}
|
|
1934
|
+
InputLabelProps={{ shrink: true }}
|
|
1935
|
+
margin="normal"
|
|
1936
|
+
/>
|
|
1937
|
+
)}
|
|
1938
|
+
</div>
|
|
1703
1939
|
</div>
|
|
1704
|
-
|
|
1940
|
+
);
|
|
1705
1941
|
}
|
|
1706
1942
|
|
|
1707
|
-
render() {
|
|
1708
|
-
return
|
|
1709
|
-
<div
|
|
1710
|
-
|
|
1711
|
-
<
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1943
|
+
render(): JSX.Element {
|
|
1944
|
+
return (
|
|
1945
|
+
<div style={{ height: 'calc(100% - 48px)', width: '100%', overflow: 'hidden' }}>
|
|
1946
|
+
<div>{this.state.desc}</div>
|
|
1947
|
+
<div style={styles.scrollWindow}>
|
|
1948
|
+
<h5>{I18n.t('sch_time')}</h5>
|
|
1949
|
+
{this.getTimePeriodElements()}
|
|
1950
|
+
{this.getTimeExactElements()}
|
|
1951
|
+
{Schedule.getDivider()}
|
|
1952
|
+
<h5>{I18n.t('sch_period')}</h5>
|
|
1953
|
+
{this.getPeriodModes()}
|
|
1954
|
+
{!this.state.schedule.period.once && Schedule.getDivider()}
|
|
1955
|
+
{!this.state.schedule.period.once && this.getValidSettings()}
|
|
1956
|
+
</div>
|
|
1719
1957
|
</div>
|
|
1720
|
-
|
|
1958
|
+
);
|
|
1721
1959
|
}
|
|
1722
1960
|
}
|
|
1723
1961
|
|