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/builders/wizard.js
CHANGED
|
@@ -1,457 +1,457 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
//T:2019-02-27
|
|
3
|
-
|
|
4
|
-
const Goblin = require('xcraft-core-goblin');
|
|
5
|
-
const T = require('goblin-nabu/widgets/helpers/t.js');
|
|
6
|
-
const common = require('goblin-workshop').common;
|
|
7
|
-
const Shredder = require('xcraft-core-shredder');
|
|
8
|
-
|
|
9
|
-
const {OrderedMap, fromJS} = require('immutable');
|
|
10
|
-
|
|
11
|
-
const defaultButtons = OrderedMap()
|
|
12
|
-
.set(
|
|
13
|
-
'main',
|
|
14
|
-
fromJS({
|
|
15
|
-
glyph: 'solid/step-forward',
|
|
16
|
-
text: T('Suivant', 'Bouton du wizard'),
|
|
17
|
-
grow: '1',
|
|
18
|
-
})
|
|
19
|
-
)
|
|
20
|
-
.set(
|
|
21
|
-
'cancel',
|
|
22
|
-
fromJS({
|
|
23
|
-
glyph: 'solid/times',
|
|
24
|
-
text: T('Annuler', 'Bouton du wizard'),
|
|
25
|
-
grow: '1',
|
|
26
|
-
})
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
module.exports = (config) => {
|
|
30
|
-
const {
|
|
31
|
-
name,
|
|
32
|
-
title,
|
|
33
|
-
skills,
|
|
34
|
-
dialog,
|
|
35
|
-
steps,
|
|
36
|
-
gadgets,
|
|
37
|
-
quests,
|
|
38
|
-
initialFormState,
|
|
39
|
-
hinters,
|
|
40
|
-
} = config;
|
|
41
|
-
const goblinName = `${name}-wizard`;
|
|
42
|
-
const wizardSteps = Object.keys(steps);
|
|
43
|
-
const wizardFlow = ['init'].concat(wizardSteps);
|
|
44
|
-
const hinterIdsByName = {};
|
|
45
|
-
const hinterWidgetIdsByName = {};
|
|
46
|
-
// Define logic handlers according rc.json
|
|
47
|
-
const logicHandlers = {
|
|
48
|
-
'create': (state, action) => {
|
|
49
|
-
const form = action.get('form');
|
|
50
|
-
const initForm = action.get('initialFormState');
|
|
51
|
-
const mergedInitialForm = Object.assign(initForm || {}, form || {});
|
|
52
|
-
return state.set('', {
|
|
53
|
-
id: action.get('id'),
|
|
54
|
-
step: 'init',
|
|
55
|
-
title: title,
|
|
56
|
-
dialog: dialog || {
|
|
57
|
-
width: '500px',
|
|
58
|
-
},
|
|
59
|
-
gadgets: action.get('wizardGadgets'),
|
|
60
|
-
busy: true,
|
|
61
|
-
buttons: defaultButtons,
|
|
62
|
-
form: mergedInitialForm,
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
'init-wizard': (state) => {
|
|
66
|
-
return state.set('step', '_goto').set('nextStep', wizardFlow[1]);
|
|
67
|
-
},
|
|
68
|
-
'buttons': (state, action) => {
|
|
69
|
-
return state.set('buttons', action.get('buttons'));
|
|
70
|
-
},
|
|
71
|
-
'change': (state, action) => {
|
|
72
|
-
return state.set(action.get('path'), action.get('newValue'));
|
|
73
|
-
},
|
|
74
|
-
'apply': (state, action) => {
|
|
75
|
-
return state.mergeDeep(action.get('path', ''), action.get('patch'));
|
|
76
|
-
},
|
|
77
|
-
'back': (state) => {
|
|
78
|
-
const c = state.get('step');
|
|
79
|
-
const cIndex = wizardFlow.indexOf(c);
|
|
80
|
-
if (cIndex === 0) {
|
|
81
|
-
return state;
|
|
82
|
-
}
|
|
83
|
-
const nIndex = cIndex - 1;
|
|
84
|
-
return state.set('step', '_goto').set('nextStep', wizardFlow[nIndex]);
|
|
85
|
-
},
|
|
86
|
-
'next': (state, action) => {
|
|
87
|
-
const c = state.get('step');
|
|
88
|
-
if (c === 'done') {
|
|
89
|
-
return state;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const cIndex = wizardFlow.indexOf(c);
|
|
93
|
-
if (cIndex === wizardFlow.length - 1) {
|
|
94
|
-
return state.set('result', action.get('result')).set('step', 'done');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const nIndex = cIndex + 1;
|
|
98
|
-
const nextStep = wizardFlow[nIndex];
|
|
99
|
-
return state.set('nextStep', nextStep).set('step', '_goto');
|
|
100
|
-
},
|
|
101
|
-
'goto': (state, action) => {
|
|
102
|
-
const step = action.get('step');
|
|
103
|
-
return state.set('nextStep', step).set('step', '_goto');
|
|
104
|
-
},
|
|
105
|
-
'_goto': (state) => {
|
|
106
|
-
const nextStep = state.get('nextStep');
|
|
107
|
-
return state.set('step', nextStep).del('nextStep');
|
|
108
|
-
},
|
|
109
|
-
'busy': (state) => {
|
|
110
|
-
return state.set('busy', true);
|
|
111
|
-
},
|
|
112
|
-
'idle': (state) => {
|
|
113
|
-
return state.set('busy', false);
|
|
114
|
-
},
|
|
115
|
-
'cancel': (state) => {
|
|
116
|
-
return state.set('canceled', true).set('step', 'done');
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
Goblin.registerQuest(
|
|
121
|
-
goblinName,
|
|
122
|
-
'create',
|
|
123
|
-
function* (quest, desktopId, form, isDialog) {
|
|
124
|
-
const id = quest.goblin.id;
|
|
125
|
-
quest.goblin.setX('desktopId', desktopId);
|
|
126
|
-
quest.goblin.setX('isDialog', isDialog);
|
|
127
|
-
quest.goblin.setX('isDisposing', false);
|
|
128
|
-
const wizardGadgets = {};
|
|
129
|
-
|
|
130
|
-
if (gadgets) {
|
|
131
|
-
yield common.createGadgets(quest, goblinName, gadgets, wizardGadgets);
|
|
132
|
-
}
|
|
133
|
-
if (hinters) {
|
|
134
|
-
yield quest.me.createHinters();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
let running = 0;
|
|
138
|
-
|
|
139
|
-
quest.goblin.defer(
|
|
140
|
-
quest.sub.local(`*::${quest.goblin.id}.<wizard-tick>`, function* (
|
|
141
|
-
err,
|
|
142
|
-
{msg, resp}
|
|
143
|
-
) {
|
|
144
|
-
const {calledFrom} = msg.data;
|
|
145
|
-
const isInternal = calledFrom.split('.')[0] === quest.goblin.id;
|
|
146
|
-
if (running > 0 && !isInternal) {
|
|
147
|
-
return; /* Drop this tick because a step is already running */
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
try {
|
|
151
|
-
++running;
|
|
152
|
-
const step = quest.goblin.getState().get('step');
|
|
153
|
-
yield resp.cmd(`${goblinName}.${step}`, {id});
|
|
154
|
-
} finally {
|
|
155
|
-
--running;
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
quest.do({id: quest.goblin.id, initialFormState, form, wizardGadgets});
|
|
161
|
-
yield quest.me.initWizard();
|
|
162
|
-
yield quest.me.idle();
|
|
163
|
-
return quest.goblin.id;
|
|
164
|
-
},
|
|
165
|
-
{skills: skills ?? []}
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
Goblin.registerQuest(goblinName, 'create-hinters', function* (quest, next) {
|
|
169
|
-
const desktopId = quest.goblin.getX('desktopId');
|
|
170
|
-
|
|
171
|
-
if (hinters) {
|
|
172
|
-
Object.keys(hinters).forEach((h) => {
|
|
173
|
-
let detailWidget = null;
|
|
174
|
-
let hName = h;
|
|
175
|
-
if (hinters[h].hinter) {
|
|
176
|
-
hName = hinters[h].hinter;
|
|
177
|
-
detailWidget = `${hName}-workitem`;
|
|
178
|
-
}
|
|
179
|
-
if (quest.hasAPI(`${hName}-hinter`)) {
|
|
180
|
-
const id = `${hName}-hinter@${h}@${quest.goblin.id}`;
|
|
181
|
-
const widgetId = `hinter@${hName}@${quest.goblin.id}`;
|
|
182
|
-
hinterIdsByName[h] = id;
|
|
183
|
-
hinterWidgetIdsByName[h] = widgetId;
|
|
184
|
-
quest.create(
|
|
185
|
-
`${hName}-hinter`,
|
|
186
|
-
{
|
|
187
|
-
id,
|
|
188
|
-
desktopId,
|
|
189
|
-
hinterName: h,
|
|
190
|
-
workitemId: quest.goblin.id,
|
|
191
|
-
detailWidget,
|
|
192
|
-
withDetails: true,
|
|
193
|
-
},
|
|
194
|
-
next.parallel()
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
yield next.sync();
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
common.registerHinters(goblinName, hinters);
|
|
203
|
-
|
|
204
|
-
Goblin.registerSafeQuest(goblinName, 'busy', function (quest) {
|
|
205
|
-
quest.do();
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
Goblin.registerSafeQuest(goblinName, 'idle', function (quest) {
|
|
209
|
-
quest.do();
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
if (gadgets) {
|
|
213
|
-
for (const key of Object.keys(gadgets)) {
|
|
214
|
-
//Gogo gadgeto stylo!
|
|
215
|
-
Goblin.registerSafeQuest(goblinName, `use-${key}`, function* (
|
|
216
|
-
quest,
|
|
217
|
-
action,
|
|
218
|
-
payload
|
|
219
|
-
) {
|
|
220
|
-
const gadgetId = quest.goblin.getState().get(`gadgets.${key}.id`);
|
|
221
|
-
const api = quest.getAPI(gadgetId);
|
|
222
|
-
yield api[action](payload);
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
//Register gagdet quest handlers
|
|
226
|
-
|
|
227
|
-
if (gadgets[key].onActions) {
|
|
228
|
-
for (const handler of Object.keys(gadgets[key].onActions)) {
|
|
229
|
-
const questName = common.jsifyQuestName(`${key}-${handler}`);
|
|
230
|
-
logicHandlers[questName] = gadgets[key].onActions[handler];
|
|
231
|
-
|
|
232
|
-
Goblin.registerSafeQuest(goblinName, questName, function* (quest) {
|
|
233
|
-
quest.do();
|
|
234
|
-
yield quest.me.update();
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (quests) {
|
|
242
|
-
Object.keys(quests).forEach((q) => {
|
|
243
|
-
Goblin.registerSafeQuest(goblinName, q, quests[q]);
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
Goblin.registerSafeQuest(goblinName, 'init-wizard', function (quest) {
|
|
248
|
-
quest.do();
|
|
249
|
-
quest.evt('<wizard-tick>', {calledFrom: quest.calledFrom});
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
Goblin.registerSafeQuest(goblinName, 'next', function (quest, result) {
|
|
253
|
-
quest.do();
|
|
254
|
-
quest.evt('<wizard-tick>', {calledFrom: quest.calledFrom});
|
|
255
|
-
return result;
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
Goblin.registerSafeQuest(goblinName, 'back', function (quest) {
|
|
259
|
-
quest.do();
|
|
260
|
-
quest.evt('<wizard-tick>', {calledFrom: quest.calledFrom});
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
Goblin.registerSafeQuest(goblinName, 'goto', function (quest, step) {
|
|
264
|
-
quest.do();
|
|
265
|
-
quest.evt('<wizard-tick>', {calledFrom: quest.calledFrom});
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
Goblin.registerSafeQuest(goblinName, '_goto', function* (quest) {
|
|
269
|
-
const state = quest.goblin.getState();
|
|
270
|
-
const form = state.get('form').toJS();
|
|
271
|
-
const nextStep = state.get('nextStep');
|
|
272
|
-
|
|
273
|
-
quest.dispatch(`init-${nextStep}`);
|
|
274
|
-
quest.do();
|
|
275
|
-
|
|
276
|
-
yield quest.me.updateButtons();
|
|
277
|
-
|
|
278
|
-
if (quest.me[nextStep]) {
|
|
279
|
-
try {
|
|
280
|
-
yield quest.me.busy();
|
|
281
|
-
yield quest.me[nextStep]({form});
|
|
282
|
-
} finally {
|
|
283
|
-
if (!quest.goblin.getX('isDisposing')) {
|
|
284
|
-
yield quest.me.idle();
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
Goblin.registerSafeQuest(goblinName, 'done', function* (quest) {
|
|
291
|
-
let result = quest.goblin.getState().get('result');
|
|
292
|
-
if (Shredder.isImmutable(result)) {
|
|
293
|
-
result = result.toJS();
|
|
294
|
-
}
|
|
295
|
-
let payload = {finished: true, result};
|
|
296
|
-
if (quest.goblin.getState().get('canceled')) {
|
|
297
|
-
payload = quest.cancel();
|
|
298
|
-
}
|
|
299
|
-
quest.evt('done', payload);
|
|
300
|
-
yield quest.me.dispose();
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
Goblin.registerSafeQuest(goblinName, 'cancel', function (quest) {
|
|
304
|
-
quest.do();
|
|
305
|
-
quest.evt('<wizard-tick>', {calledFrom: quest.calledFrom});
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
Goblin.registerSafeQuest(goblinName, 'change', function* (
|
|
309
|
-
quest,
|
|
310
|
-
path,
|
|
311
|
-
newValue
|
|
312
|
-
) {
|
|
313
|
-
if (hinters && hinters[path]) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
quest.do();
|
|
317
|
-
yield quest.me.update();
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
Goblin.registerSafeQuest(goblinName, 'apply', function* (quest) {
|
|
321
|
-
quest.do();
|
|
322
|
-
yield quest.me.update();
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
Goblin.registerSafeQuest(goblinName, 'update', function* (quest) {
|
|
326
|
-
const state = quest.goblin.getState();
|
|
327
|
-
const stepName = state.get('step');
|
|
328
|
-
const step = steps[stepName];
|
|
329
|
-
|
|
330
|
-
if (step) {
|
|
331
|
-
if (step.updateButtonsMode === 'onChange') {
|
|
332
|
-
yield quest.me.updateButtons();
|
|
333
|
-
}
|
|
334
|
-
if (step.onChange) {
|
|
335
|
-
const form = state.get('form');
|
|
336
|
-
yield quest.me[`${stepName}OnChange`]({form});
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
Goblin.registerSafeQuest(goblinName, 'update-buttons', function* (quest) {
|
|
342
|
-
const state = quest.goblin.getState();
|
|
343
|
-
const stepName = state.get('step');
|
|
344
|
-
const step = steps[stepName];
|
|
345
|
-
|
|
346
|
-
if (step && step.buttons) {
|
|
347
|
-
const form = state.get('form');
|
|
348
|
-
const currentButtons = state.get('buttons');
|
|
349
|
-
const newButtons = yield quest.me[`${stepName}Buttons`]({
|
|
350
|
-
form,
|
|
351
|
-
buttons: currentButtons,
|
|
352
|
-
});
|
|
353
|
-
quest.dispatch('buttons', {buttons: newButtons});
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
// configure steps
|
|
358
|
-
for (const stepName of wizardSteps) {
|
|
359
|
-
const step = steps[stepName];
|
|
360
|
-
logicHandlers[`init-${stepName}`] = (state) => {
|
|
361
|
-
if (step.form) {
|
|
362
|
-
return state.mergeDeep('form', step.form);
|
|
363
|
-
}
|
|
364
|
-
return state;
|
|
365
|
-
};
|
|
366
|
-
logicHandlers[stepName] = (state, action) => {
|
|
367
|
-
return state.mergeDeep('form', action.get('form'));
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
if (step.quest) {
|
|
371
|
-
Goblin.registerSafeQuest(goblinName, stepName, step.quest);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (step.buttons) {
|
|
375
|
-
Goblin.registerSafeQuest(goblinName, `${stepName}-buttons`, step.buttons);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (step.onChange) {
|
|
379
|
-
Goblin.registerSafeQuest(
|
|
380
|
-
goblinName,
|
|
381
|
-
`${stepName}-on-change`,
|
|
382
|
-
step.onChange
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
for (const action in step.actions) {
|
|
387
|
-
const actionQuest = `${stepName}-${action}`;
|
|
388
|
-
logicHandlers[actionQuest] = step.actions[action];
|
|
389
|
-
Goblin.registerSafeQuest(goblinName, actionQuest, function (quest) {
|
|
390
|
-
quest.do();
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
Goblin.registerSafeQuest(goblinName, 'get-entity', common.getEntityQuest);
|
|
396
|
-
Goblin.registerSafeQuest(goblinName, 'load-entity', common.loadEntityQuest);
|
|
397
|
-
Goblin.registerSafeQuest(goblinName, 'open-wizard', common.openWizard);
|
|
398
|
-
|
|
399
|
-
Goblin.registerSafeQuest(goblinName, 'showHinter', function* (
|
|
400
|
-
quest,
|
|
401
|
-
type,
|
|
402
|
-
withDetail = true
|
|
403
|
-
) {
|
|
404
|
-
const hinterWidgetId = hinterWidgetIdsByName[type];
|
|
405
|
-
const hinterAPI = quest.getAPI(hinterWidgetId).noThrow();
|
|
406
|
-
yield hinterAPI.show();
|
|
407
|
-
if (withDetail) {
|
|
408
|
-
yield hinterAPI.showDetail();
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
Goblin.registerSafeQuest(goblinName, 'hideHinter', function* (quest, type) {
|
|
413
|
-
const hinterAPI = quest
|
|
414
|
-
.getAPI(`${type}-hinter@${quest.goblin.id}`)
|
|
415
|
-
.noThrow();
|
|
416
|
-
yield hinterAPI.hide();
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
Goblin.registerSafeQuest(goblinName, 'setDetail', function* (
|
|
420
|
-
quest,
|
|
421
|
-
type,
|
|
422
|
-
entityId
|
|
423
|
-
) {
|
|
424
|
-
const hinterWidgetId = hinterWidgetIdsByName[type];
|
|
425
|
-
const deskAPI = quest.getAPI(quest.getDesktop()).noThrow();
|
|
426
|
-
yield deskAPI.setDetail({
|
|
427
|
-
hinterId: hinterWidgetId,
|
|
428
|
-
});
|
|
429
|
-
const hinterAPI = quest.getAPI(hinterWidgetId).noThrow();
|
|
430
|
-
yield hinterAPI.setCurrentDetailEntity({entityId});
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
function disposeQuest(quest) {
|
|
434
|
-
if (quest.goblin.getX('isDisposing')) {
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
quest.goblin.setX('isDisposing', true);
|
|
439
|
-
|
|
440
|
-
const desktopId = quest.goblin.getX('desktopId');
|
|
441
|
-
|
|
442
|
-
quest.evt(`${desktopId}.<remove-workitem-requested>`, {
|
|
443
|
-
workitemId: quest.goblin.id,
|
|
444
|
-
close: false,
|
|
445
|
-
navToLastWorkitem: true,
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
Goblin.registerSafeQuest(goblinName, 'dispose', disposeQuest);
|
|
450
|
-
|
|
451
|
-
Goblin.registerQuest(goblinName, 'delete', function (quest) {
|
|
452
|
-
quest.evt('done', {finished: true});
|
|
453
|
-
disposeQuest(quest);
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
return Goblin.configure(goblinName, {}, logicHandlers);
|
|
457
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
//T:2019-02-27
|
|
3
|
+
|
|
4
|
+
const Goblin = require('xcraft-core-goblin');
|
|
5
|
+
const T = require('goblin-nabu/widgets/helpers/t.js');
|
|
6
|
+
const common = require('goblin-workshop').common;
|
|
7
|
+
const Shredder = require('xcraft-core-shredder');
|
|
8
|
+
|
|
9
|
+
const {OrderedMap, fromJS} = require('immutable');
|
|
10
|
+
|
|
11
|
+
const defaultButtons = OrderedMap()
|
|
12
|
+
.set(
|
|
13
|
+
'main',
|
|
14
|
+
fromJS({
|
|
15
|
+
glyph: 'solid/step-forward',
|
|
16
|
+
text: T('Suivant', 'Bouton du wizard'),
|
|
17
|
+
grow: '1',
|
|
18
|
+
})
|
|
19
|
+
)
|
|
20
|
+
.set(
|
|
21
|
+
'cancel',
|
|
22
|
+
fromJS({
|
|
23
|
+
glyph: 'solid/times',
|
|
24
|
+
text: T('Annuler', 'Bouton du wizard'),
|
|
25
|
+
grow: '1',
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
module.exports = (config) => {
|
|
30
|
+
const {
|
|
31
|
+
name,
|
|
32
|
+
title,
|
|
33
|
+
skills,
|
|
34
|
+
dialog,
|
|
35
|
+
steps,
|
|
36
|
+
gadgets,
|
|
37
|
+
quests,
|
|
38
|
+
initialFormState,
|
|
39
|
+
hinters,
|
|
40
|
+
} = config;
|
|
41
|
+
const goblinName = `${name}-wizard`;
|
|
42
|
+
const wizardSteps = Object.keys(steps);
|
|
43
|
+
const wizardFlow = ['init'].concat(wizardSteps);
|
|
44
|
+
const hinterIdsByName = {};
|
|
45
|
+
const hinterWidgetIdsByName = {};
|
|
46
|
+
// Define logic handlers according rc.json
|
|
47
|
+
const logicHandlers = {
|
|
48
|
+
'create': (state, action) => {
|
|
49
|
+
const form = action.get('form');
|
|
50
|
+
const initForm = action.get('initialFormState');
|
|
51
|
+
const mergedInitialForm = Object.assign(initForm || {}, form || {});
|
|
52
|
+
return state.set('', {
|
|
53
|
+
id: action.get('id'),
|
|
54
|
+
step: 'init',
|
|
55
|
+
title: title,
|
|
56
|
+
dialog: dialog || {
|
|
57
|
+
width: '500px',
|
|
58
|
+
},
|
|
59
|
+
gadgets: action.get('wizardGadgets'),
|
|
60
|
+
busy: true,
|
|
61
|
+
buttons: defaultButtons,
|
|
62
|
+
form: mergedInitialForm,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
'init-wizard': (state) => {
|
|
66
|
+
return state.set('step', '_goto').set('nextStep', wizardFlow[1]);
|
|
67
|
+
},
|
|
68
|
+
'buttons': (state, action) => {
|
|
69
|
+
return state.set('buttons', action.get('buttons'));
|
|
70
|
+
},
|
|
71
|
+
'change': (state, action) => {
|
|
72
|
+
return state.set(action.get('path'), action.get('newValue'));
|
|
73
|
+
},
|
|
74
|
+
'apply': (state, action) => {
|
|
75
|
+
return state.mergeDeep(action.get('path', ''), action.get('patch'));
|
|
76
|
+
},
|
|
77
|
+
'back': (state) => {
|
|
78
|
+
const c = state.get('step');
|
|
79
|
+
const cIndex = wizardFlow.indexOf(c);
|
|
80
|
+
if (cIndex === 0) {
|
|
81
|
+
return state;
|
|
82
|
+
}
|
|
83
|
+
const nIndex = cIndex - 1;
|
|
84
|
+
return state.set('step', '_goto').set('nextStep', wizardFlow[nIndex]);
|
|
85
|
+
},
|
|
86
|
+
'next': (state, action) => {
|
|
87
|
+
const c = state.get('step');
|
|
88
|
+
if (c === 'done') {
|
|
89
|
+
return state;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const cIndex = wizardFlow.indexOf(c);
|
|
93
|
+
if (cIndex === wizardFlow.length - 1) {
|
|
94
|
+
return state.set('result', action.get('result')).set('step', 'done');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const nIndex = cIndex + 1;
|
|
98
|
+
const nextStep = wizardFlow[nIndex];
|
|
99
|
+
return state.set('nextStep', nextStep).set('step', '_goto');
|
|
100
|
+
},
|
|
101
|
+
'goto': (state, action) => {
|
|
102
|
+
const step = action.get('step');
|
|
103
|
+
return state.set('nextStep', step).set('step', '_goto');
|
|
104
|
+
},
|
|
105
|
+
'_goto': (state) => {
|
|
106
|
+
const nextStep = state.get('nextStep');
|
|
107
|
+
return state.set('step', nextStep).del('nextStep');
|
|
108
|
+
},
|
|
109
|
+
'busy': (state) => {
|
|
110
|
+
return state.set('busy', true);
|
|
111
|
+
},
|
|
112
|
+
'idle': (state) => {
|
|
113
|
+
return state.set('busy', false);
|
|
114
|
+
},
|
|
115
|
+
'cancel': (state) => {
|
|
116
|
+
return state.set('canceled', true).set('step', 'done');
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
Goblin.registerQuest(
|
|
121
|
+
goblinName,
|
|
122
|
+
'create',
|
|
123
|
+
function* (quest, desktopId, form, isDialog) {
|
|
124
|
+
const id = quest.goblin.id;
|
|
125
|
+
quest.goblin.setX('desktopId', desktopId);
|
|
126
|
+
quest.goblin.setX('isDialog', isDialog);
|
|
127
|
+
quest.goblin.setX('isDisposing', false);
|
|
128
|
+
const wizardGadgets = {};
|
|
129
|
+
|
|
130
|
+
if (gadgets) {
|
|
131
|
+
yield common.createGadgets(quest, goblinName, gadgets, wizardGadgets);
|
|
132
|
+
}
|
|
133
|
+
if (hinters) {
|
|
134
|
+
yield quest.me.createHinters();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let running = 0;
|
|
138
|
+
|
|
139
|
+
quest.goblin.defer(
|
|
140
|
+
quest.sub.local(`*::${quest.goblin.id}.<wizard-tick>`, function* (
|
|
141
|
+
err,
|
|
142
|
+
{msg, resp}
|
|
143
|
+
) {
|
|
144
|
+
const {calledFrom} = msg.data;
|
|
145
|
+
const isInternal = calledFrom.split('.')[0] === quest.goblin.id;
|
|
146
|
+
if (running > 0 && !isInternal) {
|
|
147
|
+
return; /* Drop this tick because a step is already running */
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
try {
|
|
151
|
+
++running;
|
|
152
|
+
const step = quest.goblin.getState().get('step');
|
|
153
|
+
yield resp.cmd(`${goblinName}.${step}`, {id});
|
|
154
|
+
} finally {
|
|
155
|
+
--running;
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
quest.do({id: quest.goblin.id, initialFormState, form, wizardGadgets});
|
|
161
|
+
yield quest.me.initWizard();
|
|
162
|
+
yield quest.me.idle();
|
|
163
|
+
return quest.goblin.id;
|
|
164
|
+
},
|
|
165
|
+
{skills: skills ?? []}
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
Goblin.registerQuest(goblinName, 'create-hinters', function* (quest, next) {
|
|
169
|
+
const desktopId = quest.goblin.getX('desktopId');
|
|
170
|
+
|
|
171
|
+
if (hinters) {
|
|
172
|
+
Object.keys(hinters).forEach((h) => {
|
|
173
|
+
let detailWidget = null;
|
|
174
|
+
let hName = h;
|
|
175
|
+
if (hinters[h].hinter) {
|
|
176
|
+
hName = hinters[h].hinter;
|
|
177
|
+
detailWidget = `${hName}-workitem`;
|
|
178
|
+
}
|
|
179
|
+
if (quest.hasAPI(`${hName}-hinter`)) {
|
|
180
|
+
const id = `${hName}-hinter@${h}@${quest.goblin.id}`;
|
|
181
|
+
const widgetId = `hinter@${hName}@${quest.goblin.id}`;
|
|
182
|
+
hinterIdsByName[h] = id;
|
|
183
|
+
hinterWidgetIdsByName[h] = widgetId;
|
|
184
|
+
quest.create(
|
|
185
|
+
`${hName}-hinter`,
|
|
186
|
+
{
|
|
187
|
+
id,
|
|
188
|
+
desktopId,
|
|
189
|
+
hinterName: h,
|
|
190
|
+
workitemId: quest.goblin.id,
|
|
191
|
+
detailWidget,
|
|
192
|
+
withDetails: true,
|
|
193
|
+
},
|
|
194
|
+
next.parallel()
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
yield next.sync();
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
common.registerHinters(goblinName, hinters);
|
|
203
|
+
|
|
204
|
+
Goblin.registerSafeQuest(goblinName, 'busy', function (quest) {
|
|
205
|
+
quest.do();
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
Goblin.registerSafeQuest(goblinName, 'idle', function (quest) {
|
|
209
|
+
quest.do();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
if (gadgets) {
|
|
213
|
+
for (const key of Object.keys(gadgets)) {
|
|
214
|
+
//Gogo gadgeto stylo!
|
|
215
|
+
Goblin.registerSafeQuest(goblinName, `use-${key}`, function* (
|
|
216
|
+
quest,
|
|
217
|
+
action,
|
|
218
|
+
payload
|
|
219
|
+
) {
|
|
220
|
+
const gadgetId = quest.goblin.getState().get(`gadgets.${key}.id`);
|
|
221
|
+
const api = quest.getAPI(gadgetId);
|
|
222
|
+
yield api[action](payload);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
//Register gagdet quest handlers
|
|
226
|
+
|
|
227
|
+
if (gadgets[key].onActions) {
|
|
228
|
+
for (const handler of Object.keys(gadgets[key].onActions)) {
|
|
229
|
+
const questName = common.jsifyQuestName(`${key}-${handler}`);
|
|
230
|
+
logicHandlers[questName] = gadgets[key].onActions[handler];
|
|
231
|
+
|
|
232
|
+
Goblin.registerSafeQuest(goblinName, questName, function* (quest) {
|
|
233
|
+
quest.do();
|
|
234
|
+
yield quest.me.update();
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (quests) {
|
|
242
|
+
Object.keys(quests).forEach((q) => {
|
|
243
|
+
Goblin.registerSafeQuest(goblinName, q, quests[q]);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
Goblin.registerSafeQuest(goblinName, 'init-wizard', function (quest) {
|
|
248
|
+
quest.do();
|
|
249
|
+
quest.evt('<wizard-tick>', {calledFrom: quest.calledFrom});
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
Goblin.registerSafeQuest(goblinName, 'next', function (quest, result) {
|
|
253
|
+
quest.do();
|
|
254
|
+
quest.evt('<wizard-tick>', {calledFrom: quest.calledFrom});
|
|
255
|
+
return result;
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
Goblin.registerSafeQuest(goblinName, 'back', function (quest) {
|
|
259
|
+
quest.do();
|
|
260
|
+
quest.evt('<wizard-tick>', {calledFrom: quest.calledFrom});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
Goblin.registerSafeQuest(goblinName, 'goto', function (quest, step) {
|
|
264
|
+
quest.do();
|
|
265
|
+
quest.evt('<wizard-tick>', {calledFrom: quest.calledFrom});
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
Goblin.registerSafeQuest(goblinName, '_goto', function* (quest) {
|
|
269
|
+
const state = quest.goblin.getState();
|
|
270
|
+
const form = state.get('form').toJS();
|
|
271
|
+
const nextStep = state.get('nextStep');
|
|
272
|
+
|
|
273
|
+
quest.dispatch(`init-${nextStep}`);
|
|
274
|
+
quest.do();
|
|
275
|
+
|
|
276
|
+
yield quest.me.updateButtons();
|
|
277
|
+
|
|
278
|
+
if (quest.me[nextStep]) {
|
|
279
|
+
try {
|
|
280
|
+
yield quest.me.busy();
|
|
281
|
+
yield quest.me[nextStep]({form});
|
|
282
|
+
} finally {
|
|
283
|
+
if (!quest.goblin.getX('isDisposing')) {
|
|
284
|
+
yield quest.me.idle();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
Goblin.registerSafeQuest(goblinName, 'done', function* (quest) {
|
|
291
|
+
let result = quest.goblin.getState().get('result');
|
|
292
|
+
if (Shredder.isImmutable(result)) {
|
|
293
|
+
result = result.toJS();
|
|
294
|
+
}
|
|
295
|
+
let payload = {finished: true, result};
|
|
296
|
+
if (quest.goblin.getState().get('canceled')) {
|
|
297
|
+
payload = quest.cancel();
|
|
298
|
+
}
|
|
299
|
+
quest.evt('done', payload);
|
|
300
|
+
yield quest.me.dispose();
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
Goblin.registerSafeQuest(goblinName, 'cancel', function (quest) {
|
|
304
|
+
quest.do();
|
|
305
|
+
quest.evt('<wizard-tick>', {calledFrom: quest.calledFrom});
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
Goblin.registerSafeQuest(goblinName, 'change', function* (
|
|
309
|
+
quest,
|
|
310
|
+
path,
|
|
311
|
+
newValue
|
|
312
|
+
) {
|
|
313
|
+
if (hinters && hinters[path]) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
quest.do();
|
|
317
|
+
yield quest.me.update();
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
Goblin.registerSafeQuest(goblinName, 'apply', function* (quest) {
|
|
321
|
+
quest.do();
|
|
322
|
+
yield quest.me.update();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
Goblin.registerSafeQuest(goblinName, 'update', function* (quest) {
|
|
326
|
+
const state = quest.goblin.getState();
|
|
327
|
+
const stepName = state.get('step');
|
|
328
|
+
const step = steps[stepName];
|
|
329
|
+
|
|
330
|
+
if (step) {
|
|
331
|
+
if (step.updateButtonsMode === 'onChange') {
|
|
332
|
+
yield quest.me.updateButtons();
|
|
333
|
+
}
|
|
334
|
+
if (step.onChange) {
|
|
335
|
+
const form = state.get('form');
|
|
336
|
+
yield quest.me[`${stepName}OnChange`]({form});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
Goblin.registerSafeQuest(goblinName, 'update-buttons', function* (quest) {
|
|
342
|
+
const state = quest.goblin.getState();
|
|
343
|
+
const stepName = state.get('step');
|
|
344
|
+
const step = steps[stepName];
|
|
345
|
+
|
|
346
|
+
if (step && step.buttons) {
|
|
347
|
+
const form = state.get('form');
|
|
348
|
+
const currentButtons = state.get('buttons');
|
|
349
|
+
const newButtons = yield quest.me[`${stepName}Buttons`]({
|
|
350
|
+
form,
|
|
351
|
+
buttons: currentButtons,
|
|
352
|
+
});
|
|
353
|
+
quest.dispatch('buttons', {buttons: newButtons});
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// configure steps
|
|
358
|
+
for (const stepName of wizardSteps) {
|
|
359
|
+
const step = steps[stepName];
|
|
360
|
+
logicHandlers[`init-${stepName}`] = (state) => {
|
|
361
|
+
if (step.form) {
|
|
362
|
+
return state.mergeDeep('form', step.form);
|
|
363
|
+
}
|
|
364
|
+
return state;
|
|
365
|
+
};
|
|
366
|
+
logicHandlers[stepName] = (state, action) => {
|
|
367
|
+
return state.mergeDeep('form', action.get('form'));
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
if (step.quest) {
|
|
371
|
+
Goblin.registerSafeQuest(goblinName, stepName, step.quest);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (step.buttons) {
|
|
375
|
+
Goblin.registerSafeQuest(goblinName, `${stepName}-buttons`, step.buttons);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (step.onChange) {
|
|
379
|
+
Goblin.registerSafeQuest(
|
|
380
|
+
goblinName,
|
|
381
|
+
`${stepName}-on-change`,
|
|
382
|
+
step.onChange
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
for (const action in step.actions) {
|
|
387
|
+
const actionQuest = `${stepName}-${action}`;
|
|
388
|
+
logicHandlers[actionQuest] = step.actions[action];
|
|
389
|
+
Goblin.registerSafeQuest(goblinName, actionQuest, function (quest) {
|
|
390
|
+
quest.do();
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
Goblin.registerSafeQuest(goblinName, 'get-entity', common.getEntityQuest);
|
|
396
|
+
Goblin.registerSafeQuest(goblinName, 'load-entity', common.loadEntityQuest);
|
|
397
|
+
Goblin.registerSafeQuest(goblinName, 'open-wizard', common.openWizard);
|
|
398
|
+
|
|
399
|
+
Goblin.registerSafeQuest(goblinName, 'showHinter', function* (
|
|
400
|
+
quest,
|
|
401
|
+
type,
|
|
402
|
+
withDetail = true
|
|
403
|
+
) {
|
|
404
|
+
const hinterWidgetId = hinterWidgetIdsByName[type];
|
|
405
|
+
const hinterAPI = quest.getAPI(hinterWidgetId).noThrow();
|
|
406
|
+
yield hinterAPI.show();
|
|
407
|
+
if (withDetail) {
|
|
408
|
+
yield hinterAPI.showDetail();
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
Goblin.registerSafeQuest(goblinName, 'hideHinter', function* (quest, type) {
|
|
413
|
+
const hinterAPI = quest
|
|
414
|
+
.getAPI(`${type}-hinter@${quest.goblin.id}`)
|
|
415
|
+
.noThrow();
|
|
416
|
+
yield hinterAPI.hide();
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
Goblin.registerSafeQuest(goblinName, 'setDetail', function* (
|
|
420
|
+
quest,
|
|
421
|
+
type,
|
|
422
|
+
entityId
|
|
423
|
+
) {
|
|
424
|
+
const hinterWidgetId = hinterWidgetIdsByName[type];
|
|
425
|
+
const deskAPI = quest.getAPI(quest.getDesktop()).noThrow();
|
|
426
|
+
yield deskAPI.setDetail({
|
|
427
|
+
hinterId: hinterWidgetId,
|
|
428
|
+
});
|
|
429
|
+
const hinterAPI = quest.getAPI(hinterWidgetId).noThrow();
|
|
430
|
+
yield hinterAPI.setCurrentDetailEntity({entityId});
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
function disposeQuest(quest) {
|
|
434
|
+
if (quest.goblin.getX('isDisposing')) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
quest.goblin.setX('isDisposing', true);
|
|
439
|
+
|
|
440
|
+
const desktopId = quest.goblin.getX('desktopId');
|
|
441
|
+
|
|
442
|
+
quest.evt(`${desktopId}.<remove-workitem-requested>`, {
|
|
443
|
+
workitemId: quest.goblin.id,
|
|
444
|
+
close: false,
|
|
445
|
+
navToLastWorkitem: true,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
Goblin.registerSafeQuest(goblinName, 'dispose', disposeQuest);
|
|
450
|
+
|
|
451
|
+
Goblin.registerQuest(goblinName, 'delete', function (quest) {
|
|
452
|
+
quest.evt('done', {finished: true});
|
|
453
|
+
disposeQuest(quest);
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
return Goblin.configure(goblinName, {}, logicHandlers);
|
|
457
|
+
};
|