goblin-desktop 2.0.21 → 2.0.24
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 +3 -3
- package/README.md +108 -108
- package/builders/builders.js +3 -3
- package/builders/wizard.js +457 -457
- package/contexts.js +13 -13
- package/desktop-manager.js +10 -10
- package/desktop-window.js +13 -13
- package/desktop.js +13 -13
- package/lib/service.js +137 -137
- package/package.json +36 -36
- package/password-wizard.js +13 -13
- package/quest-run-wizard.js +13 -13
- package/taskbar.js +13 -13
- package/widgets/audio/sfx.js +177 -177
- package/widgets/board/view.js +37 -37
- package/widgets/board/widget.js +65 -65
- package/widgets/contexts/logic-handlers.js +36 -36
- package/widgets/contexts/service.js +40 -40
- package/widgets/contexts/view.js +22 -22
- package/widgets/contexts/widget.js +147 -147
- package/widgets/datagrid/datagrid-entity.js +82 -82
- package/widgets/datagrid/datagrid-headers.js +272 -272
- package/widgets/datagrid/styles.js +13 -13
- package/widgets/datagrid/widget.js +192 -192
- package/widgets/datagrid-cell/styles.js +52 -52
- package/widgets/datagrid-cell/widget.js +41 -41
- package/widgets/datagrid-item/styles.js +15 -15
- package/widgets/datagrid-item/widget.js +74 -74
- package/widgets/default/view.js +95 -91
- package/widgets/desktop/compensator.js +9 -9
- package/widgets/desktop/logic-handlers.js +237 -237
- package/widgets/desktop/reducer.js +35 -35
- package/widgets/desktop/service.js +828 -828
- package/widgets/desktop/styles.js +28 -28
- package/widgets/desktop/widget.js +175 -175
- package/widgets/desktop-clock/styles.js +69 -69
- package/widgets/desktop-clock/widget.js +387 -387
- package/widgets/desktop-clock-clock/styles.js +56 -56
- package/widgets/desktop-clock-clock/widget.js +96 -96
- package/widgets/desktop-clock-menu/styles.js +129 -129
- package/widgets/desktop-clock-menu/widget.js +63 -63
- package/widgets/desktop-connection-status/reducer.js +15 -15
- package/widgets/desktop-connection-status/styles.js +44 -44
- package/widgets/desktop-connection-status/widget.js +129 -129
- package/widgets/desktop-content/widget.js +68 -68
- package/widgets/desktop-footer/reducer.js +31 -31
- package/widgets/desktop-footer/styles.js +36 -36
- package/widgets/desktop-footer/widget.js +52 -52
- package/widgets/desktop-monitors/styles.js +155 -155
- package/widgets/desktop-monitors/widget.js +272 -272
- package/widgets/desktop-notebook/styles.js +155 -155
- package/widgets/desktop-notebook/widget.js +252 -252
- package/widgets/desktop-notifications/styles.js +147 -147
- package/widgets/desktop-notifications/widget.js +231 -231
- package/widgets/desktop-scale/reducer.js +15 -15
- package/widgets/desktop-scale/styles.js +48 -48
- package/widgets/desktop-scale/widget.js +172 -172
- package/widgets/desktop-state-monitor/styles.js +72 -72
- package/widgets/desktop-state-monitor/widget.js +123 -123
- package/widgets/desktop-taskbar/widget.js +57 -57
- package/widgets/desktop-themes-menu/widget.js +121 -121
- package/widgets/desktop-topbar/widget.js +201 -201
- package/widgets/desktop-window/service.js +56 -56
- package/widgets/desktop-window/styles.js +22 -22
- package/widgets/desktop-window/widget.js +70 -70
- package/widgets/detail/compensator.js +17 -17
- package/widgets/detail/view.js +40 -40
- package/widgets/detail/widget.js +125 -125
- package/widgets/editor/widget.js +84 -80
- package/widgets/entity-alerts/styles.js +77 -77
- package/widgets/entity-alerts/widget.js +328 -328
- package/widgets/entity-list/styles.js +66 -66
- package/widgets/entity-list/view.js +36 -36
- package/widgets/entity-list/widget.js +209 -209
- package/widgets/entity-list-item/widget.js +68 -68
- package/widgets/entity-row/styles.js +105 -105
- package/widgets/entity-row/widget.js +524 -524
- package/widgets/entity-row-button/styles.js +46 -46
- package/widgets/entity-row-button/widget.js +57 -57
- package/widgets/entity-view/reducer.js +20 -20
- package/widgets/entity-view/styles.js +90 -90
- package/widgets/entity-view/widget.js +516 -516
- package/widgets/facet-checkbox/styles.js +17 -17
- package/widgets/facet-checkbox/widget.js +43 -43
- package/widgets/facet-filter/widget.js +94 -94
- package/widgets/facet-filter-add/styles.js +30 -30
- package/widgets/facet-filter-add/widget.js +105 -105
- package/widgets/facet-filter-button/styles.js +74 -74
- package/widgets/facet-filter-button/widget.js +214 -214
- package/widgets/facet-filter-list-dialog/styles.js +59 -59
- package/widgets/facet-filter-list-dialog/widget.js +253 -253
- package/widgets/facet-filter-list-dialog-footer/styles.js +22 -22
- package/widgets/facet-filter-list-dialog-footer/widget.js +105 -105
- package/widgets/facet-filter-range-dialog/styles.js +82 -82
- package/widgets/facet-filter-range-dialog/widget.js +399 -399
- package/widgets/facet-filter-range-dialog-footer/styles.js +22 -22
- package/widgets/facet-filter-range-dialog-footer/widget.js +182 -182
- package/widgets/gamepad/widget.js +75 -75
- package/widgets/helpers/facet-helpers.js +105 -105
- package/widgets/hinter/reducer.js +35 -35
- package/widgets/hinter/styles.js +79 -79
- package/widgets/hinter/view.js +31 -31
- package/widgets/hinter/widget.js +291 -291
- package/widgets/junction/styles.js +22 -22
- package/widgets/junction/widget.js +50 -50
- package/widgets/main-tab-menu/styles.js +17 -17
- package/widgets/main-tab-menu/widget.js +136 -136
- package/widgets/map/view.js +49 -49
- package/widgets/map/widget.js +65 -65
- package/widgets/monitor/reducer.js +15 -15
- package/widgets/monitor/widget.js +66 -66
- package/widgets/navigating-layer/widget.js +25 -25
- package/widgets/notifications-button/widget.js +44 -44
- package/widgets/password-wizard/service.js +53 -53
- package/widgets/password-wizard/ui.js +66 -66
- package/widgets/plugin/reducer.js +19 -19
- package/widgets/plugin/styles.js +294 -294
- package/widgets/plugin/widget.js +637 -636
- package/widgets/quest-run-wizard/service.js +49 -49
- package/widgets/quest-run-wizard/ui.js +25 -25
- package/widgets/search/styles.js +80 -80
- package/widgets/search/widget.js +285 -285
- package/widgets/simple/view.js +29 -29
- package/widgets/status-filters/widget.js +121 -121
- package/widgets/tab/styles.js +16 -16
- package/widgets/tab/widget.js +89 -89
- package/widgets/tab-content/widget.js +35 -35
- package/widgets/tabs/widget.js +48 -48
- package/widgets/taskbar/service.js +99 -99
- package/widgets/taskbar/view.js +24 -24
- package/widgets/taskbar/widget.js +167 -167
- package/widgets/widget-doc-caller/reducer.js +15 -15
- package/widgets/widget-doc-caller/styles.js +20 -20
- package/widgets/widget-doc-caller/widget.js +55 -55
- package/widgets/wizard/widget.js +299 -299
- package/widgets/wizard-buttons/widget.js +111 -107
- package/widgets/workitem/styles.js +281 -281
- package/widgets/workitem/view.js +62 -62
- package/widgets/workitem/widget.js +971 -971
- package/widgets/workitem-dialog/widget.js +86 -86
- package/widgets/workitem-fields/widget.js +63 -63
package/widgets/plugin/widget.js
CHANGED
|
@@ -1,636 +1,637 @@
|
|
|
1
|
-
//T:2019-02-27
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import ReactDOM from 'react-dom';
|
|
5
|
-
import scrollIntoViewIfNeeded from 'scroll-into-view-if-needed';
|
|
6
|
-
import Widget from 'goblin-laboratory/widgets/widget';
|
|
7
|
-
import {Unit} from 'goblin-theme';
|
|
8
|
-
const px = Unit.toPx;
|
|
9
|
-
|
|
10
|
-
import Workitem from 'goblin-desktop/widgets/workitem/widget';
|
|
11
|
-
import Container from 'goblin-gadgets/widgets/container/widget';
|
|
12
|
-
import Button from 'goblin-gadgets/widgets/button/widget';
|
|
13
|
-
import Label from 'goblin-gadgets/widgets/label/widget';
|
|
14
|
-
import Field from 'goblin-gadgets/widgets/field/widget';
|
|
15
|
-
import DragCab from 'goblin-gadgets/widgets/drag-cab/widget';
|
|
16
|
-
import Combo from 'goblin-gadgets/widgets/combo/widget';
|
|
17
|
-
|
|
18
|
-
import importer from 'goblin_importer';
|
|
19
|
-
import T from 't';
|
|
20
|
-
|
|
21
|
-
const uiImporter = importer('ui');
|
|
22
|
-
|
|
23
|
-
/******************************************************************************/
|
|
24
|
-
|
|
25
|
-
class Plugin extends Widget {
|
|
26
|
-
constructor() {
|
|
27
|
-
super(...arguments);
|
|
28
|
-
|
|
29
|
-
this._refs = {};
|
|
30
|
-
this._scrollEntityId = null;
|
|
31
|
-
this.comboButton = null;
|
|
32
|
-
|
|
33
|
-
this.state = {
|
|
34
|
-
showActionMenu: false,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
this.onAction = this.onAction.bind(this);
|
|
38
|
-
this.onActionAdd = this.onActionAdd.bind(this);
|
|
39
|
-
this.onSwapExtended = this.onSwapExtended.bind(this);
|
|
40
|
-
this.onDeleteEntity = this.onDeleteEntity.bind(this);
|
|
41
|
-
this.onEditEntity = this.onEditEntity.bind(this);
|
|
42
|
-
this.onEntityDragged = this.onEntityDragged.bind(this);
|
|
43
|
-
this.doProxy = this.doProxy.bind(this);
|
|
44
|
-
this.open = this.open.bind(this);
|
|
45
|
-
this.close = this.close.bind(this);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get showActionMenu() {
|
|
49
|
-
return this.state.showActionMenu;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
set showActionMenu(value) {
|
|
53
|
-
this.setState({
|
|
54
|
-
showActionMenu: value,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
_scrollIntoView(duration) {
|
|
59
|
-
if (
|
|
60
|
-
!this._scrollEntityId ||
|
|
61
|
-
!this._refs[this._scrollEntityId] ||
|
|
62
|
-
this._scrollEntityId !== this.props.extendedId
|
|
63
|
-
) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
scrollIntoViewIfNeeded(this._refs[this._scrollEntityId], {
|
|
68
|
-
duration,
|
|
69
|
-
// HACK: we need to fix the transitions in order to remove this offset
|
|
70
|
-
offset: {
|
|
71
|
-
top: 3,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
componentDidUpdate() {
|
|
77
|
-
this._scrollIntoView(150);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
onAction(actionName) {
|
|
81
|
-
const service = this.props.namespace;
|
|
82
|
-
switch (actionName) {
|
|
83
|
-
case 'add':
|
|
84
|
-
this.doAs(service, actionName);
|
|
85
|
-
break;
|
|
86
|
-
case 'clear':
|
|
87
|
-
this.doAs(service, actionName);
|
|
88
|
-
break;
|
|
89
|
-
default:
|
|
90
|
-
this.doAs(service, 'do-action', {action: actionName});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
onActionAdd() {
|
|
95
|
-
this.onAction('add');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
onSwapExtended(entityId) {
|
|
99
|
-
this._scrollEntityId = entityId;
|
|
100
|
-
this.dispatch({type: 'TOGGLE_EXTENDED', entityId});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
onDeleteEntity(entityId) {
|
|
104
|
-
const service = this.props.namespace;
|
|
105
|
-
this.doAs(service, 'remove', {entityId});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
onEditEntity(entityId) {
|
|
109
|
-
const service = this.props.namespace;
|
|
110
|
-
this.doAs(service, 'edit', {entityId});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
onEntityDragged(selectedIds, toId, ownerId, ownerKind) {
|
|
114
|
-
const service = this.props.namespace;
|
|
115
|
-
if (ownerId === this.props.id) {
|
|
116
|
-
this.doAs(service, 'drag', {
|
|
117
|
-
fromId: selectedIds[0],
|
|
118
|
-
toId: toId,
|
|
119
|
-
});
|
|
120
|
-
} else {
|
|
121
|
-
this.doAs(service, 'remove', {
|
|
122
|
-
entityId: selectedIds[0],
|
|
123
|
-
});
|
|
124
|
-
this.cmd(`${service}.add`, {
|
|
125
|
-
id: ownerId,
|
|
126
|
-
entityId: selectedIds[0],
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
getActionMenuList(numberOfIds) {
|
|
132
|
-
const list = [];
|
|
133
|
-
|
|
134
|
-
if (this.props.actionMenu) {
|
|
135
|
-
for (const item of this.props.actionMenu) {
|
|
136
|
-
if (!item.min || item.min <= numberOfIds) {
|
|
137
|
-
list.push({
|
|
138
|
-
glyph: item.glyph,
|
|
139
|
-
text: item.text,
|
|
140
|
-
action: () => this.onAction(item.actionName),
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
numberOfIds > 0 &&
|
|
148
|
-
(!this.props.arity || !this.props.arity.startsWith('1'))
|
|
149
|
-
) {
|
|
150
|
-
if (list.length > 0) {
|
|
151
|
-
list.push({
|
|
152
|
-
separator: true,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
list.push({
|
|
156
|
-
glyph: 'solid/trash',
|
|
157
|
-
text: T('Tout supprimer'),
|
|
158
|
-
action: () => this.onAction('clear'),
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return list;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
doProxy(index) {
|
|
166
|
-
return (action, args) => {
|
|
167
|
-
const workitemId = `${this.props.editorWidget}${
|
|
168
|
-
this.props.mode ? `@${this.props.mode}` : ''
|
|
169
|
-
}@${this.context.desktopId}@${this.props.entityIds.get(index)}`;
|
|
170
|
-
this.doFor(workitemId, action, args);
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
open() {
|
|
175
|
-
this.showActionMenu = true;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
close() {
|
|
179
|
-
this.showActionMenu = false;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/******************************************************************************/
|
|
183
|
-
|
|
184
|
-
renderHeaderSearch() {
|
|
185
|
-
if (this.props.searchHinter) {
|
|
186
|
-
return (
|
|
187
|
-
<Field
|
|
188
|
-
shape="rounded"
|
|
189
|
-
labelGlyph="solid/search"
|
|
190
|
-
labelWidth="24px"
|
|
191
|
-
fieldWidth="180px"
|
|
192
|
-
hintText={T('Ajouter existant')}
|
|
193
|
-
tooltip={T(
|
|
194
|
-
'Ajouter un élément existant en le choisissant dans une liste'
|
|
195
|
-
)}
|
|
196
|
-
kind="hinter"
|
|
197
|
-
required={false}
|
|
198
|
-
hinter={this.props.searchHinter}
|
|
199
|
-
horizontalSpacing="large"
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
} else {
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
renderHeaderActionMenuButton(numberOfIds) {
|
|
208
|
-
const list = this.getActionMenuList(numberOfIds);
|
|
209
|
-
if (list.length > 0) {
|
|
210
|
-
return (
|
|
211
|
-
<Button
|
|
212
|
-
ref={(x) => (this.comboButton = x)}
|
|
213
|
-
glyph="solid/ellipsis-h"
|
|
214
|
-
horizontalSpacing="large"
|
|
215
|
-
active={this.showActionMenu}
|
|
216
|
-
onClick={this.open}
|
|
217
|
-
/>
|
|
218
|
-
);
|
|
219
|
-
} else {
|
|
220
|
-
return null;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
renderHeaderActionMenu(numberOfIds) {
|
|
225
|
-
if (this.showActionMenu) {
|
|
226
|
-
const node = ReactDOM.findDOMNode(this.comboButton);
|
|
227
|
-
const rect = node.getBoundingClientRect();
|
|
228
|
-
const top = Unit.add(
|
|
229
|
-
px(rect.bottom),
|
|
230
|
-
this.context.theme.shapes.flyingBalloonTriangleSize
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
return (
|
|
234
|
-
<Combo
|
|
235
|
-
menuType="menu"
|
|
236
|
-
left={(rect.left + rect.right) / 2}
|
|
237
|
-
top={top}
|
|
238
|
-
list={this.getActionMenuList(numberOfIds)}
|
|
239
|
-
close={this.close}
|
|
240
|
-
/>
|
|
241
|
-
);
|
|
242
|
-
} else {
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
renderHeaderAdd(numberOfIds) {
|
|
248
|
-
const canAdd =
|
|
249
|
-
!this.props.disableAdd &&
|
|
250
|
-
(!this.props.arity ||
|
|
251
|
-
this.props.arity.endsWith('n') ||
|
|
252
|
-
(this.props.arity === '0..1' && numberOfIds === 0));
|
|
253
|
-
|
|
254
|
-
if (canAdd) {
|
|
255
|
-
return (
|
|
256
|
-
<Button
|
|
257
|
-
glyph="solid/plus"
|
|
258
|
-
text={this.props.addText || T('Ajouter')}
|
|
259
|
-
tooltip={this.props.addTooltip}
|
|
260
|
-
glyphPosition="right"
|
|
261
|
-
onClick={this.onActionAdd}
|
|
262
|
-
/>
|
|
263
|
-
);
|
|
264
|
-
} else {
|
|
265
|
-
return null;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
renderHeader(numberOfIds) {
|
|
270
|
-
const headerClass =
|
|
271
|
-
this.props.entityIds.size === 0
|
|
272
|
-
? this.styles.classNames.headerEmpty
|
|
273
|
-
: this.styles.classNames.header;
|
|
274
|
-
|
|
275
|
-
const title = this.props.pluginTitle
|
|
276
|
-
? this.props.pluginTitle
|
|
277
|
-
: this.props.title;
|
|
278
|
-
|
|
279
|
-
if (this.props.readonly) {
|
|
280
|
-
return (
|
|
281
|
-
<div className={headerClass}>
|
|
282
|
-
<Label text={title} grow="1" kind="title" />
|
|
283
|
-
</div>
|
|
284
|
-
);
|
|
285
|
-
} else {
|
|
286
|
-
return (
|
|
287
|
-
<div className={headerClass}>
|
|
288
|
-
<Label text={title} grow="1" kind="title" />
|
|
289
|
-
{this.renderHeaderSearch()}
|
|
290
|
-
{this.renderHeaderActionMenuButton(numberOfIds)}
|
|
291
|
-
{this.renderHeaderAdd(numberOfIds)}
|
|
292
|
-
{this.renderHeaderActionMenu(numberOfIds)}
|
|
293
|
-
</div>
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
renderItem(entityId, extended, index) {
|
|
299
|
-
const workitemUI = uiImporter(this.props.editorWidget);
|
|
300
|
-
const workitemId = `${this.props.editorWidget}${
|
|
301
|
-
this.props.mode ? `@${this.props.mode}` : ''
|
|
302
|
-
}@${this.context.desktopId}@${this.props.entityIds.get(index)}`;
|
|
303
|
-
|
|
304
|
-
if (!workitemUI.plugin) {
|
|
305
|
-
return null;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const itemClass = extended
|
|
309
|
-
? this.props.embedded
|
|
310
|
-
? this.styles.classNames.extendedEmbeddedItem
|
|
311
|
-
: this.styles.classNames.extendedItem
|
|
312
|
-
: this.props.embedded
|
|
313
|
-
? this.styles.classNames.compactedEmbeddedItem
|
|
314
|
-
: this.styles.classNames.compactedItem;
|
|
315
|
-
|
|
316
|
-
const key1 = this.props.readonly ? 'readonly' : 'edit';
|
|
317
|
-
const key2 = extended ? 'extend' : 'compact';
|
|
318
|
-
|
|
319
|
-
let UI = workitemUI.plugin[key1][key2];
|
|
320
|
-
//let UI = this.WithState(
|
|
321
|
-
// workitemUI.plugin[key1][key2],
|
|
322
|
-
// 'entityId'
|
|
323
|
-
//)('.entityId');
|
|
324
|
-
|
|
325
|
-
if (
|
|
326
|
-
workitemUI.mappers &&
|
|
327
|
-
workitemUI.mappers.plugin &&
|
|
328
|
-
workitemUI.mappers.plugin[key1] &&
|
|
329
|
-
workitemUI.mappers.plugin[key1][key2]
|
|
330
|
-
) {
|
|
331
|
-
UI = this.mapWidget(
|
|
332
|
-
UI,
|
|
333
|
-
workitemUI.mappers.plugin[key1][key2],
|
|
334
|
-
`backend.${entityId}`
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const type = entityId.split('@', 1)[0];
|
|
339
|
-
const Loader = (props) => {
|
|
340
|
-
if (props.loaded) {
|
|
341
|
-
return (
|
|
342
|
-
<Workitem
|
|
343
|
-
id={workitemId}
|
|
344
|
-
entityId={entityId}
|
|
345
|
-
kind="form"
|
|
346
|
-
readonly={this.props.readonly}
|
|
347
|
-
dragServiceId={this.props.dragServiceId}
|
|
348
|
-
>
|
|
349
|
-
{this.buildLoader(entityId, () => (
|
|
350
|
-
<UI
|
|
351
|
-
id={workitemId}
|
|
352
|
-
theme={this.context.theme}
|
|
353
|
-
entityId={entityId}
|
|
354
|
-
embeddedLevel={this.props.embeddedLevel}
|
|
355
|
-
origin={this.props.origin}
|
|
356
|
-
contextId={this.context.contextId}
|
|
357
|
-
do={this.doProxy(index)}
|
|
358
|
-
entitySchema={this.getSchema(type)}
|
|
359
|
-
/>
|
|
360
|
-
))}
|
|
361
|
-
</Workitem>
|
|
362
|
-
);
|
|
363
|
-
} else {
|
|
364
|
-
return (
|
|
365
|
-
<Container busy={true}>
|
|
366
|
-
<Label text={T('chargement...')} />
|
|
367
|
-
</Container>
|
|
368
|
-
);
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
const LoadedWorkitem = this.mapWidget(
|
|
373
|
-
Loader,
|
|
374
|
-
(wid) => ({loaded: !!wid}),
|
|
375
|
-
`backend.${workitemId}.id`
|
|
376
|
-
);
|
|
377
|
-
|
|
378
|
-
return (
|
|
379
|
-
<div className={itemClass}>
|
|
380
|
-
<LoadedWorkitem />
|
|
381
|
-
</div>
|
|
382
|
-
);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
renderButtons(entityId, extended, numberOfIds) {
|
|
386
|
-
if (extended) {
|
|
387
|
-
const buttonsClass = this.props.readonly
|
|
388
|
-
? this.props.embedded
|
|
389
|
-
? this.styles.classNames.extendedEmbeddedReadonlyButtons
|
|
390
|
-
: this.styles.classNames.extendedReadonlyButtons
|
|
391
|
-
: this.props.embedded
|
|
392
|
-
? this.styles.classNames.extendedEmbeddedButtons
|
|
393
|
-
: this.styles.classNames.extendedButtons;
|
|
394
|
-
|
|
395
|
-
const canDelete =
|
|
396
|
-
!this.props.readonly &&
|
|
397
|
-
!this.props.disableDelete &&
|
|
398
|
-
(!this.props.arity ||
|
|
399
|
-
this.props.arity.startsWith('0') ||
|
|
400
|
-
numberOfIds > 1);
|
|
401
|
-
|
|
402
|
-
const kind = this.props.readonly ? 'plugin-light' : 'plugin-dark';
|
|
403
|
-
|
|
404
|
-
let otherButtons = null;
|
|
405
|
-
if (this.props.buttons) {
|
|
406
|
-
otherButtons = this.props.buttons(entityId);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return (
|
|
410
|
-
<div className={buttonsClass}>
|
|
411
|
-
<Button
|
|
412
|
-
width="32px"
|
|
413
|
-
kind={kind}
|
|
414
|
-
glyph="solid/angle-up"
|
|
415
|
-
glyphSize="180%"
|
|
416
|
-
tooltip={T('Replier')}
|
|
417
|
-
active={false}
|
|
418
|
-
activeColor={
|
|
419
|
-
this.context.theme.palette.recurrenceExtendedBoxBackground
|
|
420
|
-
}
|
|
421
|
-
onClick={() => this.onSwapExtended(entityId)}
|
|
422
|
-
/>
|
|
423
|
-
<Button
|
|
424
|
-
width="32px"
|
|
425
|
-
kind={kind}
|
|
426
|
-
glyph="solid/pencil"
|
|
427
|
-
tooltip={T('Editer')}
|
|
428
|
-
onClick={() => this.onEditEntity(entityId)}
|
|
429
|
-
/>
|
|
430
|
-
{otherButtons}
|
|
431
|
-
{canDelete ? (
|
|
432
|
-
<Button
|
|
433
|
-
width="32px"
|
|
434
|
-
kind={kind}
|
|
435
|
-
glyph="solid/trash"
|
|
436
|
-
tooltip={T('Supprimer')}
|
|
437
|
-
onClick={() => this.onDeleteEntity(entityId)}
|
|
438
|
-
/>
|
|
439
|
-
) : null}
|
|
440
|
-
</div>
|
|
441
|
-
);
|
|
442
|
-
} else {
|
|
443
|
-
const buttonsClass = this.props.readonly
|
|
444
|
-
? this.props.embedded
|
|
445
|
-
? this.styles.classNames.compactedEmbeddedReadonlyButtons
|
|
446
|
-
: this.styles.classNames.compactedReadonlyButtons
|
|
447
|
-
: this.props.embedded
|
|
448
|
-
? this.styles.classNames.compactedEmbeddedButtons
|
|
449
|
-
: this.styles.classNames.compactedButtons;
|
|
450
|
-
|
|
451
|
-
const kind =
|
|
452
|
-
this.props.readonly || !this.props.embedded
|
|
453
|
-
? 'plugin-light'
|
|
454
|
-
: 'plugin-dark';
|
|
455
|
-
|
|
456
|
-
return (
|
|
457
|
-
<div className={buttonsClass}>
|
|
458
|
-
{this.props.readonly && !this.props.embedded ? (
|
|
459
|
-
<Button
|
|
460
|
-
width="32px"
|
|
461
|
-
kind={kind}
|
|
462
|
-
glyph="solid/pencil"
|
|
463
|
-
tooltip={T('Editer')}
|
|
464
|
-
onClick={() => this.onEditEntity(entityId)}
|
|
465
|
-
/>
|
|
466
|
-
) : null}
|
|
467
|
-
<Button
|
|
468
|
-
width="32px"
|
|
469
|
-
kind={kind}
|
|
470
|
-
glyph="solid/angle-down"
|
|
471
|
-
glyphSize="180%"
|
|
472
|
-
tooltip={T('Etendre')}
|
|
473
|
-
active={false}
|
|
474
|
-
activeColor={
|
|
475
|
-
this.context.theme.palette.recurrenceExtendedBoxBackground
|
|
476
|
-
}
|
|
477
|
-
onClick={() => this.onSwapExtended(entityId)}
|
|
478
|
-
/>
|
|
479
|
-
</div>
|
|
480
|
-
);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
renderRowContent(entityId, extended, numberOfIds, index) {
|
|
485
|
-
const rowClass = extended
|
|
486
|
-
? this.props.embedded
|
|
487
|
-
? this.styles.classNames.extendedEmbeddedRow
|
|
488
|
-
: this.styles.classNames.extendedRow
|
|
489
|
-
: numberOfIds > 1 && this.props.horizontalSeparator !== 'compact'
|
|
490
|
-
? this.props.embedded
|
|
491
|
-
? this.styles.classNames.compactedEmbeddedDashedRow
|
|
492
|
-
: this.styles.classNames.compactedDashedRow
|
|
493
|
-
: this.props.embedded
|
|
494
|
-
? this.styles.classNames.compactedEmbeddedRow
|
|
495
|
-
: this.styles.classNames.compactedRow;
|
|
496
|
-
|
|
497
|
-
return (
|
|
498
|
-
<Container
|
|
499
|
-
kind="row-draggable"
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
{this.
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
const
|
|
625
|
-
const
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
}
|
|
1
|
+
//T:2019-02-27
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import ReactDOM from 'react-dom';
|
|
5
|
+
import scrollIntoViewIfNeeded from 'scroll-into-view-if-needed';
|
|
6
|
+
import Widget from 'goblin-laboratory/widgets/widget';
|
|
7
|
+
import {Unit} from 'goblin-theme';
|
|
8
|
+
const px = Unit.toPx;
|
|
9
|
+
|
|
10
|
+
import Workitem from 'goblin-desktop/widgets/workitem/widget';
|
|
11
|
+
import Container from 'goblin-gadgets/widgets/container/widget';
|
|
12
|
+
import Button from 'goblin-gadgets/widgets/button/widget';
|
|
13
|
+
import Label from 'goblin-gadgets/widgets/label/widget';
|
|
14
|
+
import Field from 'goblin-gadgets/widgets/field/widget';
|
|
15
|
+
import DragCab from 'goblin-gadgets/widgets/drag-cab/widget';
|
|
16
|
+
import Combo from 'goblin-gadgets/widgets/combo/widget';
|
|
17
|
+
|
|
18
|
+
import importer from 'goblin_importer';
|
|
19
|
+
import T from 't';
|
|
20
|
+
|
|
21
|
+
const uiImporter = importer('ui');
|
|
22
|
+
|
|
23
|
+
/******************************************************************************/
|
|
24
|
+
|
|
25
|
+
class Plugin extends Widget {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
|
|
29
|
+
this._refs = {};
|
|
30
|
+
this._scrollEntityId = null;
|
|
31
|
+
this.comboButton = null;
|
|
32
|
+
|
|
33
|
+
this.state = {
|
|
34
|
+
showActionMenu: false,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
this.onAction = this.onAction.bind(this);
|
|
38
|
+
this.onActionAdd = this.onActionAdd.bind(this);
|
|
39
|
+
this.onSwapExtended = this.onSwapExtended.bind(this);
|
|
40
|
+
this.onDeleteEntity = this.onDeleteEntity.bind(this);
|
|
41
|
+
this.onEditEntity = this.onEditEntity.bind(this);
|
|
42
|
+
this.onEntityDragged = this.onEntityDragged.bind(this);
|
|
43
|
+
this.doProxy = this.doProxy.bind(this);
|
|
44
|
+
this.open = this.open.bind(this);
|
|
45
|
+
this.close = this.close.bind(this);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get showActionMenu() {
|
|
49
|
+
return this.state.showActionMenu;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
set showActionMenu(value) {
|
|
53
|
+
this.setState({
|
|
54
|
+
showActionMenu: value,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_scrollIntoView(duration) {
|
|
59
|
+
if (
|
|
60
|
+
!this._scrollEntityId ||
|
|
61
|
+
!this._refs[this._scrollEntityId] ||
|
|
62
|
+
this._scrollEntityId !== this.props.extendedId
|
|
63
|
+
) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
scrollIntoViewIfNeeded(this._refs[this._scrollEntityId], {
|
|
68
|
+
duration,
|
|
69
|
+
// HACK: we need to fix the transitions in order to remove this offset
|
|
70
|
+
offset: {
|
|
71
|
+
top: 3,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
componentDidUpdate() {
|
|
77
|
+
this._scrollIntoView(150);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
onAction(actionName) {
|
|
81
|
+
const service = this.props.namespace;
|
|
82
|
+
switch (actionName) {
|
|
83
|
+
case 'add':
|
|
84
|
+
this.doAs(service, actionName);
|
|
85
|
+
break;
|
|
86
|
+
case 'clear':
|
|
87
|
+
this.doAs(service, actionName);
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
this.doAs(service, 'do-action', {action: actionName});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
onActionAdd() {
|
|
95
|
+
this.onAction('add');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
onSwapExtended(entityId) {
|
|
99
|
+
this._scrollEntityId = entityId;
|
|
100
|
+
this.dispatch({type: 'TOGGLE_EXTENDED', entityId});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
onDeleteEntity(entityId) {
|
|
104
|
+
const service = this.props.namespace;
|
|
105
|
+
this.doAs(service, 'remove', {entityId});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
onEditEntity(entityId) {
|
|
109
|
+
const service = this.props.namespace;
|
|
110
|
+
this.doAs(service, 'edit', {entityId});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
onEntityDragged(selectedIds, toId, ownerId, ownerKind) {
|
|
114
|
+
const service = this.props.namespace;
|
|
115
|
+
if (ownerId === this.props.id) {
|
|
116
|
+
this.doAs(service, 'drag', {
|
|
117
|
+
fromId: selectedIds[0],
|
|
118
|
+
toId: toId,
|
|
119
|
+
});
|
|
120
|
+
} else {
|
|
121
|
+
this.doAs(service, 'remove', {
|
|
122
|
+
entityId: selectedIds[0],
|
|
123
|
+
});
|
|
124
|
+
this.cmd(`${service}.add`, {
|
|
125
|
+
id: ownerId,
|
|
126
|
+
entityId: selectedIds[0],
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
getActionMenuList(numberOfIds) {
|
|
132
|
+
const list = [];
|
|
133
|
+
|
|
134
|
+
if (this.props.actionMenu) {
|
|
135
|
+
for (const item of this.props.actionMenu) {
|
|
136
|
+
if (!item.min || item.min <= numberOfIds) {
|
|
137
|
+
list.push({
|
|
138
|
+
glyph: item.glyph,
|
|
139
|
+
text: item.text,
|
|
140
|
+
action: () => this.onAction(item.actionName),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (
|
|
147
|
+
numberOfIds > 0 &&
|
|
148
|
+
(!this.props.arity || !this.props.arity.startsWith('1'))
|
|
149
|
+
) {
|
|
150
|
+
if (list.length > 0) {
|
|
151
|
+
list.push({
|
|
152
|
+
separator: true,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
list.push({
|
|
156
|
+
glyph: 'solid/trash',
|
|
157
|
+
text: T('Tout supprimer'),
|
|
158
|
+
action: () => this.onAction('clear'),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return list;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
doProxy(index) {
|
|
166
|
+
return (action, args) => {
|
|
167
|
+
const workitemId = `${this.props.editorWidget}${
|
|
168
|
+
this.props.mode ? `@${this.props.mode}` : ''
|
|
169
|
+
}@${this.context.desktopId}@${this.props.entityIds.get(index)}`;
|
|
170
|
+
this.doFor(workitemId, action, args);
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
open() {
|
|
175
|
+
this.showActionMenu = true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
close() {
|
|
179
|
+
this.showActionMenu = false;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/******************************************************************************/
|
|
183
|
+
|
|
184
|
+
renderHeaderSearch() {
|
|
185
|
+
if (this.props.searchHinter) {
|
|
186
|
+
return (
|
|
187
|
+
<Field
|
|
188
|
+
shape="rounded"
|
|
189
|
+
labelGlyph="solid/search"
|
|
190
|
+
labelWidth="24px"
|
|
191
|
+
fieldWidth="180px"
|
|
192
|
+
hintText={T('Ajouter existant')}
|
|
193
|
+
tooltip={T(
|
|
194
|
+
'Ajouter un élément existant en le choisissant dans une liste'
|
|
195
|
+
)}
|
|
196
|
+
kind="hinter"
|
|
197
|
+
required={false}
|
|
198
|
+
hinter={this.props.searchHinter}
|
|
199
|
+
horizontalSpacing="large"
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
} else {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
renderHeaderActionMenuButton(numberOfIds) {
|
|
208
|
+
const list = this.getActionMenuList(numberOfIds);
|
|
209
|
+
if (list.length > 0) {
|
|
210
|
+
return (
|
|
211
|
+
<Button
|
|
212
|
+
ref={(x) => (this.comboButton = x)}
|
|
213
|
+
glyph="solid/ellipsis-h"
|
|
214
|
+
horizontalSpacing="large"
|
|
215
|
+
active={this.showActionMenu}
|
|
216
|
+
onClick={this.open}
|
|
217
|
+
/>
|
|
218
|
+
);
|
|
219
|
+
} else {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
renderHeaderActionMenu(numberOfIds) {
|
|
225
|
+
if (this.showActionMenu) {
|
|
226
|
+
const node = ReactDOM.findDOMNode(this.comboButton);
|
|
227
|
+
const rect = node.getBoundingClientRect();
|
|
228
|
+
const top = Unit.add(
|
|
229
|
+
px(rect.bottom),
|
|
230
|
+
this.context.theme.shapes.flyingBalloonTriangleSize
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
return (
|
|
234
|
+
<Combo
|
|
235
|
+
menuType="menu"
|
|
236
|
+
left={(rect.left + rect.right) / 2}
|
|
237
|
+
top={top}
|
|
238
|
+
list={this.getActionMenuList(numberOfIds)}
|
|
239
|
+
close={this.close}
|
|
240
|
+
/>
|
|
241
|
+
);
|
|
242
|
+
} else {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
renderHeaderAdd(numberOfIds) {
|
|
248
|
+
const canAdd =
|
|
249
|
+
!this.props.disableAdd &&
|
|
250
|
+
(!this.props.arity ||
|
|
251
|
+
this.props.arity.endsWith('n') ||
|
|
252
|
+
(this.props.arity === '0..1' && numberOfIds === 0));
|
|
253
|
+
|
|
254
|
+
if (canAdd) {
|
|
255
|
+
return (
|
|
256
|
+
<Button
|
|
257
|
+
glyph="solid/plus"
|
|
258
|
+
text={this.props.addText || T('Ajouter')}
|
|
259
|
+
tooltip={this.props.addTooltip}
|
|
260
|
+
glyphPosition="right"
|
|
261
|
+
onClick={this.onActionAdd}
|
|
262
|
+
/>
|
|
263
|
+
);
|
|
264
|
+
} else {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
renderHeader(numberOfIds) {
|
|
270
|
+
const headerClass =
|
|
271
|
+
this.props.entityIds.size === 0
|
|
272
|
+
? this.styles.classNames.headerEmpty
|
|
273
|
+
: this.styles.classNames.header;
|
|
274
|
+
|
|
275
|
+
const title = this.props.pluginTitle
|
|
276
|
+
? this.props.pluginTitle
|
|
277
|
+
: this.props.title;
|
|
278
|
+
|
|
279
|
+
if (this.props.readonly) {
|
|
280
|
+
return (
|
|
281
|
+
<div className={headerClass}>
|
|
282
|
+
<Label text={title} grow="1" kind="title" />
|
|
283
|
+
</div>
|
|
284
|
+
);
|
|
285
|
+
} else {
|
|
286
|
+
return (
|
|
287
|
+
<div className={headerClass}>
|
|
288
|
+
<Label text={title} grow="1" kind="title" />
|
|
289
|
+
{this.renderHeaderSearch()}
|
|
290
|
+
{this.renderHeaderActionMenuButton(numberOfIds)}
|
|
291
|
+
{this.renderHeaderAdd(numberOfIds)}
|
|
292
|
+
{this.renderHeaderActionMenu(numberOfIds)}
|
|
293
|
+
</div>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
renderItem(entityId, extended, index) {
|
|
299
|
+
const workitemUI = uiImporter(this.props.editorWidget);
|
|
300
|
+
const workitemId = `${this.props.editorWidget}${
|
|
301
|
+
this.props.mode ? `@${this.props.mode}` : ''
|
|
302
|
+
}@${this.context.desktopId}@${this.props.entityIds.get(index)}`;
|
|
303
|
+
|
|
304
|
+
if (!workitemUI.plugin) {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const itemClass = extended
|
|
309
|
+
? this.props.embedded
|
|
310
|
+
? this.styles.classNames.extendedEmbeddedItem
|
|
311
|
+
: this.styles.classNames.extendedItem
|
|
312
|
+
: this.props.embedded
|
|
313
|
+
? this.styles.classNames.compactedEmbeddedItem
|
|
314
|
+
: this.styles.classNames.compactedItem;
|
|
315
|
+
|
|
316
|
+
const key1 = this.props.readonly ? 'readonly' : 'edit';
|
|
317
|
+
const key2 = extended ? 'extend' : 'compact';
|
|
318
|
+
|
|
319
|
+
let UI = workitemUI.plugin[key1][key2];
|
|
320
|
+
//let UI = this.WithState(
|
|
321
|
+
// workitemUI.plugin[key1][key2],
|
|
322
|
+
// 'entityId'
|
|
323
|
+
//)('.entityId');
|
|
324
|
+
|
|
325
|
+
if (
|
|
326
|
+
workitemUI.mappers &&
|
|
327
|
+
workitemUI.mappers.plugin &&
|
|
328
|
+
workitemUI.mappers.plugin[key1] &&
|
|
329
|
+
workitemUI.mappers.plugin[key1][key2]
|
|
330
|
+
) {
|
|
331
|
+
UI = this.mapWidget(
|
|
332
|
+
UI,
|
|
333
|
+
workitemUI.mappers.plugin[key1][key2],
|
|
334
|
+
`backend.${entityId}`
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const type = entityId.split('@', 1)[0];
|
|
339
|
+
const Loader = (props) => {
|
|
340
|
+
if (props.loaded) {
|
|
341
|
+
return (
|
|
342
|
+
<Workitem
|
|
343
|
+
id={workitemId}
|
|
344
|
+
entityId={entityId}
|
|
345
|
+
kind="form"
|
|
346
|
+
readonly={this.props.readonly}
|
|
347
|
+
dragServiceId={this.props.dragServiceId}
|
|
348
|
+
>
|
|
349
|
+
{this.buildLoader(entityId, () => (
|
|
350
|
+
<UI
|
|
351
|
+
id={workitemId}
|
|
352
|
+
theme={this.context.theme}
|
|
353
|
+
entityId={entityId}
|
|
354
|
+
embeddedLevel={this.props.embeddedLevel}
|
|
355
|
+
origin={this.props.origin}
|
|
356
|
+
contextId={this.context.contextId}
|
|
357
|
+
do={this.doProxy(index)}
|
|
358
|
+
entitySchema={this.getSchema(type)}
|
|
359
|
+
/>
|
|
360
|
+
))}
|
|
361
|
+
</Workitem>
|
|
362
|
+
);
|
|
363
|
+
} else {
|
|
364
|
+
return (
|
|
365
|
+
<Container busy={true}>
|
|
366
|
+
<Label text={T('chargement...')} />
|
|
367
|
+
</Container>
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
const LoadedWorkitem = this.mapWidget(
|
|
373
|
+
Loader,
|
|
374
|
+
(wid) => ({loaded: !!wid}),
|
|
375
|
+
`backend.${workitemId}.id`
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
return (
|
|
379
|
+
<div className={itemClass}>
|
|
380
|
+
<LoadedWorkitem />
|
|
381
|
+
</div>
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
renderButtons(entityId, extended, numberOfIds) {
|
|
386
|
+
if (extended) {
|
|
387
|
+
const buttonsClass = this.props.readonly
|
|
388
|
+
? this.props.embedded
|
|
389
|
+
? this.styles.classNames.extendedEmbeddedReadonlyButtons
|
|
390
|
+
: this.styles.classNames.extendedReadonlyButtons
|
|
391
|
+
: this.props.embedded
|
|
392
|
+
? this.styles.classNames.extendedEmbeddedButtons
|
|
393
|
+
: this.styles.classNames.extendedButtons;
|
|
394
|
+
|
|
395
|
+
const canDelete =
|
|
396
|
+
!this.props.readonly &&
|
|
397
|
+
!this.props.disableDelete &&
|
|
398
|
+
(!this.props.arity ||
|
|
399
|
+
this.props.arity.startsWith('0') ||
|
|
400
|
+
numberOfIds > 1);
|
|
401
|
+
|
|
402
|
+
const kind = this.props.readonly ? 'plugin-light' : 'plugin-dark';
|
|
403
|
+
|
|
404
|
+
let otherButtons = null;
|
|
405
|
+
if (this.props.buttons) {
|
|
406
|
+
otherButtons = this.props.buttons(entityId);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
return (
|
|
410
|
+
<div className={buttonsClass}>
|
|
411
|
+
<Button
|
|
412
|
+
width="32px"
|
|
413
|
+
kind={kind}
|
|
414
|
+
glyph="solid/angle-up"
|
|
415
|
+
glyphSize="180%"
|
|
416
|
+
tooltip={T('Replier')}
|
|
417
|
+
active={false}
|
|
418
|
+
activeColor={
|
|
419
|
+
this.context.theme.palette.recurrenceExtendedBoxBackground
|
|
420
|
+
}
|
|
421
|
+
onClick={() => this.onSwapExtended(entityId)}
|
|
422
|
+
/>
|
|
423
|
+
<Button
|
|
424
|
+
width="32px"
|
|
425
|
+
kind={kind}
|
|
426
|
+
glyph="solid/pencil"
|
|
427
|
+
tooltip={T('Editer')}
|
|
428
|
+
onClick={() => this.onEditEntity(entityId)}
|
|
429
|
+
/>
|
|
430
|
+
{otherButtons}
|
|
431
|
+
{canDelete ? (
|
|
432
|
+
<Button
|
|
433
|
+
width="32px"
|
|
434
|
+
kind={kind}
|
|
435
|
+
glyph="solid/trash"
|
|
436
|
+
tooltip={T('Supprimer')}
|
|
437
|
+
onClick={() => this.onDeleteEntity(entityId)}
|
|
438
|
+
/>
|
|
439
|
+
) : null}
|
|
440
|
+
</div>
|
|
441
|
+
);
|
|
442
|
+
} else {
|
|
443
|
+
const buttonsClass = this.props.readonly
|
|
444
|
+
? this.props.embedded
|
|
445
|
+
? this.styles.classNames.compactedEmbeddedReadonlyButtons
|
|
446
|
+
: this.styles.classNames.compactedReadonlyButtons
|
|
447
|
+
: this.props.embedded
|
|
448
|
+
? this.styles.classNames.compactedEmbeddedButtons
|
|
449
|
+
: this.styles.classNames.compactedButtons;
|
|
450
|
+
|
|
451
|
+
const kind =
|
|
452
|
+
this.props.readonly || !this.props.embedded
|
|
453
|
+
? 'plugin-light'
|
|
454
|
+
: 'plugin-dark';
|
|
455
|
+
|
|
456
|
+
return (
|
|
457
|
+
<div className={buttonsClass}>
|
|
458
|
+
{this.props.readonly && !this.props.embedded ? (
|
|
459
|
+
<Button
|
|
460
|
+
width="32px"
|
|
461
|
+
kind={kind}
|
|
462
|
+
glyph="solid/pencil"
|
|
463
|
+
tooltip={T('Editer')}
|
|
464
|
+
onClick={() => this.onEditEntity(entityId)}
|
|
465
|
+
/>
|
|
466
|
+
) : null}
|
|
467
|
+
<Button
|
|
468
|
+
width="32px"
|
|
469
|
+
kind={kind}
|
|
470
|
+
glyph="solid/angle-down"
|
|
471
|
+
glyphSize="180%"
|
|
472
|
+
tooltip={T('Etendre')}
|
|
473
|
+
active={false}
|
|
474
|
+
activeColor={
|
|
475
|
+
this.context.theme.palette.recurrenceExtendedBoxBackground
|
|
476
|
+
}
|
|
477
|
+
onClick={() => this.onSwapExtended(entityId)}
|
|
478
|
+
/>
|
|
479
|
+
</div>
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
renderRowContent(entityId, extended, numberOfIds, index) {
|
|
485
|
+
const rowClass = extended
|
|
486
|
+
? this.props.embedded
|
|
487
|
+
? this.styles.classNames.extendedEmbeddedRow
|
|
488
|
+
: this.styles.classNames.extendedRow
|
|
489
|
+
: numberOfIds > 1 && this.props.horizontalSeparator !== 'compact'
|
|
490
|
+
? this.props.embedded
|
|
491
|
+
? this.styles.classNames.compactedEmbeddedDashedRow
|
|
492
|
+
: this.styles.classNames.compactedDashedRow
|
|
493
|
+
: this.props.embedded
|
|
494
|
+
? this.styles.classNames.compactedEmbeddedRow
|
|
495
|
+
: this.styles.classNames.compactedRow;
|
|
496
|
+
|
|
497
|
+
return (
|
|
498
|
+
<Container
|
|
499
|
+
kind="row-draggable"
|
|
500
|
+
busyLook={extended ? null : 'smallest'}
|
|
501
|
+
key={index}
|
|
502
|
+
ref={(n) => {
|
|
503
|
+
if (n) {
|
|
504
|
+
this._refs[entityId] = ReactDOM.findDOMNode(n);
|
|
505
|
+
}
|
|
506
|
+
}}
|
|
507
|
+
>
|
|
508
|
+
<div className={rowClass}>
|
|
509
|
+
{this.renderItem(entityId, extended, index)}
|
|
510
|
+
{this.renderButtons(entityId, extended, numberOfIds)}
|
|
511
|
+
</div>
|
|
512
|
+
</Container>
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
renderRow(entityId, extended, dragEnabled, numberOfIds, index) {
|
|
517
|
+
if (dragEnabled) {
|
|
518
|
+
return (
|
|
519
|
+
<DragCab
|
|
520
|
+
key={index}
|
|
521
|
+
dragController={this.props.dragType || this.props.id}
|
|
522
|
+
dragOwnerId={entityId}
|
|
523
|
+
dragMode="handle"
|
|
524
|
+
dragHandleWidth={this.context.theme.shapes.containerMargin}
|
|
525
|
+
direction="vertical"
|
|
526
|
+
color={this.context.theme.palette.dragAndDropHover}
|
|
527
|
+
thickness={this.context.theme.shapes.dragAndDropTicketThickness}
|
|
528
|
+
overSpacing="0px"
|
|
529
|
+
verticalSpacing="0px"
|
|
530
|
+
radius="0px"
|
|
531
|
+
doClickAction={() => this.onSwapExtended(entityId)}
|
|
532
|
+
doDragEnding={this.onEntityDragged}
|
|
533
|
+
>
|
|
534
|
+
{this.renderRowContent(entityId, extended, numberOfIds, index)}
|
|
535
|
+
</DragCab>
|
|
536
|
+
);
|
|
537
|
+
} else {
|
|
538
|
+
return this.renderRowContent(entityId, extended, numberOfIds, index);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
renderRows(entityIds) {
|
|
543
|
+
const dragEnabled =
|
|
544
|
+
!this.props.readonly && (entityIds.length > 1 || !!this.props.dragType);
|
|
545
|
+
|
|
546
|
+
let index = 0;
|
|
547
|
+
|
|
548
|
+
return entityIds.map((entityId) => {
|
|
549
|
+
const extended = entityId === this.props.extendedId;
|
|
550
|
+
return this.renderRow(
|
|
551
|
+
entityId,
|
|
552
|
+
extended,
|
|
553
|
+
dragEnabled,
|
|
554
|
+
entityIds.length,
|
|
555
|
+
index++
|
|
556
|
+
);
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
renderDefault() {
|
|
561
|
+
const entityIds = this.props.entityIds.valueSeq().toArray();
|
|
562
|
+
if (entityIds.length === 0 && this.props.readonly && this.props.embedded) {
|
|
563
|
+
return null;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
let boxClass = null;
|
|
567
|
+
if (!this.props.entityIds || this.props.entityIds.size === 0) {
|
|
568
|
+
boxClass = this.props.embedded
|
|
569
|
+
? this.styles.classNames.emptyembeddedBox
|
|
570
|
+
: this.styles.classNames.emptyBox;
|
|
571
|
+
} else {
|
|
572
|
+
boxClass = this.props.embedded
|
|
573
|
+
? this.styles.classNames.embeddedBox
|
|
574
|
+
: this.styles.classNames.box;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
return (
|
|
578
|
+
<div className={boxClass}>
|
|
579
|
+
{this.renderHeader(entityIds.length)}
|
|
580
|
+
<Container
|
|
581
|
+
kind="column"
|
|
582
|
+
dragController={this.props.dragType || this.props.id}
|
|
583
|
+
dragSource={this.props.id}
|
|
584
|
+
dragOwnerId={this.props.id}
|
|
585
|
+
>
|
|
586
|
+
{this.renderRows(entityIds)}
|
|
587
|
+
</Container>
|
|
588
|
+
</div>
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
render() {
|
|
593
|
+
this._refs = {};
|
|
594
|
+
|
|
595
|
+
if (!this.props.id || !this.props.entityIds) {
|
|
596
|
+
return null;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if (!this.props.editorWidget) {
|
|
600
|
+
return null;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
return this.renderDefault();
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/******************************************************************************/
|
|
608
|
+
|
|
609
|
+
const select = (root) => (state, id) => (prop) => {
|
|
610
|
+
if (!id) {
|
|
611
|
+
return null;
|
|
612
|
+
}
|
|
613
|
+
const target = state.get(`${root}.${id}`);
|
|
614
|
+
if (!target) {
|
|
615
|
+
return null;
|
|
616
|
+
}
|
|
617
|
+
return target.get(prop);
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
const withBackend = select('backend');
|
|
621
|
+
const withWidget = select('widgets');
|
|
622
|
+
|
|
623
|
+
export default Widget.connect((state, props) => {
|
|
624
|
+
const plugin = withBackend(state, props.id);
|
|
625
|
+
const entity = withBackend(state, plugin('forEntity'));
|
|
626
|
+
const widget = withWidget(state, props.id);
|
|
627
|
+
return {
|
|
628
|
+
id: props.id,
|
|
629
|
+
title: plugin('title'),
|
|
630
|
+
editorWidget: plugin('editorWidget'),
|
|
631
|
+
arity: plugin('arity'),
|
|
632
|
+
mode: plugin('mode'),
|
|
633
|
+
entityIds: entity(plugin('entityPath')),
|
|
634
|
+
namespace: `${plugin('type')}-plugin`,
|
|
635
|
+
extendedId: widget('extendedId'),
|
|
636
|
+
};
|
|
637
|
+
})(Plugin);
|