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.
- package/.editorconfig +9 -9
- package/.eslintrc.js +28 -28
- package/.zou-flow +2 -2
- package/builders/builders.js +5 -5
- package/builders/gadget.js +85 -85
- package/calendar-boards-gadget.js +64 -64
- package/demo-gadget.js +17 -17
- package/glyphs-dialog.js +13 -13
- package/login-dialog.js +13 -13
- package/package.json +46 -46
- package/pivot-gadget.js +18 -18
- package/stack-navigation.js +13 -13
- package/table-gadget.js +102 -102
- package/test/code-parser.spec.js +61 -61
- package/tree-gadget.js +70 -70
- package/types/types.js +455 -455
- package/widgets/accordion/styles.js +16 -16
- package/widgets/accordion/widget.js +90 -90
- package/widgets/analog-clock/props.js +102 -102
- package/widgets/analog-clock/scenarios.js +43 -43
- package/widgets/analog-clock/styles.js +754 -754
- package/widgets/analog-clock/widget.js +404 -404
- package/widgets/animated-container/animations.js +566 -566
- package/widgets/animated-container/styles.js +36 -36
- package/widgets/animated-container/widget.js +24 -24
- package/widgets/badge/styles.js +107 -107
- package/widgets/badge/widget.js +33 -33
- package/widgets/button/props.js +377 -377
- package/widgets/button/scenarios.js +54 -54
- package/widgets/button/styles.js +1082 -1082
- package/widgets/button/widget.js +426 -426
- package/widgets/button-combo/styles.js +73 -73
- package/widgets/button-combo/widget.js +297 -297
- package/widgets/calendar/props.js +207 -207
- package/widgets/calendar/scenarios.js +50 -50
- package/widgets/calendar/styles.js +198 -198
- package/widgets/calendar/widget.js +895 -895
- package/widgets/calendar-boards/styles.js +29 -29
- package/widgets/calendar-boards/widget.js +215 -215
- package/widgets/calendar-button/styles.js +273 -273
- package/widgets/calendar-button/widget.js +94 -94
- package/widgets/calendar-list/styles.js +35 -35
- package/widgets/calendar-list/widget.js +223 -223
- package/widgets/calendar-recurrence/widget.js +183 -183
- package/widgets/carousel/props.js +104 -104
- package/widgets/carousel/scenarios.js +163 -163
- package/widgets/carousel/styles.js +133 -133
- package/widgets/carousel/widget.js +491 -491
- package/widgets/carousel-bullet/styles.js +29 -29
- package/widgets/carousel-bullet/widget.js +25 -25
- package/widgets/carousel-button/styles.js +71 -71
- package/widgets/carousel-button/widget.js +33 -33
- package/widgets/carousel-item/styles.js +21 -21
- package/widgets/carousel-item/widget.js +24 -24
- package/widgets/chat-balloon/props.js +65 -65
- package/widgets/chat-balloon/scenarios.js +47 -47
- package/widgets/chat-balloon/styles.js +193 -193
- package/widgets/chat-balloon/widget.js +62 -62
- package/widgets/chat-dialog/styles.js +15 -15
- package/widgets/chat-dialog/widget.js +62 -62
- package/widgets/check-list/styles.js +66 -66
- package/widgets/check-list/widget.js +168 -168
- package/widgets/checkbox/widget.js +15 -15
- package/widgets/checkbox-nc/props.js +191 -191
- package/widgets/checkbox-nc/scenarios.js +41 -41
- package/widgets/checkbox-nc/styles.js +122 -122
- package/widgets/checkbox-nc/widget.js +116 -116
- package/widgets/clock-combo/styles.js +174 -174
- package/widgets/clock-combo/widget.js +390 -390
- package/widgets/color-picker/props.js +145 -145
- package/widgets/color-picker/scenarios.js +34 -34
- package/widgets/color-picker/styles.js +209 -209
- package/widgets/color-picker/widget.js +735 -735
- package/widgets/colored-container/props.js +34 -34
- package/widgets/colored-container/scenarios.js +54 -54
- package/widgets/colored-container/styles.js +100 -100
- package/widgets/colored-container/widget.js +27 -27
- package/widgets/combo/styles.js +69 -69
- package/widgets/combo/widget.js +224 -224
- package/widgets/combo-container/styles.js +66 -66
- package/widgets/combo-container/widget.js +188 -188
- package/widgets/command-button/widget.js +39 -39
- package/widgets/container/props.js +295 -295
- package/widgets/container/scenarios.js +47 -47
- package/widgets/container/styles.js +1439 -1439
- package/widgets/container/widget.js +279 -279
- package/widgets/demo/widget.js +24 -24
- package/widgets/dialog/styles.js +29 -29
- package/widgets/dialog/widget.js +26 -26
- package/widgets/dialog-modal/props.js +126 -126
- package/widgets/dialog-modal/styles.js +234 -234
- package/widgets/dialog-modal/widget.js +273 -273
- package/widgets/dialog-resizable/props.js +1 -1
- package/widgets/dialog-resizable/scenarios.js +18 -18
- package/widgets/dialog-resizable/widget.js +367 -367
- package/widgets/dialog-resizable-nc/props.js +150 -150
- package/widgets/dialog-resizable-nc/scenarios.js +18 -18
- package/widgets/dialog-resizable-nc/styles.js +259 -259
- package/widgets/dialog-resizable-nc/widget.js +197 -197
- package/widgets/directory-input/widget.js +18 -18
- package/widgets/directory-input-nc/widget.js +20 -20
- package/widgets/document-container/getPath.js +43 -43
- package/widgets/document-container/props.js +79 -79
- package/widgets/document-container/scenarios.js +39 -39
- package/widgets/document-container/styles.js +69 -69
- package/widgets/document-container/widget.js +53 -53
- package/widgets/drag-cab/styles.js +56 -56
- package/widgets/drag-cab/widget.js +285 -285
- package/widgets/drag-carrier/styles.js +21 -21
- package/widgets/drag-carrier/widget.js +780 -780
- package/widgets/dynamic-toolbar/styles.js +110 -110
- package/widgets/dynamic-toolbar/widget.js +128 -128
- package/widgets/field/readonly/label.js +39 -39
- package/widgets/field/widget.js +1743 -1743
- package/widgets/file-input/widget.js +18 -18
- package/widgets/file-input-nc/styles.js +38 -38
- package/widgets/file-input-nc/widget.js +88 -88
- package/widgets/flat-combo/styles.js +21 -21
- package/widgets/flat-combo/widget.js +61 -61
- package/widgets/flat-list/styles.js +30 -30
- package/widgets/flat-list/widget.js +219 -219
- package/widgets/flying-balloon/styles.js +52 -52
- package/widgets/flying-balloon/widget.js +43 -43
- package/widgets/fragment/widget.js +26 -26
- package/widgets/full-screen/props.js +27 -27
- package/widgets/full-screen/styles.js +32 -32
- package/widgets/full-screen/widget.js +40 -40
- package/widgets/gauge/props.js +71 -71
- package/widgets/gauge/scenarios.js +83 -83
- package/widgets/gauge/styles.js +183 -183
- package/widgets/gauge/widget.js +36 -36
- package/widgets/glyph-detail/service.js +9 -9
- package/widgets/glyph-detail/widget.js +109 -109
- package/widgets/glyphs-dialog/service.js +94 -94
- package/widgets/glyphs-dialog/styles.js +37 -37
- package/widgets/glyphs-dialog/widget.js +236 -236
- package/widgets/goblin-editor/widget.js +146 -146
- package/widgets/guild-entry/props.js +53 -53
- package/widgets/guild-entry/scenarios.js +26 -26
- package/widgets/guild-entry/styles.js +98 -98
- package/widgets/guild-entry/widget.js +126 -126
- package/widgets/guild-user-logo/guild-helpers.js +77 -77
- package/widgets/guild-user-logo/props.js +48 -48
- package/widgets/guild-user-logo/scenarios.js +64 -64
- package/widgets/guild-user-logo/styles.js +114 -114
- package/widgets/guild-user-logo/widget.js +81 -81
- package/widgets/guild-user-profile/props.js +73 -73
- package/widgets/guild-user-profile/scenarios.js +54 -54
- package/widgets/guild-user-profile/styles.js +162 -162
- package/widgets/guild-user-profile/widget.js +202 -202
- package/widgets/helpers/combo-helpers.js +218 -218
- package/widgets/helpers/geom-helpers.js +80 -80
- package/widgets/helpers/rect-helpers.js +10 -10
- package/widgets/helpers/shortcut-helpers.js +56 -56
- package/widgets/helpers/spacing-helpers.js +26 -26
- package/widgets/helpers/svg-helpers.js +151 -151
- package/widgets/helpers/table-helpers.js +68 -68
- package/widgets/hinter/styles.js +79 -79
- package/widgets/hinter/widget.js +205 -205
- package/widgets/hinter-column/widget.js +49 -49
- package/widgets/hinter-field/reducer.js +18 -18
- package/widgets/hinter-field/widget.js +176 -176
- package/widgets/hinter-field-nc/props.js +114 -114
- package/widgets/hinter-field-nc/scenarios.js +47 -47
- package/widgets/hinter-field-nc/widget.js +191 -191
- package/widgets/input-wrapper/widget.js +157 -157
- package/widgets/key-trap.js +96 -96
- package/widgets/label/props.js +1 -1
- package/widgets/label/scenarios.js +1 -1
- package/widgets/label/widget.js +7 -7
- package/widgets/label-nc/props.js +308 -308
- package/widgets/label-nc/scenarios.js +29 -29
- package/widgets/label-nc/styles.js +1218 -1218
- package/widgets/label-nc/widget.js +314 -314
- package/widgets/label-row/props.js +1 -1
- package/widgets/label-row/scenarios.js +1 -1
- package/widgets/label-row/widget.js +7 -7
- package/widgets/label-row-nc/props.js +94 -94
- package/widgets/label-row-nc/scenarios.js +46 -46
- package/widgets/label-row-nc/widget.js +81 -81
- package/widgets/label-text-field/styles.js +55 -55
- package/widgets/label-text-field/widget.js +178 -178
- package/widgets/launcher/props.js +177 -177
- package/widgets/launcher/scenarios.js +55 -55
- package/widgets/launcher/styles.js +46 -46
- package/widgets/launcher/widget.js +79 -79
- package/widgets/launcher-blob/props.js +25 -25
- package/widgets/launcher-blob/scenarios.js +24 -24
- package/widgets/launcher-blob/styles.js +62 -62
- package/widgets/launcher-blob/widget.js +50 -50
- package/widgets/list/widget.js +211 -211
- package/widgets/login-dialog/service.js +117 -117
- package/widgets/login-dialog/widget.js +117 -117
- package/widgets/map/reaflet.js +208 -208
- package/widgets/map/widget.js +67 -67
- package/widgets/markdown/styles.js +85 -85
- package/widgets/markdown/widget.js +31 -31
- package/widgets/notification/styles.js +97 -97
- package/widgets/notification/widget.js +207 -207
- package/widgets/pivot/custom.css +320 -320
- package/widgets/pivot/widget.js +42 -42
- package/widgets/radio-list/styles.js +48 -48
- package/widgets/radio-list/widget.js +111 -111
- package/widgets/resizable-container/styles.js +108 -108
- package/widgets/resizable-container/widget.js +225 -225
- package/widgets/retro-action-button/helpers.js +106 -106
- package/widgets/retro-action-button/styles.js +285 -285
- package/widgets/retro-action-button/widget.js +364 -364
- package/widgets/retro-badge-button/styles.js +87 -87
- package/widgets/retro-badge-button/widget.js +251 -251
- package/widgets/retro-gear/helpers.js +156 -156
- package/widgets/retro-gear/styles.js +130 -130
- package/widgets/retro-gear/widget.js +51 -51
- package/widgets/retro-illuminated-button/styles.js +274 -274
- package/widgets/retro-illuminated-button/widget.js +147 -147
- package/widgets/retro-panel/helpers.js +57 -57
- package/widgets/retro-panel/styles.js +293 -293
- package/widgets/retro-panel/widget.js +239 -239
- package/widgets/retro-screw/styles.js +80 -80
- package/widgets/retro-screw/widget.js +25 -25
- package/widgets/rocket/props.js +124 -124
- package/widgets/rocket/scenarios.js +71 -71
- package/widgets/rocket/styles.js +306 -306
- package/widgets/rocket/widget.js +225 -225
- package/widgets/samples-monitor/helpers.js +147 -147
- package/widgets/samples-monitor/styles.js +529 -529
- package/widgets/samples-monitor/widget.js +516 -516
- package/widgets/scrollable-container/styles.js +58 -58
- package/widgets/scrollable-container/widget.js +132 -132
- package/widgets/scrollable-linkable-container/reducer.js +18 -18
- package/widgets/scrollable-linkable-container/styles.js +42 -42
- package/widgets/scrollable-linkable-container/widget.js +78 -78
- package/widgets/select/styles.js +68 -68
- package/widgets/select/widget.js +119 -119
- package/widgets/separator/props.js +46 -46
- package/widgets/separator/styles.js +116 -116
- package/widgets/separator/widget.js +27 -27
- package/widgets/slider/props.js +136 -136
- package/widgets/slider/scenarios.js +74 -74
- package/widgets/slider/styles.js +246 -246
- package/widgets/slider/widget.js +404 -404
- package/widgets/slider-circle/props.js +72 -72
- package/widgets/slider-circle/scenarios.js +16 -16
- package/widgets/slider-circle/styles.js +78 -78
- package/widgets/slider-circle/widget.js +154 -154
- package/widgets/slider-xy/props.js +87 -87
- package/widgets/slider-xy/scenarios.js +19 -19
- package/widgets/slider-xy/styles.js +102 -102
- package/widgets/slider-xy/widget.js +234 -234
- package/widgets/smiley/props.js +51 -51
- package/widgets/smiley/scenarios.js +58 -58
- package/widgets/smiley/styles.js +489 -489
- package/widgets/smiley/widget.js +72 -72
- package/widgets/spinner/props.js +31 -31
- package/widgets/spinner/scenarios.js +31 -31
- package/widgets/spinner/styles.js +49 -49
- package/widgets/spinner/widget.js +23 -23
- package/widgets/splitter/props.js +71 -71
- package/widgets/splitter/scenarios.js +182 -182
- package/widgets/splitter/styles.js +41 -41
- package/widgets/splitter/widget.js +455 -455
- package/widgets/stack-navigation/service.js +324 -324
- package/widgets/stack-navigation/widget.js +296 -296
- package/widgets/state-browser/styles.js +19 -19
- package/widgets/state-browser/widget.js +135 -135
- package/widgets/state-browser-dialog/styles.js +100 -100
- package/widgets/state-browser-dialog/widget.js +253 -253
- package/widgets/state-monitor/styles.js +50 -50
- package/widgets/state-monitor/widget.js +324 -324
- package/widgets/switch-on-off/props.js +30 -30
- package/widgets/switch-on-off/scenarios.js +34 -34
- package/widgets/switch-on-off/styles.js +63 -63
- package/widgets/switch-on-off/widget.js +41 -41
- package/widgets/table/helpers.js +160 -160
- package/widgets/table/props.js +658 -658
- package/widgets/table/reducer.js +196 -196
- package/widgets/table/scenarios.js +54 -54
- package/widgets/table/widget.js +253 -253
- package/widgets/table-cell/props.js +145 -145
- package/widgets/table-cell/styles.js +160 -160
- package/widgets/table-cell/widget.js +139 -139
- package/widgets/table-header-drag-manager/styles.js +184 -184
- package/widgets/table-header-drag-manager/widget.js +392 -392
- package/widgets/table-nc/styles.js +100 -100
- package/widgets/table-nc/widget.js +409 -409
- package/widgets/table-row/props.js +73 -73
- package/widgets/table-row/styles.js +82 -82
- package/widgets/table-row/widget.js +207 -207
- package/widgets/text-field/widget.js +18 -18
- package/widgets/text-field-combo/widget.js +21 -21
- package/widgets/text-field-combo-nc/props.js +300 -300
- package/widgets/text-field-combo-nc/scenarios.js +72 -72
- package/widgets/text-field-combo-nc/widget.js +339 -339
- package/widgets/text-field-date-interval/styles.js +37 -37
- package/widgets/text-field-date-interval/widget.js +162 -162
- package/widgets/text-field-nc/props.js +40 -40
- package/widgets/text-field-nc/scenarios.js +67 -67
- package/widgets/text-field-nc/widget.js +14 -14
- package/widgets/text-field-time-interval/styles.js +37 -37
- package/widgets/text-field-time-interval/widget.js +160 -160
- package/widgets/text-field-typed/widget.js +51 -51
- package/widgets/text-field-typed-nc/props.js +81 -81
- package/widgets/text-field-typed-nc/scenarios.js +105 -105
- package/widgets/text-field-typed-nc/styles.js +20 -20
- package/widgets/text-field-typed-nc/widget.js +749 -750
- package/widgets/text-input-info-nc/props.js +62 -62
- package/widgets/text-input-info-nc/widget.js +55 -55
- package/widgets/text-input-nc/props.js +143 -143
- package/widgets/text-input-nc/scenarios.js +44 -44
- package/widgets/text-input-nc/styles.js +242 -242
- package/widgets/text-input-nc/widget.js +234 -234
- package/widgets/ticket/getPath.js +128 -128
- package/widgets/ticket/props.js +181 -181
- package/widgets/ticket/scenarios.js +39 -39
- package/widgets/ticket/styles.js +332 -332
- package/widgets/ticket/ticket-helpers.js +33 -33
- package/widgets/ticket/widget.js +348 -348
- package/widgets/ticket-hover/styles.js +207 -207
- package/widgets/ticket-hover/widget.js +53 -53
- package/widgets/time-gauge/widget.js +64 -64
- package/widgets/tips/styles.js +48 -48
- package/widgets/tips/widget.js +171 -171
- package/widgets/translatable-text-field/styles.js +202 -202
- package/widgets/translatable-text-field/text-field.js +132 -132
- package/widgets/translatable-text-field/widget.js +660 -660
- package/widgets/tree/props.js +246 -246
- package/widgets/tree/scenarios.js +14 -14
- package/widgets/tree/styles.js +142 -142
- package/widgets/tree/widget.js +383 -383
- package/widgets/tree-cell/styles.js +140 -140
- package/widgets/tree-cell/widget.js +100 -100
- package/widgets/tree-row/styles.js +77 -77
- package/widgets/tree-row/widget.js +135 -135
- package/widgets/triangle/props.js +48 -48
- package/widgets/triangle/scenarios.js +33 -33
- package/widgets/triangle/styles.js +92 -92
- package/widgets/triangle/widget.js +36 -36
- package/widgets/well-done/widget.js +170 -170
- package/widgets/widget-doc/reducer.js +68 -68
- package/widgets/widget-doc/styles.js +15 -15
- package/widgets/widget-doc/widget-list.js +25 -25
- package/widgets/widget-doc/widget.js +89 -89
- package/widgets/widget-doc-menu/styles.js +12 -12
- package/widgets/widget-doc-menu/widget.js +79 -79
- package/widgets/widget-doc-preview/parse-code.js +20 -20
- package/widgets/widget-doc-preview/styles.js +77 -77
- package/widgets/widget-doc-preview/widget.js +481 -481
- package/widgets/widget-doc-preview-container/styles.js +60 -60
- package/widgets/widget-doc-preview-container/widget.js +129 -129
- package/widgets/widget-doc-properties/styles.js +41 -41
- package/widgets/widget-doc-properties/widget.js +307 -307
- package/widgets/widget-doc-property/styles.js +75 -75
- package/widgets/widget-doc-property/widget.js +108 -108
- package/widgets/widget-doc-property-control/styles.js +14 -14
- package/widgets/widget-doc-property-control/widget.js +343 -343
- package/widgets/wizard/service.js +2132 -2132
- package/widgets/wizard/styles.js +21 -21
- package/widgets/wizard/widget.js +927 -927
- package/widgets/work-dialog/styles.js +31 -31
- package/widgets/work-dialog/widget.js +162 -162
- package/wizard.js +13 -13
|
@@ -1,660 +1,660 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Widget from 'goblin-laboratory/widgets/widget';
|
|
3
|
-
import * as styles from './styles';
|
|
4
|
-
|
|
5
|
-
import MouseTrap from 'mousetrap';
|
|
6
|
-
import ComboHelpers from 'goblin-gadgets/widgets/helpers/combo-helpers';
|
|
7
|
-
import {Unit} from 'goblin-theme';
|
|
8
|
-
import Button from 'goblin-gadgets/widgets/button/widget';
|
|
9
|
-
import Label from 'goblin-gadgets/widgets/label/widget';
|
|
10
|
-
import Combo from 'goblin-gadgets/widgets/combo/widget';
|
|
11
|
-
import DialogModal from 'goblin-gadgets/widgets/dialog-modal/widget';
|
|
12
|
-
import Splitter from 'goblin-gadgets/widgets/splitter/widget';
|
|
13
|
-
|
|
14
|
-
import {isShredder} from 'xcraft-core-shredder';
|
|
15
|
-
import NabuTextField from './text-field';
|
|
16
|
-
import ToNabuObject from 'goblin-nabu/widgets/helpers/t.js';
|
|
17
|
-
import T from 't';
|
|
18
|
-
import SchemaHelpers from 'goblin-toolbox/lib/schema-helpers';
|
|
19
|
-
|
|
20
|
-
/******************************************************************************/
|
|
21
|
-
|
|
22
|
-
function WrapT(...args) {
|
|
23
|
-
// Otherwise extractor complains about T not being statically evaluate-able
|
|
24
|
-
return ToNabuObject(...args);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function localeToText(locale) {
|
|
28
|
-
if (locale) {
|
|
29
|
-
return locale.substring(0, 2).toUpperCase();
|
|
30
|
-
} else {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/******************************************************************************/
|
|
36
|
-
|
|
37
|
-
class TranslatableTextField extends Widget {
|
|
38
|
-
constructor() {
|
|
39
|
-
super(...arguments);
|
|
40
|
-
this.styles = styles;
|
|
41
|
-
|
|
42
|
-
this.mainButtonDiv = null;
|
|
43
|
-
this.primaryButtonDiv = null;
|
|
44
|
-
this.secondaryButtonDiv = null;
|
|
45
|
-
|
|
46
|
-
let list = this.props.list || [];
|
|
47
|
-
if (isShredder(list)) {
|
|
48
|
-
list = list.toJS();
|
|
49
|
-
}
|
|
50
|
-
list = list.map((locale) => ({
|
|
51
|
-
value: locale.name,
|
|
52
|
-
text: `${localeToText(locale.name)} — ${locale.text}`,
|
|
53
|
-
}));
|
|
54
|
-
this.list = list;
|
|
55
|
-
|
|
56
|
-
this.state = {
|
|
57
|
-
showCombo: null,
|
|
58
|
-
showEdit: false,
|
|
59
|
-
focus: false,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
this.comboLocation = null;
|
|
63
|
-
|
|
64
|
-
this.onFocus = this.onFocus.bind(this);
|
|
65
|
-
this.onBlur = this.onBlur.bind(this);
|
|
66
|
-
this.onMouseUp = this.onMouseUp.bind(this);
|
|
67
|
-
this.onKeyCombo = this.onKeyCombo.bind(this);
|
|
68
|
-
this.onShowCombo = this.onShowCombo.bind(this);
|
|
69
|
-
this.onHideCombo = this.onHideCombo.bind(this);
|
|
70
|
-
this.onShowEdit = this.onShowEdit.bind(this);
|
|
71
|
-
this.onHideEdit = this.onHideEdit.bind(this);
|
|
72
|
-
this.swapLocales = this.swapLocales.bind(this);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
componentDidMount() {
|
|
76
|
-
const nabuId = `${this.context.entityId}${this.props.model}`;
|
|
77
|
-
|
|
78
|
-
this.doFor(this.context.entityId, 'change', {
|
|
79
|
-
path: this.props.model.startsWith('.')
|
|
80
|
-
? this.props.model.slice(1)
|
|
81
|
-
: this.props.model,
|
|
82
|
-
newValue: WrapT(nabuId, null, null, null, true),
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
//#region get/set
|
|
87
|
-
get showCombo() {
|
|
88
|
-
return this.state.showCombo;
|
|
89
|
-
}
|
|
90
|
-
set showCombo(value) {
|
|
91
|
-
this.setState({
|
|
92
|
-
showCombo: value,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
get showEdit() {
|
|
97
|
-
return this.state.showEdit;
|
|
98
|
-
}
|
|
99
|
-
set showEdit(value) {
|
|
100
|
-
this.setState({
|
|
101
|
-
showEdit: value,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
get focus() {
|
|
106
|
-
return this.state.focus;
|
|
107
|
-
}
|
|
108
|
-
set focus(value) {
|
|
109
|
-
this.setState({
|
|
110
|
-
focus: value,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
//#endregion
|
|
114
|
-
|
|
115
|
-
//#region state in user session
|
|
116
|
-
getPrimaryLocale() {
|
|
117
|
-
let locale = this.props.translatableState.get('primaryLocale', null);
|
|
118
|
-
if (!locale) {
|
|
119
|
-
locale = this.props.defaultValue;
|
|
120
|
-
}
|
|
121
|
-
return locale;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
getSecondaryLocale() {
|
|
125
|
-
let locale = this.props.translatableState.get('secondaryLocale', null);
|
|
126
|
-
if (!locale) {
|
|
127
|
-
const primaryLocale = this.getPrimaryLocale();
|
|
128
|
-
for (const x of this.list) {
|
|
129
|
-
if (x.value !== primaryLocale) {
|
|
130
|
-
locale = x.value;
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return locale;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
setPrimaryLocale(locale) {
|
|
139
|
-
const newState = {
|
|
140
|
-
primaryLocale: locale,
|
|
141
|
-
secondaryLocale: this.getSecondaryLocale(),
|
|
142
|
-
};
|
|
143
|
-
this.doFor(this.props.clientSessionId, 'set-translatable-text-field', {
|
|
144
|
-
state: newState,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
setSecondaryLocale(locale) {
|
|
149
|
-
const newState = {
|
|
150
|
-
primaryLocale: this.getPrimaryLocale(),
|
|
151
|
-
secondaryLocale: locale,
|
|
152
|
-
};
|
|
153
|
-
this.doFor(this.props.clientSessionId, 'set-translatable-text-field', {
|
|
154
|
-
state: newState,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
swapLocales() {
|
|
159
|
-
const newState = {
|
|
160
|
-
primaryLocale: this.getSecondaryLocale(),
|
|
161
|
-
secondaryLocale: this.getPrimaryLocale(),
|
|
162
|
-
};
|
|
163
|
-
this.doFor(this.props.clientSessionId, 'set-translatable-text-field', {
|
|
164
|
-
state: newState,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
//#endregion
|
|
168
|
-
|
|
169
|
-
getEntitySchema() {
|
|
170
|
-
const entityId = this.context.entityId; // by example "portfolio@e564950b-cd9f-4d35-abd0-b85bf93017f1"
|
|
171
|
-
if (entityId) {
|
|
172
|
-
const entityType = entityId.split('@', 2)[0]; // by example "portfolio"
|
|
173
|
-
return this.getSchema(entityType);
|
|
174
|
-
}
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
getLabelText() {
|
|
179
|
-
const entitySchema = this.getEntitySchema();
|
|
180
|
-
return SchemaHelpers.getLabelText(entitySchema, this.props.model);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/******************************************************************************/
|
|
184
|
-
|
|
185
|
-
onShowCombo(position) {
|
|
186
|
-
if (!this.props.list) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
let node = this.mainButtonDiv;
|
|
191
|
-
switch (position) {
|
|
192
|
-
case 'primary':
|
|
193
|
-
node = this.primaryButtonDiv;
|
|
194
|
-
break;
|
|
195
|
-
case 'secondary':
|
|
196
|
-
node = this.secondaryButtonDiv;
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (!node) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const itemCount = this.list.length;
|
|
205
|
-
|
|
206
|
-
this.comboLocation = ComboHelpers.getComboLocation(
|
|
207
|
-
node,
|
|
208
|
-
this.context.theme.shapes.flyingBalloonTriangleSize,
|
|
209
|
-
this.context.theme.shapes.flyingBalloonPadding,
|
|
210
|
-
itemCount,
|
|
211
|
-
'200px',
|
|
212
|
-
this.context.theme.shapes.menuButtonHeight, // height of Button kind='combo-wrap-item'
|
|
213
|
-
null,
|
|
214
|
-
null,
|
|
215
|
-
Unit.multiply(this.context.theme.shapes.dialogDistanceFromEdge, 2)
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
this.showCombo = position || 'main';
|
|
219
|
-
|
|
220
|
-
const x = this.props.onShowCombo;
|
|
221
|
-
if (x) {
|
|
222
|
-
x();
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
onHideCombo() {
|
|
227
|
-
this.showCombo = null;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
onShowEdit() {
|
|
231
|
-
MouseTrap.bind('esc', this.onHideEdit, 'keydown');
|
|
232
|
-
this.showEdit = true;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
onHideEdit() {
|
|
236
|
-
MouseTrap.unbind('esc');
|
|
237
|
-
this.showEdit = false;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
onChange(e) {
|
|
241
|
-
this.onChange(e);
|
|
242
|
-
const x = this.props.onChange;
|
|
243
|
-
if (x) {
|
|
244
|
-
x(e);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
onFocus() {
|
|
249
|
-
//- console.log ('text-field-combo.onFocus');
|
|
250
|
-
MouseTrap.bind('up', this.onKeyCombo, 'keydown');
|
|
251
|
-
MouseTrap.bind('down', this.onKeyCombo, 'keydown');
|
|
252
|
-
this.focus = true;
|
|
253
|
-
|
|
254
|
-
if (this.props.onFocus) {
|
|
255
|
-
this.props.onFocus();
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
onBlur() {
|
|
260
|
-
//- console.log ('text-field-combo.onBlur');
|
|
261
|
-
MouseTrap.unbind('up');
|
|
262
|
-
MouseTrap.unbind('down');
|
|
263
|
-
this.focus = false;
|
|
264
|
-
|
|
265
|
-
if (this.props.onBlur) {
|
|
266
|
-
this.props.onBlur();
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
onMouseUp() {
|
|
271
|
-
if (this.props.readonly) {
|
|
272
|
-
this.onShowCombo('main');
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
onKeyCombo(e) {
|
|
277
|
-
if (this.showEdit) {
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
e.preventDefault();
|
|
282
|
-
this.onShowCombo('mainb');
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/******************************************************************************/
|
|
286
|
-
|
|
287
|
-
getLocale() {
|
|
288
|
-
if (this.showCombo === 'primary') {
|
|
289
|
-
return this.getPrimaryLocale();
|
|
290
|
-
} else if (this.showCombo === 'secondary') {
|
|
291
|
-
return this.getSecondaryLocale();
|
|
292
|
-
} else {
|
|
293
|
-
return this.getPrimaryLocale();
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
setLocale(value) {
|
|
298
|
-
if (this.showCombo === 'primary') {
|
|
299
|
-
this.setPrimaryLocale(value);
|
|
300
|
-
} else if (this.showCombo === 'secondary') {
|
|
301
|
-
this.setSecondaryLocale(value);
|
|
302
|
-
} else {
|
|
303
|
-
this.setPrimaryLocale(value);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
getItem(item) {
|
|
308
|
-
const active = item.value === this.getLocale();
|
|
309
|
-
|
|
310
|
-
return {
|
|
311
|
-
text: item.text,
|
|
312
|
-
value: item.value,
|
|
313
|
-
glyph: active ? 'check' : 'none',
|
|
314
|
-
active: active,
|
|
315
|
-
action: () => this.setLocale(item.value),
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/******************************************************************************/
|
|
320
|
-
|
|
321
|
-
renderTextField() {
|
|
322
|
-
const {shape, model, defaultValue, ...other} = this.props;
|
|
323
|
-
|
|
324
|
-
const s = shape || 'smooth';
|
|
325
|
-
const textFieldShapes = {
|
|
326
|
-
smooth: 'left-smooth',
|
|
327
|
-
rounded: 'left-rounded',
|
|
328
|
-
};
|
|
329
|
-
const textFieldShape = textFieldShapes[s];
|
|
330
|
-
const nabuId = `${this.context.entityId}${model}`;
|
|
331
|
-
|
|
332
|
-
if (this.props.readonly && this.props.rows && this.props.rows > 1) {
|
|
333
|
-
return (
|
|
334
|
-
<div className={this.styles.classNames.editReadonly}>
|
|
335
|
-
<NabuTextField
|
|
336
|
-
nabuId={nabuId}
|
|
337
|
-
localeName={this.getPrimaryLocale()}
|
|
338
|
-
workitemId={this.props.id || this.context.id}
|
|
339
|
-
shape={textFieldShape}
|
|
340
|
-
embeddedFocus={true}
|
|
341
|
-
onFocus={this.onFocus}
|
|
342
|
-
onBlur={this.onBlur}
|
|
343
|
-
onMouseUp={this.onMouseUp}
|
|
344
|
-
className={this.styles.classNames.nabuTextField}
|
|
345
|
-
preview={true}
|
|
346
|
-
{...other}
|
|
347
|
-
/>
|
|
348
|
-
</div>
|
|
349
|
-
);
|
|
350
|
-
} else {
|
|
351
|
-
return (
|
|
352
|
-
<NabuTextField
|
|
353
|
-
nabuId={nabuId}
|
|
354
|
-
localeName={this.getPrimaryLocale()}
|
|
355
|
-
workitemId={this.props.id || this.context.id}
|
|
356
|
-
shape={textFieldShape}
|
|
357
|
-
embeddedFocus={true}
|
|
358
|
-
onFocus={this.onFocus}
|
|
359
|
-
onBlur={this.onBlur}
|
|
360
|
-
onMouseUp={this.onMouseUp}
|
|
361
|
-
className={this.styles.classNames.nabuTextField}
|
|
362
|
-
{...other}
|
|
363
|
-
/>
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
renderButtonCombo() {
|
|
369
|
-
const text = localeToText(this.getPrimaryLocale());
|
|
370
|
-
|
|
371
|
-
return (
|
|
372
|
-
<div ref={(x) => (this.mainButtonDiv = x)}>
|
|
373
|
-
<Button
|
|
374
|
-
kind="compact"
|
|
375
|
-
width="32px"
|
|
376
|
-
height="32px"
|
|
377
|
-
border="none"
|
|
378
|
-
text={text}
|
|
379
|
-
fontSize="80%"
|
|
380
|
-
disabled={this.props.disabled}
|
|
381
|
-
onClick={() => this.onShowCombo('main')}
|
|
382
|
-
/>
|
|
383
|
-
</div>
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
renderButtonEdit() {
|
|
388
|
-
if (!this.props.rows || this.props.rows === 1) {
|
|
389
|
-
return null;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
const glyph = this.props.readonly ? 'solid/eye' : 'solid/pen';
|
|
393
|
-
|
|
394
|
-
return (
|
|
395
|
-
<Button
|
|
396
|
-
width="32px"
|
|
397
|
-
height="32px"
|
|
398
|
-
border="none"
|
|
399
|
-
glyph={glyph}
|
|
400
|
-
glyphSize="100%"
|
|
401
|
-
disabled={this.props.disabled}
|
|
402
|
-
onClick={this.onShowEdit}
|
|
403
|
-
/>
|
|
404
|
-
);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
renderToolbar() {
|
|
408
|
-
return (
|
|
409
|
-
<div className={this.styles.classNames.toolbar}>
|
|
410
|
-
{this.renderButtonCombo()}
|
|
411
|
-
{this.renderButtonEdit()}
|
|
412
|
-
</div>
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
/******************************************************************************/
|
|
417
|
-
|
|
418
|
-
renderCombo() {
|
|
419
|
-
if (!this.showCombo || !this.comboLocation) {
|
|
420
|
-
return null;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
const x = [];
|
|
424
|
-
for (var item of this.list) {
|
|
425
|
-
if (
|
|
426
|
-
(this.showCombo === 'primary' &&
|
|
427
|
-
item.value === this.getPrimaryLocale()) ||
|
|
428
|
-
(this.showCombo === 'secondary' &&
|
|
429
|
-
item.value === this.getSecondaryLocale())
|
|
430
|
-
) {
|
|
431
|
-
continue;
|
|
432
|
-
}
|
|
433
|
-
x.push(this.getItem(item));
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
return (
|
|
437
|
-
<Combo
|
|
438
|
-
menuType="combo"
|
|
439
|
-
menuItemWidth="200px"
|
|
440
|
-
menuItemTooltips={this.props.menuItemTooltips}
|
|
441
|
-
left={this.comboLocation.center}
|
|
442
|
-
triangleShift={this.comboLocation.triangleShift}
|
|
443
|
-
top={this.comboLocation.top}
|
|
444
|
-
bottom={this.comboLocation.bottom}
|
|
445
|
-
maxHeight={this.comboLocation.maxHeight}
|
|
446
|
-
width={this.comboLocation.width}
|
|
447
|
-
list={x}
|
|
448
|
-
comboTextTransform={this.props.comboTextTransform}
|
|
449
|
-
close={this.onHideCombo}
|
|
450
|
-
/>
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/******************************************************************************/
|
|
455
|
-
|
|
456
|
-
renderEditLocaleTitle(position, locale) {
|
|
457
|
-
if (!locale) {
|
|
458
|
-
return null;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
const selected = this.list.find((x) => x.value === locale);
|
|
462
|
-
const title = selected ? selected.text : null;
|
|
463
|
-
|
|
464
|
-
const l = localeToText(locale);
|
|
465
|
-
const isPrimary = position === 'primary';
|
|
466
|
-
|
|
467
|
-
return (
|
|
468
|
-
<div className={this.styles.classNames.editTitle}>
|
|
469
|
-
<Label text={title} justify="center" grow="1" />
|
|
470
|
-
<Button
|
|
471
|
-
kind="compact"
|
|
472
|
-
width="32px"
|
|
473
|
-
height="32px"
|
|
474
|
-
border="none"
|
|
475
|
-
glyph={isPrimary ? 'solid/chevron-right' : 'solid/chevron-left'}
|
|
476
|
-
onClick={this.swapLocales}
|
|
477
|
-
/>
|
|
478
|
-
<div
|
|
479
|
-
ref={(x) => {
|
|
480
|
-
if (isPrimary) {
|
|
481
|
-
this.primaryButtonDiv = x;
|
|
482
|
-
} else {
|
|
483
|
-
this.secondaryButtonDiv = x;
|
|
484
|
-
}
|
|
485
|
-
}}
|
|
486
|
-
>
|
|
487
|
-
<Button
|
|
488
|
-
kind="compact"
|
|
489
|
-
width="32px"
|
|
490
|
-
height="32px"
|
|
491
|
-
border="none"
|
|
492
|
-
text={l}
|
|
493
|
-
fontSize="80%"
|
|
494
|
-
onClick={() => this.onShowCombo(position)}
|
|
495
|
-
/>
|
|
496
|
-
</div>
|
|
497
|
-
</div>
|
|
498
|
-
);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
renderEditLocaleUp(position, locale) {
|
|
502
|
-
if (!locale) {
|
|
503
|
-
return null;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
const nabuId = `${this.context.entityId}${this.props.model}`;
|
|
507
|
-
|
|
508
|
-
return (
|
|
509
|
-
<div className={this.styles.classNames.editLocale}>
|
|
510
|
-
{this.props.readonly ? (
|
|
511
|
-
<div className={this.styles.classNames.editMarkdown}>
|
|
512
|
-
<NabuTextField
|
|
513
|
-
nabuId={nabuId}
|
|
514
|
-
localeName={locale}
|
|
515
|
-
workitemId={this.props.id || this.context.id}
|
|
516
|
-
embeddedFocus={true}
|
|
517
|
-
className={this.styles.classNames.nabuTextField}
|
|
518
|
-
stretchHeight={true}
|
|
519
|
-
preview={true}
|
|
520
|
-
/>
|
|
521
|
-
</div>
|
|
522
|
-
) : (
|
|
523
|
-
<div className={this.styles.classNames.editField}>
|
|
524
|
-
<NabuTextField
|
|
525
|
-
nabuId={nabuId}
|
|
526
|
-
localeName={locale}
|
|
527
|
-
workitemId={this.props.id || this.context.id}
|
|
528
|
-
embeddedFocus={true}
|
|
529
|
-
className={this.styles.classNames.nabuTextField}
|
|
530
|
-
stretchHeight={true}
|
|
531
|
-
readonly={false}
|
|
532
|
-
changeMode="throttled"
|
|
533
|
-
throttleDelay={20}
|
|
534
|
-
/>
|
|
535
|
-
</div>
|
|
536
|
-
)}
|
|
537
|
-
</div>
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
renderEditLocaleDown(position, locale) {
|
|
542
|
-
if (!locale || this.props.readonly) {
|
|
543
|
-
return null;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
const nabuId = `${this.context.entityId}${this.props.model}`;
|
|
547
|
-
|
|
548
|
-
return (
|
|
549
|
-
<div className={this.styles.classNames.editLocale}>
|
|
550
|
-
<div className={this.styles.classNames.editMarkdown}>
|
|
551
|
-
<NabuTextField
|
|
552
|
-
nabuId={nabuId}
|
|
553
|
-
localeName={locale}
|
|
554
|
-
workitemId={this.props.id || this.context.id}
|
|
555
|
-
embeddedFocus={true}
|
|
556
|
-
className={this.styles.classNames.nabuTextField}
|
|
557
|
-
stretchHeight={true}
|
|
558
|
-
preview={true}
|
|
559
|
-
/>
|
|
560
|
-
</div>
|
|
561
|
-
</div>
|
|
562
|
-
);
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
renderEdit() {
|
|
566
|
-
if (!this.showEdit) {
|
|
567
|
-
return null;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
return (
|
|
571
|
-
<DialogModal
|
|
572
|
-
id="goblin-gadgets/translatable-text-field"
|
|
573
|
-
resizable={true}
|
|
574
|
-
enterKeyStaysInside={true}
|
|
575
|
-
zIndex="10"
|
|
576
|
-
title={this.getLabelText() || T('Edition')}
|
|
577
|
-
margin="0px"
|
|
578
|
-
minWidth="600px"
|
|
579
|
-
minHeight="400px"
|
|
580
|
-
width="1000px"
|
|
581
|
-
height="600px"
|
|
582
|
-
horizontal="0px"
|
|
583
|
-
vertical="0px"
|
|
584
|
-
close={this.onHideEdit}
|
|
585
|
-
>
|
|
586
|
-
<div className={this.styles.classNames.editTitles}>
|
|
587
|
-
{this.renderEditLocaleTitle('primary', this.getPrimaryLocale())}
|
|
588
|
-
{this.renderEditLocaleTitle('secondary', this.getSecondaryLocale())}
|
|
589
|
-
</div>
|
|
590
|
-
{this.props.readonly ? (
|
|
591
|
-
<div className={this.styles.classNames.editSingle}>
|
|
592
|
-
{this.renderEditLocaleUp('primary', this.getPrimaryLocale())}
|
|
593
|
-
{this.renderEditLocaleUp('secondary', this.getSecondaryLocale())}
|
|
594
|
-
</div>
|
|
595
|
-
) : (
|
|
596
|
-
<Splitter kind="horizontal" firstSize="50%">
|
|
597
|
-
<div className={this.styles.classNames.editUp}>
|
|
598
|
-
{this.renderEditLocaleUp('primary', this.getPrimaryLocale())}
|
|
599
|
-
{this.renderEditLocaleUp('secondary', this.getSecondaryLocale())}
|
|
600
|
-
</div>
|
|
601
|
-
<div className={this.styles.classNames.editDown}>
|
|
602
|
-
{this.renderEditLocaleDown('primary', this.getPrimaryLocale())}
|
|
603
|
-
{this.renderEditLocaleDown(
|
|
604
|
-
'secondary',
|
|
605
|
-
this.getSecondaryLocale()
|
|
606
|
-
)}
|
|
607
|
-
</div>
|
|
608
|
-
</Splitter>
|
|
609
|
-
)}
|
|
610
|
-
</DialogModal>
|
|
611
|
-
);
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
/******************************************************************************/
|
|
615
|
-
|
|
616
|
-
render() {
|
|
617
|
-
if (this.props.show === false) {
|
|
618
|
-
return null;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
const boxClass = this.focus
|
|
622
|
-
? this.styles.classNames.translatableTextFieldFocused
|
|
623
|
-
: this.styles.classNames.translatableTextField;
|
|
624
|
-
|
|
625
|
-
return (
|
|
626
|
-
<div className={boxClass} disabled={this.props.disabled}>
|
|
627
|
-
{this.renderTextField()}
|
|
628
|
-
{this.renderToolbar()}
|
|
629
|
-
{this.renderEdit()}
|
|
630
|
-
{this.renderCombo()}
|
|
631
|
-
</div>
|
|
632
|
-
);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/******************************************************************************/
|
|
637
|
-
|
|
638
|
-
export default Widget.connect((state, props) => {
|
|
639
|
-
const locales = state.get('backend.nabu.locales');
|
|
640
|
-
|
|
641
|
-
if (!locales || locales.length === 0) {
|
|
642
|
-
return {};
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
const userSession = Widget.getUserSession(state);
|
|
646
|
-
const clientSessionId = userSession.get('id');
|
|
647
|
-
const translatableState = userSession.get('translatableTextField');
|
|
648
|
-
|
|
649
|
-
const selectedLocaleId = userSession.get('locale');
|
|
650
|
-
const defaultLocale =
|
|
651
|
-
locales.find((locale) => locale.get('id') === selectedLocaleId) ||
|
|
652
|
-
locales.first();
|
|
653
|
-
|
|
654
|
-
return {
|
|
655
|
-
clientSessionId,
|
|
656
|
-
translatableState,
|
|
657
|
-
list: locales,
|
|
658
|
-
defaultValue: defaultLocale.get('name'),
|
|
659
|
-
};
|
|
660
|
-
})(TranslatableTextField);
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Widget from 'goblin-laboratory/widgets/widget';
|
|
3
|
+
import * as styles from './styles';
|
|
4
|
+
|
|
5
|
+
import MouseTrap from 'mousetrap';
|
|
6
|
+
import ComboHelpers from 'goblin-gadgets/widgets/helpers/combo-helpers';
|
|
7
|
+
import {Unit} from 'goblin-theme';
|
|
8
|
+
import Button from 'goblin-gadgets/widgets/button/widget';
|
|
9
|
+
import Label from 'goblin-gadgets/widgets/label/widget';
|
|
10
|
+
import Combo from 'goblin-gadgets/widgets/combo/widget';
|
|
11
|
+
import DialogModal from 'goblin-gadgets/widgets/dialog-modal/widget';
|
|
12
|
+
import Splitter from 'goblin-gadgets/widgets/splitter/widget';
|
|
13
|
+
|
|
14
|
+
import {isShredder} from 'xcraft-core-shredder';
|
|
15
|
+
import NabuTextField from './text-field';
|
|
16
|
+
import ToNabuObject from 'goblin-nabu/widgets/helpers/t.js';
|
|
17
|
+
import T from 't';
|
|
18
|
+
import SchemaHelpers from 'goblin-toolbox/lib/schema-helpers';
|
|
19
|
+
|
|
20
|
+
/******************************************************************************/
|
|
21
|
+
|
|
22
|
+
function WrapT(...args) {
|
|
23
|
+
// Otherwise extractor complains about T not being statically evaluate-able
|
|
24
|
+
return ToNabuObject(...args);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function localeToText(locale) {
|
|
28
|
+
if (locale) {
|
|
29
|
+
return locale.substring(0, 2).toUpperCase();
|
|
30
|
+
} else {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/******************************************************************************/
|
|
36
|
+
|
|
37
|
+
class TranslatableTextField extends Widget {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
this.styles = styles;
|
|
41
|
+
|
|
42
|
+
this.mainButtonDiv = null;
|
|
43
|
+
this.primaryButtonDiv = null;
|
|
44
|
+
this.secondaryButtonDiv = null;
|
|
45
|
+
|
|
46
|
+
let list = this.props.list || [];
|
|
47
|
+
if (isShredder(list)) {
|
|
48
|
+
list = list.toJS();
|
|
49
|
+
}
|
|
50
|
+
list = list.map((locale) => ({
|
|
51
|
+
value: locale.name,
|
|
52
|
+
text: `${localeToText(locale.name)} — ${locale.text}`,
|
|
53
|
+
}));
|
|
54
|
+
this.list = list;
|
|
55
|
+
|
|
56
|
+
this.state = {
|
|
57
|
+
showCombo: null,
|
|
58
|
+
showEdit: false,
|
|
59
|
+
focus: false,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
this.comboLocation = null;
|
|
63
|
+
|
|
64
|
+
this.onFocus = this.onFocus.bind(this);
|
|
65
|
+
this.onBlur = this.onBlur.bind(this);
|
|
66
|
+
this.onMouseUp = this.onMouseUp.bind(this);
|
|
67
|
+
this.onKeyCombo = this.onKeyCombo.bind(this);
|
|
68
|
+
this.onShowCombo = this.onShowCombo.bind(this);
|
|
69
|
+
this.onHideCombo = this.onHideCombo.bind(this);
|
|
70
|
+
this.onShowEdit = this.onShowEdit.bind(this);
|
|
71
|
+
this.onHideEdit = this.onHideEdit.bind(this);
|
|
72
|
+
this.swapLocales = this.swapLocales.bind(this);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
componentDidMount() {
|
|
76
|
+
const nabuId = `${this.context.entityId}${this.props.model}`;
|
|
77
|
+
|
|
78
|
+
this.doFor(this.context.entityId, 'change', {
|
|
79
|
+
path: this.props.model.startsWith('.')
|
|
80
|
+
? this.props.model.slice(1)
|
|
81
|
+
: this.props.model,
|
|
82
|
+
newValue: WrapT(nabuId, null, null, null, true),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#region get/set
|
|
87
|
+
get showCombo() {
|
|
88
|
+
return this.state.showCombo;
|
|
89
|
+
}
|
|
90
|
+
set showCombo(value) {
|
|
91
|
+
this.setState({
|
|
92
|
+
showCombo: value,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
get showEdit() {
|
|
97
|
+
return this.state.showEdit;
|
|
98
|
+
}
|
|
99
|
+
set showEdit(value) {
|
|
100
|
+
this.setState({
|
|
101
|
+
showEdit: value,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
get focus() {
|
|
106
|
+
return this.state.focus;
|
|
107
|
+
}
|
|
108
|
+
set focus(value) {
|
|
109
|
+
this.setState({
|
|
110
|
+
focus: value,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
|
|
115
|
+
//#region state in user session
|
|
116
|
+
getPrimaryLocale() {
|
|
117
|
+
let locale = this.props.translatableState.get('primaryLocale', null);
|
|
118
|
+
if (!locale) {
|
|
119
|
+
locale = this.props.defaultValue;
|
|
120
|
+
}
|
|
121
|
+
return locale;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
getSecondaryLocale() {
|
|
125
|
+
let locale = this.props.translatableState.get('secondaryLocale', null);
|
|
126
|
+
if (!locale) {
|
|
127
|
+
const primaryLocale = this.getPrimaryLocale();
|
|
128
|
+
for (const x of this.list) {
|
|
129
|
+
if (x.value !== primaryLocale) {
|
|
130
|
+
locale = x.value;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return locale;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
setPrimaryLocale(locale) {
|
|
139
|
+
const newState = {
|
|
140
|
+
primaryLocale: locale,
|
|
141
|
+
secondaryLocale: this.getSecondaryLocale(),
|
|
142
|
+
};
|
|
143
|
+
this.doFor(this.props.clientSessionId, 'set-translatable-text-field', {
|
|
144
|
+
state: newState,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
setSecondaryLocale(locale) {
|
|
149
|
+
const newState = {
|
|
150
|
+
primaryLocale: this.getPrimaryLocale(),
|
|
151
|
+
secondaryLocale: locale,
|
|
152
|
+
};
|
|
153
|
+
this.doFor(this.props.clientSessionId, 'set-translatable-text-field', {
|
|
154
|
+
state: newState,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
swapLocales() {
|
|
159
|
+
const newState = {
|
|
160
|
+
primaryLocale: this.getSecondaryLocale(),
|
|
161
|
+
secondaryLocale: this.getPrimaryLocale(),
|
|
162
|
+
};
|
|
163
|
+
this.doFor(this.props.clientSessionId, 'set-translatable-text-field', {
|
|
164
|
+
state: newState,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
|
|
169
|
+
getEntitySchema() {
|
|
170
|
+
const entityId = this.context.entityId; // by example "portfolio@e564950b-cd9f-4d35-abd0-b85bf93017f1"
|
|
171
|
+
if (entityId) {
|
|
172
|
+
const entityType = entityId.split('@', 2)[0]; // by example "portfolio"
|
|
173
|
+
return this.getSchema(entityType);
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
getLabelText() {
|
|
179
|
+
const entitySchema = this.getEntitySchema();
|
|
180
|
+
return SchemaHelpers.getLabelText(entitySchema, this.props.model);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/******************************************************************************/
|
|
184
|
+
|
|
185
|
+
onShowCombo(position) {
|
|
186
|
+
if (!this.props.list) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let node = this.mainButtonDiv;
|
|
191
|
+
switch (position) {
|
|
192
|
+
case 'primary':
|
|
193
|
+
node = this.primaryButtonDiv;
|
|
194
|
+
break;
|
|
195
|
+
case 'secondary':
|
|
196
|
+
node = this.secondaryButtonDiv;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (!node) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const itemCount = this.list.length;
|
|
205
|
+
|
|
206
|
+
this.comboLocation = ComboHelpers.getComboLocation(
|
|
207
|
+
node,
|
|
208
|
+
this.context.theme.shapes.flyingBalloonTriangleSize,
|
|
209
|
+
this.context.theme.shapes.flyingBalloonPadding,
|
|
210
|
+
itemCount,
|
|
211
|
+
'200px',
|
|
212
|
+
this.context.theme.shapes.menuButtonHeight, // height of Button kind='combo-wrap-item'
|
|
213
|
+
null,
|
|
214
|
+
null,
|
|
215
|
+
Unit.multiply(this.context.theme.shapes.dialogDistanceFromEdge, 2)
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
this.showCombo = position || 'main';
|
|
219
|
+
|
|
220
|
+
const x = this.props.onShowCombo;
|
|
221
|
+
if (x) {
|
|
222
|
+
x();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
onHideCombo() {
|
|
227
|
+
this.showCombo = null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
onShowEdit() {
|
|
231
|
+
MouseTrap.bind('esc', this.onHideEdit, 'keydown');
|
|
232
|
+
this.showEdit = true;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
onHideEdit() {
|
|
236
|
+
MouseTrap.unbind('esc');
|
|
237
|
+
this.showEdit = false;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
onChange(e) {
|
|
241
|
+
this.onChange(e);
|
|
242
|
+
const x = this.props.onChange;
|
|
243
|
+
if (x) {
|
|
244
|
+
x(e);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
onFocus() {
|
|
249
|
+
//- console.log ('text-field-combo.onFocus');
|
|
250
|
+
MouseTrap.bind('up', this.onKeyCombo, 'keydown');
|
|
251
|
+
MouseTrap.bind('down', this.onKeyCombo, 'keydown');
|
|
252
|
+
this.focus = true;
|
|
253
|
+
|
|
254
|
+
if (this.props.onFocus) {
|
|
255
|
+
this.props.onFocus();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
onBlur() {
|
|
260
|
+
//- console.log ('text-field-combo.onBlur');
|
|
261
|
+
MouseTrap.unbind('up');
|
|
262
|
+
MouseTrap.unbind('down');
|
|
263
|
+
this.focus = false;
|
|
264
|
+
|
|
265
|
+
if (this.props.onBlur) {
|
|
266
|
+
this.props.onBlur();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
onMouseUp() {
|
|
271
|
+
if (this.props.readonly) {
|
|
272
|
+
this.onShowCombo('main');
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
onKeyCombo(e) {
|
|
277
|
+
if (this.showEdit) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
e.preventDefault();
|
|
282
|
+
this.onShowCombo('mainb');
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/******************************************************************************/
|
|
286
|
+
|
|
287
|
+
getLocale() {
|
|
288
|
+
if (this.showCombo === 'primary') {
|
|
289
|
+
return this.getPrimaryLocale();
|
|
290
|
+
} else if (this.showCombo === 'secondary') {
|
|
291
|
+
return this.getSecondaryLocale();
|
|
292
|
+
} else {
|
|
293
|
+
return this.getPrimaryLocale();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
setLocale(value) {
|
|
298
|
+
if (this.showCombo === 'primary') {
|
|
299
|
+
this.setPrimaryLocale(value);
|
|
300
|
+
} else if (this.showCombo === 'secondary') {
|
|
301
|
+
this.setSecondaryLocale(value);
|
|
302
|
+
} else {
|
|
303
|
+
this.setPrimaryLocale(value);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
getItem(item) {
|
|
308
|
+
const active = item.value === this.getLocale();
|
|
309
|
+
|
|
310
|
+
return {
|
|
311
|
+
text: item.text,
|
|
312
|
+
value: item.value,
|
|
313
|
+
glyph: active ? 'check' : 'none',
|
|
314
|
+
active: active,
|
|
315
|
+
action: () => this.setLocale(item.value),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/******************************************************************************/
|
|
320
|
+
|
|
321
|
+
renderTextField() {
|
|
322
|
+
const {shape, model, defaultValue, ...other} = this.props;
|
|
323
|
+
|
|
324
|
+
const s = shape || 'smooth';
|
|
325
|
+
const textFieldShapes = {
|
|
326
|
+
smooth: 'left-smooth',
|
|
327
|
+
rounded: 'left-rounded',
|
|
328
|
+
};
|
|
329
|
+
const textFieldShape = textFieldShapes[s];
|
|
330
|
+
const nabuId = `${this.context.entityId}${model}`;
|
|
331
|
+
|
|
332
|
+
if (this.props.readonly && this.props.rows && this.props.rows > 1) {
|
|
333
|
+
return (
|
|
334
|
+
<div className={this.styles.classNames.editReadonly}>
|
|
335
|
+
<NabuTextField
|
|
336
|
+
nabuId={nabuId}
|
|
337
|
+
localeName={this.getPrimaryLocale()}
|
|
338
|
+
workitemId={this.props.id || this.context.id}
|
|
339
|
+
shape={textFieldShape}
|
|
340
|
+
embeddedFocus={true}
|
|
341
|
+
onFocus={this.onFocus}
|
|
342
|
+
onBlur={this.onBlur}
|
|
343
|
+
onMouseUp={this.onMouseUp}
|
|
344
|
+
className={this.styles.classNames.nabuTextField}
|
|
345
|
+
preview={true}
|
|
346
|
+
{...other}
|
|
347
|
+
/>
|
|
348
|
+
</div>
|
|
349
|
+
);
|
|
350
|
+
} else {
|
|
351
|
+
return (
|
|
352
|
+
<NabuTextField
|
|
353
|
+
nabuId={nabuId}
|
|
354
|
+
localeName={this.getPrimaryLocale()}
|
|
355
|
+
workitemId={this.props.id || this.context.id}
|
|
356
|
+
shape={textFieldShape}
|
|
357
|
+
embeddedFocus={true}
|
|
358
|
+
onFocus={this.onFocus}
|
|
359
|
+
onBlur={this.onBlur}
|
|
360
|
+
onMouseUp={this.onMouseUp}
|
|
361
|
+
className={this.styles.classNames.nabuTextField}
|
|
362
|
+
{...other}
|
|
363
|
+
/>
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
renderButtonCombo() {
|
|
369
|
+
const text = localeToText(this.getPrimaryLocale());
|
|
370
|
+
|
|
371
|
+
return (
|
|
372
|
+
<div ref={(x) => (this.mainButtonDiv = x)}>
|
|
373
|
+
<Button
|
|
374
|
+
kind="compact"
|
|
375
|
+
width="32px"
|
|
376
|
+
height="32px"
|
|
377
|
+
border="none"
|
|
378
|
+
text={text}
|
|
379
|
+
fontSize="80%"
|
|
380
|
+
disabled={this.props.disabled}
|
|
381
|
+
onClick={() => this.onShowCombo('main')}
|
|
382
|
+
/>
|
|
383
|
+
</div>
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
renderButtonEdit() {
|
|
388
|
+
if (!this.props.rows || this.props.rows === 1) {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const glyph = this.props.readonly ? 'solid/eye' : 'solid/pen';
|
|
393
|
+
|
|
394
|
+
return (
|
|
395
|
+
<Button
|
|
396
|
+
width="32px"
|
|
397
|
+
height="32px"
|
|
398
|
+
border="none"
|
|
399
|
+
glyph={glyph}
|
|
400
|
+
glyphSize="100%"
|
|
401
|
+
disabled={this.props.disabled}
|
|
402
|
+
onClick={this.onShowEdit}
|
|
403
|
+
/>
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
renderToolbar() {
|
|
408
|
+
return (
|
|
409
|
+
<div className={this.styles.classNames.toolbar}>
|
|
410
|
+
{this.renderButtonCombo()}
|
|
411
|
+
{this.renderButtonEdit()}
|
|
412
|
+
</div>
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/******************************************************************************/
|
|
417
|
+
|
|
418
|
+
renderCombo() {
|
|
419
|
+
if (!this.showCombo || !this.comboLocation) {
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const x = [];
|
|
424
|
+
for (var item of this.list) {
|
|
425
|
+
if (
|
|
426
|
+
(this.showCombo === 'primary' &&
|
|
427
|
+
item.value === this.getPrimaryLocale()) ||
|
|
428
|
+
(this.showCombo === 'secondary' &&
|
|
429
|
+
item.value === this.getSecondaryLocale())
|
|
430
|
+
) {
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
x.push(this.getItem(item));
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return (
|
|
437
|
+
<Combo
|
|
438
|
+
menuType="combo"
|
|
439
|
+
menuItemWidth="200px"
|
|
440
|
+
menuItemTooltips={this.props.menuItemTooltips}
|
|
441
|
+
left={this.comboLocation.center}
|
|
442
|
+
triangleShift={this.comboLocation.triangleShift}
|
|
443
|
+
top={this.comboLocation.top}
|
|
444
|
+
bottom={this.comboLocation.bottom}
|
|
445
|
+
maxHeight={this.comboLocation.maxHeight}
|
|
446
|
+
width={this.comboLocation.width}
|
|
447
|
+
list={x}
|
|
448
|
+
comboTextTransform={this.props.comboTextTransform}
|
|
449
|
+
close={this.onHideCombo}
|
|
450
|
+
/>
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/******************************************************************************/
|
|
455
|
+
|
|
456
|
+
renderEditLocaleTitle(position, locale) {
|
|
457
|
+
if (!locale) {
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const selected = this.list.find((x) => x.value === locale);
|
|
462
|
+
const title = selected ? selected.text : null;
|
|
463
|
+
|
|
464
|
+
const l = localeToText(locale);
|
|
465
|
+
const isPrimary = position === 'primary';
|
|
466
|
+
|
|
467
|
+
return (
|
|
468
|
+
<div className={this.styles.classNames.editTitle}>
|
|
469
|
+
<Label text={title} justify="center" grow="1" />
|
|
470
|
+
<Button
|
|
471
|
+
kind="compact"
|
|
472
|
+
width="32px"
|
|
473
|
+
height="32px"
|
|
474
|
+
border="none"
|
|
475
|
+
glyph={isPrimary ? 'solid/chevron-right' : 'solid/chevron-left'}
|
|
476
|
+
onClick={this.swapLocales}
|
|
477
|
+
/>
|
|
478
|
+
<div
|
|
479
|
+
ref={(x) => {
|
|
480
|
+
if (isPrimary) {
|
|
481
|
+
this.primaryButtonDiv = x;
|
|
482
|
+
} else {
|
|
483
|
+
this.secondaryButtonDiv = x;
|
|
484
|
+
}
|
|
485
|
+
}}
|
|
486
|
+
>
|
|
487
|
+
<Button
|
|
488
|
+
kind="compact"
|
|
489
|
+
width="32px"
|
|
490
|
+
height="32px"
|
|
491
|
+
border="none"
|
|
492
|
+
text={l}
|
|
493
|
+
fontSize="80%"
|
|
494
|
+
onClick={() => this.onShowCombo(position)}
|
|
495
|
+
/>
|
|
496
|
+
</div>
|
|
497
|
+
</div>
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
renderEditLocaleUp(position, locale) {
|
|
502
|
+
if (!locale) {
|
|
503
|
+
return null;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const nabuId = `${this.context.entityId}${this.props.model}`;
|
|
507
|
+
|
|
508
|
+
return (
|
|
509
|
+
<div className={this.styles.classNames.editLocale}>
|
|
510
|
+
{this.props.readonly ? (
|
|
511
|
+
<div className={this.styles.classNames.editMarkdown}>
|
|
512
|
+
<NabuTextField
|
|
513
|
+
nabuId={nabuId}
|
|
514
|
+
localeName={locale}
|
|
515
|
+
workitemId={this.props.id || this.context.id}
|
|
516
|
+
embeddedFocus={true}
|
|
517
|
+
className={this.styles.classNames.nabuTextField}
|
|
518
|
+
stretchHeight={true}
|
|
519
|
+
preview={true}
|
|
520
|
+
/>
|
|
521
|
+
</div>
|
|
522
|
+
) : (
|
|
523
|
+
<div className={this.styles.classNames.editField}>
|
|
524
|
+
<NabuTextField
|
|
525
|
+
nabuId={nabuId}
|
|
526
|
+
localeName={locale}
|
|
527
|
+
workitemId={this.props.id || this.context.id}
|
|
528
|
+
embeddedFocus={true}
|
|
529
|
+
className={this.styles.classNames.nabuTextField}
|
|
530
|
+
stretchHeight={true}
|
|
531
|
+
readonly={false}
|
|
532
|
+
changeMode="throttled"
|
|
533
|
+
throttleDelay={20}
|
|
534
|
+
/>
|
|
535
|
+
</div>
|
|
536
|
+
)}
|
|
537
|
+
</div>
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
renderEditLocaleDown(position, locale) {
|
|
542
|
+
if (!locale || this.props.readonly) {
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
const nabuId = `${this.context.entityId}${this.props.model}`;
|
|
547
|
+
|
|
548
|
+
return (
|
|
549
|
+
<div className={this.styles.classNames.editLocale}>
|
|
550
|
+
<div className={this.styles.classNames.editMarkdown}>
|
|
551
|
+
<NabuTextField
|
|
552
|
+
nabuId={nabuId}
|
|
553
|
+
localeName={locale}
|
|
554
|
+
workitemId={this.props.id || this.context.id}
|
|
555
|
+
embeddedFocus={true}
|
|
556
|
+
className={this.styles.classNames.nabuTextField}
|
|
557
|
+
stretchHeight={true}
|
|
558
|
+
preview={true}
|
|
559
|
+
/>
|
|
560
|
+
</div>
|
|
561
|
+
</div>
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
renderEdit() {
|
|
566
|
+
if (!this.showEdit) {
|
|
567
|
+
return null;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
return (
|
|
571
|
+
<DialogModal
|
|
572
|
+
id="goblin-gadgets/translatable-text-field"
|
|
573
|
+
resizable={true}
|
|
574
|
+
enterKeyStaysInside={true}
|
|
575
|
+
zIndex="10"
|
|
576
|
+
title={this.getLabelText() || T('Edition')}
|
|
577
|
+
margin="0px"
|
|
578
|
+
minWidth="600px"
|
|
579
|
+
minHeight="400px"
|
|
580
|
+
width="1000px"
|
|
581
|
+
height="600px"
|
|
582
|
+
horizontal="0px"
|
|
583
|
+
vertical="0px"
|
|
584
|
+
close={this.onHideEdit}
|
|
585
|
+
>
|
|
586
|
+
<div className={this.styles.classNames.editTitles}>
|
|
587
|
+
{this.renderEditLocaleTitle('primary', this.getPrimaryLocale())}
|
|
588
|
+
{this.renderEditLocaleTitle('secondary', this.getSecondaryLocale())}
|
|
589
|
+
</div>
|
|
590
|
+
{this.props.readonly ? (
|
|
591
|
+
<div className={this.styles.classNames.editSingle}>
|
|
592
|
+
{this.renderEditLocaleUp('primary', this.getPrimaryLocale())}
|
|
593
|
+
{this.renderEditLocaleUp('secondary', this.getSecondaryLocale())}
|
|
594
|
+
</div>
|
|
595
|
+
) : (
|
|
596
|
+
<Splitter kind="horizontal" firstSize="50%">
|
|
597
|
+
<div className={this.styles.classNames.editUp}>
|
|
598
|
+
{this.renderEditLocaleUp('primary', this.getPrimaryLocale())}
|
|
599
|
+
{this.renderEditLocaleUp('secondary', this.getSecondaryLocale())}
|
|
600
|
+
</div>
|
|
601
|
+
<div className={this.styles.classNames.editDown}>
|
|
602
|
+
{this.renderEditLocaleDown('primary', this.getPrimaryLocale())}
|
|
603
|
+
{this.renderEditLocaleDown(
|
|
604
|
+
'secondary',
|
|
605
|
+
this.getSecondaryLocale()
|
|
606
|
+
)}
|
|
607
|
+
</div>
|
|
608
|
+
</Splitter>
|
|
609
|
+
)}
|
|
610
|
+
</DialogModal>
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/******************************************************************************/
|
|
615
|
+
|
|
616
|
+
render() {
|
|
617
|
+
if (this.props.show === false) {
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const boxClass = this.focus
|
|
622
|
+
? this.styles.classNames.translatableTextFieldFocused
|
|
623
|
+
: this.styles.classNames.translatableTextField;
|
|
624
|
+
|
|
625
|
+
return (
|
|
626
|
+
<div className={boxClass} disabled={this.props.disabled}>
|
|
627
|
+
{this.renderTextField()}
|
|
628
|
+
{this.renderToolbar()}
|
|
629
|
+
{this.renderEdit()}
|
|
630
|
+
{this.renderCombo()}
|
|
631
|
+
</div>
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/******************************************************************************/
|
|
637
|
+
|
|
638
|
+
export default Widget.connect((state, props) => {
|
|
639
|
+
const locales = state.get('backend.nabu.locales');
|
|
640
|
+
|
|
641
|
+
if (!locales || locales.length === 0) {
|
|
642
|
+
return {};
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
const userSession = Widget.getUserSession(state);
|
|
646
|
+
const clientSessionId = userSession.get('id');
|
|
647
|
+
const translatableState = userSession.get('translatableTextField');
|
|
648
|
+
|
|
649
|
+
const selectedLocaleId = userSession.get('locale');
|
|
650
|
+
const defaultLocale =
|
|
651
|
+
locales.find((locale) => locale.get('id') === selectedLocaleId) ||
|
|
652
|
+
locales.first();
|
|
653
|
+
|
|
654
|
+
return {
|
|
655
|
+
clientSessionId,
|
|
656
|
+
translatableState,
|
|
657
|
+
list: locales,
|
|
658
|
+
defaultValue: defaultLocale.get('name'),
|
|
659
|
+
};
|
|
660
|
+
})(TranslatableTextField);
|