@iobroker/adapter-react-v5 7.0.2 → 7.1.1

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.
Files changed (307) hide show
  1. package/Components/404.d.ts +3 -2
  2. package/Components/404.js +3 -2
  3. package/Components/ColorPicker.d.ts +22 -8
  4. package/Components/ColorPicker.js +34 -17
  5. package/Components/ComplexCron.js +24 -24
  6. package/Components/CopyToClipboard.d.ts +10 -1
  7. package/Components/CopyToClipboard.js +17 -8
  8. package/Components/CustomModal.d.ts +1 -1
  9. package/Components/CustomModal.js +8 -8
  10. package/Components/FileBrowser.d.ts +11 -11
  11. package/Components/FileBrowser.js +135 -152
  12. package/Components/FileViewer.js +34 -23
  13. package/Components/Icon.d.ts +16 -2
  14. package/Components/Icon.js +19 -8
  15. package/Components/IconPicker.js +10 -14
  16. package/Components/IconSelector.d.ts +1 -1
  17. package/Components/IconSelector.js +64 -74
  18. package/Components/Image.d.ts +8 -4
  19. package/Components/Image.js +13 -32
  20. package/Components/Loader.d.ts +2 -2
  21. package/Components/Loader.js +21 -18
  22. package/Components/Loaders/MV.d.ts +6 -1
  23. package/Components/Loaders/MV.js +23 -7
  24. package/Components/Loaders/PT.d.ts +7 -2
  25. package/Components/Loaders/PT.js +20 -7
  26. package/Components/Loaders/Vendor.d.ts +2 -2
  27. package/Components/Loaders/Vendor.js +15 -7
  28. package/Components/Logo.js +16 -18
  29. package/Components/MDUtils.d.ts +1 -1
  30. package/Components/MDUtils.js +8 -4
  31. package/Components/ObjectBrowser.d.ts +40 -39
  32. package/Components/ObjectBrowser.js +550 -435
  33. package/Components/Router.d.ts +1 -3
  34. package/Components/Router.js +3 -1
  35. package/Components/SaveCloseButtons.d.ts +3 -3
  36. package/Components/SaveCloseButtons.js +3 -3
  37. package/Components/Schedule.d.ts +15 -15
  38. package/Components/Schedule.js +177 -154
  39. package/Components/SelectWithIcon.d.ts +2 -2
  40. package/Components/SelectWithIcon.js +45 -34
  41. package/Components/SimpleCron/index.js +83 -43
  42. package/Components/TabContainer.js +2 -2
  43. package/Components/TabContent.js +1 -1
  44. package/Components/TabHeader.js +1 -1
  45. package/Components/TableResize.d.ts +2 -2
  46. package/Components/TableResize.js +5 -5
  47. package/Components/TextWithIcon.d.ts +1 -1
  48. package/Components/TextWithIcon.js +10 -8
  49. package/Components/ToggleThemeMenu.d.ts +2 -2
  50. package/Components/ToggleThemeMenu.js +3 -3
  51. package/Components/TreeTable.d.ts +18 -18
  52. package/Components/TreeTable.js +76 -72
  53. package/Components/UploadImage.d.ts +2 -2
  54. package/Components/UploadImage.js +25 -21
  55. package/Components/Utils.d.ts +42 -22
  56. package/Components/Utils.js +66 -65
  57. package/Components/withWidth.d.ts +2 -2
  58. package/Components/withWidth.js +10 -6
  59. package/Dialogs/ComplexCron.d.ts +2 -2
  60. package/Dialogs/ComplexCron.js +3 -3
  61. package/Dialogs/Confirm.d.ts +4 -4
  62. package/Dialogs/Confirm.js +18 -8
  63. package/Dialogs/Cron.d.ts +3 -3
  64. package/Dialogs/Cron.js +21 -17
  65. package/Dialogs/Error.d.ts +3 -3
  66. package/Dialogs/Error.js +6 -4
  67. package/Dialogs/Message.d.ts +3 -3
  68. package/Dialogs/Message.js +6 -4
  69. package/Dialogs/SelectFile.d.ts +4 -4
  70. package/Dialogs/SelectFile.js +6 -4
  71. package/Dialogs/SelectID.d.ts +12 -10
  72. package/Dialogs/SelectID.js +12 -8
  73. package/Dialogs/SimpleCron.d.ts +2 -2
  74. package/Dialogs/SimpleCron.js +2 -2
  75. package/Dialogs/TextInput.d.ts +2 -2
  76. package/Dialogs/TextInput.js +3 -3
  77. package/GenericApp.d.ts +19 -13
  78. package/GenericApp.js +128 -85
  79. package/LegacyConnection.d.ts +240 -248
  80. package/LegacyConnection.js +500 -525
  81. package/README.md +1264 -1171
  82. package/Theme.d.ts +1 -1
  83. package/Theme.js +9 -12
  84. package/assets/devices.json +1 -0
  85. package/assets/rooms.json +1 -0
  86. package/craco-module-federation.js +3 -12
  87. package/i18n/de.json +434 -434
  88. package/i18n/en.json +434 -434
  89. package/i18n/es.json +434 -434
  90. package/i18n/fr.json +434 -434
  91. package/i18n/it.json +434 -434
  92. package/i18n/nl.json +434 -434
  93. package/i18n/pl.json +434 -434
  94. package/i18n/pt.json +434 -434
  95. package/i18n/ru.json +434 -434
  96. package/i18n/uk.json +434 -434
  97. package/i18n/zh-cn.json +434 -434
  98. package/i18n.d.ts +26 -19
  99. package/i18n.js +28 -22
  100. package/icons/IconAdapter.js +2 -2
  101. package/icons/IconAlias.js +2 -2
  102. package/icons/IconChannel.js +2 -2
  103. package/icons/IconClearFilter.js +2 -2
  104. package/icons/IconClosed.js +2 -2
  105. package/icons/IconCopy.js +2 -2
  106. package/icons/IconDevice.js +2 -2
  107. package/icons/IconDocument.js +2 -2
  108. package/icons/IconDocumentReadOnly.js +2 -2
  109. package/icons/IconExpert.js +2 -2
  110. package/icons/IconFx.js +2 -2
  111. package/icons/IconInstance.js +2 -2
  112. package/icons/IconLogout.js +2 -2
  113. package/icons/IconNoIcon.js +2 -2
  114. package/icons/IconOpen.d.ts +2 -2
  115. package/icons/IconOpen.js +2 -2
  116. package/icons/IconProps.d.ts +4 -3
  117. package/icons/IconState.d.ts +2 -2
  118. package/icons/IconState.js +2 -2
  119. package/index.css +3 -2
  120. package/package.json +4 -4
  121. package/src/Components/404.tsx +32 -31
  122. package/src/Components/ColorPicker.tsx +142 -114
  123. package/src/Components/ComplexCron.tsx +174 -137
  124. package/src/Components/CopyToClipboard.tsx +22 -9
  125. package/src/Components/CustomModal.tsx +76 -69
  126. package/src/Components/FileBrowser.tsx +959 -852
  127. package/src/Components/FileViewer.tsx +146 -127
  128. package/src/Components/Icon.tsx +80 -52
  129. package/src/Components/IconPicker.tsx +83 -67
  130. package/src/Components/IconSelector.tsx +159 -141
  131. package/src/Components/Image.tsx +43 -26
  132. package/src/Components/Loader.tsx +56 -32
  133. package/src/Components/Logo.tsx +62 -52
  134. package/src/Components/MDUtils.tsx +10 -6
  135. package/src/Components/ObjectBrowser.tsx +3198 -2478
  136. package/src/Components/Router.tsx +11 -11
  137. package/src/Components/SaveCloseButtons.tsx +43 -39
  138. package/src/Components/Schedule.tsx +1091 -853
  139. package/src/Components/SelectWithIcon.tsx +135 -93
  140. package/src/Components/TabContainer.tsx +22 -20
  141. package/src/Components/TabContent.tsx +13 -12
  142. package/src/Components/TabHeader.tsx +10 -9
  143. package/src/Components/TableResize.tsx +52 -37
  144. package/src/Components/TextWithIcon.tsx +30 -19
  145. package/src/Components/ToggleThemeMenu.tsx +31 -13
  146. package/src/Components/TreeTable.tsx +468 -385
  147. package/src/Components/UploadImage.tsx +153 -121
  148. package/src/Components/Utils.tsx +135 -127
  149. package/src/Components/loader.css +40 -31
  150. package/src/Components/withWidth.tsx +23 -12
  151. package/src/Connection.tsx +1 -3
  152. package/src/Dialogs/ComplexCron.tsx +55 -61
  153. package/src/Dialogs/Confirm.tsx +88 -65
  154. package/src/Dialogs/Cron.tsx +122 -112
  155. package/src/Dialogs/Error.tsx +37 -42
  156. package/src/Dialogs/Message.tsx +39 -37
  157. package/src/Dialogs/SelectFile.tsx +95 -85
  158. package/src/Dialogs/SelectID.tsx +141 -129
  159. package/src/Dialogs/SimpleCron.tsx +44 -44
  160. package/src/Dialogs/TextInput.tsx +60 -68
  161. package/src/GenericApp.tsx +342 -242
  162. package/src/LegacyConnection.tsx +972 -842
  163. package/src/Prompt.tsx +3 -1
  164. package/src/Theme.tsx +19 -26
  165. package/src/icons/IconAdapter.tsx +16 -14
  166. package/src/icons/IconAlias.tsx +16 -14
  167. package/src/icons/IconChannel.tsx +55 -16
  168. package/src/icons/IconClearFilter.tsx +17 -15
  169. package/src/icons/IconClosed.tsx +16 -11
  170. package/src/icons/IconCopy.tsx +16 -11
  171. package/src/icons/IconDevice.tsx +121 -22
  172. package/src/icons/IconDocument.tsx +16 -11
  173. package/src/icons/IconDocumentReadOnly.tsx +21 -12
  174. package/src/icons/IconExpert.tsx +20 -12
  175. package/src/icons/IconFx.tsx +16 -14
  176. package/src/icons/IconInstance.tsx +16 -14
  177. package/src/icons/IconLogout.tsx +20 -18
  178. package/src/icons/IconNoIcon.tsx +16 -14
  179. package/src/icons/IconOpen.tsx +17 -12
  180. package/src/icons/IconProps.tsx +4 -3
  181. package/src/icons/IconState.tsx +34 -13
  182. package/src/index.css +3 -2
  183. package/tasks.js +91 -0
  184. package/types.d.ts +141 -0
  185. package/Components/Loaders/PT.css +0 -109
  186. package/Components/Loaders/Vendor.css +0 -13
  187. package/Components/loader.css +0 -222
  188. package/Components/types.d.ts +0 -82
  189. package/assets/devices/Alarm Systems.svg +0 -19
  190. package/assets/devices/Amplifier.svg +0 -22
  191. package/assets/devices/Awnings.svg +0 -5
  192. package/assets/devices/Battery Status.svg +0 -5
  193. package/assets/devices/Ceiling Spotlights.svg +0 -16
  194. package/assets/devices/Chandelier.svg +0 -7
  195. package/assets/devices/Climate.svg +0 -12
  196. package/assets/devices/Coffee Makers.svg +0 -6
  197. package/assets/devices/Cold Water.svg +0 -31
  198. package/assets/devices/Computer.svg +0 -21
  199. package/assets/devices/Consumption.svg +0 -8
  200. package/assets/devices/Curtains.svg +0 -43
  201. package/assets/devices/Dishwashers.svg +0 -12
  202. package/assets/devices/Doors.svg +0 -6
  203. package/assets/devices/Doorstep.svg +0 -35
  204. package/assets/devices/Dryer.svg +0 -14
  205. package/assets/devices/Fan.svg +0 -20
  206. package/assets/devices/Floor Lamps.svg +0 -5
  207. package/assets/devices/Garage Doors.svg +0 -9
  208. package/assets/devices/Gates.svg +0 -32
  209. package/assets/devices/Hairdryer.svg +0 -23
  210. package/assets/devices/Handle.svg +0 -6
  211. package/assets/devices/Hanging Lamps.svg +0 -9
  212. package/assets/devices/Heater.svg +0 -44
  213. package/assets/devices/Hoods.svg +0 -12
  214. package/assets/devices/Hot Water.svg +0 -10
  215. package/assets/devices/Humidity.svg +0 -41
  216. package/assets/devices/Iron.svg +0 -5
  217. package/assets/devices/Irrigation.svg +0 -23
  218. package/assets/devices/Led Strip.svg +0 -31
  219. package/assets/devices/Light.svg +0 -30
  220. package/assets/devices/Lightings.svg +0 -46
  221. package/assets/devices/Lock.svg +0 -19
  222. package/assets/devices/Louvre.svg +0 -7
  223. package/assets/devices/Mowing Machine.svg +0 -9
  224. package/assets/devices/Music.svg +0 -13
  225. package/assets/devices/Outdoor Blinds.svg +0 -7
  226. package/assets/devices/People.svg +0 -19
  227. package/assets/devices/Pool.svg +0 -8
  228. package/assets/devices/Power Consumption.svg +0 -13
  229. package/assets/devices/Printer.svg +0 -10
  230. package/assets/devices/Pump.svg +0 -10
  231. package/assets/devices/Receiver.svg +0 -19
  232. package/assets/devices/Sconces.svg +0 -10
  233. package/assets/devices/Security.svg +0 -34
  234. package/assets/devices/Shading.svg +0 -5
  235. package/assets/devices/Shutters.svg +0 -11
  236. package/assets/devices/SmokeDetector.svg +0 -13
  237. package/assets/devices/Sockets.svg +0 -13
  238. package/assets/devices/Speaker.svg +0 -35
  239. package/assets/devices/Stove.svg +0 -12
  240. package/assets/devices/Table Lamps.svg +0 -12
  241. package/assets/devices/Temperature Sensors.svg +0 -28
  242. package/assets/devices/Tv.svg +0 -8
  243. package/assets/devices/Vacuum Cleaner.svg +0 -16
  244. package/assets/devices/Ventilation.svg +0 -12
  245. package/assets/devices/Washing Machines.svg +0 -16
  246. package/assets/devices/Water Consumption.svg +0 -6
  247. package/assets/devices/Water Heater.svg +0 -8
  248. package/assets/devices/Water.svg +0 -40
  249. package/assets/devices/Weather.svg +0 -28
  250. package/assets/devices/Window.svg +0 -8
  251. package/assets/rooms/Anteroom.svg +0 -53
  252. package/assets/rooms/Attic.svg +0 -21
  253. package/assets/rooms/Balcony.svg +0 -13
  254. package/assets/rooms/Barn.svg +0 -6
  255. package/assets/rooms/Basement.svg +0 -5
  256. package/assets/rooms/Bathroom.svg +0 -38
  257. package/assets/rooms/Bedroom.svg +0 -5
  258. package/assets/rooms/Boiler Room.svg +0 -13
  259. package/assets/rooms/Carport.svg +0 -17
  260. package/assets/rooms/Cellar.svg +0 -89
  261. package/assets/rooms/Chamber.svg +0 -9
  262. package/assets/rooms/Corridor.svg +0 -53
  263. package/assets/rooms/Dining Area.svg +0 -37
  264. package/assets/rooms/Dining Room.svg +0 -37
  265. package/assets/rooms/Dining.svg +0 -37
  266. package/assets/rooms/Dressing Room.svg +0 -5
  267. package/assets/rooms/Driveway.svg +0 -15
  268. package/assets/rooms/Entrance.svg +0 -44
  269. package/assets/rooms/Equipment Room.svg +0 -15
  270. package/assets/rooms/Front Yard.svg +0 -64
  271. package/assets/rooms/Gallery.svg +0 -14
  272. package/assets/rooms/Garage.svg +0 -20
  273. package/assets/rooms/Garden.svg +0 -13
  274. package/assets/rooms/Ground Floor.svg +0 -95
  275. package/assets/rooms/Guest Bathroom.svg +0 -33
  276. package/assets/rooms/Guest Room.svg +0 -5
  277. package/assets/rooms/Gym.svg +0 -5
  278. package/assets/rooms/Hall.svg +0 -19
  279. package/assets/rooms/Home Theater.svg +0 -8
  280. package/assets/rooms/Kitchen.svg +0 -18
  281. package/assets/rooms/Laundry Room.svg +0 -12
  282. package/assets/rooms/Living Area.svg +0 -11
  283. package/assets/rooms/Living Room.svg +0 -10
  284. package/assets/rooms/Locker Room.svg +0 -17
  285. package/assets/rooms/Nursery.svg +0 -5
  286. package/assets/rooms/Office.svg +0 -8
  287. package/assets/rooms/Outdoors.svg +0 -7
  288. package/assets/rooms/Playroom.svg +0 -6
  289. package/assets/rooms/Pool.svg +0 -8
  290. package/assets/rooms/Rear Wall.svg +0 -30
  291. package/assets/rooms/Second Floor.svg +0 -95
  292. package/assets/rooms/Shed.svg +0 -16
  293. package/assets/rooms/Sleeping Area.svg +0 -22
  294. package/assets/rooms/Stairway.svg +0 -5
  295. package/assets/rooms/Stairwell.svg +0 -15
  296. package/assets/rooms/Storeroom.svg +0 -5
  297. package/assets/rooms/Summer House.svg +0 -27
  298. package/assets/rooms/Swimming Pool.svg +0 -21
  299. package/assets/rooms/Terrace.svg +0 -7
  300. package/assets/rooms/Toilet.svg +0 -10
  301. package/assets/rooms/Upstairs.svg +0 -6
  302. package/assets/rooms/Wardrobe.svg +0 -60
  303. package/assets/rooms/Washroom.svg +0 -20
  304. package/assets/rooms/Wc.svg +0 -10
  305. package/assets/rooms/Windscreen.svg +0 -60
  306. package/assets/rooms/Workshop.svg +0 -23
  307. 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 (e) {
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 ((!schedule || !Object.keys(schedule).length)) {
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 (copy.period.days === 1 || copy.period.weeks === 1 || copy.period.months === 1 || copy.period.years === 1) {
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 (e) {
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 (daysOfWeek.length === 5 && daysOfWeek[0] === 1 && daysOfWeek[1] === 2 && daysOfWeek[2] === 3 && daysOfWeek[3] === 4 && daysOfWeek[4] === 5) {
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 (daysOfWeek.length === 5 && daysOfWeek[0] === 1 && daysOfWeek[1] === 2 && daysOfWeek[2] === 3 && daysOfWeek[3] === 4 && daysOfWeek[4] === 5) {
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(I18n.t(
527
- 'sch_desc_onDate',
528
- schedule.period.yearDate.toString(),
529
- schedule.period.yearMonth ? I18n.t(MONTHS[schedule.period.yearMonth - 1]) : I18n.t('sch_desc_everyMonth'),
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 = ASTRO.indexOf(schedule.time.start) !== -1 ? I18n.t(`sch_astro_${schedule.time.start}`) : schedule.time.start;
560
- const end = ASTRO.indexOf(schedule.time.end) !== -1 ? I18n.t(`sch_astro_${schedule.time.end}`) : schedule.time.end;
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 <div key="timePeriod" style={styles.rowDiv}>
601
- <div style={styles.modeDiv}>
602
- <FormControlLabel
603
- control={<Radio
604
- style={styles.inputRadio}
605
- checked={!schedule.time.exactTime}
606
- onClick={() => {
607
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
608
- _schedule.time.exactTime = false;
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={!!night}
616
+ checked={!schedule.time.exactTime}
706
617
  onClick={() => {
707
618
  const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
708
- _schedule.time.start = 'sunset';
709
- _schedule.time.end = 'sunrise';
619
+ _schedule.time.exactTime = false;
710
620
  this.onChange(_schedule);
711
621
  }}
712
- />}
713
- label={I18n.t('sch_astroNight')}
714
- />
715
- </div>}
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
- </div>;
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 <div key="timeExact" style={styles.rowDiv}>
726
- <div style={styles.modeDiv}>
727
- <FormControlLabel
728
- control={<Radio
729
- style={styles.inputRadio}
730
- checked={!!this.state.schedule.time.exactTime}
731
- onClick={() => {
732
- const schedule = JSON.parse(JSON.stringify(this.state.schedule));
733
- schedule.time.exactTime = true;
734
- this.onChange(schedule);
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
- label={I18n.t('sch_exactTime')}
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
- {this.state.schedule.time.exactTime && <Select
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 = !schedule.period.dows && !schedule.period.months && !schedule.period.dates && !schedule.period.years && !schedule.period.days && !schedule.period.weeks;
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 key="once" style={{ ...styles.rowDiv, ...styles.rowOnce }}>
847
+ <div
848
+ key="once"
849
+ style={{ ...styles.rowDiv, ...styles.rowOnce }}
850
+ >
787
851
  <div style={styles.modeDiv}>
788
852
  <FormControlLabel
789
- control={<Radio
790
- style={styles.inputRadio}
791
- checked={!!isOnce}
792
- onClick={() => {
793
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
794
- _schedule.period.once = _schedule.period.once || Schedule.now2string(true);
795
- _schedule.period.dows = '';
796
- _schedule.period.months = '';
797
- _schedule.period.dates = '';
798
- _schedule.period.years = 0;
799
- _schedule.period.yearDate = 0;
800
- _schedule.period.yearMonth = 0;
801
- _schedule.period.weeks = 0;
802
- _schedule.period.days = 0;
803
- this.onChange(_schedule);
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 && <div style={styles.settingsDiv}>
810
- <TextField
811
- variant="standard"
812
- style={styles.inputDate}
813
- type="date"
814
- ref={this.refOnce}
815
- key="exactDateAt"
816
- defaultValue={string2USdate(schedule.period.once)}
817
- // InputProps={{inputComponent: TextTime}}
818
- onChange={e => {
819
- this.timerOnce && clearTimeout(this.timerOnce);
820
- this.timerOnce = null;
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
- }, 1500, e.target.value);
837
- }}
838
- InputLabelProps={{ shrink: true }}
839
- label={I18n.t('sch_at')}
840
- margin="normal"
841
- />
842
- </div>}
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 component="div" key="days" sx={Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowDays)}>
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={<Radio
850
- style={styles.inputRadio}
851
- checked={!!schedule.period.days}
852
- onClick={() => {
853
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
854
- _schedule.period.days = 1;
855
- _schedule.period.dows = '';
856
- _schedule.period.months = '';
857
- _schedule.period.dates = '';
858
- _schedule.period.years = 0;
859
- _schedule.period.yearDate = 0;
860
- _schedule.period.yearMonth = 0;
861
- _schedule.period.weeks = 0;
862
- _schedule.period.once = '';
863
- this.onChange(_schedule);
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 component="div" key="weeks" sx={Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowDows)}>
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={<Radio
897
- style={styles.inputRadio}
898
- checked={!!schedule.period.weeks}
899
- onClick={() => {
900
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
901
- _schedule.period.weeks = schedule.period.weeks ? 0 : 1;
902
- _schedule.period.dows = schedule.period.dows || '[0]';
903
- _schedule.period.months = '';
904
- _schedule.period.dates = '';
905
- _schedule.period.years = 0;
906
- _schedule.period.yearDate = 0;
907
- _schedule.period.yearMonth = 0;
908
- _schedule.period.days = 0;
909
- _schedule.period.once = '';
910
- this.onChange(_schedule);
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 component="div" style={styles.settingsDiv}>
1000
+ <Box
1001
+ component="div"
1002
+ style={styles.settingsDiv}
1003
+ >
917
1004
  <div style={styles.settingsDiv}>{this.getPeriodSettingsWeekly()}</div>
918
- <Box component="div" sx={Utils.getStyle(this.props.theme, styles.settingsDiv, styles.rowDowsDows)}>
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 component="div" key="months" sx={Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowMonths)}>
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={<Radio
929
- style={styles.inputRadio}
930
- checked={!!schedule.period.months}
931
- onClick={() => {
932
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
933
- _schedule.period.months = 1;
934
- _schedule.period.dows = '';
935
- _schedule.period.dates = '';
936
- _schedule.period.years = 0;
937
- _schedule.period.yearDate = 0;
938
- _schedule.period.yearMonth = 0;
939
- _schedule.period.weeks = 0;
940
- _schedule.period.days = 0;
941
- _schedule.period.once = '';
942
- this.onChange(_schedule);
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 ? <Box>
951
- <Box component="div" sx={Utils.getStyle(this.props.theme, styles.settingsDiv, styles.rowMonthsDates)}>
952
- <FormControlLabel
953
- control={<Checkbox
954
- style={styles.inputRadio}
955
- checked={!!schedule.period.dates}
956
- onClick={() => {
957
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
958
- _schedule.period.months = _schedule.period.months || 1;
959
- const dates = [];
960
- for (let i = 1; i <= 31; i++) {
961
- dates.push(i);
962
- }
963
- _schedule.period.dates = _schedule.period.dates || JSON.stringify(dates);
964
- _schedule.period.dows = '';
965
- _schedule.period.years = 0;
966
- _schedule.period.yearDate = 0;
967
- _schedule.period.yearMonth = 0;
968
- _schedule.period.weeks = 0;
969
- _schedule.period.days = 0;
970
- _schedule.period.once = '';
971
-
972
- this.onChange(_schedule);
973
- }}
974
- />}
975
- label={I18n.t('sch_periodDates')}
976
- />
977
- </Box>
978
- <Box component="div" sx={Utils.getStyle(this.props.theme, styles.settingsDiv, styles.rowMonthsDates)}>
979
- {this.getPeriodSettingsDates()}
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
- </Box> : null}
1088
+ ) : null}
982
1089
  </div>
983
1090
  </Box>,
984
1091
 
985
1092
  // ----- years ---
986
- <Box component="div" key="years" sx={Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowYears)}>
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={<Radio
990
- style={styles.inputRadio}
991
- checked={!!schedule.period.years}
992
- onClick={() => {
993
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
994
- _schedule.period.years = 1;
995
- _schedule.period.yearDate = 1;
996
- _schedule.period.yearMonth = 1;
997
- _schedule.period.dows = '';
998
- _schedule.period.months = 0;
999
- _schedule.period.dates = '';
1000
- _schedule.period.weeks = 0;
1001
- _schedule.period.days = 0;
1002
- _schedule.period.once = '';
1003
- this.onChange(_schedule);
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 && <div style={styles.settingsDiv}>
1012
- <span>{I18n.t('sch_on')}</span>
1013
- <Input
1014
- key="input"
1015
- value={this.state.schedule.period.yearDate}
1016
- style={styles.inputEvery}
1017
- type="number"
1018
- inputProps={{ min: 1, max: 31 }}
1019
- onChange={e => {
1020
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1021
- _schedule.period.yearDate = parseInt(e.target.value, 10);
1022
- if (_schedule.period.yearDate < 1) _schedule.period.yearDate = 31;
1023
- if (_schedule.period.yearDate > 31) _schedule.period.yearDate = 1;
1024
- this.onChange(_schedule);
1025
- }}
1026
- />
1027
- <Select
1028
- variant="standard"
1029
- value={schedule.period.yearMonth}
1030
- onChange={e => {
1031
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1032
- _schedule.period.yearMonth = e.target.value;
1033
- this.onChange(_schedule);
1034
- }}
1035
- >
1036
- <MenuItem key="every" value={0}>{I18n.t('sch_yearEveryMonth')}</MenuItem>
1037
- {MONTHS.map((month, i) => <MenuItem key={month} value={i + 1}>{I18n.t(month)}</MenuItem>)}
1038
- </Select>
1039
- </div>}
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 <div style={{ display: 'inline-block' }}>
1047
- <label>{I18n.t('sch_every')}</label>
1048
- <Input
1049
- value={this.state.schedule.time.interval}
1050
- style={{ ...styles.inputEvery, verticalAlign: 'bottom' }}
1051
- type="number"
1052
- inputProps={{ min: 1 }}
1053
- onChange={e => {
1054
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1055
- _schedule.time.interval = parseInt(e.target.value, 10);
1056
- this.onChange(_schedule);
1057
- }}
1058
- />
1059
- <Select
1060
- variant="standard"
1061
- value={this.state.schedule.time.mode}
1062
- onChange={e => {
1063
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1064
- _schedule.time.mode = e.target.value;
1065
- this.onChange(_schedule);
1066
- }}
1067
- >
1068
- <MenuItem value={PERIODS.minutes}>{I18n.t('sch_periodMinutes')}</MenuItem>
1069
- <MenuItem value={PERIODS.hours}>{I18n.t('sch_periodHours')}</MenuItem>
1070
- </Select>
1071
- </div>;
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 = schedule.period.dows && schedule.period.dows !== '[1, 2, 3, 4, 5]' && schedule.period.dows !== '[0, 6]';
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={<Radio
1082
- style={styles.inputRadio}
1083
- checked={schedule.period.dows === '[1, 2, 3, 4, 5]'}
1084
- onClick={() => {
1085
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1086
- _schedule.period.dows = '[1, 2, 3, 4, 5]';
1087
- if (_schedule.period.days) {
1088
- _schedule.period.days = 1;
1089
- }
1090
- this.onChange(_schedule);
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={<Radio
1100
- style={styles.inputRadio}
1101
- checked={schedule.period.dows === '[0, 6]'}
1102
- onClick={() => {
1103
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1104
- _schedule.period.dows = '[0, 6]';
1105
- if (_schedule.period.days) {
1106
- _schedule.period.days = 1;
1107
- }
1108
- this.onChange(_schedule);
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={<Radio
1122
- style={styles.inputRadio}
1123
- checked={!!isSpecific}
1124
- onClick={() => {
1125
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1126
- _schedule.period.dows = '[0, 1, 2, 3, 4, 5, 6]';
1127
- if (_schedule.period.days) {
1128
- _schedule.period.days = 1;
1129
- }
1130
- this.onChange(_schedule);
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
- <FormGroup row style={{ ...styles.inputGroup, width: 150 }}>
1137
- {[1, 2, 3, 4, 5, 6, 0].map(i =>
1138
- <FormControlLabel
1139
- key={`specific_${i}`}
1140
- style={styles.inputGroupElement}
1141
- control={<Checkbox
1142
- style={styles.inputSmallCheck}
1143
- checked={schedule.period.dows.includes(i.toString())}
1144
- onChange={e => {
1145
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1146
- let daysOfWeek: number[];
1147
- try {
1148
- daysOfWeek = JSON.parse(_schedule.period.dows);
1149
- } catch (err) {
1150
- daysOfWeek = [];
1151
- }
1152
- if (e.target.checked && !daysOfWeek.includes(i)) {
1153
- daysOfWeek.push(i);
1154
- } else if (!e.target.checked && daysOfWeek.includes(i)) {
1155
- daysOfWeek.splice(daysOfWeek.indexOf(i), 1);
1156
- }
1157
- daysOfWeek.sort((a: number, b: number) => a - b);
1158
- _schedule.period.dows = JSON.stringify(daysOfWeek);
1159
- if (_schedule.period.days) {
1160
- _schedule.period.days = 1;
1161
- }
1162
- this.onChange(_schedule);
1163
- }}
1164
- />}
1165
- label={I18n.t(WEEKDAYS[i])}
1166
- />)}
1167
- </FormGroup>}
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={<Radio
1181
- style={styles.inputRadio}
1182
- checked={schedule.period.days === 1 && !schedule.period.dows}
1183
- onClick={() => {
1184
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1185
- _schedule.period.days = 1;
1186
- _schedule.period.dows = '';
1187
- this.onChange(_schedule);
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={<Radio
1196
- style={styles.inputRadio}
1197
- checked={schedule.period.days > 1}
1198
- onClick={() => {
1199
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1200
- _schedule.period.days = 2;
1201
- _schedule.period.dows = '';
1202
- this.onChange(_schedule);
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 key="span" style={{ paddingRight: 10 }}>{I18n.t('sch_periodDay')}</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 key="radios" style={{ display: 'inline-block', verticalAlign: 'top' }}>
1389
+ <div
1390
+ key="radios"
1391
+ style={{ display: 'inline-block', verticalAlign: 'top' }}
1392
+ >
1234
1393
  <div>
1235
1394
  <FormControlLabel
1236
- control={<Radio
1237
- style={styles.inputRadio}
1238
- checked={schedule.period.weeks === 1}
1239
- onClick={() => {
1240
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1241
- _schedule.period.weeks = 1;
1242
- this.onChange(_schedule);
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={<Radio
1251
- style={styles.inputRadio}
1252
- checked={schedule.period.weeks > 1}
1253
- onClick={() => {
1254
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1255
- _schedule.period.weeks = 2;
1256
- this.onChange(_schedule);
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 <FormGroup
1295
- row
1296
- style={{ ...styles.inputGroup, maxWidth: 620 }}
1297
- >
1298
- <FormControlLabel
1299
- style={styles.inputDateDay}
1300
- control={<Checkbox
1301
- style={styles.inputDateDayCheck}
1302
- checked={parsedDates.length === 31}
1303
- onChange={() => {
1304
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1305
- const _dates = [];
1306
- for (let i = 1; i <= 31; i++) {
1307
- _dates.push(i);
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
- _schedule.period.dates = JSON.stringify(_dates);
1310
- this.onChange(_schedule);
1311
- }}
1312
- />}
1313
- label={I18n.t('sch_all')}
1314
- />
1315
- <FormControlLabel
1316
- style={styles.inputDateDay}
1317
- control={<Checkbox
1318
- style={styles.inputDateDayCheck}
1319
- checked={!parsedDates.length}
1320
- onChange={() => {
1321
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1322
- _schedule.period.dates = '[]';
1323
- this.onChange(_schedule);
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
- result.sort((a, b) => a - b);
1344
- _schedule.period.dates = JSON.stringify(result);
1345
- this.onChange(_schedule);
1346
- }}
1347
- />}
1348
- label={I18n.t('sch_invert')}
1349
- />}
1350
- <div />
1351
- {dates.map(i =>
1352
- <FormControlLabel
1353
- key={`date_${i}`}
1354
- style={!i ? {
1355
- ...styles.inputDateDay,
1356
- opacity: 0,
1357
- cursor: 'default',
1358
- userSelect: 'none',
1359
- pointerEvents: 'none',
1360
- } : styles.inputDateDay}
1361
- control={<Checkbox
1362
- style={styles.inputDateDayCheck}
1363
- checked={JSON.parse(schedule.period.dates).includes(i)}
1364
- onChange={e => {
1365
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1366
- let _dates;
1367
- try {
1368
- _dates = JSON.parse(_schedule.period.dates);
1369
- } catch (err) {
1370
- _dates = [];
1371
- }
1372
- if (e.target.checked && !_dates.includes(i)) {
1373
- _dates.push(i);
1374
- } else if (!e.target.checked && _dates.includes(i)) {
1375
- _dates.splice(_dates.indexOf(i), 1);
1376
- }
1377
- _dates.sort((a: number, b: number) => a - b);
1378
- _schedule.period.dates = JSON.stringify(_dates);
1379
- this.onChange(_schedule);
1380
- }}
1381
- />}
1382
- label={i < 10 ? [
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={<Radio
1401
- style={styles.inputRadio}
1402
- checked={typeof schedule.period.months === 'number' && schedule.period.months === 1}
1403
- onClick={() => {
1404
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1405
- _schedule.period.months = 1;
1406
- this.onChange(schedule);
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={<Radio
1415
- style={styles.inputRadio}
1416
- checked={typeof schedule.period.months === 'number' && schedule.period.months > 1}
1417
- onClick={() => {
1418
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1419
- _schedule.period.months = 2;
1420
- this.onChange(_schedule);
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' && schedule.period.months > 1 && [
1426
- <Input
1427
- key="input"
1428
- value={schedule.period.months}
1429
- style={styles.inputEvery}
1430
- type="number"
1431
- inputProps={{ min: 2 }}
1432
- onChange={e => {
1433
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
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
- const months = [];
1469
- for (let i = 1; i <= 12; i++) {
1470
- months.push(i);
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
- label={I18n.t('sch_all')}
1477
- />
1478
- <FormControlLabel
1479
- style={styles.inputDateDay}
1480
- control={<Checkbox
1481
- style={styles.inputDateDayCheck}
1482
- checked={!parsedMonths.length}
1483
- onChange={() => {
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
- label={I18n.t('sch_no_one')}
1490
- />
1491
- {parsedMonths.length !== 12 && !!parsedMonths.length &&
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={<Checkbox
1495
- style={styles.inputDateDayCheck}
1496
- checked={false}
1497
- onChange={() => {
1498
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1499
- const result = [];
1500
- const _parsedMonths = JSON.parse(_schedule.period.months);
1501
- for (let i = 1; i <= 12; i++) {
1502
- if (!_parsedMonths.includes(i)) {
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
- result.sort((a, b) => a - b);
1507
- _schedule.period.months = JSON.stringify(result);
1508
- this.onChange(_schedule);
1509
- }}
1510
- />}
1511
- label={I18n.t('sch_invert')}
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.inputGroupElement}
1517
- control={<Checkbox
1518
- style={styles.inputSmallCheck}
1519
- checked={typeof schedule.period.months === 'string' ? JSON.parse(schedule.period.months).includes(i + 1) : schedule.period.months === i}
1520
- onChange={e => {
1521
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1522
- let months;
1523
- try {
1524
- months = JSON.parse(_schedule.period.months);
1525
- } catch (err) {
1526
- months = [];
1527
- }
1528
- if (e.target.checked && !months.includes(i + 1)) {
1529
- months.push(i + 1);
1530
- } else if (!e.target.checked && months.includes(i + 1)) {
1531
- months.splice(months.indexOf(i + 1), 1);
1532
- }
1533
- months.sort((a: number, b: number) => a - b);
1534
- _schedule.period.months = JSON.stringify(months);
1535
- this.onChange(_schedule);
1536
- }}
1537
- />}
1538
- label={I18n.t(month)}
1539
- />)}
1540
- </FormGroup>}
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={<Radio
1554
- style={styles.inputRadio}
1555
- checked={schedule.period.years === 1}
1556
- onClick={() => {
1557
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1558
- _schedule.period.years = 1;
1559
- this.onChange(_schedule);
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={<Radio
1568
- style={styles.inputRadio}
1569
- checked={schedule.period.years > 1}
1570
- onClick={() => {
1571
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1572
- _schedule.period.years = 2;
1573
- this.onChange(_schedule);
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) _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 <div style={styles.rowDiv}>
1625
- <div style={{ ...styles.modeDiv, verticalAlign: 'middle' }}>
1626
- <span style={{ fontWeight: 'bold', paddingRight: 10 }}>{I18n.t('sch_valid')}</span>
1627
- <span>{I18n.t('sch_validFrom')}</span>
1628
- </div>
1629
- <div style={styles.settingsDiv}>
1630
- <TextField
1631
- variant="standard"
1632
- style={{ ...styles.inputDate, marginRight: 10 }}
1633
- key="exactTimeFrom"
1634
- inputRef={this.refFrom}
1635
- defaultValue={string2USdate(schedule.valid.from)}
1636
- type="date"
1637
- // inputComponent={TextDate}
1638
- onChange={e => {
1639
- this.timerFrom && clearTimeout(this.timerFrom);
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
- if (this.refTo.current) {
1685
- this.refTo.current.style.background = '#ff000030';
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
- this.timerTo = setTimeout(value => {
1688
- this.timerTo = null;
1689
- if (this.refTo.current) {
1690
- this.refTo.current.style.background = '';
1691
- }
1692
- const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1693
- const date = Schedule.string2date(value);
1694
- if (date.toString() !== 'Invalid Date') {
1695
- _schedule.valid.to = `${padding(date.getDate())}.${padding(date.getMonth() + 1)}.${date.getFullYear()}`;
1696
- this.onChange(_schedule);
1697
- }
1698
- }, 1500, e.target.value);
1699
- }}
1700
- InputLabelProps={{ shrink: true }}
1701
- margin="normal"
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
- </div>;
1940
+ );
1705
1941
  }
1706
1942
 
1707
- render() {
1708
- return <div style={{ height: 'calc(100% - 48px)', width: '100%', overflow: 'hidden' }}>
1709
- <div>{this.state.desc}</div>
1710
- <div style={styles.scrollWindow}>
1711
- <h5>{I18n.t('sch_time')}</h5>
1712
- {this.getTimePeriodElements()}
1713
- {this.getTimeExactElements()}
1714
- {Schedule.getDivider()}
1715
- <h5>{I18n.t('sch_period')}</h5>
1716
- {this.getPeriodModes()}
1717
- {!this.state.schedule.period.once && Schedule.getDivider()}
1718
- {!this.state.schedule.period.once && this.getValidSettings()}
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
- </div>;
1958
+ );
1721
1959
  }
1722
1960
  }
1723
1961