goblin-gadgets 3.2.2 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (361) hide show
  1. package/.editorconfig +9 -9
  2. package/.eslintrc.js +28 -28
  3. package/.zou-flow +2 -2
  4. package/builders/builders.js +5 -5
  5. package/builders/gadget.js +85 -85
  6. package/calendar-boards-gadget.js +64 -64
  7. package/demo-gadget.js +17 -17
  8. package/glyphs-dialog.js +13 -13
  9. package/login-dialog.js +13 -13
  10. package/package.json +46 -46
  11. package/pivot-gadget.js +18 -18
  12. package/stack-navigation.js +13 -13
  13. package/table-gadget.js +102 -102
  14. package/test/code-parser.spec.js +61 -61
  15. package/tree-gadget.js +70 -70
  16. package/types/types.js +455 -455
  17. package/widgets/accordion/styles.js +16 -16
  18. package/widgets/accordion/widget.js +90 -90
  19. package/widgets/analog-clock/props.js +102 -102
  20. package/widgets/analog-clock/scenarios.js +43 -43
  21. package/widgets/analog-clock/styles.js +754 -754
  22. package/widgets/analog-clock/widget.js +404 -404
  23. package/widgets/animated-container/animations.js +566 -566
  24. package/widgets/animated-container/styles.js +36 -36
  25. package/widgets/animated-container/widget.js +24 -24
  26. package/widgets/badge/styles.js +107 -107
  27. package/widgets/badge/widget.js +33 -33
  28. package/widgets/button/props.js +377 -377
  29. package/widgets/button/scenarios.js +54 -54
  30. package/widgets/button/styles.js +1082 -1082
  31. package/widgets/button/widget.js +426 -426
  32. package/widgets/button-combo/styles.js +73 -73
  33. package/widgets/button-combo/widget.js +297 -297
  34. package/widgets/calendar/props.js +207 -207
  35. package/widgets/calendar/scenarios.js +50 -50
  36. package/widgets/calendar/styles.js +198 -198
  37. package/widgets/calendar/widget.js +895 -895
  38. package/widgets/calendar-boards/styles.js +29 -29
  39. package/widgets/calendar-boards/widget.js +215 -215
  40. package/widgets/calendar-button/styles.js +273 -273
  41. package/widgets/calendar-button/widget.js +94 -94
  42. package/widgets/calendar-list/styles.js +35 -35
  43. package/widgets/calendar-list/widget.js +223 -223
  44. package/widgets/calendar-recurrence/widget.js +183 -183
  45. package/widgets/carousel/props.js +104 -104
  46. package/widgets/carousel/scenarios.js +163 -163
  47. package/widgets/carousel/styles.js +133 -133
  48. package/widgets/carousel/widget.js +491 -491
  49. package/widgets/carousel-bullet/styles.js +29 -29
  50. package/widgets/carousel-bullet/widget.js +25 -25
  51. package/widgets/carousel-button/styles.js +71 -71
  52. package/widgets/carousel-button/widget.js +33 -33
  53. package/widgets/carousel-item/styles.js +21 -21
  54. package/widgets/carousel-item/widget.js +24 -24
  55. package/widgets/chat-balloon/props.js +65 -65
  56. package/widgets/chat-balloon/scenarios.js +47 -47
  57. package/widgets/chat-balloon/styles.js +193 -193
  58. package/widgets/chat-balloon/widget.js +62 -62
  59. package/widgets/chat-dialog/styles.js +15 -15
  60. package/widgets/chat-dialog/widget.js +62 -62
  61. package/widgets/check-list/styles.js +66 -66
  62. package/widgets/check-list/widget.js +168 -168
  63. package/widgets/checkbox/widget.js +15 -15
  64. package/widgets/checkbox-nc/props.js +191 -191
  65. package/widgets/checkbox-nc/scenarios.js +41 -41
  66. package/widgets/checkbox-nc/styles.js +122 -122
  67. package/widgets/checkbox-nc/widget.js +116 -116
  68. package/widgets/clock-combo/styles.js +174 -174
  69. package/widgets/clock-combo/widget.js +390 -390
  70. package/widgets/color-picker/props.js +145 -145
  71. package/widgets/color-picker/scenarios.js +34 -34
  72. package/widgets/color-picker/styles.js +209 -209
  73. package/widgets/color-picker/widget.js +735 -735
  74. package/widgets/colored-container/props.js +34 -34
  75. package/widgets/colored-container/scenarios.js +54 -54
  76. package/widgets/colored-container/styles.js +100 -100
  77. package/widgets/colored-container/widget.js +27 -27
  78. package/widgets/combo/styles.js +69 -69
  79. package/widgets/combo/widget.js +224 -224
  80. package/widgets/combo-container/styles.js +66 -66
  81. package/widgets/combo-container/widget.js +188 -188
  82. package/widgets/command-button/widget.js +39 -39
  83. package/widgets/container/props.js +295 -295
  84. package/widgets/container/scenarios.js +47 -47
  85. package/widgets/container/styles.js +1439 -1439
  86. package/widgets/container/widget.js +279 -279
  87. package/widgets/demo/widget.js +24 -24
  88. package/widgets/dialog/styles.js +29 -29
  89. package/widgets/dialog/widget.js +26 -26
  90. package/widgets/dialog-modal/props.js +126 -126
  91. package/widgets/dialog-modal/styles.js +234 -234
  92. package/widgets/dialog-modal/widget.js +273 -273
  93. package/widgets/dialog-resizable/props.js +1 -1
  94. package/widgets/dialog-resizable/scenarios.js +18 -18
  95. package/widgets/dialog-resizable/widget.js +367 -367
  96. package/widgets/dialog-resizable-nc/props.js +150 -150
  97. package/widgets/dialog-resizable-nc/scenarios.js +18 -18
  98. package/widgets/dialog-resizable-nc/styles.js +259 -259
  99. package/widgets/dialog-resizable-nc/widget.js +197 -197
  100. package/widgets/directory-input/widget.js +18 -18
  101. package/widgets/directory-input-nc/widget.js +20 -20
  102. package/widgets/document-container/getPath.js +43 -43
  103. package/widgets/document-container/props.js +79 -79
  104. package/widgets/document-container/scenarios.js +39 -39
  105. package/widgets/document-container/styles.js +69 -69
  106. package/widgets/document-container/widget.js +53 -53
  107. package/widgets/drag-cab/styles.js +56 -56
  108. package/widgets/drag-cab/widget.js +285 -285
  109. package/widgets/drag-carrier/styles.js +21 -21
  110. package/widgets/drag-carrier/widget.js +780 -780
  111. package/widgets/dynamic-toolbar/styles.js +110 -110
  112. package/widgets/dynamic-toolbar/widget.js +128 -128
  113. package/widgets/field/readonly/label.js +39 -39
  114. package/widgets/field/widget.js +1743 -1743
  115. package/widgets/file-input/widget.js +18 -18
  116. package/widgets/file-input-nc/styles.js +38 -38
  117. package/widgets/file-input-nc/widget.js +88 -88
  118. package/widgets/flat-combo/styles.js +21 -21
  119. package/widgets/flat-combo/widget.js +61 -61
  120. package/widgets/flat-list/styles.js +30 -30
  121. package/widgets/flat-list/widget.js +219 -219
  122. package/widgets/flying-balloon/styles.js +52 -52
  123. package/widgets/flying-balloon/widget.js +43 -43
  124. package/widgets/fragment/widget.js +26 -26
  125. package/widgets/full-screen/props.js +27 -27
  126. package/widgets/full-screen/styles.js +32 -32
  127. package/widgets/full-screen/widget.js +40 -40
  128. package/widgets/gauge/props.js +71 -71
  129. package/widgets/gauge/scenarios.js +83 -83
  130. package/widgets/gauge/styles.js +183 -183
  131. package/widgets/gauge/widget.js +36 -36
  132. package/widgets/glyph-detail/service.js +9 -9
  133. package/widgets/glyph-detail/widget.js +109 -109
  134. package/widgets/glyphs-dialog/service.js +94 -94
  135. package/widgets/glyphs-dialog/styles.js +37 -37
  136. package/widgets/glyphs-dialog/widget.js +236 -236
  137. package/widgets/goblin-editor/widget.js +146 -146
  138. package/widgets/guild-entry/props.js +53 -53
  139. package/widgets/guild-entry/scenarios.js +26 -26
  140. package/widgets/guild-entry/styles.js +98 -98
  141. package/widgets/guild-entry/widget.js +126 -126
  142. package/widgets/guild-user-logo/guild-helpers.js +77 -77
  143. package/widgets/guild-user-logo/props.js +48 -48
  144. package/widgets/guild-user-logo/scenarios.js +64 -64
  145. package/widgets/guild-user-logo/styles.js +114 -114
  146. package/widgets/guild-user-logo/widget.js +81 -81
  147. package/widgets/guild-user-profile/props.js +73 -73
  148. package/widgets/guild-user-profile/scenarios.js +54 -54
  149. package/widgets/guild-user-profile/styles.js +162 -162
  150. package/widgets/guild-user-profile/widget.js +202 -202
  151. package/widgets/helpers/combo-helpers.js +218 -218
  152. package/widgets/helpers/geom-helpers.js +80 -80
  153. package/widgets/helpers/rect-helpers.js +10 -10
  154. package/widgets/helpers/shortcut-helpers.js +56 -56
  155. package/widgets/helpers/spacing-helpers.js +26 -26
  156. package/widgets/helpers/svg-helpers.js +151 -151
  157. package/widgets/helpers/table-helpers.js +68 -68
  158. package/widgets/hinter/styles.js +79 -79
  159. package/widgets/hinter/widget.js +205 -205
  160. package/widgets/hinter-column/widget.js +49 -49
  161. package/widgets/hinter-field/reducer.js +18 -18
  162. package/widgets/hinter-field/widget.js +176 -176
  163. package/widgets/hinter-field-nc/props.js +114 -114
  164. package/widgets/hinter-field-nc/scenarios.js +47 -47
  165. package/widgets/hinter-field-nc/widget.js +191 -191
  166. package/widgets/input-wrapper/widget.js +157 -157
  167. package/widgets/key-trap.js +96 -96
  168. package/widgets/label/props.js +1 -1
  169. package/widgets/label/scenarios.js +1 -1
  170. package/widgets/label/widget.js +7 -7
  171. package/widgets/label-nc/props.js +308 -308
  172. package/widgets/label-nc/scenarios.js +29 -29
  173. package/widgets/label-nc/styles.js +1218 -1218
  174. package/widgets/label-nc/widget.js +314 -314
  175. package/widgets/label-row/props.js +1 -1
  176. package/widgets/label-row/scenarios.js +1 -1
  177. package/widgets/label-row/widget.js +7 -7
  178. package/widgets/label-row-nc/props.js +94 -94
  179. package/widgets/label-row-nc/scenarios.js +46 -46
  180. package/widgets/label-row-nc/widget.js +81 -81
  181. package/widgets/label-text-field/styles.js +55 -55
  182. package/widgets/label-text-field/widget.js +178 -178
  183. package/widgets/launcher/props.js +177 -177
  184. package/widgets/launcher/scenarios.js +55 -55
  185. package/widgets/launcher/styles.js +46 -46
  186. package/widgets/launcher/widget.js +79 -79
  187. package/widgets/launcher-blob/props.js +25 -25
  188. package/widgets/launcher-blob/scenarios.js +24 -24
  189. package/widgets/launcher-blob/styles.js +62 -62
  190. package/widgets/launcher-blob/widget.js +50 -50
  191. package/widgets/list/widget.js +211 -211
  192. package/widgets/login-dialog/service.js +117 -117
  193. package/widgets/login-dialog/widget.js +117 -117
  194. package/widgets/map/reaflet.js +208 -208
  195. package/widgets/map/widget.js +67 -67
  196. package/widgets/markdown/styles.js +85 -85
  197. package/widgets/markdown/widget.js +31 -31
  198. package/widgets/notification/styles.js +97 -97
  199. package/widgets/notification/widget.js +207 -207
  200. package/widgets/pivot/custom.css +320 -320
  201. package/widgets/pivot/widget.js +42 -42
  202. package/widgets/radio-list/styles.js +48 -48
  203. package/widgets/radio-list/widget.js +111 -111
  204. package/widgets/resizable-container/styles.js +108 -108
  205. package/widgets/resizable-container/widget.js +225 -225
  206. package/widgets/retro-action-button/helpers.js +106 -106
  207. package/widgets/retro-action-button/styles.js +285 -285
  208. package/widgets/retro-action-button/widget.js +364 -364
  209. package/widgets/retro-badge-button/styles.js +87 -87
  210. package/widgets/retro-badge-button/widget.js +251 -251
  211. package/widgets/retro-gear/helpers.js +156 -156
  212. package/widgets/retro-gear/styles.js +130 -130
  213. package/widgets/retro-gear/widget.js +51 -51
  214. package/widgets/retro-illuminated-button/styles.js +274 -274
  215. package/widgets/retro-illuminated-button/widget.js +147 -147
  216. package/widgets/retro-panel/helpers.js +57 -57
  217. package/widgets/retro-panel/styles.js +293 -293
  218. package/widgets/retro-panel/widget.js +239 -239
  219. package/widgets/retro-screw/styles.js +80 -80
  220. package/widgets/retro-screw/widget.js +25 -25
  221. package/widgets/rocket/props.js +124 -124
  222. package/widgets/rocket/scenarios.js +71 -71
  223. package/widgets/rocket/styles.js +306 -306
  224. package/widgets/rocket/widget.js +225 -225
  225. package/widgets/samples-monitor/helpers.js +147 -147
  226. package/widgets/samples-monitor/styles.js +529 -529
  227. package/widgets/samples-monitor/widget.js +516 -516
  228. package/widgets/scrollable-container/styles.js +58 -58
  229. package/widgets/scrollable-container/widget.js +132 -132
  230. package/widgets/scrollable-linkable-container/reducer.js +18 -18
  231. package/widgets/scrollable-linkable-container/styles.js +42 -42
  232. package/widgets/scrollable-linkable-container/widget.js +78 -78
  233. package/widgets/select/styles.js +68 -68
  234. package/widgets/select/widget.js +119 -119
  235. package/widgets/separator/props.js +46 -46
  236. package/widgets/separator/styles.js +116 -116
  237. package/widgets/separator/widget.js +27 -27
  238. package/widgets/slider/props.js +136 -136
  239. package/widgets/slider/scenarios.js +74 -74
  240. package/widgets/slider/styles.js +246 -246
  241. package/widgets/slider/widget.js +404 -404
  242. package/widgets/slider-circle/props.js +72 -72
  243. package/widgets/slider-circle/scenarios.js +16 -16
  244. package/widgets/slider-circle/styles.js +78 -78
  245. package/widgets/slider-circle/widget.js +154 -154
  246. package/widgets/slider-xy/props.js +87 -87
  247. package/widgets/slider-xy/scenarios.js +19 -19
  248. package/widgets/slider-xy/styles.js +102 -102
  249. package/widgets/slider-xy/widget.js +234 -234
  250. package/widgets/smiley/props.js +51 -51
  251. package/widgets/smiley/scenarios.js +58 -58
  252. package/widgets/smiley/styles.js +489 -489
  253. package/widgets/smiley/widget.js +72 -72
  254. package/widgets/spinner/props.js +31 -31
  255. package/widgets/spinner/scenarios.js +31 -31
  256. package/widgets/spinner/styles.js +49 -49
  257. package/widgets/spinner/widget.js +23 -23
  258. package/widgets/splitter/props.js +71 -71
  259. package/widgets/splitter/scenarios.js +182 -182
  260. package/widgets/splitter/styles.js +41 -41
  261. package/widgets/splitter/widget.js +455 -455
  262. package/widgets/stack-navigation/service.js +324 -324
  263. package/widgets/stack-navigation/widget.js +296 -296
  264. package/widgets/state-browser/styles.js +19 -19
  265. package/widgets/state-browser/widget.js +135 -135
  266. package/widgets/state-browser-dialog/styles.js +100 -100
  267. package/widgets/state-browser-dialog/widget.js +253 -253
  268. package/widgets/state-monitor/styles.js +50 -50
  269. package/widgets/state-monitor/widget.js +324 -324
  270. package/widgets/switch-on-off/props.js +30 -30
  271. package/widgets/switch-on-off/scenarios.js +34 -34
  272. package/widgets/switch-on-off/styles.js +63 -63
  273. package/widgets/switch-on-off/widget.js +41 -41
  274. package/widgets/table/helpers.js +160 -160
  275. package/widgets/table/props.js +658 -658
  276. package/widgets/table/reducer.js +196 -196
  277. package/widgets/table/scenarios.js +54 -54
  278. package/widgets/table/widget.js +253 -253
  279. package/widgets/table-cell/props.js +145 -145
  280. package/widgets/table-cell/styles.js +160 -160
  281. package/widgets/table-cell/widget.js +139 -139
  282. package/widgets/table-header-drag-manager/styles.js +184 -184
  283. package/widgets/table-header-drag-manager/widget.js +392 -392
  284. package/widgets/table-nc/styles.js +100 -100
  285. package/widgets/table-nc/widget.js +409 -409
  286. package/widgets/table-row/props.js +73 -73
  287. package/widgets/table-row/styles.js +82 -82
  288. package/widgets/table-row/widget.js +207 -207
  289. package/widgets/text-field/widget.js +18 -18
  290. package/widgets/text-field-combo/widget.js +21 -21
  291. package/widgets/text-field-combo-nc/props.js +300 -300
  292. package/widgets/text-field-combo-nc/scenarios.js +72 -72
  293. package/widgets/text-field-combo-nc/widget.js +339 -339
  294. package/widgets/text-field-date-interval/styles.js +37 -37
  295. package/widgets/text-field-date-interval/widget.js +162 -162
  296. package/widgets/text-field-nc/props.js +40 -40
  297. package/widgets/text-field-nc/scenarios.js +67 -67
  298. package/widgets/text-field-nc/widget.js +14 -14
  299. package/widgets/text-field-time-interval/styles.js +37 -37
  300. package/widgets/text-field-time-interval/widget.js +160 -160
  301. package/widgets/text-field-typed/widget.js +51 -51
  302. package/widgets/text-field-typed-nc/props.js +81 -81
  303. package/widgets/text-field-typed-nc/scenarios.js +105 -105
  304. package/widgets/text-field-typed-nc/styles.js +20 -20
  305. package/widgets/text-field-typed-nc/widget.js +749 -750
  306. package/widgets/text-input-info-nc/props.js +62 -62
  307. package/widgets/text-input-info-nc/widget.js +55 -55
  308. package/widgets/text-input-nc/props.js +143 -143
  309. package/widgets/text-input-nc/scenarios.js +44 -44
  310. package/widgets/text-input-nc/styles.js +242 -242
  311. package/widgets/text-input-nc/widget.js +234 -234
  312. package/widgets/ticket/getPath.js +128 -128
  313. package/widgets/ticket/props.js +181 -181
  314. package/widgets/ticket/scenarios.js +39 -39
  315. package/widgets/ticket/styles.js +332 -332
  316. package/widgets/ticket/ticket-helpers.js +33 -33
  317. package/widgets/ticket/widget.js +348 -348
  318. package/widgets/ticket-hover/styles.js +207 -207
  319. package/widgets/ticket-hover/widget.js +53 -53
  320. package/widgets/time-gauge/widget.js +64 -64
  321. package/widgets/tips/styles.js +48 -48
  322. package/widgets/tips/widget.js +171 -171
  323. package/widgets/translatable-text-field/styles.js +202 -202
  324. package/widgets/translatable-text-field/text-field.js +132 -132
  325. package/widgets/translatable-text-field/widget.js +660 -660
  326. package/widgets/tree/props.js +246 -246
  327. package/widgets/tree/scenarios.js +14 -14
  328. package/widgets/tree/styles.js +142 -142
  329. package/widgets/tree/widget.js +383 -383
  330. package/widgets/tree-cell/styles.js +140 -140
  331. package/widgets/tree-cell/widget.js +100 -100
  332. package/widgets/tree-row/styles.js +77 -77
  333. package/widgets/tree-row/widget.js +135 -135
  334. package/widgets/triangle/props.js +48 -48
  335. package/widgets/triangle/scenarios.js +33 -33
  336. package/widgets/triangle/styles.js +92 -92
  337. package/widgets/triangle/widget.js +36 -36
  338. package/widgets/well-done/widget.js +170 -170
  339. package/widgets/widget-doc/reducer.js +68 -68
  340. package/widgets/widget-doc/styles.js +15 -15
  341. package/widgets/widget-doc/widget-list.js +25 -25
  342. package/widgets/widget-doc/widget.js +89 -89
  343. package/widgets/widget-doc-menu/styles.js +12 -12
  344. package/widgets/widget-doc-menu/widget.js +79 -79
  345. package/widgets/widget-doc-preview/parse-code.js +20 -20
  346. package/widgets/widget-doc-preview/styles.js +77 -77
  347. package/widgets/widget-doc-preview/widget.js +481 -481
  348. package/widgets/widget-doc-preview-container/styles.js +60 -60
  349. package/widgets/widget-doc-preview-container/widget.js +129 -129
  350. package/widgets/widget-doc-properties/styles.js +41 -41
  351. package/widgets/widget-doc-properties/widget.js +307 -307
  352. package/widgets/widget-doc-property/styles.js +75 -75
  353. package/widgets/widget-doc-property/widget.js +108 -108
  354. package/widgets/widget-doc-property-control/styles.js +14 -14
  355. package/widgets/widget-doc-property-control/widget.js +343 -343
  356. package/widgets/wizard/service.js +2132 -2132
  357. package/widgets/wizard/styles.js +21 -21
  358. package/widgets/wizard/widget.js +927 -927
  359. package/widgets/work-dialog/styles.js +31 -31
  360. package/widgets/work-dialog/widget.js +162 -162
  361. package/wizard.js +13 -13
@@ -1,1743 +1,1743 @@
1
- //T:2019-02-27
2
-
3
- import React from 'react';
4
- import Form from 'goblin-laboratory/widgets/form';
5
- import Widget from 'goblin-laboratory/widgets/widget';
6
- import T from 't';
7
- import C from 'goblin-laboratory/widgets/connect-helpers/c';
8
-
9
- /******************************************************************************/
10
- //migrated
11
- import ReadonlyLabel from './readonly/label.js';
12
- /******************************************************************************/
13
-
14
- import Container from 'goblin-gadgets/widgets/container/widget';
15
- import Button from 'goblin-gadgets/widgets/button/widget';
16
- import Checkbox from 'goblin-gadgets/widgets/checkbox/widget';
17
- import Label from 'goblin-gadgets/widgets/label/widget';
18
- import TextField from 'goblin-gadgets/widgets/text-field/widget';
19
- import TranslatableTextField from 'goblin-gadgets/widgets/translatable-text-field/widget';
20
- import LabelRow from 'goblin-gadgets/widgets/label-row/widget';
21
- import TextFieldTyped from 'goblin-gadgets/widgets/text-field-typed/widget';
22
- import TextFieldCombo from 'goblin-gadgets/widgets/text-field-combo/widget';
23
- import TextFieldTimeInterval from 'goblin-gadgets/widgets/text-field-time-interval/widget';
24
- import TextFieldDateInterval from 'goblin-gadgets/widgets/text-field-date-interval/widget';
25
- import RadioList from 'goblin-gadgets/widgets/radio-list/widget';
26
- import CheckList from 'goblin-gadgets/widgets/check-list/widget';
27
- import CalendarRecurrence from 'goblin-gadgets/widgets/calendar-recurrence/widget';
28
- import Calendar from 'goblin-gadgets/widgets/calendar/widget';
29
- import CalendarBoards from 'goblin-gadgets/widgets/calendar-boards/widget';
30
- import FileInput from 'goblin-gadgets/widgets/file-input/widget';
31
- import DirectoryInput from 'goblin-gadgets/widgets/directory-input/widget';
32
- import StateBrowser from 'goblin-gadgets/widgets/state-browser/widget';
33
-
34
- import SchemaHelpers from 'goblin-toolbox/lib/schema-helpers';
35
-
36
- import importer from 'goblin_importer';
37
- import HinterField from 'goblin-gadgets/widgets/hinter-field/widget';
38
- const widgetImporter = importer('widget');
39
-
40
- /******************************************************************************/
41
-
42
- const defaultLabelWidth = '120px';
43
- const pluginBlackListedProps = [
44
- 'kind',
45
- 'containerKind',
46
- 'plugin',
47
- 'mode',
48
- 'grow',
49
- 'width',
50
- 'height',
51
- 'verticalSpacing',
52
- 'verticalJustify',
53
- 'dragServiceId',
54
- 'embeddedLevel',
55
- ];
56
-
57
- function getPluginProps(propsToFilter) {
58
- return Object.entries(propsToFilter).reduce((props, [key, value]) => {
59
- if (!pluginBlackListedProps.includes(key)) {
60
- props[key] = value;
61
- }
62
- return props;
63
- }, {});
64
- }
65
-
66
- /******************************************************************************/
67
-
68
- class Field extends Form {
69
- constructor() {
70
- super(...arguments);
71
-
72
- this.radioListSelectionChanged = this.radioListSelectionChanged.bind(this);
73
- this.isShowed = this.isShowed.bind(this);
74
- }
75
-
76
- get readonly() {
77
- return this.props.readonly || this.context.readonly;
78
- }
79
-
80
- getFullPathFromModel(model) {
81
- if (!this.context.model) {
82
- throw new Error(
83
- 'Cannot resolve context model, your Field is not in a Form ?'
84
- );
85
- }
86
- return `${this.context.model}${model}`;
87
- }
88
-
89
- get fullPath() {
90
- return this.getFullPathFromModel(this.props.model);
91
- }
92
-
93
- isShowed(value) {
94
- return Boolean(this.props.showStrategy === 'alwaysVisible' || value);
95
- }
96
-
97
- getEntitySchema() {
98
- const entityId = this.context.entityId; // by example "portfolio@e564950b-cd9f-4d35-abd0-b85bf93017f1"
99
- if (entityId) {
100
- const entityType = entityId.split('@', 2)[0]; // by example "portfolio"
101
- return this.getSchema(entityType);
102
- }
103
- return null;
104
- }
105
-
106
- getKind() {
107
- if (this.props.kind) {
108
- return this.props.kind;
109
- } else {
110
- return SchemaHelpers.getKind(this.getEntitySchema(), this.props.model);
111
- }
112
- }
113
-
114
- getShift() {
115
- if (this.props.shift) {
116
- return this.props.shift;
117
- } else {
118
- return SchemaHelpers.getShift(this.getEntitySchema(), this.props.model);
119
- }
120
- }
121
-
122
- getComboList() {
123
- if (this.props.listModel) {
124
- return C(this.props.listModel);
125
- } else if (this.props.list) {
126
- return this.props.list;
127
- } else {
128
- return SchemaHelpers.getComboList(
129
- this.getEntitySchema(),
130
- this.props.model
131
- );
132
- }
133
- }
134
-
135
- getRestrictsToList() {
136
- if (this.props.listModel || this.props.list) {
137
- return this.props.restrictsToList;
138
- } else {
139
- const list = SchemaHelpers.getComboList(
140
- this.getEntitySchema(),
141
- this.props.model
142
- );
143
- return !!list;
144
- }
145
- }
146
-
147
- getLabelText() {
148
- if (this.props.labelText) {
149
- return this.props.labelText;
150
- } else {
151
- return SchemaHelpers.getLabelText(
152
- this.getEntitySchema(),
153
- this.props.model
154
- );
155
- }
156
- }
157
-
158
- getTooltip() {
159
- let tooltip = this.props.tooltip || this.props.hintText;
160
- if (!tooltip) {
161
- tooltip = SchemaHelpers.getTooltip(
162
- this.getEntitySchema(),
163
- this.props.model
164
- );
165
- }
166
- return tooltip;
167
- }
168
-
169
- /******************************************************************************/
170
-
171
- //#region Readonly
172
- renderReadonlyField() {
173
- const {
174
- show = C(this.props.model, this.isShowed),
175
- labelWrap,
176
- labelGlyph,
177
- labelWidth = defaultLabelWidth,
178
- horizontalSpacing,
179
- verticalSpacing,
180
- verticalJustify,
181
- width,
182
- grow,
183
- fieldWidth,
184
- kind,
185
- ...otherProps
186
- } = this.props;
187
-
188
- return (
189
- <LabelRow
190
- show={show}
191
- labelText={this.getLabelText()}
192
- labelWrap={labelWrap}
193
- labelGlyph={labelGlyph}
194
- labelWidth={labelWidth}
195
- horizontalSpacing={horizontalSpacing}
196
- verticalSpacing={verticalSpacing}
197
- verticalJustify={verticalJustify}
198
- width={width}
199
- grow={grow || (fieldWidth ? null : '1')}
200
- >
201
- <TextField
202
- type={this.getKind()}
203
- selectAllOnFocus={true}
204
- width={fieldWidth}
205
- grow={fieldWidth ? null : '1'}
206
- {...otherProps}
207
- readonly={true}
208
- tooltip={this.getTooltip()}
209
- />
210
- </LabelRow>
211
- );
212
- }
213
-
214
- renderReadonlyTranslatable() {
215
- const {
216
- show = C(this.props.model, this.isShowed),
217
- labelWrap,
218
- labelGlyph,
219
- labelWidth = defaultLabelWidth,
220
- horizontalSpacing,
221
- verticalSpacing,
222
- verticalJustify,
223
- width,
224
- grow,
225
- fieldWidth,
226
- kind,
227
- ...otherProps
228
- } = this.props;
229
-
230
- return (
231
- <LabelRow
232
- show={show}
233
- labelText={this.getLabelText()}
234
- labelWrap={labelWrap}
235
- labelGlyph={labelGlyph}
236
- labelWidth={labelWidth}
237
- horizontalSpacing={horizontalSpacing}
238
- verticalSpacing={verticalSpacing}
239
- verticalJustify={verticalJustify}
240
- width={width}
241
- grow={grow || (fieldWidth ? null : '1')}
242
- >
243
- <TranslatableTextField
244
- type={this.getKind()}
245
- selectAllOnFocus={true}
246
- width={fieldWidth}
247
- grow={fieldWidth ? null : '1'}
248
- {...otherProps}
249
- readonly={true}
250
- tooltip={this.getTooltip()}
251
- />
252
- </LabelRow>
253
- );
254
- }
255
-
256
- renderReadonlyGadget() {
257
- const target = this.context.id
258
- ? `backend.${this.context.id}.gadgets.${this.props.name}`
259
- : `${this.context.model}.gadgets.${this.props.name}`;
260
-
261
- const parentId = this.context.id || this.context.model;
262
-
263
- const GadgetLoader = (props) => {
264
- if (props.available) {
265
- const gadgetInfo = this.getBackendValue(target, true);
266
- const type = gadgetInfo.get('type');
267
- const Gadget = widgetImporter(type);
268
- const WiredGadget = Widget.Wired(Gadget)(gadgetInfo.get('id'));
269
- return (
270
- <WiredGadget
271
- readonly={true}
272
- {...this.props}
273
- widgetId={gadgetInfo.get('id')}
274
- parentId={parentId}
275
- />
276
- );
277
- } else {
278
- return null;
279
- }
280
- };
281
- const DisplayGadget = this.mapWidget(GadgetLoader, 'available', target);
282
-
283
- return <DisplayGadget />;
284
- }
285
-
286
- renderReadonlyTyped() {
287
- const {
288
- show = C(this.props.model, this.isShowed),
289
- labelWrap,
290
- labelGlyph,
291
- labelWidth = defaultLabelWidth,
292
- horizontalSpacing,
293
- verticalSpacing,
294
- verticalJustify,
295
- width,
296
- fieldWidth,
297
- kind,
298
- ...otherProps
299
- } = this.props;
300
-
301
- return (
302
- <LabelRow
303
- show={show}
304
- labelText={this.getLabelText()}
305
- labelWrap={labelWrap}
306
- labelGlyph={labelGlyph}
307
- labelWidth={labelWidth}
308
- horizontalSpacing={horizontalSpacing}
309
- verticalSpacing={verticalSpacing}
310
- verticalJustify={verticalJustify}
311
- width={width}
312
- >
313
- <TextFieldTyped
314
- type={this.getKind()}
315
- shift={this.getShift()}
316
- selectAllOnFocus={true}
317
- width={fieldWidth}
318
- {...otherProps}
319
- readonly={true}
320
- tooltip={this.getTooltip()}
321
- />
322
- </LabelRow>
323
- );
324
- }
325
-
326
- renderReadonlyTimeInterval() {
327
- const {
328
- show,
329
- labelWrap,
330
- labelGlyph,
331
- labelWidth = defaultLabelWidth,
332
- horizontalSpacing,
333
- verticalSpacing,
334
- verticalJustify,
335
- width,
336
- kind,
337
- ...otherProps
338
- } = this.props;
339
-
340
- return (
341
- <LabelRow
342
- show={show}
343
- width={width}
344
- labelText={this.getLabelText()}
345
- labelWrap={labelWrap}
346
- labelGlyph={labelGlyph}
347
- labelWidth={labelWidth}
348
- horizontalSpacing={horizontalSpacing}
349
- verticalSpacing={verticalSpacing}
350
- verticalJustify={verticalJustify}
351
- >
352
- <TextFieldTimeInterval
353
- selectAllOnFocus={true}
354
- {...otherProps}
355
- readonly={true}
356
- entityFullPath={this.context.model}
357
- tooltip={this.getTooltip()}
358
- />
359
- </LabelRow>
360
- );
361
- }
362
-
363
- renderReadonlyDateInterval() {
364
- const {
365
- show,
366
- labelWrap,
367
- labelGlyph,
368
- labelWidth = defaultLabelWidth,
369
- horizontalSpacing,
370
- verticalSpacing,
371
- verticalJustify,
372
- width,
373
- kind,
374
- ...otherProps
375
- } = this.props;
376
-
377
- return (
378
- <LabelRow
379
- show={show}
380
- width={width}
381
- labelText={this.getLabelText()}
382
- labelWrap={labelWrap}
383
- labelGlyph={labelGlyph}
384
- labelWidth={labelWidth}
385
- horizontalSpacing={horizontalSpacing}
386
- verticalSpacing={verticalSpacing}
387
- verticalJustify={verticalJustify}
388
- >
389
- <TextFieldDateInterval
390
- selectAllOnFocus={true}
391
- {...otherProps}
392
- readonly={true}
393
- entityFullPath={this.context.model}
394
- tooltip={this.getTooltip()}
395
- />
396
- </LabelRow>
397
- );
398
- }
399
-
400
- renderReadonlyCombo() {
401
- return (
402
- <LabelRow
403
- show={this.props.show}
404
- grow={this.props.grow}
405
- width={this.props.width}
406
- height={this.props.height}
407
- labelText={this.getLabelText()}
408
- labelWrap={this.props.labelWrap}
409
- labelGlyph={this.props.labelGlyph}
410
- labelWidth={this.props.labelWidth || defaultLabelWidth}
411
- horizontalSpacing={this.props.horizontalSpacing}
412
- verticalSpacing={this.props.verticalSpacing}
413
- verticalJustify={this.props.verticalJustify}
414
- >
415
- <TextFieldCombo
416
- selectAllOnFocus={true}
417
- shape={this.props.shape}
418
- getGlyph={this.props.getGlyph}
419
- hintText={this.props.hintText}
420
- tooltip={this.getTooltip()}
421
- width={this.props.fieldWidth}
422
- hideButtonCombo={this.props.hideButtonCombo}
423
- selectedId={
424
- this.props.selectedId ? this.props.selectedId : C(this.props.model)
425
- }
426
- readonly={true}
427
- restrictsToList={this.getRestrictsToList()}
428
- required={this.props.required}
429
- list={this.getComboList()}
430
- menuType="wrap"
431
- menuItemWidth={this.props.menuItemWidth}
432
- comboTextTransform="none"
433
- grow="1"
434
- />
435
- </LabelRow>
436
- );
437
- }
438
-
439
- renderReadonlyBool() {
440
- const {
441
- kind,
442
- show,
443
- grow,
444
- height,
445
- labelGlyph,
446
- labelWidth = defaultLabelWidth,
447
- horizontalSpacing,
448
- verticalSpacing,
449
- verticalJustify,
450
- width,
451
- subkind,
452
- ...otherProps
453
- } = this.props;
454
-
455
- return (
456
- <LabelRow
457
- show={show}
458
- grow={grow}
459
- width={width}
460
- height={height}
461
- labelGlyph={labelGlyph}
462
- labelWidth={labelWidth || defaultLabelWidth}
463
- horizontalSpacing={horizontalSpacing}
464
- verticalSpacing={verticalSpacing}
465
- verticalJustify={verticalJustify}
466
- >
467
- <Checkbox
468
- kind={subkind}
469
- text={this.getLabelText()}
470
- {...otherProps}
471
- tooltip={this.getTooltip()}
472
- readonly={true}
473
- />
474
- </LabelRow>
475
- );
476
- }
477
-
478
- renderReadonlyHinter() {
479
- const {
480
- show = C(this.props.model, this.isShowed),
481
- labelWrap,
482
- labelGlyph,
483
- labelWidth = defaultLabelWidth,
484
- horizontalSpacing,
485
- verticalSpacing,
486
- verticalJustify,
487
- width,
488
- fieldWidth,
489
- kind,
490
- ...otherProps
491
- } = this.props;
492
-
493
- return (
494
- <LabelRow
495
- show={show}
496
- labelText={this.getLabelText()}
497
- labelWrap={labelWrap}
498
- labelGlyph={labelGlyph}
499
- labelWidth={labelWidth}
500
- horizontalSpacing={horizontalSpacing}
501
- verticalSpacing={verticalSpacing}
502
- verticalJustify={verticalJustify}
503
- width={width}
504
- grow={this.props.fieldWidth ? null : '1'}
505
- >
506
- <HinterField width={fieldWidth} {...otherProps} readonly={true} />
507
- </LabelRow>
508
- );
509
- }
510
-
511
- renderReadonlyEntity() {
512
- const summary = this.props.summary || 'info';
513
- const Viewer = (props) => {
514
- if (!props.entityId) {
515
- return (
516
- <Label
517
- grow="1"
518
- empty={true}
519
- horizontalSpacing={this.props.horizontalSpacing}
520
- />
521
- );
522
- }
523
- const Info = this.mapWidget(
524
- Label,
525
- (entity) => {
526
- let glyph = 'solid/spinner';
527
- let glyphColor = null;
528
- let text = T('Chargement...');
529
- if (entity) {
530
- glyph = entity.get('meta.summaries.glyph');
531
- glyphColor = entity.get('meta.summaries.glyphColor');
532
- text = entity.get(`meta.summaries.${summary}`);
533
- }
534
- return {
535
- kind: 'combo-text-markdown',
536
- glyph,
537
- glyphColor,
538
- text,
539
- grow: '1',
540
- justify: this.props.justify,
541
- wrap: this.props.wrap,
542
- };
543
- },
544
- `backend.${props.entityId}`
545
- );
546
- return <Info userSelect="text" />;
547
- };
548
-
549
- const Action = (props) => {
550
- const openEntityWorkitem = () => {
551
- const service = this.context.id.split('@')[0];
552
- this.doAs(service, 'open-entity-workitem', {
553
- entityId: props.entityId,
554
- desktopId: this.context.desktopId,
555
- });
556
- };
557
-
558
- return !!props.entityId && !this.props.disableAdd ? (
559
- <Button
560
- kind="combo"
561
- shape="right-smooth"
562
- leftSpacing="overlap"
563
- horizontalSpacing={this.props.horizontalSpacing}
564
- glyph="solid/pencil"
565
- tooltip={T('Editer')}
566
- onClick={openEntityWorkitem}
567
- />
568
- ) : null;
569
- };
570
-
571
- const EntityViewer = this.mapWidget(Viewer, 'entityId', this.fullPath);
572
- const EntityAction = this.mapWidget(Action, 'entityId', this.fullPath);
573
-
574
- return (
575
- <LabelRow
576
- show={this.props.show}
577
- grow={this.props.grow}
578
- width={this.props.width}
579
- height={this.props.height}
580
- labelText={this.getLabelText()}
581
- labelWrap={this.props.labelWrap}
582
- labelGlyph={this.props.labelGlyph}
583
- labelWidth={this.props.labelWidth || defaultLabelWidth}
584
- horizontalSpacing={this.props.horizontalSpacing}
585
- verticalSpacing={this.props.verticalSpacing}
586
- verticalJustify={this.props.verticalJustify}
587
- >
588
- <EntityViewer />
589
- <EntityAction />
590
- </LabelRow>
591
- );
592
- }
593
-
594
- renderReadonlyEntities() {
595
- const pluginProps = getPluginProps(this.props);
596
- if (this.props.plugin) {
597
- let WiredPlugin = null;
598
- let FinalPlugin = null;
599
- if (this.props.pluginType) {
600
- const CustomPlugin = widgetImporter(`plugin-${this.props.pluginType}`);
601
- WiredPlugin = Widget.Wired(CustomPlugin)(
602
- `${this.props.plugin}-plugin@${this.context.id}`
603
- );
604
- FinalPlugin = this.mapWidget(WiredPlugin, 'entityIds', this.fullPath);
605
- } else {
606
- FinalPlugin = widgetImporter('plugin');
607
- }
608
-
609
- const FinalContainer = this.mapWidget(
610
- Container,
611
- (value) => {
612
- const length = value ? value.length : 0;
613
- const embedded = this.props.embedded;
614
- const show = length > 0 || !embedded;
615
- return {show};
616
- },
617
- this.fullPath
618
- );
619
-
620
- return (
621
- <FinalContainer
622
- kind={this.props.containerKind || 'row-field'}
623
- subkind={this.props.containerSubkind || 'light-box'}
624
- grow={this.props.grow}
625
- width={this.props.width}
626
- height={this.props.height}
627
- verticalSpacing={this.props.verticalSpacing}
628
- verticalJustify={this.props.verticalJustify}
629
- >
630
- <FinalPlugin
631
- {...pluginProps}
632
- id={`${this.props.plugin}-plugin@${this.context.id}`}
633
- readonly={true}
634
- embeddedLevel={
635
- this.props.embeddedLevel ? this.props.embeddedLevel + 1 : 1
636
- }
637
- dragServiceId={
638
- this.props.dragServiceId || this.context.dragServiceId
639
- }
640
- />
641
- </FinalContainer>
642
- );
643
- } else if (this.props.item) {
644
- const Items = (props) => {
645
- if (!props.entityIds) {
646
- return (
647
- <Label
648
- grow="1"
649
- empty={true}
650
- horizontalSpacing={this.props.horizontalSpacing}
651
- />
652
- );
653
- }
654
- return (
655
- <Container
656
- kind="row-field"
657
- grow={this.props.grow}
658
- width={this.props.width}
659
- height={this.props.height}
660
- verticalSpacing={this.props.verticalSpacing}
661
- verticalJustify={this.props.verticalJustify}
662
- >
663
- {props.entityIds.map((entityId, index) => {
664
- const Item = this.mapWidget(
665
- this.props.item,
666
- (state) => (state ? state : null),
667
- `backend.${entityId}`
668
- );
669
- return <Item key={index} />;
670
- })}
671
- </Container>
672
- );
673
- };
674
- const FinalItems = this.mapWidget(Items, 'entityIds', this.fullPath);
675
- return <FinalItems />;
676
- } else {
677
- throw new Error('Property plugin is required in this case!');
678
- }
679
- }
680
- //#endregion
681
-
682
- //#region Edit
683
- renderEditField() {
684
- const {
685
- show,
686
- labelWrap,
687
- labelGlyph,
688
- labelWidth = defaultLabelWidth,
689
- horizontalSpacing,
690
- verticalSpacing,
691
- verticalJustify,
692
- width,
693
- grow,
694
- fieldWidth,
695
- kind,
696
- ...otherProps
697
- } = this.props;
698
-
699
- return (
700
- <LabelRow
701
- show={show}
702
- labelText={this.getLabelText()}
703
- labelWrap={labelWrap}
704
- labelGlyph={labelGlyph}
705
- labelWidth={labelWidth}
706
- horizontalSpacing={horizontalSpacing}
707
- verticalSpacing={verticalSpacing}
708
- verticalJustify={verticalJustify}
709
- width={width}
710
- grow={grow || (fieldWidth ? null : '1')}
711
- >
712
- <TextField
713
- type={this.getKind()}
714
- width={fieldWidth}
715
- grow={fieldWidth ? null : '1'}
716
- {...otherProps}
717
- tooltip={this.getTooltip()}
718
- />
719
- </LabelRow>
720
- );
721
- }
722
-
723
- renderEditTranslatable() {
724
- const {
725
- show,
726
- labelWrap,
727
- labelGlyph,
728
- labelWidth = defaultLabelWidth,
729
- horizontalSpacing,
730
- verticalSpacing,
731
- verticalJustify,
732
- width,
733
- grow,
734
- fieldWidth,
735
- kind,
736
- type,
737
- ...otherProps
738
- } = this.props;
739
-
740
- return (
741
- <LabelRow
742
- show={show}
743
- labelText={this.getLabelText()}
744
- labelWrap={labelWrap}
745
- labelGlyph={labelGlyph}
746
- labelWidth={labelWidth}
747
- horizontalSpacing={horizontalSpacing}
748
- verticalSpacing={verticalSpacing}
749
- verticalJustify={verticalJustify}
750
- width={width}
751
- grow={grow || (fieldWidth ? null : '1')}
752
- >
753
- <TranslatableTextField
754
- type={this.getKind()}
755
- width={fieldWidth}
756
- grow={fieldWidth ? null : '1'}
757
- {...otherProps}
758
- tooltip={this.getTooltip()}
759
- />
760
- </LabelRow>
761
- );
762
- }
763
-
764
- renderEditGadget() {
765
- const target = this.context.id
766
- ? `backend.${this.context.id}.gadgets.${this.props.name}`
767
- : `${this.context.model}.gadgets.${this.props.name}`;
768
-
769
- const parentId = this.context.id || this.context.model;
770
-
771
- const GadgetLoader = (props) => {
772
- if (props.available) {
773
- const gadgetInfo = this.getBackendValue(target, true);
774
- const type = gadgetInfo.get('type');
775
- const Gadget = widgetImporter(type);
776
- const WiredGadget = Widget.Wired(Gadget)(gadgetInfo.get('id'));
777
- return (
778
- <WiredGadget
779
- {...this.props}
780
- parentId={parentId}
781
- widgetId={gadgetInfo.get('id')}
782
- />
783
- );
784
- } else {
785
- return null;
786
- }
787
- };
788
- const DisplayGadget = this.mapWidget(GadgetLoader, 'available', target);
789
-
790
- return <DisplayGadget />;
791
- }
792
-
793
- renderEditTyped() {
794
- const {
795
- show,
796
- labelWrap,
797
- labelGlyph,
798
- labelWidth = defaultLabelWidth,
799
- horizontalSpacing,
800
- verticalSpacing,
801
- verticalJustify,
802
- width,
803
- fieldWidth,
804
- kind,
805
- ...otherProps
806
- } = this.props;
807
-
808
- return (
809
- <LabelRow
810
- show={show}
811
- labelText={this.getLabelText()}
812
- labelWrap={labelWrap}
813
- labelGlyph={labelGlyph}
814
- labelWidth={labelWidth}
815
- horizontalSpacing={horizontalSpacing}
816
- verticalSpacing={verticalSpacing}
817
- verticalJustify={verticalJustify}
818
- width={width}
819
- >
820
- <TextFieldTyped
821
- type={this.getKind()}
822
- shift={this.getShift()}
823
- selectAllOnFocus={true}
824
- width={fieldWidth}
825
- {...otherProps}
826
- tooltip={this.getTooltip()}
827
- />
828
- </LabelRow>
829
- );
830
- }
831
-
832
- renderEditTimeInterval() {
833
- //- const EntityInterval = this.mapWidget(
834
- //- TextFieldTimeInterval,
835
- //- value => {
836
- //- return {entityId: value};
837
- //- },
838
- //- this.getFullPathFromModel('.id')
839
- //- );
840
- //- const StartInterval = this.mapWidget(
841
- //- EntityInterval,
842
- //- value => {
843
- //- return {startValue: value};
844
- //- },
845
- //- this.getFullPathFromModel(this.props.startModel)
846
- //- );
847
- //- const TimeInterval = this.mapWidget(
848
- //- StartInterval,
849
- //- value => {
850
- //- return {endValue: value};
851
- //- },
852
- //- this.getFullPathFromModel(this.props.endModel)
853
- //- );
854
- const {
855
- show,
856
- labelWrap,
857
- labelGlyph,
858
- labelWidth = defaultLabelWidth,
859
- horizontalSpacing,
860
- verticalSpacing,
861
- verticalJustify,
862
- width,
863
- kind,
864
- ...otherProps
865
- } = this.props;
866
-
867
- return (
868
- <LabelRow
869
- show={show}
870
- width={width}
871
- labelText={this.getLabelText()}
872
- labelWrap={labelWrap}
873
- labelGlyph={labelGlyph}
874
- labelWidth={labelWidth}
875
- horizontalSpacing={horizontalSpacing}
876
- verticalSpacing={verticalSpacing}
877
- verticalJustify={verticalJustify}
878
- >
879
- <TextFieldTimeInterval
880
- selectAllOnFocus={true}
881
- {...otherProps}
882
- entityFullPath={this.context.model}
883
- tooltip={this.getTooltip()}
884
- />
885
- </LabelRow>
886
- );
887
- }
888
-
889
- renderEditDateInterval() {
890
- const {
891
- show,
892
- labelWrap,
893
- labelGlyph,
894
- labelWidth = defaultLabelWidth,
895
- horizontalSpacing,
896
- verticalSpacing,
897
- verticalJustify,
898
- width,
899
- kind,
900
- ...otherProps
901
- } = this.props;
902
-
903
- return (
904
- <LabelRow
905
- show={show}
906
- width={width}
907
- labelText={this.getLabelText()}
908
- labelWrap={labelWrap}
909
- labelGlyph={labelGlyph}
910
- labelWidth={labelWidth}
911
- horizontalSpacing={horizontalSpacing}
912
- verticalSpacing={verticalSpacing}
913
- verticalJustify={verticalJustify}
914
- >
915
- <TextFieldDateInterval
916
- selectAllOnFocus={true}
917
- {...otherProps}
918
- entityFullPath={this.context.model}
919
- tooltip={this.getTooltip()}
920
- />
921
- </LabelRow>
922
- );
923
- }
924
-
925
- renderEditCombo() {
926
- return (
927
- <LabelRow
928
- show={this.props.show}
929
- grow={this.props.grow}
930
- width={this.props.width}
931
- height={this.props.height}
932
- labelText={this.getLabelText()}
933
- labelWrap={this.props.labelWrap}
934
- labelGlyph={this.props.labelGlyph}
935
- labelWidth={this.props.labelWidth || defaultLabelWidth}
936
- horizontalSpacing={this.props.horizontalSpacing}
937
- verticalSpacing={this.props.verticalSpacing}
938
- verticalJustify={this.props.verticalJustify}
939
- >
940
- <TextFieldCombo
941
- shape={this.props.shape}
942
- getGlyph={this.props.getGlyph}
943
- hintText={this.props.hintText}
944
- tooltip={this.getTooltip()}
945
- width={this.props.fieldWidth}
946
- selectedId={C(this.props.model)}
947
- readonly={false}
948
- restrictsToList={this.getRestrictsToList()}
949
- required={this.props.required}
950
- list={this.getComboList()}
951
- menuType="wrap"
952
- menuItemWidth={this.props.menuItemWidth}
953
- comboTextTransform="none"
954
- grow="1"
955
- />
956
- </LabelRow>
957
- );
958
- }
959
-
960
- radioListSelectionChanged(index) {
961
- const value =
962
- typeof this.props.list[index] === 'string'
963
- ? this.props.list[index]
964
- : this.props.list[index].value;
965
-
966
- this.setBackendValue(this.fullPath, value);
967
- if (this.props.onChange) {
968
- this.props.onChange(value, index);
969
- }
970
- }
971
-
972
- renderEditRadio() {
973
- const WiredRadioList = this.mapWidget(
974
- RadioList,
975
- (value) => {
976
- if (value && value !== '') {
977
- return {
978
- selectedIndex: this.props.list.findIndex((item) => {
979
- if (typeof item === 'string') {
980
- return item === value;
981
- } else {
982
- return item.value === value;
983
- }
984
- }),
985
- };
986
- } else {
987
- return {};
988
- }
989
- },
990
- this.fullPath
991
- );
992
-
993
- return (
994
- <LabelRow
995
- show={this.props.show}
996
- grow={this.props.grow}
997
- width={this.props.width}
998
- height={this.props.height}
999
- labelGlyph={this.props.labelGlyph}
1000
- labelWidth={this.props.labelWidth || defaultLabelWidth}
1001
- horizontalSpacing={this.props.horizontalSpacing}
1002
- verticalSpacing={this.props.verticalSpacing}
1003
- verticalJustify={this.props.verticalJustify}
1004
- >
1005
- <WiredRadioList
1006
- buttonWidth={this.props.buttonWidth}
1007
- height={this.props.height}
1008
- direction={this.props.direction || 'row'}
1009
- disabled={this.props.disabled}
1010
- list={this.props.list}
1011
- selectionChanged={this.radioListSelectionChanged}
1012
- />
1013
- </LabelRow>
1014
- );
1015
- }
1016
-
1017
- renderCheckList() {
1018
- const WiredCheckList = this.mapWidget(
1019
- CheckList,
1020
- (value) => {
1021
- if (value && value !== '') {
1022
- return {value};
1023
- } else {
1024
- return {};
1025
- }
1026
- },
1027
- this.fullPath
1028
- );
1029
-
1030
- return (
1031
- <LabelRow
1032
- show={this.props.show}
1033
- grow={this.props.grow}
1034
- width={this.props.width}
1035
- height={this.props.height}
1036
- labelText={this.getLabelText()}
1037
- labelWrap={this.props.labelWrap}
1038
- labelGlyph={this.props.labelGlyph}
1039
- labelWidth={this.props.labelWidth || defaultLabelWidth}
1040
- horizontalSpacing={this.props.horizontalSpacing}
1041
- verticalSpacing={this.props.verticalSpacing}
1042
- verticalJustify={this.props.verticalJustify}
1043
- >
1044
- <WiredCheckList
1045
- width={this.props.width}
1046
- height={this.props.height}
1047
- heightStrategy={this.props.heightStrategy || 'compact'}
1048
- look={this.props.look || 'modern'}
1049
- direction={this.props.direction || 'column'}
1050
- showHeader={this.props.showHeader}
1051
- list={this.props.list}
1052
- readonly={this.readonly}
1053
- selectionChanged={(value) => {
1054
- this.setBackendValue(this.fullPath, value);
1055
- }}
1056
- />
1057
- </LabelRow>
1058
- );
1059
- }
1060
-
1061
- renderEditBool() {
1062
- const {
1063
- kind,
1064
- show,
1065
- grow,
1066
- height,
1067
- labelGlyph,
1068
- labelWidth = defaultLabelWidth,
1069
- horizontalSpacing,
1070
- verticalSpacing,
1071
- verticalJustify,
1072
- width,
1073
- subkind,
1074
- ...otherProps
1075
- } = this.props;
1076
-
1077
- return (
1078
- <LabelRow
1079
- show={show}
1080
- grow={grow}
1081
- width={width}
1082
- height={height}
1083
- labelGlyph={labelGlyph}
1084
- labelWidth={labelWidth || defaultLabelWidth}
1085
- horizontalSpacing={horizontalSpacing}
1086
- verticalSpacing={verticalSpacing}
1087
- verticalJustify={verticalJustify}
1088
- >
1089
- <Checkbox
1090
- kind={subkind}
1091
- heightStrategy={verticalSpacing === 'compact' ? 'compact' : null}
1092
- text={this.getLabelText()}
1093
- {...otherProps}
1094
- tooltip={this.getTooltip()}
1095
- />
1096
- </LabelRow>
1097
- );
1098
- }
1099
-
1100
- renderCalendar() {
1101
- const Dynamic = this.mapWidget(
1102
- Calendar,
1103
- (calendar) => {
1104
- // FIXME: calendar is undefined!
1105
- return {
1106
- visibleDate: calendar.get('visibleDate', null),
1107
- startDate: calendar.get('startDate', null),
1108
- endDate: calendar.get('endDate', null),
1109
- dates: calendar.get('dates', []).valueSeq().toArray(),
1110
- badges: calendar.get('badges', []).valueSeq().toArray(),
1111
- };
1112
- },
1113
- this.fullPath
1114
- );
1115
-
1116
- return (
1117
- <Dynamic
1118
- grow="1"
1119
- tooltip={this.getTooltip()}
1120
- dateClicked={this.props.dateClicked}
1121
- visibleDateChanged={this.props.visibleDateChanged}
1122
- monthCount={this.props.monthCount}
1123
- frame={this.props.frame}
1124
- />
1125
- );
1126
- }
1127
-
1128
- renderCalendarBoards() {
1129
- const Dynamic = this.mapWidget(
1130
- CalendarBoards,
1131
- (calendarBoards) => {
1132
- return {
1133
- boards: calendarBoards.get('boards', []).valueSeq().toArray(),
1134
- selectedDate: calendarBoards.get('selectedDate'),
1135
- selectedId: calendarBoards.get('selectedId'),
1136
- };
1137
- },
1138
- this.fullPath
1139
- );
1140
-
1141
- return (
1142
- <Dynamic
1143
- grow="1"
1144
- tooltip={this.getTooltip()}
1145
- onBoardChanged={this.props.onBoardChanged}
1146
- />
1147
- );
1148
- }
1149
-
1150
- renderCalendarRecurrence() {
1151
- const WiredCalendarRecurrence = this.mapWidget(
1152
- CalendarRecurrence,
1153
- (r) => {
1154
- return {
1155
- startDate: r.get('startDate'),
1156
- endDate: r.get('endDate'),
1157
- days: r.get('days'),
1158
- addDates: r.get('addDates'),
1159
- };
1160
- },
1161
- this.fullPath
1162
- );
1163
-
1164
- return (
1165
- <WiredCalendarRecurrence
1166
- readonly={this.readonly}
1167
- dateClicked={(date) => {
1168
- const service = this.context.id.split('@')[0];
1169
- this.doAs(service, 'date-clicked', {
1170
- date,
1171
- });
1172
- }}
1173
- flushAdd={() => {
1174
- const service = this.context.id.split('@')[0];
1175
- this.doAs(service, 'flush-add');
1176
- }}
1177
- />
1178
- );
1179
- }
1180
-
1181
- renderEditEntity() {
1182
- const summary = this.props.summary || 'info';
1183
- const Viewer = (props) => {
1184
- if (!props.entityId) {
1185
- return <Label grow="1" empty={true} />;
1186
- }
1187
- const Info = this.mapWidget(
1188
- Label,
1189
- (entity) => {
1190
- let glyph = 'solid/spinner';
1191
- let glyphColor = null;
1192
- let text = T('chargement...');
1193
- if (entity) {
1194
- glyph = entity.get('meta.summaries.glyph');
1195
- glyphColor = entity.get('meta.summaries.glyphColor');
1196
- text = entity.get(`meta.summaries.${summary}`);
1197
- }
1198
- return {
1199
- glyph,
1200
- glyphColor,
1201
- text,
1202
- };
1203
- },
1204
- `backend.${props.entityId}`
1205
- );
1206
- return <Info userSelect="text" />;
1207
- };
1208
-
1209
- const EntityViewer = this.mapWidget(Viewer, 'entityId', this.fullPath);
1210
-
1211
- return (
1212
- <Container
1213
- kind="row-field"
1214
- subkind="light-box"
1215
- grow={this.props.grow}
1216
- width={this.props.width}
1217
- height={this.props.height}
1218
- horizontalSpacing={this.props.horizontalSpacing}
1219
- verticalSpacing={this.props.verticalSpacing}
1220
- verticalJustify={this.props.verticalJustify}
1221
- >
1222
- <EntityViewer />
1223
- </Container>
1224
- );
1225
- }
1226
-
1227
- renderEditEntities() {
1228
- const pluginProps = getPluginProps(this.props);
1229
- if (this.props.plugin) {
1230
- let WiredPlugin = null;
1231
- let FinalPlugin = null;
1232
- const pluginId = `${this.props.plugin}-plugin@${this.context.id}`;
1233
- if (this.props.pluginType) {
1234
- const CustomPlugin = widgetImporter(`plugin-${this.props.pluginType}`);
1235
- WiredPlugin = Widget.Wired(CustomPlugin)(pluginId);
1236
- FinalPlugin = this.mapWidget(WiredPlugin, 'entityIds', this.fullPath);
1237
- } else {
1238
- FinalPlugin = widgetImporter('plugin');
1239
- }
1240
-
1241
- return (
1242
- <Container
1243
- kind={this.props.containerKind || 'row-field'}
1244
- subkind={this.props.containerSubkind || 'light-box'}
1245
- grow={this.props.grow}
1246
- width={this.props.width}
1247
- height={this.props.height}
1248
- horizontalSpacing={this.props.horizontalSpacing}
1249
- verticalSpacing={this.props.verticalSpacing}
1250
- verticalJustify="top"
1251
- >
1252
- <FinalPlugin
1253
- {...pluginProps}
1254
- id={pluginId}
1255
- dragServiceId={
1256
- this.props.dragServiceId || this.context.dragServiceId
1257
- }
1258
- embeddedLevel={
1259
- this.props.embeddedLevel ? this.props.embeddedLevel + 1 : 1
1260
- }
1261
- />
1262
- </Container>
1263
- );
1264
- } else if (this.props.item) {
1265
- const Items = (props) => {
1266
- if (!props.entityIds) {
1267
- return <Label grow="1" empty={true} />;
1268
- }
1269
- return (
1270
- <Container
1271
- kind="row-field"
1272
- grow={this.props.grow}
1273
- width={this.props.width}
1274
- height={this.props.height}
1275
- horizontalSpacing={this.props.horizontalSpacing}
1276
- verticalSpacing={this.props.verticalSpacing}
1277
- verticalJustify={this.props.verticalJustify}
1278
- >
1279
- {props.entityIds.map((entityId, index) => {
1280
- const Item = this.mapWidget(
1281
- this.props.item,
1282
- (state) => (state ? state : null),
1283
- `backend.${entityId}`
1284
- );
1285
- return <Item key={index} />;
1286
- })}
1287
- </Container>
1288
- );
1289
- };
1290
- const FinalItems = this.mapWidget(Items, 'entityIds', this.fullPath);
1291
- return <FinalItems />;
1292
- } else {
1293
- throw new Error('Property plugin or item is required in this case!');
1294
- }
1295
- }
1296
-
1297
- renderComboIds() {
1298
- const Option = (props) => {
1299
- if (!props.id) {
1300
- return null;
1301
- }
1302
- return <option value={props.id}>{props.text}</option>;
1303
- };
1304
- let targetPath = null;
1305
- if (this.props.targetModel) {
1306
- targetPath = this.getFullPathFromModel(this.props.targetModel);
1307
- }
1308
- const modelTextKey = this.props.modelTextKey || 'meta.summaries.info';
1309
- const ComboIds = (props) => {
1310
- const disabled = this.readonly ? {disabled: true} : null;
1311
- let currentValue = '';
1312
- if (props.currentValue != null) {
1313
- // currentValue is not null nor undefined
1314
- currentValue = props.currentValue;
1315
- } else if (this.props.defaultValue != null) {
1316
- // defaultValue is not null nor undefined
1317
- currentValue = this.props.defaultValue;
1318
- }
1319
- return (
1320
- <select
1321
- value={currentValue}
1322
- style={{
1323
- margin: '0px',
1324
- padding: '0px 10px',
1325
- height: '35px',
1326
- ...props.style,
1327
- }}
1328
- onChange={(event) => {
1329
- if (this.props.onChange) {
1330
- this.props.onChange(event.target.value);
1331
- }
1332
- if (this.props.targetModel) {
1333
- this.setBackendValue(targetPath, event.target.value);
1334
- }
1335
- }}
1336
- {...disabled}
1337
- >
1338
- {props.entityIds.map((entityId, index) => {
1339
- const WiredOption = this.mapWidget(
1340
- Option,
1341
- (state) => {
1342
- const id = state.get('id');
1343
- if (id) {
1344
- return {id, text: state.get(modelTextKey)};
1345
- }
1346
- return null;
1347
- },
1348
- `backend.${entityId}`
1349
- );
1350
- const Item = () =>
1351
- this.buildLoader(entityId, () => <WiredOption />);
1352
- return <Item key={index} />;
1353
- })}
1354
- </select>
1355
- );
1356
- };
1357
-
1358
- let FinalCombo = this.mapWidget(ComboIds, 'entityIds', this.fullPath);
1359
- if (targetPath) {
1360
- FinalCombo = this.mapWidget(FinalCombo, 'currentValue', targetPath);
1361
- }
1362
-
1363
- if (this.props.labelText) {
1364
- return (
1365
- <LabelRow
1366
- show={this.props.show}
1367
- grow={this.props.grow}
1368
- width={this.props.width}
1369
- height={this.props.height}
1370
- labelText={this.getLabelText()}
1371
- labelWrap={this.props.labelWrap}
1372
- labelGlyph={this.props.labelGlyph}
1373
- labelWidth={this.props.labelWidth || defaultLabelWidth}
1374
- horizontalSpacing={this.props.horizontalSpacing}
1375
- verticalSpacing={this.props.verticalSpacing}
1376
- verticalJustify={this.props.verticalJustify}
1377
- disabled={this.props.disabled}
1378
- >
1379
- <FinalCombo style={{flexGrow: 1}} />
1380
- </LabelRow>
1381
- );
1382
- }
1383
-
1384
- return <FinalCombo />;
1385
- }
1386
-
1387
- renderEditHinter() {
1388
- const {
1389
- show,
1390
- labelWrap,
1391
- labelGlyph,
1392
- labelWidth = defaultLabelWidth,
1393
- horizontalSpacing,
1394
- verticalSpacing,
1395
- verticalJustify,
1396
- width,
1397
- fieldWidth,
1398
- kind,
1399
- ...otherProps
1400
- } = this.props;
1401
-
1402
- return (
1403
- <LabelRow
1404
- show={show}
1405
- labelText={this.getLabelText()}
1406
- labelWrap={labelWrap}
1407
- labelGlyph={labelGlyph}
1408
- labelWidth={labelWidth}
1409
- horizontalSpacing={horizontalSpacing}
1410
- verticalSpacing={verticalSpacing}
1411
- verticalJustify={verticalJustify}
1412
- width={width}
1413
- grow={this.props.fieldWidth ? null : '1'}
1414
- >
1415
- <HinterField width={fieldWidth} {...otherProps} />
1416
- </LabelRow>
1417
- );
1418
- }
1419
-
1420
- renderCompleteHinter() {
1421
- const Form = this.Form;
1422
-
1423
- const CompleteHinter = (props) => {
1424
- if (props.content === '') {
1425
- return (
1426
- <LabelRow
1427
- show={this.props.show}
1428
- grow={this.props.grow}
1429
- width={this.props.width}
1430
- height={this.props.height}
1431
- labelText={this.getLabelText()}
1432
- labelWrap={this.props.labelWrap}
1433
- labelGlyph={this.props.labelGlyph}
1434
- labelWidth={this.props.labelWidth || defaultLabelWidth}
1435
- horizontalSpacing={this.props.horizontalSpacing}
1436
- verticalSpacing={this.props.verticalSpacing}
1437
- verticalJustify={this.props.verticalJustify}
1438
- >
1439
- <Form
1440
- {...this.formConfigWithComponent(
1441
- React.forwardRef((props, ref) => (
1442
- <TextField
1443
- ref={ref}
1444
- id={this.context.id}
1445
- shape={
1446
- !this.props.onValue && this.props.enableAdd
1447
- ? 'left-smooth'
1448
- : 'smooth'
1449
- }
1450
- getGlyph={this.props.getGlyph}
1451
- hintText={this.props.hintText}
1452
- tooltip={this.getTooltip()}
1453
- hinter={this.props.hinter}
1454
- comboType={this.props.hinter}
1455
- width={this.props.fieldWidth}
1456
- grow="1"
1457
- requiredHinter={true}
1458
- autocomplete={this.fullPath}
1459
- />
1460
- ))
1461
- )}
1462
- />
1463
- </LabelRow>
1464
- );
1465
- } else {
1466
- return this.renderEditField();
1467
- }
1468
- };
1469
-
1470
- const HinterField = this.mapWidget(
1471
- CompleteHinter,
1472
- 'content',
1473
- this.fullPath
1474
- );
1475
- return <HinterField />;
1476
- }
1477
-
1478
- renderFileInput() {
1479
- const {
1480
- show,
1481
- labelWrap,
1482
- labelGlyph,
1483
- labelWidth = defaultLabelWidth,
1484
- horizontalSpacing,
1485
- verticalSpacing,
1486
- verticalJustify,
1487
- width,
1488
- grow,
1489
- kind,
1490
- ...otherProps
1491
- } = this.props;
1492
- return (
1493
- <LabelRow
1494
- show={show}
1495
- labelText={this.getLabelText()}
1496
- labelWrap={labelWrap}
1497
- labelGlyph={labelGlyph}
1498
- labelWidth={labelWidth}
1499
- horizontalSpacing={horizontalSpacing}
1500
- verticalSpacing={verticalSpacing}
1501
- verticalJustify={verticalJustify}
1502
- width={width}
1503
- grow={grow}
1504
- >
1505
- <FileInput {...otherProps} />
1506
- </LabelRow>
1507
- );
1508
- }
1509
-
1510
- renderDirectoryInput() {
1511
- const {
1512
- show,
1513
- labelWrap,
1514
- labelGlyph,
1515
- labelWidth = defaultLabelWidth,
1516
- horizontalSpacing,
1517
- verticalSpacing,
1518
- verticalJustify,
1519
- width,
1520
- grow,
1521
- kind,
1522
- ...otherProps
1523
- } = this.props;
1524
- return (
1525
- <LabelRow
1526
- show={show}
1527
- labelText={this.getLabelText()}
1528
- labelWrap={labelWrap}
1529
- labelGlyph={labelGlyph}
1530
- labelWidth={labelWidth}
1531
- horizontalSpacing={horizontalSpacing}
1532
- verticalSpacing={verticalSpacing}
1533
- verticalJustify={verticalJustify}
1534
- width={width}
1535
- grow={grow}
1536
- >
1537
- <DirectoryInput {...otherProps} />
1538
- </LabelRow>
1539
- );
1540
- }
1541
-
1542
- renderEditStateBrowser() {
1543
- let {
1544
- show,
1545
- labelWrap,
1546
- labelGlyph,
1547
- labelWidth = defaultLabelWidth,
1548
- horizontalSpacing,
1549
- verticalSpacing,
1550
- verticalJustify,
1551
- width,
1552
- grow,
1553
- value,
1554
- model,
1555
- state,
1556
- path,
1557
- ...otherProps
1558
- } = this.props;
1559
-
1560
- if (model) {
1561
- value = C(model);
1562
- }
1563
- if (path) {
1564
- state = C(path);
1565
- }
1566
-
1567
- return (
1568
- <LabelRow
1569
- show={show}
1570
- labelText={this.getLabelText()}
1571
- labelWrap={labelWrap}
1572
- labelGlyph={labelGlyph}
1573
- labelWidth={labelWidth}
1574
- horizontalSpacing={horizontalSpacing}
1575
- verticalSpacing={verticalSpacing}
1576
- verticalJustify={verticalJustify}
1577
- width={width}
1578
- grow={grow}
1579
- >
1580
- <StateBrowser
1581
- grow={grow}
1582
- value={value}
1583
- state={state}
1584
- path={path}
1585
- {...otherProps}
1586
- />
1587
- </LabelRow>
1588
- );
1589
- }
1590
-
1591
- //#endregion
1592
-
1593
- renderReadonly() {
1594
- switch (this.getKind()) {
1595
- case 'field':
1596
- case 'string':
1597
- return this.renderReadonlyField();
1598
- case 'gadget':
1599
- return this.renderReadonlyGadget();
1600
- case 'date':
1601
- case 'time':
1602
- case 'datetime':
1603
- case 'price':
1604
- case 'weight':
1605
- case 'length':
1606
- case 'pixel':
1607
- case 'volume':
1608
- case 'number':
1609
- case 'integer':
1610
- case 'percent':
1611
- case 'delay':
1612
- case 'color':
1613
- return this.renderReadonlyTyped();
1614
- case 'time-interval':
1615
- return this.renderReadonlyTimeInterval();
1616
- case 'date-interval':
1617
- return this.renderReadonlyDateInterval();
1618
- case 'combo':
1619
- return this.renderReadonlyCombo();
1620
- case 'radio':
1621
- return this.renderReadonlyField();
1622
- case 'check-list':
1623
- return this.renderCheckList();
1624
- case 'bool':
1625
- return this.renderReadonlyBool();
1626
- case 'calendar':
1627
- return this.renderCalendar();
1628
- case 'calendar-boards':
1629
- return this.renderCalendarBoards();
1630
- case 'calendar-recurrence':
1631
- return this.renderCalendarRecurrence();
1632
- case 'hinter':
1633
- return this.renderReadonlyHinter();
1634
- case 'complete-hinter':
1635
- return this.renderReadonlyField();
1636
- case 'file':
1637
- return this.renderFileInput();
1638
- case 'directory':
1639
- return this.renderDirectoryInput();
1640
- case 'id':
1641
- return this.renderReadonlyEntity();
1642
- case 'ids':
1643
- return this.renderReadonlyEntities();
1644
- case 'combo-ids':
1645
- return this.renderComboIds();
1646
- case 'translatable':
1647
- return this.renderReadonlyTranslatable();
1648
- case 'state-browser':
1649
- return this.renderEditStateBrowser();
1650
- case 'label':
1651
- return (
1652
- <ReadonlyLabel
1653
- defaultLabelWidth={defaultLabelWidth}
1654
- fullpath={this.fullPath}
1655
- {...this.props}
1656
- />
1657
- );
1658
- default:
1659
- return this.renderReadonlyField();
1660
- }
1661
- }
1662
-
1663
- renderEdit() {
1664
- switch (this.getKind()) {
1665
- case 'field':
1666
- case 'string':
1667
- return this.renderEditField();
1668
- case 'gadget':
1669
- return this.renderEditGadget();
1670
- case 'date':
1671
- case 'time':
1672
- case 'datetime':
1673
- case 'price':
1674
- case 'weight':
1675
- case 'length':
1676
- case 'pixel':
1677
- case 'volume':
1678
- case 'number':
1679
- case 'integer':
1680
- case 'percent':
1681
- case 'delay':
1682
- case 'color':
1683
- return this.renderEditTyped();
1684
- case 'time-interval':
1685
- return this.renderEditTimeInterval();
1686
- case 'date-interval':
1687
- return this.renderEditDateInterval();
1688
- case 'combo':
1689
- return this.renderEditCombo();
1690
- case 'radio':
1691
- return this.renderEditRadio();
1692
- case 'check-list':
1693
- return this.renderCheckList();
1694
- case 'bool':
1695
- return this.renderEditBool();
1696
- case 'calendar':
1697
- return this.renderCalendar();
1698
- case 'calendar-boards':
1699
- return this.renderCalendarBoards();
1700
- case 'calendar-recurrence':
1701
- return this.renderCalendarRecurrence();
1702
- case 'hinter':
1703
- return this.renderEditHinter();
1704
- case 'complete-hinter':
1705
- return this.renderCompleteHinter();
1706
- case 'file':
1707
- return this.renderFileInput();
1708
- case 'directory':
1709
- return this.renderDirectoryInput();
1710
- case 'id':
1711
- return this.renderEditEntity();
1712
- case 'ids':
1713
- return this.renderEditEntities();
1714
- case 'combo-ids':
1715
- return this.renderComboIds();
1716
- case 'translatable':
1717
- return this.renderEditTranslatable();
1718
- case 'state-browser':
1719
- return this.renderEditStateBrowser();
1720
- case 'label':
1721
- return (
1722
- <ReadonlyLabel
1723
- defaultLabelWidth={defaultLabelWidth}
1724
- fullpath={this.fullPath}
1725
- {...this.props}
1726
- />
1727
- );
1728
- default:
1729
- return this.renderEditField();
1730
- }
1731
- }
1732
-
1733
- render() {
1734
- if (this.readonly) {
1735
- return this.renderReadonly();
1736
- } else {
1737
- return this.renderEdit();
1738
- }
1739
- }
1740
- }
1741
-
1742
- /******************************************************************************/
1743
- export default Field;
1
+ //T:2019-02-27
2
+
3
+ import React from 'react';
4
+ import Form from 'goblin-laboratory/widgets/form';
5
+ import Widget from 'goblin-laboratory/widgets/widget';
6
+ import T from 't';
7
+ import C from 'goblin-laboratory/widgets/connect-helpers/c';
8
+
9
+ /******************************************************************************/
10
+ //migrated
11
+ import ReadonlyLabel from './readonly/label.js';
12
+ /******************************************************************************/
13
+
14
+ import Container from 'goblin-gadgets/widgets/container/widget';
15
+ import Button from 'goblin-gadgets/widgets/button/widget';
16
+ import Checkbox from 'goblin-gadgets/widgets/checkbox/widget';
17
+ import Label from 'goblin-gadgets/widgets/label/widget';
18
+ import TextField from 'goblin-gadgets/widgets/text-field/widget';
19
+ import TranslatableTextField from 'goblin-gadgets/widgets/translatable-text-field/widget';
20
+ import LabelRow from 'goblin-gadgets/widgets/label-row/widget';
21
+ import TextFieldTyped from 'goblin-gadgets/widgets/text-field-typed/widget';
22
+ import TextFieldCombo from 'goblin-gadgets/widgets/text-field-combo/widget';
23
+ import TextFieldTimeInterval from 'goblin-gadgets/widgets/text-field-time-interval/widget';
24
+ import TextFieldDateInterval from 'goblin-gadgets/widgets/text-field-date-interval/widget';
25
+ import RadioList from 'goblin-gadgets/widgets/radio-list/widget';
26
+ import CheckList from 'goblin-gadgets/widgets/check-list/widget';
27
+ import CalendarRecurrence from 'goblin-gadgets/widgets/calendar-recurrence/widget';
28
+ import Calendar from 'goblin-gadgets/widgets/calendar/widget';
29
+ import CalendarBoards from 'goblin-gadgets/widgets/calendar-boards/widget';
30
+ import FileInput from 'goblin-gadgets/widgets/file-input/widget';
31
+ import DirectoryInput from 'goblin-gadgets/widgets/directory-input/widget';
32
+ import StateBrowser from 'goblin-gadgets/widgets/state-browser/widget';
33
+
34
+ import SchemaHelpers from 'goblin-toolbox/lib/schema-helpers';
35
+
36
+ import importer from 'goblin_importer';
37
+ import HinterField from 'goblin-gadgets/widgets/hinter-field/widget';
38
+ const widgetImporter = importer('widget');
39
+
40
+ /******************************************************************************/
41
+
42
+ const defaultLabelWidth = '120px';
43
+ const pluginBlackListedProps = [
44
+ 'kind',
45
+ 'containerKind',
46
+ 'plugin',
47
+ 'mode',
48
+ 'grow',
49
+ 'width',
50
+ 'height',
51
+ 'verticalSpacing',
52
+ 'verticalJustify',
53
+ 'dragServiceId',
54
+ 'embeddedLevel',
55
+ ];
56
+
57
+ function getPluginProps(propsToFilter) {
58
+ return Object.entries(propsToFilter).reduce((props, [key, value]) => {
59
+ if (!pluginBlackListedProps.includes(key)) {
60
+ props[key] = value;
61
+ }
62
+ return props;
63
+ }, {});
64
+ }
65
+
66
+ /******************************************************************************/
67
+
68
+ class Field extends Form {
69
+ constructor() {
70
+ super(...arguments);
71
+
72
+ this.radioListSelectionChanged = this.radioListSelectionChanged.bind(this);
73
+ this.isShowed = this.isShowed.bind(this);
74
+ }
75
+
76
+ get readonly() {
77
+ return this.props.readonly || this.context.readonly;
78
+ }
79
+
80
+ getFullPathFromModel(model) {
81
+ if (!this.context.model) {
82
+ throw new Error(
83
+ 'Cannot resolve context model, your Field is not in a Form ?'
84
+ );
85
+ }
86
+ return `${this.context.model}${model}`;
87
+ }
88
+
89
+ get fullPath() {
90
+ return this.getFullPathFromModel(this.props.model);
91
+ }
92
+
93
+ isShowed(value) {
94
+ return Boolean(this.props.showStrategy === 'alwaysVisible' || value);
95
+ }
96
+
97
+ getEntitySchema() {
98
+ const entityId = this.context.entityId; // by example "portfolio@e564950b-cd9f-4d35-abd0-b85bf93017f1"
99
+ if (entityId) {
100
+ const entityType = entityId.split('@', 2)[0]; // by example "portfolio"
101
+ return this.getSchema(entityType);
102
+ }
103
+ return null;
104
+ }
105
+
106
+ getKind() {
107
+ if (this.props.kind) {
108
+ return this.props.kind;
109
+ } else {
110
+ return SchemaHelpers.getKind(this.getEntitySchema(), this.props.model);
111
+ }
112
+ }
113
+
114
+ getShift() {
115
+ if (this.props.shift) {
116
+ return this.props.shift;
117
+ } else {
118
+ return SchemaHelpers.getShift(this.getEntitySchema(), this.props.model);
119
+ }
120
+ }
121
+
122
+ getComboList() {
123
+ if (this.props.listModel) {
124
+ return C(this.props.listModel);
125
+ } else if (this.props.list) {
126
+ return this.props.list;
127
+ } else {
128
+ return SchemaHelpers.getComboList(
129
+ this.getEntitySchema(),
130
+ this.props.model
131
+ );
132
+ }
133
+ }
134
+
135
+ getRestrictsToList() {
136
+ if (this.props.listModel || this.props.list) {
137
+ return this.props.restrictsToList;
138
+ } else {
139
+ const list = SchemaHelpers.getComboList(
140
+ this.getEntitySchema(),
141
+ this.props.model
142
+ );
143
+ return !!list;
144
+ }
145
+ }
146
+
147
+ getLabelText() {
148
+ if (this.props.labelText) {
149
+ return this.props.labelText;
150
+ } else {
151
+ return SchemaHelpers.getLabelText(
152
+ this.getEntitySchema(),
153
+ this.props.model
154
+ );
155
+ }
156
+ }
157
+
158
+ getTooltip() {
159
+ let tooltip = this.props.tooltip || this.props.hintText;
160
+ if (!tooltip) {
161
+ tooltip = SchemaHelpers.getTooltip(
162
+ this.getEntitySchema(),
163
+ this.props.model
164
+ );
165
+ }
166
+ return tooltip;
167
+ }
168
+
169
+ /******************************************************************************/
170
+
171
+ //#region Readonly
172
+ renderReadonlyField() {
173
+ const {
174
+ show = C(this.props.model, this.isShowed),
175
+ labelWrap,
176
+ labelGlyph,
177
+ labelWidth = defaultLabelWidth,
178
+ horizontalSpacing,
179
+ verticalSpacing,
180
+ verticalJustify,
181
+ width,
182
+ grow,
183
+ fieldWidth,
184
+ kind,
185
+ ...otherProps
186
+ } = this.props;
187
+
188
+ return (
189
+ <LabelRow
190
+ show={show}
191
+ labelText={this.getLabelText()}
192
+ labelWrap={labelWrap}
193
+ labelGlyph={labelGlyph}
194
+ labelWidth={labelWidth}
195
+ horizontalSpacing={horizontalSpacing}
196
+ verticalSpacing={verticalSpacing}
197
+ verticalJustify={verticalJustify}
198
+ width={width}
199
+ grow={grow || (fieldWidth ? null : '1')}
200
+ >
201
+ <TextField
202
+ type={this.getKind()}
203
+ selectAllOnFocus={true}
204
+ width={fieldWidth}
205
+ grow={fieldWidth ? null : '1'}
206
+ {...otherProps}
207
+ readonly={true}
208
+ tooltip={this.getTooltip()}
209
+ />
210
+ </LabelRow>
211
+ );
212
+ }
213
+
214
+ renderReadonlyTranslatable() {
215
+ const {
216
+ show = C(this.props.model, this.isShowed),
217
+ labelWrap,
218
+ labelGlyph,
219
+ labelWidth = defaultLabelWidth,
220
+ horizontalSpacing,
221
+ verticalSpacing,
222
+ verticalJustify,
223
+ width,
224
+ grow,
225
+ fieldWidth,
226
+ kind,
227
+ ...otherProps
228
+ } = this.props;
229
+
230
+ return (
231
+ <LabelRow
232
+ show={show}
233
+ labelText={this.getLabelText()}
234
+ labelWrap={labelWrap}
235
+ labelGlyph={labelGlyph}
236
+ labelWidth={labelWidth}
237
+ horizontalSpacing={horizontalSpacing}
238
+ verticalSpacing={verticalSpacing}
239
+ verticalJustify={verticalJustify}
240
+ width={width}
241
+ grow={grow || (fieldWidth ? null : '1')}
242
+ >
243
+ <TranslatableTextField
244
+ type={this.getKind()}
245
+ selectAllOnFocus={true}
246
+ width={fieldWidth}
247
+ grow={fieldWidth ? null : '1'}
248
+ {...otherProps}
249
+ readonly={true}
250
+ tooltip={this.getTooltip()}
251
+ />
252
+ </LabelRow>
253
+ );
254
+ }
255
+
256
+ renderReadonlyGadget() {
257
+ const target = this.context.id
258
+ ? `backend.${this.context.id}.gadgets.${this.props.name}`
259
+ : `${this.context.model}.gadgets.${this.props.name}`;
260
+
261
+ const parentId = this.context.id || this.context.model;
262
+
263
+ const GadgetLoader = (props) => {
264
+ if (props.available) {
265
+ const gadgetInfo = this.getBackendValue(target, true);
266
+ const type = gadgetInfo.get('type');
267
+ const Gadget = widgetImporter(type);
268
+ const WiredGadget = Widget.Wired(Gadget)(gadgetInfo.get('id'));
269
+ return (
270
+ <WiredGadget
271
+ readonly={true}
272
+ {...this.props}
273
+ widgetId={gadgetInfo.get('id')}
274
+ parentId={parentId}
275
+ />
276
+ );
277
+ } else {
278
+ return null;
279
+ }
280
+ };
281
+ const DisplayGadget = this.mapWidget(GadgetLoader, 'available', target);
282
+
283
+ return <DisplayGadget />;
284
+ }
285
+
286
+ renderReadonlyTyped() {
287
+ const {
288
+ show = C(this.props.model, this.isShowed),
289
+ labelWrap,
290
+ labelGlyph,
291
+ labelWidth = defaultLabelWidth,
292
+ horizontalSpacing,
293
+ verticalSpacing,
294
+ verticalJustify,
295
+ width,
296
+ fieldWidth,
297
+ kind,
298
+ ...otherProps
299
+ } = this.props;
300
+
301
+ return (
302
+ <LabelRow
303
+ show={show}
304
+ labelText={this.getLabelText()}
305
+ labelWrap={labelWrap}
306
+ labelGlyph={labelGlyph}
307
+ labelWidth={labelWidth}
308
+ horizontalSpacing={horizontalSpacing}
309
+ verticalSpacing={verticalSpacing}
310
+ verticalJustify={verticalJustify}
311
+ width={width}
312
+ >
313
+ <TextFieldTyped
314
+ type={this.getKind()}
315
+ shift={this.getShift()}
316
+ selectAllOnFocus={true}
317
+ width={fieldWidth}
318
+ {...otherProps}
319
+ readonly={true}
320
+ tooltip={this.getTooltip()}
321
+ />
322
+ </LabelRow>
323
+ );
324
+ }
325
+
326
+ renderReadonlyTimeInterval() {
327
+ const {
328
+ show,
329
+ labelWrap,
330
+ labelGlyph,
331
+ labelWidth = defaultLabelWidth,
332
+ horizontalSpacing,
333
+ verticalSpacing,
334
+ verticalJustify,
335
+ width,
336
+ kind,
337
+ ...otherProps
338
+ } = this.props;
339
+
340
+ return (
341
+ <LabelRow
342
+ show={show}
343
+ width={width}
344
+ labelText={this.getLabelText()}
345
+ labelWrap={labelWrap}
346
+ labelGlyph={labelGlyph}
347
+ labelWidth={labelWidth}
348
+ horizontalSpacing={horizontalSpacing}
349
+ verticalSpacing={verticalSpacing}
350
+ verticalJustify={verticalJustify}
351
+ >
352
+ <TextFieldTimeInterval
353
+ selectAllOnFocus={true}
354
+ {...otherProps}
355
+ readonly={true}
356
+ entityFullPath={this.context.model}
357
+ tooltip={this.getTooltip()}
358
+ />
359
+ </LabelRow>
360
+ );
361
+ }
362
+
363
+ renderReadonlyDateInterval() {
364
+ const {
365
+ show,
366
+ labelWrap,
367
+ labelGlyph,
368
+ labelWidth = defaultLabelWidth,
369
+ horizontalSpacing,
370
+ verticalSpacing,
371
+ verticalJustify,
372
+ width,
373
+ kind,
374
+ ...otherProps
375
+ } = this.props;
376
+
377
+ return (
378
+ <LabelRow
379
+ show={show}
380
+ width={width}
381
+ labelText={this.getLabelText()}
382
+ labelWrap={labelWrap}
383
+ labelGlyph={labelGlyph}
384
+ labelWidth={labelWidth}
385
+ horizontalSpacing={horizontalSpacing}
386
+ verticalSpacing={verticalSpacing}
387
+ verticalJustify={verticalJustify}
388
+ >
389
+ <TextFieldDateInterval
390
+ selectAllOnFocus={true}
391
+ {...otherProps}
392
+ readonly={true}
393
+ entityFullPath={this.context.model}
394
+ tooltip={this.getTooltip()}
395
+ />
396
+ </LabelRow>
397
+ );
398
+ }
399
+
400
+ renderReadonlyCombo() {
401
+ return (
402
+ <LabelRow
403
+ show={this.props.show}
404
+ grow={this.props.grow}
405
+ width={this.props.width}
406
+ height={this.props.height}
407
+ labelText={this.getLabelText()}
408
+ labelWrap={this.props.labelWrap}
409
+ labelGlyph={this.props.labelGlyph}
410
+ labelWidth={this.props.labelWidth || defaultLabelWidth}
411
+ horizontalSpacing={this.props.horizontalSpacing}
412
+ verticalSpacing={this.props.verticalSpacing}
413
+ verticalJustify={this.props.verticalJustify}
414
+ >
415
+ <TextFieldCombo
416
+ selectAllOnFocus={true}
417
+ shape={this.props.shape}
418
+ getGlyph={this.props.getGlyph}
419
+ hintText={this.props.hintText}
420
+ tooltip={this.getTooltip()}
421
+ width={this.props.fieldWidth}
422
+ hideButtonCombo={this.props.hideButtonCombo}
423
+ selectedId={
424
+ this.props.selectedId ? this.props.selectedId : C(this.props.model)
425
+ }
426
+ readonly={true}
427
+ restrictsToList={this.getRestrictsToList()}
428
+ required={this.props.required}
429
+ list={this.getComboList()}
430
+ menuType="wrap"
431
+ menuItemWidth={this.props.menuItemWidth}
432
+ comboTextTransform="none"
433
+ grow="1"
434
+ />
435
+ </LabelRow>
436
+ );
437
+ }
438
+
439
+ renderReadonlyBool() {
440
+ const {
441
+ kind,
442
+ show,
443
+ grow,
444
+ height,
445
+ labelGlyph,
446
+ labelWidth = defaultLabelWidth,
447
+ horizontalSpacing,
448
+ verticalSpacing,
449
+ verticalJustify,
450
+ width,
451
+ subkind,
452
+ ...otherProps
453
+ } = this.props;
454
+
455
+ return (
456
+ <LabelRow
457
+ show={show}
458
+ grow={grow}
459
+ width={width}
460
+ height={height}
461
+ labelGlyph={labelGlyph}
462
+ labelWidth={labelWidth || defaultLabelWidth}
463
+ horizontalSpacing={horizontalSpacing}
464
+ verticalSpacing={verticalSpacing}
465
+ verticalJustify={verticalJustify}
466
+ >
467
+ <Checkbox
468
+ kind={subkind}
469
+ text={this.getLabelText()}
470
+ {...otherProps}
471
+ tooltip={this.getTooltip()}
472
+ readonly={true}
473
+ />
474
+ </LabelRow>
475
+ );
476
+ }
477
+
478
+ renderReadonlyHinter() {
479
+ const {
480
+ show = C(this.props.model, this.isShowed),
481
+ labelWrap,
482
+ labelGlyph,
483
+ labelWidth = defaultLabelWidth,
484
+ horizontalSpacing,
485
+ verticalSpacing,
486
+ verticalJustify,
487
+ width,
488
+ fieldWidth,
489
+ kind,
490
+ ...otherProps
491
+ } = this.props;
492
+
493
+ return (
494
+ <LabelRow
495
+ show={show}
496
+ labelText={this.getLabelText()}
497
+ labelWrap={labelWrap}
498
+ labelGlyph={labelGlyph}
499
+ labelWidth={labelWidth}
500
+ horizontalSpacing={horizontalSpacing}
501
+ verticalSpacing={verticalSpacing}
502
+ verticalJustify={verticalJustify}
503
+ width={width}
504
+ grow={this.props.fieldWidth ? null : '1'}
505
+ >
506
+ <HinterField width={fieldWidth} {...otherProps} readonly={true} />
507
+ </LabelRow>
508
+ );
509
+ }
510
+
511
+ renderReadonlyEntity() {
512
+ const summary = this.props.summary || 'info';
513
+ const Viewer = (props) => {
514
+ if (!props.entityId) {
515
+ return (
516
+ <Label
517
+ grow="1"
518
+ empty={true}
519
+ horizontalSpacing={this.props.horizontalSpacing}
520
+ />
521
+ );
522
+ }
523
+ const Info = this.mapWidget(
524
+ Label,
525
+ (entity) => {
526
+ let glyph = 'solid/spinner';
527
+ let glyphColor = null;
528
+ let text = T('Chargement...');
529
+ if (entity) {
530
+ glyph = entity.get('meta.summaries.glyph');
531
+ glyphColor = entity.get('meta.summaries.glyphColor');
532
+ text = entity.get(`meta.summaries.${summary}`);
533
+ }
534
+ return {
535
+ kind: 'combo-text-markdown',
536
+ glyph,
537
+ glyphColor,
538
+ text,
539
+ grow: '1',
540
+ justify: this.props.justify,
541
+ wrap: this.props.wrap,
542
+ };
543
+ },
544
+ `backend.${props.entityId}`
545
+ );
546
+ return <Info userSelect="text" />;
547
+ };
548
+
549
+ const Action = (props) => {
550
+ const openEntityWorkitem = () => {
551
+ const service = this.context.id.split('@')[0];
552
+ this.doAs(service, 'open-entity-workitem', {
553
+ entityId: props.entityId,
554
+ desktopId: this.context.desktopId,
555
+ });
556
+ };
557
+
558
+ return !!props.entityId && !this.props.disableAdd ? (
559
+ <Button
560
+ kind="combo"
561
+ shape="right-smooth"
562
+ leftSpacing="overlap"
563
+ horizontalSpacing={this.props.horizontalSpacing}
564
+ glyph="solid/pencil"
565
+ tooltip={T('Editer')}
566
+ onClick={openEntityWorkitem}
567
+ />
568
+ ) : null;
569
+ };
570
+
571
+ const EntityViewer = this.mapWidget(Viewer, 'entityId', this.fullPath);
572
+ const EntityAction = this.mapWidget(Action, 'entityId', this.fullPath);
573
+
574
+ return (
575
+ <LabelRow
576
+ show={this.props.show}
577
+ grow={this.props.grow}
578
+ width={this.props.width}
579
+ height={this.props.height}
580
+ labelText={this.getLabelText()}
581
+ labelWrap={this.props.labelWrap}
582
+ labelGlyph={this.props.labelGlyph}
583
+ labelWidth={this.props.labelWidth || defaultLabelWidth}
584
+ horizontalSpacing={this.props.horizontalSpacing}
585
+ verticalSpacing={this.props.verticalSpacing}
586
+ verticalJustify={this.props.verticalJustify}
587
+ >
588
+ <EntityViewer />
589
+ <EntityAction />
590
+ </LabelRow>
591
+ );
592
+ }
593
+
594
+ renderReadonlyEntities() {
595
+ const pluginProps = getPluginProps(this.props);
596
+ if (this.props.plugin) {
597
+ let WiredPlugin = null;
598
+ let FinalPlugin = null;
599
+ if (this.props.pluginType) {
600
+ const CustomPlugin = widgetImporter(`plugin-${this.props.pluginType}`);
601
+ WiredPlugin = Widget.Wired(CustomPlugin)(
602
+ `${this.props.plugin}-plugin@${this.context.id}`
603
+ );
604
+ FinalPlugin = this.mapWidget(WiredPlugin, 'entityIds', this.fullPath);
605
+ } else {
606
+ FinalPlugin = widgetImporter('plugin');
607
+ }
608
+
609
+ const FinalContainer = this.mapWidget(
610
+ Container,
611
+ (value) => {
612
+ const length = value ? value.length : 0;
613
+ const embedded = this.props.embedded;
614
+ const show = length > 0 || !embedded;
615
+ return {show};
616
+ },
617
+ this.fullPath
618
+ );
619
+
620
+ return (
621
+ <FinalContainer
622
+ kind={this.props.containerKind || 'row-field'}
623
+ subkind={this.props.containerSubkind || 'light-box'}
624
+ grow={this.props.grow}
625
+ width={this.props.width}
626
+ height={this.props.height}
627
+ verticalSpacing={this.props.verticalSpacing}
628
+ verticalJustify={this.props.verticalJustify}
629
+ >
630
+ <FinalPlugin
631
+ {...pluginProps}
632
+ id={`${this.props.plugin}-plugin@${this.context.id}`}
633
+ readonly={true}
634
+ embeddedLevel={
635
+ this.props.embeddedLevel ? this.props.embeddedLevel + 1 : 1
636
+ }
637
+ dragServiceId={
638
+ this.props.dragServiceId || this.context.dragServiceId
639
+ }
640
+ />
641
+ </FinalContainer>
642
+ );
643
+ } else if (this.props.item) {
644
+ const Items = (props) => {
645
+ if (!props.entityIds) {
646
+ return (
647
+ <Label
648
+ grow="1"
649
+ empty={true}
650
+ horizontalSpacing={this.props.horizontalSpacing}
651
+ />
652
+ );
653
+ }
654
+ return (
655
+ <Container
656
+ kind="row-field"
657
+ grow={this.props.grow}
658
+ width={this.props.width}
659
+ height={this.props.height}
660
+ verticalSpacing={this.props.verticalSpacing}
661
+ verticalJustify={this.props.verticalJustify}
662
+ >
663
+ {props.entityIds.map((entityId, index) => {
664
+ const Item = this.mapWidget(
665
+ this.props.item,
666
+ (state) => (state ? state : null),
667
+ `backend.${entityId}`
668
+ );
669
+ return <Item key={index} />;
670
+ })}
671
+ </Container>
672
+ );
673
+ };
674
+ const FinalItems = this.mapWidget(Items, 'entityIds', this.fullPath);
675
+ return <FinalItems />;
676
+ } else {
677
+ throw new Error('Property plugin is required in this case!');
678
+ }
679
+ }
680
+ //#endregion
681
+
682
+ //#region Edit
683
+ renderEditField() {
684
+ const {
685
+ show,
686
+ labelWrap,
687
+ labelGlyph,
688
+ labelWidth = defaultLabelWidth,
689
+ horizontalSpacing,
690
+ verticalSpacing,
691
+ verticalJustify,
692
+ width,
693
+ grow,
694
+ fieldWidth,
695
+ kind,
696
+ ...otherProps
697
+ } = this.props;
698
+
699
+ return (
700
+ <LabelRow
701
+ show={show}
702
+ labelText={this.getLabelText()}
703
+ labelWrap={labelWrap}
704
+ labelGlyph={labelGlyph}
705
+ labelWidth={labelWidth}
706
+ horizontalSpacing={horizontalSpacing}
707
+ verticalSpacing={verticalSpacing}
708
+ verticalJustify={verticalJustify}
709
+ width={width}
710
+ grow={grow || (fieldWidth ? null : '1')}
711
+ >
712
+ <TextField
713
+ type={this.getKind()}
714
+ width={fieldWidth}
715
+ grow={fieldWidth ? null : '1'}
716
+ {...otherProps}
717
+ tooltip={this.getTooltip()}
718
+ />
719
+ </LabelRow>
720
+ );
721
+ }
722
+
723
+ renderEditTranslatable() {
724
+ const {
725
+ show,
726
+ labelWrap,
727
+ labelGlyph,
728
+ labelWidth = defaultLabelWidth,
729
+ horizontalSpacing,
730
+ verticalSpacing,
731
+ verticalJustify,
732
+ width,
733
+ grow,
734
+ fieldWidth,
735
+ kind,
736
+ type,
737
+ ...otherProps
738
+ } = this.props;
739
+
740
+ return (
741
+ <LabelRow
742
+ show={show}
743
+ labelText={this.getLabelText()}
744
+ labelWrap={labelWrap}
745
+ labelGlyph={labelGlyph}
746
+ labelWidth={labelWidth}
747
+ horizontalSpacing={horizontalSpacing}
748
+ verticalSpacing={verticalSpacing}
749
+ verticalJustify={verticalJustify}
750
+ width={width}
751
+ grow={grow || (fieldWidth ? null : '1')}
752
+ >
753
+ <TranslatableTextField
754
+ type={this.getKind()}
755
+ width={fieldWidth}
756
+ grow={fieldWidth ? null : '1'}
757
+ {...otherProps}
758
+ tooltip={this.getTooltip()}
759
+ />
760
+ </LabelRow>
761
+ );
762
+ }
763
+
764
+ renderEditGadget() {
765
+ const target = this.context.id
766
+ ? `backend.${this.context.id}.gadgets.${this.props.name}`
767
+ : `${this.context.model}.gadgets.${this.props.name}`;
768
+
769
+ const parentId = this.context.id || this.context.model;
770
+
771
+ const GadgetLoader = (props) => {
772
+ if (props.available) {
773
+ const gadgetInfo = this.getBackendValue(target, true);
774
+ const type = gadgetInfo.get('type');
775
+ const Gadget = widgetImporter(type);
776
+ const WiredGadget = Widget.Wired(Gadget)(gadgetInfo.get('id'));
777
+ return (
778
+ <WiredGadget
779
+ {...this.props}
780
+ parentId={parentId}
781
+ widgetId={gadgetInfo.get('id')}
782
+ />
783
+ );
784
+ } else {
785
+ return null;
786
+ }
787
+ };
788
+ const DisplayGadget = this.mapWidget(GadgetLoader, 'available', target);
789
+
790
+ return <DisplayGadget />;
791
+ }
792
+
793
+ renderEditTyped() {
794
+ const {
795
+ show,
796
+ labelWrap,
797
+ labelGlyph,
798
+ labelWidth = defaultLabelWidth,
799
+ horizontalSpacing,
800
+ verticalSpacing,
801
+ verticalJustify,
802
+ width,
803
+ fieldWidth,
804
+ kind,
805
+ ...otherProps
806
+ } = this.props;
807
+
808
+ return (
809
+ <LabelRow
810
+ show={show}
811
+ labelText={this.getLabelText()}
812
+ labelWrap={labelWrap}
813
+ labelGlyph={labelGlyph}
814
+ labelWidth={labelWidth}
815
+ horizontalSpacing={horizontalSpacing}
816
+ verticalSpacing={verticalSpacing}
817
+ verticalJustify={verticalJustify}
818
+ width={width}
819
+ >
820
+ <TextFieldTyped
821
+ type={this.getKind()}
822
+ shift={this.getShift()}
823
+ selectAllOnFocus={true}
824
+ width={fieldWidth}
825
+ {...otherProps}
826
+ tooltip={this.getTooltip()}
827
+ />
828
+ </LabelRow>
829
+ );
830
+ }
831
+
832
+ renderEditTimeInterval() {
833
+ //- const EntityInterval = this.mapWidget(
834
+ //- TextFieldTimeInterval,
835
+ //- value => {
836
+ //- return {entityId: value};
837
+ //- },
838
+ //- this.getFullPathFromModel('.id')
839
+ //- );
840
+ //- const StartInterval = this.mapWidget(
841
+ //- EntityInterval,
842
+ //- value => {
843
+ //- return {startValue: value};
844
+ //- },
845
+ //- this.getFullPathFromModel(this.props.startModel)
846
+ //- );
847
+ //- const TimeInterval = this.mapWidget(
848
+ //- StartInterval,
849
+ //- value => {
850
+ //- return {endValue: value};
851
+ //- },
852
+ //- this.getFullPathFromModel(this.props.endModel)
853
+ //- );
854
+ const {
855
+ show,
856
+ labelWrap,
857
+ labelGlyph,
858
+ labelWidth = defaultLabelWidth,
859
+ horizontalSpacing,
860
+ verticalSpacing,
861
+ verticalJustify,
862
+ width,
863
+ kind,
864
+ ...otherProps
865
+ } = this.props;
866
+
867
+ return (
868
+ <LabelRow
869
+ show={show}
870
+ width={width}
871
+ labelText={this.getLabelText()}
872
+ labelWrap={labelWrap}
873
+ labelGlyph={labelGlyph}
874
+ labelWidth={labelWidth}
875
+ horizontalSpacing={horizontalSpacing}
876
+ verticalSpacing={verticalSpacing}
877
+ verticalJustify={verticalJustify}
878
+ >
879
+ <TextFieldTimeInterval
880
+ selectAllOnFocus={true}
881
+ {...otherProps}
882
+ entityFullPath={this.context.model}
883
+ tooltip={this.getTooltip()}
884
+ />
885
+ </LabelRow>
886
+ );
887
+ }
888
+
889
+ renderEditDateInterval() {
890
+ const {
891
+ show,
892
+ labelWrap,
893
+ labelGlyph,
894
+ labelWidth = defaultLabelWidth,
895
+ horizontalSpacing,
896
+ verticalSpacing,
897
+ verticalJustify,
898
+ width,
899
+ kind,
900
+ ...otherProps
901
+ } = this.props;
902
+
903
+ return (
904
+ <LabelRow
905
+ show={show}
906
+ width={width}
907
+ labelText={this.getLabelText()}
908
+ labelWrap={labelWrap}
909
+ labelGlyph={labelGlyph}
910
+ labelWidth={labelWidth}
911
+ horizontalSpacing={horizontalSpacing}
912
+ verticalSpacing={verticalSpacing}
913
+ verticalJustify={verticalJustify}
914
+ >
915
+ <TextFieldDateInterval
916
+ selectAllOnFocus={true}
917
+ {...otherProps}
918
+ entityFullPath={this.context.model}
919
+ tooltip={this.getTooltip()}
920
+ />
921
+ </LabelRow>
922
+ );
923
+ }
924
+
925
+ renderEditCombo() {
926
+ return (
927
+ <LabelRow
928
+ show={this.props.show}
929
+ grow={this.props.grow}
930
+ width={this.props.width}
931
+ height={this.props.height}
932
+ labelText={this.getLabelText()}
933
+ labelWrap={this.props.labelWrap}
934
+ labelGlyph={this.props.labelGlyph}
935
+ labelWidth={this.props.labelWidth || defaultLabelWidth}
936
+ horizontalSpacing={this.props.horizontalSpacing}
937
+ verticalSpacing={this.props.verticalSpacing}
938
+ verticalJustify={this.props.verticalJustify}
939
+ >
940
+ <TextFieldCombo
941
+ shape={this.props.shape}
942
+ getGlyph={this.props.getGlyph}
943
+ hintText={this.props.hintText}
944
+ tooltip={this.getTooltip()}
945
+ width={this.props.fieldWidth}
946
+ selectedId={C(this.props.model)}
947
+ readonly={false}
948
+ restrictsToList={this.getRestrictsToList()}
949
+ required={this.props.required}
950
+ list={this.getComboList()}
951
+ menuType="wrap"
952
+ menuItemWidth={this.props.menuItemWidth}
953
+ comboTextTransform="none"
954
+ grow="1"
955
+ />
956
+ </LabelRow>
957
+ );
958
+ }
959
+
960
+ radioListSelectionChanged(index) {
961
+ const value =
962
+ typeof this.props.list[index] === 'string'
963
+ ? this.props.list[index]
964
+ : this.props.list[index].value;
965
+
966
+ this.setBackendValue(this.fullPath, value);
967
+ if (this.props.onChange) {
968
+ this.props.onChange(value, index);
969
+ }
970
+ }
971
+
972
+ renderEditRadio() {
973
+ const WiredRadioList = this.mapWidget(
974
+ RadioList,
975
+ (value) => {
976
+ if (value && value !== '') {
977
+ return {
978
+ selectedIndex: this.props.list.findIndex((item) => {
979
+ if (typeof item === 'string') {
980
+ return item === value;
981
+ } else {
982
+ return item.value === value;
983
+ }
984
+ }),
985
+ };
986
+ } else {
987
+ return {};
988
+ }
989
+ },
990
+ this.fullPath
991
+ );
992
+
993
+ return (
994
+ <LabelRow
995
+ show={this.props.show}
996
+ grow={this.props.grow}
997
+ width={this.props.width}
998
+ height={this.props.height}
999
+ labelGlyph={this.props.labelGlyph}
1000
+ labelWidth={this.props.labelWidth || defaultLabelWidth}
1001
+ horizontalSpacing={this.props.horizontalSpacing}
1002
+ verticalSpacing={this.props.verticalSpacing}
1003
+ verticalJustify={this.props.verticalJustify}
1004
+ >
1005
+ <WiredRadioList
1006
+ buttonWidth={this.props.buttonWidth}
1007
+ height={this.props.height}
1008
+ direction={this.props.direction || 'row'}
1009
+ disabled={this.props.disabled}
1010
+ list={this.props.list}
1011
+ selectionChanged={this.radioListSelectionChanged}
1012
+ />
1013
+ </LabelRow>
1014
+ );
1015
+ }
1016
+
1017
+ renderCheckList() {
1018
+ const WiredCheckList = this.mapWidget(
1019
+ CheckList,
1020
+ (value) => {
1021
+ if (value && value !== '') {
1022
+ return {value};
1023
+ } else {
1024
+ return {};
1025
+ }
1026
+ },
1027
+ this.fullPath
1028
+ );
1029
+
1030
+ return (
1031
+ <LabelRow
1032
+ show={this.props.show}
1033
+ grow={this.props.grow}
1034
+ width={this.props.width}
1035
+ height={this.props.height}
1036
+ labelText={this.getLabelText()}
1037
+ labelWrap={this.props.labelWrap}
1038
+ labelGlyph={this.props.labelGlyph}
1039
+ labelWidth={this.props.labelWidth || defaultLabelWidth}
1040
+ horizontalSpacing={this.props.horizontalSpacing}
1041
+ verticalSpacing={this.props.verticalSpacing}
1042
+ verticalJustify={this.props.verticalJustify}
1043
+ >
1044
+ <WiredCheckList
1045
+ width={this.props.width}
1046
+ height={this.props.height}
1047
+ heightStrategy={this.props.heightStrategy || 'compact'}
1048
+ look={this.props.look || 'modern'}
1049
+ direction={this.props.direction || 'column'}
1050
+ showHeader={this.props.showHeader}
1051
+ list={this.props.list}
1052
+ readonly={this.readonly}
1053
+ selectionChanged={(value) => {
1054
+ this.setBackendValue(this.fullPath, value);
1055
+ }}
1056
+ />
1057
+ </LabelRow>
1058
+ );
1059
+ }
1060
+
1061
+ renderEditBool() {
1062
+ const {
1063
+ kind,
1064
+ show,
1065
+ grow,
1066
+ height,
1067
+ labelGlyph,
1068
+ labelWidth = defaultLabelWidth,
1069
+ horizontalSpacing,
1070
+ verticalSpacing,
1071
+ verticalJustify,
1072
+ width,
1073
+ subkind,
1074
+ ...otherProps
1075
+ } = this.props;
1076
+
1077
+ return (
1078
+ <LabelRow
1079
+ show={show}
1080
+ grow={grow}
1081
+ width={width}
1082
+ height={height}
1083
+ labelGlyph={labelGlyph}
1084
+ labelWidth={labelWidth || defaultLabelWidth}
1085
+ horizontalSpacing={horizontalSpacing}
1086
+ verticalSpacing={verticalSpacing}
1087
+ verticalJustify={verticalJustify}
1088
+ >
1089
+ <Checkbox
1090
+ kind={subkind}
1091
+ heightStrategy={verticalSpacing === 'compact' ? 'compact' : null}
1092
+ text={this.getLabelText()}
1093
+ {...otherProps}
1094
+ tooltip={this.getTooltip()}
1095
+ />
1096
+ </LabelRow>
1097
+ );
1098
+ }
1099
+
1100
+ renderCalendar() {
1101
+ const Dynamic = this.mapWidget(
1102
+ Calendar,
1103
+ (calendar) => {
1104
+ // FIXME: calendar is undefined!
1105
+ return {
1106
+ visibleDate: calendar.get('visibleDate', null),
1107
+ startDate: calendar.get('startDate', null),
1108
+ endDate: calendar.get('endDate', null),
1109
+ dates: calendar.get('dates', []).valueSeq().toArray(),
1110
+ badges: calendar.get('badges', []).valueSeq().toArray(),
1111
+ };
1112
+ },
1113
+ this.fullPath
1114
+ );
1115
+
1116
+ return (
1117
+ <Dynamic
1118
+ grow="1"
1119
+ tooltip={this.getTooltip()}
1120
+ dateClicked={this.props.dateClicked}
1121
+ visibleDateChanged={this.props.visibleDateChanged}
1122
+ monthCount={this.props.monthCount}
1123
+ frame={this.props.frame}
1124
+ />
1125
+ );
1126
+ }
1127
+
1128
+ renderCalendarBoards() {
1129
+ const Dynamic = this.mapWidget(
1130
+ CalendarBoards,
1131
+ (calendarBoards) => {
1132
+ return {
1133
+ boards: calendarBoards.get('boards', []).valueSeq().toArray(),
1134
+ selectedDate: calendarBoards.get('selectedDate'),
1135
+ selectedId: calendarBoards.get('selectedId'),
1136
+ };
1137
+ },
1138
+ this.fullPath
1139
+ );
1140
+
1141
+ return (
1142
+ <Dynamic
1143
+ grow="1"
1144
+ tooltip={this.getTooltip()}
1145
+ onBoardChanged={this.props.onBoardChanged}
1146
+ />
1147
+ );
1148
+ }
1149
+
1150
+ renderCalendarRecurrence() {
1151
+ const WiredCalendarRecurrence = this.mapWidget(
1152
+ CalendarRecurrence,
1153
+ (r) => {
1154
+ return {
1155
+ startDate: r.get('startDate'),
1156
+ endDate: r.get('endDate'),
1157
+ days: r.get('days'),
1158
+ addDates: r.get('addDates'),
1159
+ };
1160
+ },
1161
+ this.fullPath
1162
+ );
1163
+
1164
+ return (
1165
+ <WiredCalendarRecurrence
1166
+ readonly={this.readonly}
1167
+ dateClicked={(date) => {
1168
+ const service = this.context.id.split('@')[0];
1169
+ this.doAs(service, 'date-clicked', {
1170
+ date,
1171
+ });
1172
+ }}
1173
+ flushAdd={() => {
1174
+ const service = this.context.id.split('@')[0];
1175
+ this.doAs(service, 'flush-add');
1176
+ }}
1177
+ />
1178
+ );
1179
+ }
1180
+
1181
+ renderEditEntity() {
1182
+ const summary = this.props.summary || 'info';
1183
+ const Viewer = (props) => {
1184
+ if (!props.entityId) {
1185
+ return <Label grow="1" empty={true} />;
1186
+ }
1187
+ const Info = this.mapWidget(
1188
+ Label,
1189
+ (entity) => {
1190
+ let glyph = 'solid/spinner';
1191
+ let glyphColor = null;
1192
+ let text = T('chargement...');
1193
+ if (entity) {
1194
+ glyph = entity.get('meta.summaries.glyph');
1195
+ glyphColor = entity.get('meta.summaries.glyphColor');
1196
+ text = entity.get(`meta.summaries.${summary}`);
1197
+ }
1198
+ return {
1199
+ glyph,
1200
+ glyphColor,
1201
+ text,
1202
+ };
1203
+ },
1204
+ `backend.${props.entityId}`
1205
+ );
1206
+ return <Info userSelect="text" />;
1207
+ };
1208
+
1209
+ const EntityViewer = this.mapWidget(Viewer, 'entityId', this.fullPath);
1210
+
1211
+ return (
1212
+ <Container
1213
+ kind="row-field"
1214
+ subkind="light-box"
1215
+ grow={this.props.grow}
1216
+ width={this.props.width}
1217
+ height={this.props.height}
1218
+ horizontalSpacing={this.props.horizontalSpacing}
1219
+ verticalSpacing={this.props.verticalSpacing}
1220
+ verticalJustify={this.props.verticalJustify}
1221
+ >
1222
+ <EntityViewer />
1223
+ </Container>
1224
+ );
1225
+ }
1226
+
1227
+ renderEditEntities() {
1228
+ const pluginProps = getPluginProps(this.props);
1229
+ if (this.props.plugin) {
1230
+ let WiredPlugin = null;
1231
+ let FinalPlugin = null;
1232
+ const pluginId = `${this.props.plugin}-plugin@${this.context.id}`;
1233
+ if (this.props.pluginType) {
1234
+ const CustomPlugin = widgetImporter(`plugin-${this.props.pluginType}`);
1235
+ WiredPlugin = Widget.Wired(CustomPlugin)(pluginId);
1236
+ FinalPlugin = this.mapWidget(WiredPlugin, 'entityIds', this.fullPath);
1237
+ } else {
1238
+ FinalPlugin = widgetImporter('plugin');
1239
+ }
1240
+
1241
+ return (
1242
+ <Container
1243
+ kind={this.props.containerKind || 'row-field'}
1244
+ subkind={this.props.containerSubkind || 'light-box'}
1245
+ grow={this.props.grow}
1246
+ width={this.props.width}
1247
+ height={this.props.height}
1248
+ horizontalSpacing={this.props.horizontalSpacing}
1249
+ verticalSpacing={this.props.verticalSpacing}
1250
+ verticalJustify="top"
1251
+ >
1252
+ <FinalPlugin
1253
+ {...pluginProps}
1254
+ id={pluginId}
1255
+ dragServiceId={
1256
+ this.props.dragServiceId || this.context.dragServiceId
1257
+ }
1258
+ embeddedLevel={
1259
+ this.props.embeddedLevel ? this.props.embeddedLevel + 1 : 1
1260
+ }
1261
+ />
1262
+ </Container>
1263
+ );
1264
+ } else if (this.props.item) {
1265
+ const Items = (props) => {
1266
+ if (!props.entityIds) {
1267
+ return <Label grow="1" empty={true} />;
1268
+ }
1269
+ return (
1270
+ <Container
1271
+ kind="row-field"
1272
+ grow={this.props.grow}
1273
+ width={this.props.width}
1274
+ height={this.props.height}
1275
+ horizontalSpacing={this.props.horizontalSpacing}
1276
+ verticalSpacing={this.props.verticalSpacing}
1277
+ verticalJustify={this.props.verticalJustify}
1278
+ >
1279
+ {props.entityIds.map((entityId, index) => {
1280
+ const Item = this.mapWidget(
1281
+ this.props.item,
1282
+ (state) => (state ? state : null),
1283
+ `backend.${entityId}`
1284
+ );
1285
+ return <Item key={index} />;
1286
+ })}
1287
+ </Container>
1288
+ );
1289
+ };
1290
+ const FinalItems = this.mapWidget(Items, 'entityIds', this.fullPath);
1291
+ return <FinalItems />;
1292
+ } else {
1293
+ throw new Error('Property plugin or item is required in this case!');
1294
+ }
1295
+ }
1296
+
1297
+ renderComboIds() {
1298
+ const Option = (props) => {
1299
+ if (!props.id) {
1300
+ return null;
1301
+ }
1302
+ return <option value={props.id}>{props.text}</option>;
1303
+ };
1304
+ let targetPath = null;
1305
+ if (this.props.targetModel) {
1306
+ targetPath = this.getFullPathFromModel(this.props.targetModel);
1307
+ }
1308
+ const modelTextKey = this.props.modelTextKey || 'meta.summaries.info';
1309
+ const ComboIds = (props) => {
1310
+ const disabled = this.readonly ? {disabled: true} : null;
1311
+ let currentValue = '';
1312
+ if (props.currentValue != null) {
1313
+ // currentValue is not null nor undefined
1314
+ currentValue = props.currentValue;
1315
+ } else if (this.props.defaultValue != null) {
1316
+ // defaultValue is not null nor undefined
1317
+ currentValue = this.props.defaultValue;
1318
+ }
1319
+ return (
1320
+ <select
1321
+ value={currentValue}
1322
+ style={{
1323
+ margin: '0px',
1324
+ padding: '0px 10px',
1325
+ height: '35px',
1326
+ ...props.style,
1327
+ }}
1328
+ onChange={(event) => {
1329
+ if (this.props.onChange) {
1330
+ this.props.onChange(event.target.value);
1331
+ }
1332
+ if (this.props.targetModel) {
1333
+ this.setBackendValue(targetPath, event.target.value);
1334
+ }
1335
+ }}
1336
+ {...disabled}
1337
+ >
1338
+ {props.entityIds.map((entityId, index) => {
1339
+ const WiredOption = this.mapWidget(
1340
+ Option,
1341
+ (state) => {
1342
+ const id = state.get('id');
1343
+ if (id) {
1344
+ return {id, text: state.get(modelTextKey)};
1345
+ }
1346
+ return null;
1347
+ },
1348
+ `backend.${entityId}`
1349
+ );
1350
+ const Item = () =>
1351
+ this.buildLoader(entityId, () => <WiredOption />);
1352
+ return <Item key={index} />;
1353
+ })}
1354
+ </select>
1355
+ );
1356
+ };
1357
+
1358
+ let FinalCombo = this.mapWidget(ComboIds, 'entityIds', this.fullPath);
1359
+ if (targetPath) {
1360
+ FinalCombo = this.mapWidget(FinalCombo, 'currentValue', targetPath);
1361
+ }
1362
+
1363
+ if (this.props.labelText) {
1364
+ return (
1365
+ <LabelRow
1366
+ show={this.props.show}
1367
+ grow={this.props.grow}
1368
+ width={this.props.width}
1369
+ height={this.props.height}
1370
+ labelText={this.getLabelText()}
1371
+ labelWrap={this.props.labelWrap}
1372
+ labelGlyph={this.props.labelGlyph}
1373
+ labelWidth={this.props.labelWidth || defaultLabelWidth}
1374
+ horizontalSpacing={this.props.horizontalSpacing}
1375
+ verticalSpacing={this.props.verticalSpacing}
1376
+ verticalJustify={this.props.verticalJustify}
1377
+ disabled={this.props.disabled}
1378
+ >
1379
+ <FinalCombo style={{flexGrow: 1}} />
1380
+ </LabelRow>
1381
+ );
1382
+ }
1383
+
1384
+ return <FinalCombo />;
1385
+ }
1386
+
1387
+ renderEditHinter() {
1388
+ const {
1389
+ show,
1390
+ labelWrap,
1391
+ labelGlyph,
1392
+ labelWidth = defaultLabelWidth,
1393
+ horizontalSpacing,
1394
+ verticalSpacing,
1395
+ verticalJustify,
1396
+ width,
1397
+ fieldWidth,
1398
+ kind,
1399
+ ...otherProps
1400
+ } = this.props;
1401
+
1402
+ return (
1403
+ <LabelRow
1404
+ show={show}
1405
+ labelText={this.getLabelText()}
1406
+ labelWrap={labelWrap}
1407
+ labelGlyph={labelGlyph}
1408
+ labelWidth={labelWidth}
1409
+ horizontalSpacing={horizontalSpacing}
1410
+ verticalSpacing={verticalSpacing}
1411
+ verticalJustify={verticalJustify}
1412
+ width={width}
1413
+ grow={this.props.fieldWidth ? null : '1'}
1414
+ >
1415
+ <HinterField width={fieldWidth} {...otherProps} />
1416
+ </LabelRow>
1417
+ );
1418
+ }
1419
+
1420
+ renderCompleteHinter() {
1421
+ const Form = this.Form;
1422
+
1423
+ const CompleteHinter = (props) => {
1424
+ if (props.content === '') {
1425
+ return (
1426
+ <LabelRow
1427
+ show={this.props.show}
1428
+ grow={this.props.grow}
1429
+ width={this.props.width}
1430
+ height={this.props.height}
1431
+ labelText={this.getLabelText()}
1432
+ labelWrap={this.props.labelWrap}
1433
+ labelGlyph={this.props.labelGlyph}
1434
+ labelWidth={this.props.labelWidth || defaultLabelWidth}
1435
+ horizontalSpacing={this.props.horizontalSpacing}
1436
+ verticalSpacing={this.props.verticalSpacing}
1437
+ verticalJustify={this.props.verticalJustify}
1438
+ >
1439
+ <Form
1440
+ {...this.formConfigWithComponent(
1441
+ React.forwardRef((props, ref) => (
1442
+ <TextField
1443
+ ref={ref}
1444
+ id={this.context.id}
1445
+ shape={
1446
+ !this.props.onValue && this.props.enableAdd
1447
+ ? 'left-smooth'
1448
+ : 'smooth'
1449
+ }
1450
+ getGlyph={this.props.getGlyph}
1451
+ hintText={this.props.hintText}
1452
+ tooltip={this.getTooltip()}
1453
+ hinter={this.props.hinter}
1454
+ comboType={this.props.hinter}
1455
+ width={this.props.fieldWidth}
1456
+ grow="1"
1457
+ requiredHinter={true}
1458
+ autocomplete={this.fullPath}
1459
+ />
1460
+ ))
1461
+ )}
1462
+ />
1463
+ </LabelRow>
1464
+ );
1465
+ } else {
1466
+ return this.renderEditField();
1467
+ }
1468
+ };
1469
+
1470
+ const HinterField = this.mapWidget(
1471
+ CompleteHinter,
1472
+ 'content',
1473
+ this.fullPath
1474
+ );
1475
+ return <HinterField />;
1476
+ }
1477
+
1478
+ renderFileInput() {
1479
+ const {
1480
+ show,
1481
+ labelWrap,
1482
+ labelGlyph,
1483
+ labelWidth = defaultLabelWidth,
1484
+ horizontalSpacing,
1485
+ verticalSpacing,
1486
+ verticalJustify,
1487
+ width,
1488
+ grow,
1489
+ kind,
1490
+ ...otherProps
1491
+ } = this.props;
1492
+ return (
1493
+ <LabelRow
1494
+ show={show}
1495
+ labelText={this.getLabelText()}
1496
+ labelWrap={labelWrap}
1497
+ labelGlyph={labelGlyph}
1498
+ labelWidth={labelWidth}
1499
+ horizontalSpacing={horizontalSpacing}
1500
+ verticalSpacing={verticalSpacing}
1501
+ verticalJustify={verticalJustify}
1502
+ width={width}
1503
+ grow={grow}
1504
+ >
1505
+ <FileInput {...otherProps} />
1506
+ </LabelRow>
1507
+ );
1508
+ }
1509
+
1510
+ renderDirectoryInput() {
1511
+ const {
1512
+ show,
1513
+ labelWrap,
1514
+ labelGlyph,
1515
+ labelWidth = defaultLabelWidth,
1516
+ horizontalSpacing,
1517
+ verticalSpacing,
1518
+ verticalJustify,
1519
+ width,
1520
+ grow,
1521
+ kind,
1522
+ ...otherProps
1523
+ } = this.props;
1524
+ return (
1525
+ <LabelRow
1526
+ show={show}
1527
+ labelText={this.getLabelText()}
1528
+ labelWrap={labelWrap}
1529
+ labelGlyph={labelGlyph}
1530
+ labelWidth={labelWidth}
1531
+ horizontalSpacing={horizontalSpacing}
1532
+ verticalSpacing={verticalSpacing}
1533
+ verticalJustify={verticalJustify}
1534
+ width={width}
1535
+ grow={grow}
1536
+ >
1537
+ <DirectoryInput {...otherProps} />
1538
+ </LabelRow>
1539
+ );
1540
+ }
1541
+
1542
+ renderEditStateBrowser() {
1543
+ let {
1544
+ show,
1545
+ labelWrap,
1546
+ labelGlyph,
1547
+ labelWidth = defaultLabelWidth,
1548
+ horizontalSpacing,
1549
+ verticalSpacing,
1550
+ verticalJustify,
1551
+ width,
1552
+ grow,
1553
+ value,
1554
+ model,
1555
+ state,
1556
+ path,
1557
+ ...otherProps
1558
+ } = this.props;
1559
+
1560
+ if (model) {
1561
+ value = C(model);
1562
+ }
1563
+ if (path) {
1564
+ state = C(path);
1565
+ }
1566
+
1567
+ return (
1568
+ <LabelRow
1569
+ show={show}
1570
+ labelText={this.getLabelText()}
1571
+ labelWrap={labelWrap}
1572
+ labelGlyph={labelGlyph}
1573
+ labelWidth={labelWidth}
1574
+ horizontalSpacing={horizontalSpacing}
1575
+ verticalSpacing={verticalSpacing}
1576
+ verticalJustify={verticalJustify}
1577
+ width={width}
1578
+ grow={grow}
1579
+ >
1580
+ <StateBrowser
1581
+ grow={grow}
1582
+ value={value}
1583
+ state={state}
1584
+ path={path}
1585
+ {...otherProps}
1586
+ />
1587
+ </LabelRow>
1588
+ );
1589
+ }
1590
+
1591
+ //#endregion
1592
+
1593
+ renderReadonly() {
1594
+ switch (this.getKind()) {
1595
+ case 'field':
1596
+ case 'string':
1597
+ return this.renderReadonlyField();
1598
+ case 'gadget':
1599
+ return this.renderReadonlyGadget();
1600
+ case 'date':
1601
+ case 'time':
1602
+ case 'datetime':
1603
+ case 'price':
1604
+ case 'weight':
1605
+ case 'length':
1606
+ case 'pixel':
1607
+ case 'volume':
1608
+ case 'number':
1609
+ case 'integer':
1610
+ case 'percent':
1611
+ case 'delay':
1612
+ case 'color':
1613
+ return this.renderReadonlyTyped();
1614
+ case 'time-interval':
1615
+ return this.renderReadonlyTimeInterval();
1616
+ case 'date-interval':
1617
+ return this.renderReadonlyDateInterval();
1618
+ case 'combo':
1619
+ return this.renderReadonlyCombo();
1620
+ case 'radio':
1621
+ return this.renderReadonlyField();
1622
+ case 'check-list':
1623
+ return this.renderCheckList();
1624
+ case 'bool':
1625
+ return this.renderReadonlyBool();
1626
+ case 'calendar':
1627
+ return this.renderCalendar();
1628
+ case 'calendar-boards':
1629
+ return this.renderCalendarBoards();
1630
+ case 'calendar-recurrence':
1631
+ return this.renderCalendarRecurrence();
1632
+ case 'hinter':
1633
+ return this.renderReadonlyHinter();
1634
+ case 'complete-hinter':
1635
+ return this.renderReadonlyField();
1636
+ case 'file':
1637
+ return this.renderFileInput();
1638
+ case 'directory':
1639
+ return this.renderDirectoryInput();
1640
+ case 'id':
1641
+ return this.renderReadonlyEntity();
1642
+ case 'ids':
1643
+ return this.renderReadonlyEntities();
1644
+ case 'combo-ids':
1645
+ return this.renderComboIds();
1646
+ case 'translatable':
1647
+ return this.renderReadonlyTranslatable();
1648
+ case 'state-browser':
1649
+ return this.renderEditStateBrowser();
1650
+ case 'label':
1651
+ return (
1652
+ <ReadonlyLabel
1653
+ defaultLabelWidth={defaultLabelWidth}
1654
+ fullpath={this.fullPath}
1655
+ {...this.props}
1656
+ />
1657
+ );
1658
+ default:
1659
+ return this.renderReadonlyField();
1660
+ }
1661
+ }
1662
+
1663
+ renderEdit() {
1664
+ switch (this.getKind()) {
1665
+ case 'field':
1666
+ case 'string':
1667
+ return this.renderEditField();
1668
+ case 'gadget':
1669
+ return this.renderEditGadget();
1670
+ case 'date':
1671
+ case 'time':
1672
+ case 'datetime':
1673
+ case 'price':
1674
+ case 'weight':
1675
+ case 'length':
1676
+ case 'pixel':
1677
+ case 'volume':
1678
+ case 'number':
1679
+ case 'integer':
1680
+ case 'percent':
1681
+ case 'delay':
1682
+ case 'color':
1683
+ return this.renderEditTyped();
1684
+ case 'time-interval':
1685
+ return this.renderEditTimeInterval();
1686
+ case 'date-interval':
1687
+ return this.renderEditDateInterval();
1688
+ case 'combo':
1689
+ return this.renderEditCombo();
1690
+ case 'radio':
1691
+ return this.renderEditRadio();
1692
+ case 'check-list':
1693
+ return this.renderCheckList();
1694
+ case 'bool':
1695
+ return this.renderEditBool();
1696
+ case 'calendar':
1697
+ return this.renderCalendar();
1698
+ case 'calendar-boards':
1699
+ return this.renderCalendarBoards();
1700
+ case 'calendar-recurrence':
1701
+ return this.renderCalendarRecurrence();
1702
+ case 'hinter':
1703
+ return this.renderEditHinter();
1704
+ case 'complete-hinter':
1705
+ return this.renderCompleteHinter();
1706
+ case 'file':
1707
+ return this.renderFileInput();
1708
+ case 'directory':
1709
+ return this.renderDirectoryInput();
1710
+ case 'id':
1711
+ return this.renderEditEntity();
1712
+ case 'ids':
1713
+ return this.renderEditEntities();
1714
+ case 'combo-ids':
1715
+ return this.renderComboIds();
1716
+ case 'translatable':
1717
+ return this.renderEditTranslatable();
1718
+ case 'state-browser':
1719
+ return this.renderEditStateBrowser();
1720
+ case 'label':
1721
+ return (
1722
+ <ReadonlyLabel
1723
+ defaultLabelWidth={defaultLabelWidth}
1724
+ fullpath={this.fullPath}
1725
+ {...this.props}
1726
+ />
1727
+ );
1728
+ default:
1729
+ return this.renderEditField();
1730
+ }
1731
+ }
1732
+
1733
+ render() {
1734
+ if (this.readonly) {
1735
+ return this.renderReadonly();
1736
+ } else {
1737
+ return this.renderEdit();
1738
+ }
1739
+ }
1740
+ }
1741
+
1742
+ /******************************************************************************/
1743
+ export default Field;