jamespot-front-business 1.1.38 → 1.1.40

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/dist/cjs.js CHANGED
@@ -11,26 +11,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
11
11
 
12
12
  var jamespot__default = /*#__PURE__*/_interopDefaultLegacy(jamespot);
13
13
 
14
- const adapter$1 = toolkit.createEntityAdapter({
15
- selectId: (app) => app.name,
16
- sortComparer: (a, b) => a.label.localeCompare(b.label),
17
- });
18
- const slice$3 = toolkit.createSlice({
19
- name: 'applications',
20
- initialState: adapter$1.getInitialState(),
21
- reducers: {
22
- addOne: adapter$1.addOne,
23
- addMany: adapter$1.addMany,
24
- setAll: adapter$1.setAll,
25
- },
26
- });
27
- const selectors$2 = adapter$1.getSelectors((state) => state.entities.applications);
28
- const Application = {
29
- slice: slice$3,
30
- actions: Object.assign({}, slice$3.actions),
31
- selectors: selectors$2,
32
- };
33
-
34
14
  /******************************************************************************
35
15
  Copyright (c) Microsoft Corporation.
36
16
 
@@ -68,6 +48,195 @@ function __awaiter(thisArg, _arguments, P, generator) {
68
48
  });
69
49
  }
70
50
 
51
+ const toastAdapter = toolkit.createEntityAdapter({
52
+ selectId: (toast) => toast.id,
53
+ });
54
+ const slice$3 = toolkit.createSlice({
55
+ name: 'toasts',
56
+ initialState: toastAdapter.getInitialState(),
57
+ reducers: {
58
+ addOne: toastAdapter.addOne,
59
+ removeOne: toastAdapter.removeOne,
60
+ },
61
+ });
62
+ const randomId = () => Math.random().toString(16).slice(2);
63
+ const addMessage = (_a, type, timeout) => {
64
+ var { id = randomId() } = _a, toast = __rest(_a, ["id"]);
65
+ if (type === void 0) { type = 'success'; }
66
+ if (timeout === void 0) { timeout = 3000; }
67
+ return (dispatch) => {
68
+ dispatch(slice$3.actions.addOne(Object.assign(Object.assign({ id }, toast), { timeout, type })));
69
+ setTimeout(() => {
70
+ dispatch(slice$3.actions.removeOne(id));
71
+ }, timeout);
72
+ return id;
73
+ };
74
+ };
75
+ const actions = {
76
+ addMessage,
77
+ success: (toast, timeout) => addMessage(toast, 'success', timeout),
78
+ warning: (toast, timeout) => addMessage(toast, 'warning', timeout),
79
+ error: (toast, timeout) => addMessage(toast, 'error', timeout),
80
+ };
81
+ const selectors$2 = toastAdapter.getSelectors((state) => state.toasts);
82
+ const Toast = {
83
+ slice: slice$3,
84
+ actions: Object.assign(Object.assign({}, actions), slice$3.actions),
85
+ selectors: selectors$2,
86
+ };
87
+
88
+ const getAnimationsRTHandlers = function (dispatch) {
89
+ const addAnimationHandler = function (message) {
90
+ if (message.namespace === 'ANIMATIONS' &&
91
+ message.function === 'add') {
92
+ dispatch(fetchCurrentAnimation());
93
+ dispatch(fetchCurrentAnimationApp());
94
+ }
95
+ };
96
+ const deleteAnimationHandler = function (message) {
97
+ if (message.namespace === 'ANIMATIONS' &&
98
+ message.function === 'delete') {
99
+ dispatch(fetchCurrentAnimation());
100
+ dispatch(fetchCurrentAnimationApp());
101
+ }
102
+ };
103
+ const toggleIsActiveAnimationHandler = function (message) {
104
+ if (message.namespace === 'ANIMATIONS' &&
105
+ message.function === 'toggle') {
106
+ dispatch(fetchCurrentAnimation());
107
+ }
108
+ };
109
+ return [
110
+ {
111
+ namespace: 'ANIMATIONS',
112
+ function: 'add',
113
+ handler: addAnimationHandler,
114
+ },
115
+ {
116
+ namespace: 'ANIMATIONS',
117
+ function: 'delete',
118
+ handler: deleteAnimationHandler,
119
+ },
120
+ {
121
+ namespace: 'ANIMATIONS',
122
+ function: 'toggle',
123
+ handler: toggleIsActiveAnimationHandler,
124
+ },
125
+ ];
126
+ };
127
+
128
+ const initialState$k = {
129
+ animationConfiguration: null,
130
+ isActiveForCurrentUser: false,
131
+ isInitialized: false,
132
+ isToggleLoading: false,
133
+ };
134
+ const animationsSlice = toolkit.createSlice({
135
+ name: 'animations',
136
+ initialState: initialState$k,
137
+ reducers: {},
138
+ extraReducers: (builder) => {
139
+ builder.addCase(fetchCurrentAnimation.fulfilled, (state, action) => {
140
+ state.isActiveForCurrentUser = action.payload.isActiveForCurrentUser;
141
+ state.animationConfiguration = action.payload.animationConfiguration;
142
+ state.isInitialized = action.payload.isInitialized;
143
+ });
144
+ builder.addCase(fetchCurrentAnimationApp.fulfilled, (state, action) => {
145
+ state.animationConfigurationApp = action.payload;
146
+ });
147
+ builder.addCase(toggleAnimationIsActive.pending, (state) => {
148
+ state.isToggleLoading = true;
149
+ });
150
+ builder.addCase(toggleAnimationIsActive.fulfilled, (state) => {
151
+ state.isToggleLoading = false;
152
+ });
153
+ builder.addCase(toggleAnimationIsActive.rejected, (state) => {
154
+ state.isToggleLoading = false;
155
+ });
156
+ },
157
+ });
158
+ const fetchCurrentAnimation = toolkit.createAsyncThunk('animations/fetchCurrentAnimation', (_, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
159
+ try {
160
+ const animationConfiguration = (yield extra.jApi.animations.GetCurrentAnimation()).result;
161
+ const isActiveForCurrentUser = (yield extra.jApi.animations.GetAnimationActive()).result;
162
+ return { animationConfiguration, isActiveForCurrentUser, isInitialized: true };
163
+ }
164
+ catch (_) {
165
+ dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
166
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve animation' });
167
+ }
168
+ }));
169
+ const fetchCurrentAnimationApp = toolkit.createAsyncThunk('animations/fetchCurrentAnimationApp', (_, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
170
+ try {
171
+ return (yield extra.jApi.animations.GetCurrentAnimationApp()).result;
172
+ }
173
+ catch (_) {
174
+ dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
175
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve animation' });
176
+ }
177
+ }));
178
+ const deleteCurrentAnimation = toolkit.createAsyncThunk('animations/deleteCurrentAnimation', (_, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
179
+ try {
180
+ yield extra.jApi.animations.DeleteAnimation();
181
+ return;
182
+ }
183
+ catch (_) {
184
+ dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
185
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot delete animation' });
186
+ }
187
+ }));
188
+ const saveCurrentAnimation = toolkit.createAsyncThunk('animations/saveCurrentAnimation', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
189
+ try {
190
+ yield extra.jApi.animations.SaveAnimationConfiguration(params);
191
+ return;
192
+ }
193
+ catch (_) {
194
+ dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
195
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot update animation' });
196
+ }
197
+ }));
198
+ const toggleAnimationIsActive = toolkit.createAsyncThunk('animations/toggleAnimationIsActive', (_, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
199
+ try {
200
+ yield extra.jApi.animations.ToggleAnimationActive();
201
+ return;
202
+ }
203
+ catch (_) {
204
+ dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
205
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot update animation' });
206
+ }
207
+ }));
208
+ const selectCurrentAnimation = (state) => state.animations.animationConfiguration;
209
+ const isActiveAnimation = (state) => state.animations.isActiveForCurrentUser;
210
+ const isToggleLoading = (state) => state.animations.isToggleLoading;
211
+ const selectAnimationConfigurationApp = (state) => state.animations.animationConfigurationApp;
212
+ const animationsReducer = animationsSlice.reducer;
213
+ const Animations = {
214
+ slice: animationsSlice,
215
+ actions: { saveCurrentAnimation, fetchCurrentAnimation, deleteCurrentAnimation, toggleAnimationIsActive, fetchCurrentAnimationApp },
216
+ selectors: { selectCurrentAnimation, isActiveAnimation, isToggleLoading, selectAnimationConfigurationApp },
217
+ getAnimationsRTHandlers
218
+ };
219
+
220
+ const adapter$1 = toolkit.createEntityAdapter({
221
+ selectId: (app) => app.name,
222
+ sortComparer: (a, b) => a.label.localeCompare(b.label),
223
+ });
224
+ const slice$2 = toolkit.createSlice({
225
+ name: 'applications',
226
+ initialState: adapter$1.getInitialState(),
227
+ reducers: {
228
+ addOne: adapter$1.addOne,
229
+ addMany: adapter$1.addMany,
230
+ setAll: adapter$1.setAll,
231
+ },
232
+ });
233
+ const selectors$1 = adapter$1.getSelectors((state) => state.entities.applications);
234
+ const Application = {
235
+ slice: slice$2,
236
+ actions: Object.assign({}, slice$2.actions),
237
+ selectors: selectors$1,
238
+ };
239
+
71
240
  const initialState$j = {
72
241
  entities: [],
73
242
  loading: 'idle',
@@ -203,43 +372,6 @@ const AssetReservation = {
203
372
  },
204
373
  };
205
374
 
206
- const toastAdapter = toolkit.createEntityAdapter({
207
- selectId: (toast) => toast.id,
208
- });
209
- const slice$2 = toolkit.createSlice({
210
- name: 'toasts',
211
- initialState: toastAdapter.getInitialState(),
212
- reducers: {
213
- addOne: toastAdapter.addOne,
214
- removeOne: toastAdapter.removeOne,
215
- },
216
- });
217
- const randomId = () => Math.random().toString(16).slice(2);
218
- const addMessage = (_a, type, timeout) => {
219
- var { id = randomId() } = _a, toast = __rest(_a, ["id"]);
220
- if (type === void 0) { type = 'success'; }
221
- if (timeout === void 0) { timeout = 3000; }
222
- return (dispatch) => {
223
- dispatch(slice$2.actions.addOne(Object.assign(Object.assign({ id }, toast), { timeout, type })));
224
- setTimeout(() => {
225
- dispatch(slice$2.actions.removeOne(id));
226
- }, timeout);
227
- return id;
228
- };
229
- };
230
- const actions = {
231
- addMessage,
232
- success: (toast, timeout) => addMessage(toast, 'success', timeout),
233
- warning: (toast, timeout) => addMessage(toast, 'warning', timeout),
234
- error: (toast, timeout) => addMessage(toast, 'error', timeout),
235
- };
236
- const selectors$1 = toastAdapter.getSelectors((state) => state.toasts);
237
- const Toast = {
238
- slice: slice$2,
239
- actions: Object.assign(Object.assign({}, actions), slice$2.actions),
240
- selectors: selectors$1,
241
- };
242
-
243
375
  const initialState$g = {
244
376
  loading: 'idle',
245
377
  comments: [],
@@ -1664,6 +1796,22 @@ const widgetArticleTitleContent = {
1664
1796
  backgroundColor: 'transparent',
1665
1797
  };
1666
1798
 
1799
+ const widgetApiDefinition = {
1800
+ label: 'WIDGET_Api',
1801
+ description: 'WIDGET_Api_Description',
1802
+ name: 'widget-api',
1803
+ img: '/img/fast-intranet/widget-text.png',
1804
+ available: true,
1805
+ panel: {
1806
+ useWrapper: false,
1807
+ useEditor: true,
1808
+ useWidgets: false,
1809
+ },
1810
+ };
1811
+ const widgetApiContent = {
1812
+ url: '',
1813
+ };
1814
+
1667
1815
  const widgetArticleSliderDefinition = {
1668
1816
  label: 'WIDGET_Slider',
1669
1817
  description: 'WIDGET_Slider_Description',
@@ -1710,6 +1858,8 @@ function content(name) {
1710
1858
  default:
1711
1859
  case 'widget-article-attachment':
1712
1860
  return Object.assign({}, widgetArticleAttachmentContent);
1861
+ case 'widget-api':
1862
+ return Object.assign({}, widgetApiContent);
1713
1863
  case 'widget-article-slider':
1714
1864
  return Object.assign({}, widgetArticleSliderContent);
1715
1865
  case 'widget-article-gallery':
@@ -1758,6 +1908,8 @@ function widgetDefinition(name) {
1758
1908
  return widgetArticleTitleDefinition;
1759
1909
  case 'widget-article-image':
1760
1910
  return widgetArticleImageDefinition;
1911
+ case 'widget-api':
1912
+ return widgetApiDefinition;
1761
1913
  case 'widget-article-button':
1762
1914
  return widgetArticleButtonDefinition;
1763
1915
  }
@@ -2016,6 +2168,7 @@ exports.AppFormItemTypes = void 0;
2016
2168
  AppFormItemTypes["CODEHTML"] = "CODEHTML";
2017
2169
  AppFormItemTypes["USERLINK"] = "USERLINK";
2018
2170
  AppFormItemTypes["CONTENTLINK"] = "CONTENTLINK";
2171
+ AppFormItemTypes["RANGE"] = "RANGE";
2019
2172
  })(exports.AppFormItemTypes || (exports.AppFormItemTypes = {}));
2020
2173
  exports.ExtraAppFieldsItemViews = void 0;
2021
2174
  (function (ExtraAppFieldsItemViews) {
@@ -2037,8 +2190,8 @@ exports.AppFieldFormPropertyTypes = void 0;
2037
2190
  AppFieldFormPropertyTypes["CONTENTTYPE"] = "contenttype";
2038
2191
  })(exports.AppFieldFormPropertyTypes || (exports.AppFieldFormPropertyTypes = {}));
2039
2192
  const AppFormUniqueList = [exports.AppFormItemTypes.DESCRIPTION, exports.AppFormItemTypes.IMAGE];
2040
- const AppFormBannedFromViews = new Map();
2041
- AppFormBannedFromViews.set(exports.AppFormItemTypes.IMAGE, ['list', 'filter', 'view']);
2193
+ const AppFormBannedFromViews$1 = new Map();
2194
+ AppFormBannedFromViews$1.set(exports.AppFormItemTypes.IMAGE, ['list', 'filter', 'view']);
2042
2195
  const MapExtraFieldsWithView = {
2043
2196
  create: {
2044
2197
  fixed: [exports.ExtraAppFieldsItemViews.TITLE],
@@ -2069,6 +2222,275 @@ const MapExtraFieldsWithView = {
2069
2222
  optional: [],
2070
2223
  },
2071
2224
  };
2225
+ const AppColumnsDefaultTypes = [
2226
+ exports.ExtraAppFieldsItemViews.TITLE,
2227
+ exports.ExtraAppFieldsItemViews.USER,
2228
+ exports.ExtraAppFieldsItemViews.CREATIONDATE,
2229
+ exports.AppFormItemTypes.DESCRIPTION,
2230
+ ];
2231
+ const AppFormPrimaryList = [exports.AppFormItemTypes.DESCRIPTION];
2232
+
2233
+ var StatusType;
2234
+ (function (StatusType) {
2235
+ StatusType["draft"] = "draft";
2236
+ StatusType["installed"] = "installed";
2237
+ StatusType["suspended"] = "suspended";
2238
+ })(StatusType || (StatusType = {}));
2239
+ ({
2240
+ DRAFT: StatusType.draft,
2241
+ INSTALLED: StatusType.installed,
2242
+ SUSPENDED: StatusType.suspended,
2243
+ });
2244
+ var AppFormItemType;
2245
+ (function (AppFormItemType) {
2246
+ AppFormItemType["TITLE"] = "TITLE";
2247
+ AppFormItemType["IMAGE"] = "IMAGE";
2248
+ AppFormItemType["DESCRIPTION"] = "DESCRIPTION";
2249
+ AppFormItemType["IDUSER"] = "IDUSER";
2250
+ AppFormItemType["PUBLISHTO"] = "PUBLISHTO";
2251
+ AppFormItemType["SENDALERTTOSUBSCRIBERS"] = "SENDALERTTOSUBSCRIBERS";
2252
+ AppFormItemType["RECEIVEACOPY"] = "RECEIVEACOPY";
2253
+ AppFormItemType["TEXT"] = "TEXT";
2254
+ AppFormItemType["TEXTAREA"] = "TEXTAREA";
2255
+ AppFormItemType["TEXTAREAHTML"] = "TEXTAREAHTML";
2256
+ AppFormItemType["DATE"] = "DATE";
2257
+ AppFormItemType["DATETIME"] = "DATETIME";
2258
+ AppFormItemType["RANGE"] = "RANGE";
2259
+ AppFormItemType["NUMBER"] = "NUMBER";
2260
+ AppFormItemType["URL"] = "URL";
2261
+ AppFormItemType["EMAIL"] = "EMAIL";
2262
+ AppFormItemType["SELECT"] = "SELECT";
2263
+ AppFormItemType["CHECKBOX"] = "CHECKBOX";
2264
+ AppFormItemType["TOGGLE"] = "TOGGLE";
2265
+ AppFormItemType["RADIO"] = "RADIO";
2266
+ AppFormItemType["TAGS"] = "TAGS";
2267
+ AppFormItemType["ADDFILEATTACHMENT"] = "ADDFILEATTACHMENT";
2268
+ AppFormItemType["AUDIENCE"] = "AUDIENCE";
2269
+ AppFormItemType["CODEHTML"] = "CODEHTML";
2270
+ AppFormItemType["DATECREATION"] = "DATECREATION";
2271
+ AppFormItemType["USERLINK"] = "USERLINK";
2272
+ AppFormItemType["CONTENTLINK"] = "CONTENTLINK";
2273
+ })(AppFormItemType || (AppFormItemType = {}));
2274
+ [AppFormItemType.DESCRIPTION];
2275
+ const AppFormNotFields = [AppFormItemType.AUDIENCE, AppFormItemType.RANGE];
2276
+ ({
2277
+ create: [AppFormItemType.TITLE],
2278
+ popup: [AppFormItemType.TITLE],
2279
+ edit: [AppFormItemType.TITLE],
2280
+ list: [AppFormItemType.TITLE, AppFormItemType.IDUSER],
2281
+ filter: [AppFormItemType.TITLE, AppFormItemType.IDUSER],
2282
+ view: [AppFormItemType.TITLE],
2283
+ });
2284
+ ({
2285
+ create: [AppFormItemType.PUBLISHTO, AppFormItemType.SENDALERTTOSUBSCRIBERS, AppFormItemType.RECEIVEACOPY],
2286
+ popup: [AppFormItemType.PUBLISHTO],
2287
+ edit: [AppFormItemType.PUBLISHTO],
2288
+ list: [AppFormItemType.DATECREATION],
2289
+ filter: [AppFormItemType.DATECREATION],
2290
+ view: [],
2291
+ });
2292
+ const AppFormFixedList = [
2293
+ AppFormItemType.TITLE,
2294
+ AppFormItemType.PUBLISHTO,
2295
+ AppFormItemType.SENDALERTTOSUBSCRIBERS,
2296
+ AppFormItemType.RECEIVEACOPY,
2297
+ AppFormItemType.IDUSER,
2298
+ AppFormItemType.DATECREATION,
2299
+ ];
2300
+ [AppFormItemType.DESCRIPTION, AppFormItemType.IMAGE];
2301
+ const AppFormBannedFromViews = new Map();
2302
+ AppFormBannedFromViews.set(AppFormItemType.IMAGE, ['list', 'filter', 'view']);
2303
+ const AppListFilter = [
2304
+ AppFormItemType.TITLE,
2305
+ AppFormItemType.DESCRIPTION,
2306
+ AppFormItemType.TEXT,
2307
+ AppFormItemType.TEXTAREA,
2308
+ AppFormItemType.TEXTAREAHTML,
2309
+ AppFormItemType.DATE,
2310
+ AppFormItemType.DATETIME,
2311
+ AppFormItemType.RANGE,
2312
+ AppFormItemType.NUMBER,
2313
+ AppFormItemType.URL,
2314
+ AppFormItemType.EMAIL,
2315
+ AppFormItemType.SELECT,
2316
+ AppFormItemType.TOGGLE,
2317
+ AppFormItemType.CHECKBOX,
2318
+ AppFormItemType.RADIO,
2319
+ AppFormItemType.TAGS,
2320
+ AppFormItemType.PUBLISHTO,
2321
+ AppFormItemType.SENDALERTTOSUBSCRIBERS,
2322
+ AppFormItemType.RECEIVEACOPY,
2323
+ AppFormItemType.ADDFILEATTACHMENT,
2324
+ AppFormItemType.CODEHTML,
2325
+ AppFormItemType.IDUSER,
2326
+ AppFormItemType.DATECREATION,
2327
+ AppFormItemType.USERLINK,
2328
+ AppFormItemType.CONTENTLINK,
2329
+ ];
2330
+ ({
2331
+ create: [AppFormItemType.IMAGE, AppFormItemType.ADDFILEATTACHMENT, AppFormItemType.CODEHTML],
2332
+ popup: [AppFormItemType.IMAGE, AppFormItemType.ADDFILEATTACHMENT, AppFormItemType.CODEHTML],
2333
+ edit: [AppFormItemType.IMAGE, AppFormItemType.ADDFILEATTACHMENT, AppFormItemType.CODEHTML],
2334
+ list: AppListFilter,
2335
+ filter: AppListFilter,
2336
+ view: AppListFilter,
2337
+ });
2338
+ AppFormFixedList.concat(AppFormNotFields)
2339
+ .concat(AppFormItemType.IDUSER)
2340
+ .concat(AppFormItemType.TITLE);
2341
+ [AppFormItemType.CODEHTML];
2342
+
2343
+ function migrateJson(v1Json) {
2344
+ const v1 = v1Json;
2345
+ const v1Manifest = v1.manifest;
2346
+ const newFields = _renderFields();
2347
+ const v2 = {
2348
+ idApp: v1.idApp,
2349
+ status: v1.status,
2350
+ studioVersion: 2,
2351
+ author: v1.author || '',
2352
+ manifest: {
2353
+ appShortName: v1Manifest.appShortName,
2354
+ appName: v1Manifest.appName,
2355
+ description: v1Manifest.description,
2356
+ author: v1Manifest.author || '',
2357
+ typeLabel: v1Manifest.typeLabel,
2358
+ cssColor: v1Manifest.cssColor,
2359
+ cssClass: v1Manifest.cssClass,
2360
+ version: v1Manifest.version,
2361
+ dateCreation: new Date(v1Manifest.dateCreation).toISOString(),
2362
+ viewSolr: v1Manifest.viewSolr,
2363
+ checkAccess: v1Manifest.checkAccess,
2364
+ accessRightList: v1Manifest.accessRightList || '',
2365
+ attrExposed: v1Manifest.attrExposed,
2366
+ },
2367
+ fields: newFields,
2368
+ views: _renderViews(),
2369
+ audience: v1.audience || '1',
2370
+ installFor: v1.installFor || [],
2371
+ };
2372
+ function _renderFields() {
2373
+ var _a;
2374
+ const v2Fields = [];
2375
+ for (const v1FormItem of v1.form.formItems) {
2376
+ const type = _matctTypes(v1FormItem.type);
2377
+ v2Fields.push({
2378
+ id: v1FormItem.id,
2379
+ type,
2380
+ properties: _renderProperties((_a = v1FormItem.properties) !== null && _a !== void 0 ? _a : {}),
2381
+ mandatory: v1FormItem.mandatory || false,
2382
+ views: v1FormItem.views,
2383
+ isActive: true,
2384
+ isFixed: false,
2385
+ isOptional: false,
2386
+ value: null,
2387
+ });
2388
+ }
2389
+ return v2Fields;
2390
+ }
2391
+ function _matctTypes(v1Type) {
2392
+ return exports.AppFormItemTypes[v1Type];
2393
+ }
2394
+ function _renderProperties(v1FormItemProperties) {
2395
+ var _a, _b, _c, _d, _e, _f, _g;
2396
+ const v2Properties = [];
2397
+ const isEnhancedOptionEditor = v1FormItemProperties.options &&
2398
+ Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'hasDefaultValue');
2399
+ const baseProperty = Object.assign({ isRequired: v1FormItemProperties.mandatory || false }, (isEnhancedOptionEditor && { isOptionsEditorEnhanced: true }));
2400
+ if (v1FormItemProperties.labels) {
2401
+ v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.LABEL, value: ((_a = v1FormItemProperties.labels.label) === null || _a === void 0 ? void 0 : _a.content) || '' }, baseProperty));
2402
+ v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.DESCRIPTION, value: ((_b = v1FormItemProperties.labels.description) === null || _b === void 0 ? void 0 : _b.content) || '' }, baseProperty));
2403
+ }
2404
+ if (v1FormItemProperties.options) {
2405
+ v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR, value: isEnhancedOptionEditor
2406
+ ? {
2407
+ propertyOptions: _renderSelectOptions((_c = v1FormItemProperties.options) !== null && _c !== void 0 ? _c : []),
2408
+ defaultSelectOptionValue: v1FormItemProperties.defaultValue,
2409
+ defaultSelectOption: (_d = v1FormItemProperties.hasDefaultValue) !== null && _d !== void 0 ? _d : false,
2410
+ canSelectMultiple: (_e = v1FormItemProperties.multiple) !== null && _e !== void 0 ? _e : false,
2411
+ userCanModifiyByComment: (_f = v1FormItemProperties.explain) !== null && _f !== void 0 ? _f : false,
2412
+ }
2413
+ : { propertyOptions: _renderSelectOptions((_g = v1FormItemProperties.options) !== null && _g !== void 0 ? _g : []) } }, baseProperty));
2414
+ }
2415
+ if (v1FormItemProperties.code) {
2416
+ v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.RICHTEXT, value: v1FormItemProperties.code.html || v1FormItemProperties.code.text || '' }, baseProperty));
2417
+ }
2418
+ if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'digits')) {
2419
+ v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.CHECKBOX, value: v1FormItemProperties.digits || false, checkBoxOptions: [{ label: 'APPSTUDIO_FormEditProps_Digits', value: v1FormItemProperties.digits }] }, baseProperty));
2420
+ }
2421
+ if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'taxonomy')) {
2422
+ v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.TAXONOMY, value: v1FormItemProperties.taxonomy || '' }, baseProperty));
2423
+ }
2424
+ if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'contentType')) {
2425
+ v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.CONTENTTYPE, value: v1FormItemProperties.contentType || '' }, baseProperty));
2426
+ }
2427
+ return v2Properties;
2428
+ }
2429
+ function _renderSelectOptions(v1Options) {
2430
+ const v2Options = [];
2431
+ for (const option of v1Options) {
2432
+ v2Options.push({
2433
+ title: option.label,
2434
+ value: option.value,
2435
+ });
2436
+ }
2437
+ return v2Options;
2438
+ }
2439
+ function _renderViews() {
2440
+ return {
2441
+ create: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'create').formItemRefs),
2442
+ popup: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'popup').formItemRefs),
2443
+ edit: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'edit').formItemRefs),
2444
+ list: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'list').formItemRefs),
2445
+ filter: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'filter').formItemRefs),
2446
+ view: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'view').formItemRefs),
2447
+ };
2448
+ }
2449
+ function _renderViewFields(v1FormItemRefs) {
2450
+ const viewItems = {};
2451
+ v1FormItemRefs.forEach((v1FormItemRef) => {
2452
+ const viewBase = {
2453
+ isUsed: true,
2454
+ isFixed: false,
2455
+ isOptional: false,
2456
+ properties: [],
2457
+ pos: 0,
2458
+ isLockedValue: !!v1FormItemRef.fixedValue || false,
2459
+ value: v1FormItemRef.fixedValue || '',
2460
+ };
2461
+ if (v1FormItemRef.ref === AppFormItemType.TITLE) {
2462
+ viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.TITLE, isFixed: true });
2463
+ }
2464
+ else if (v1FormItemRef.ref === AppFormItemType.IDUSER) {
2465
+ viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.USER, isFixed: true });
2466
+ }
2467
+ else if (v1FormItemRef.ref === AppFormItemType.PUBLISHTO) {
2468
+ viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.PUBLISHTO, isOptional: true });
2469
+ }
2470
+ else if (v1FormItemRef.ref === AppFormItemType.SENDALERTTOSUBSCRIBERS) {
2471
+ viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS, isOptional: true });
2472
+ }
2473
+ else if (v1FormItemRef.ref === AppFormItemType.RECEIVEACOPY) {
2474
+ viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.RECEIVEACOPY, isOptional: true });
2475
+ }
2476
+ else {
2477
+ const v2Field = _mapFormItemRefWithField(v1FormItemRef);
2478
+ if (v2Field) {
2479
+ viewItems[v2Field.id] = Object.assign(Object.assign({ type: v2Field.type }, viewBase), { properties: v2Field.properties || [] });
2480
+ }
2481
+ }
2482
+ });
2483
+ return viewItems;
2484
+ }
2485
+ function _mapFormItemRefWithField(v1FormItemRef) {
2486
+ const v1Field = v1.form.formItems.find((field) => v1FormItemRef.ref === field.id || v1FormItemRef.ref === field.name);
2487
+ if (v1Field) {
2488
+ return newFields.find((field) => field.id === v1Field.id);
2489
+ }
2490
+ return null;
2491
+ }
2492
+ return v2;
2493
+ }
2072
2494
 
2073
2495
  function InstalledAppStudioAdapter(serverApp, serverApps) {
2074
2496
  const { version, dateCreation } = serverApp.manifest;
@@ -2079,6 +2501,7 @@ function InstalledAppStudioAdapter(serverApp, serverApps) {
2079
2501
  const studioApp = {
2080
2502
  idApp: serverApp.idApp,
2081
2503
  status: _formatStatus(serverApp),
2504
+ studioVersion: 2,
2082
2505
  manifest: Object.assign({ appShortName: serverApp.name, appName: serverApp.label, description: serverApp.description, author: serverApp.author, cssColor: appTypeServer.cssColor, cssClass: { label: appTypeServer.cssClass, value: appTypeServer.cssClass }, version: version, dateCreation: dateCreation, checkAccess: serverApp.checkAccess, attrExposed: serverApp.attrExposed, viewSolr: serverApp.view, typeLabel: appTypeServer.typeLabel }, (serverApp.articlesCount && { articlesCount: serverApp.articlesCount })),
2083
2506
  fields: [],
2084
2507
  views,
@@ -2098,15 +2521,21 @@ function DraftAppStudioAdapter(serverApp) {
2098
2521
  if (!serverApp.value)
2099
2522
  return undefined;
2100
2523
  const parsedJson = JSON.parse(serverApp.value);
2101
- return {
2102
- idApp: serverApp.idApp,
2103
- status: _formatStatus(serverApp),
2104
- manifest: parsedJson.manifest,
2105
- fields: parsedJson.fields,
2106
- views: parsedJson.views,
2107
- audience: parsedJson.audience,
2108
- installFor: parsedJson.installFor,
2109
- };
2524
+ if (parsedJson.studioVersion == 2) {
2525
+ return {
2526
+ idApp: serverApp.idApp,
2527
+ studioVersion: 2,
2528
+ status: _formatStatus(serverApp),
2529
+ manifest: parsedJson.manifest,
2530
+ fields: parsedJson.fields,
2531
+ views: parsedJson.views,
2532
+ audience: parsedJson.audience,
2533
+ installFor: parsedJson.installFor,
2534
+ };
2535
+ }
2536
+ else {
2537
+ return Object.assign(Object.assign({}, migrateJson(JSON.parse(serverApp.value))), { status: _formatStatus(serverApp) });
2538
+ }
2110
2539
  }
2111
2540
  function _formatStatus(serverApp) {
2112
2541
  return serverApp.status === jamespot.StudioApplicationStatus.installed
@@ -2138,10 +2567,493 @@ function serverAppsToStudioApps(serverApps) {
2138
2567
  return studioApps;
2139
2568
  }
2140
2569
 
2570
+ function appToXml(studioApp) {
2571
+ const { manifest, views, audience, installFor } = studioApp;
2572
+ return `<?xml version='1.0' encoding='utf-8'?>
2573
+ <Application>
2574
+ ${createAppManifest(manifest, views, audience, installFor)}
2575
+ <Types>
2576
+ <objecttype
2577
+ label="${manifest.typeLabel}"
2578
+ labelPlural="${manifest.typeLabel}"
2579
+ labelLinkSingular="${manifest.typeLabel}"
2580
+ labelLinkPlural="${manifest.typeLabel}"
2581
+ name="${manifest.appShortName}"
2582
+ classImpl="JPBEContent"
2583
+ classCodeLocation="jamespot/jpro/objs/JPBEContent.php"
2584
+ cssClass="${manifest.cssClass.value}"
2585
+ cssColor="${manifest.cssColor}"
2586
+ searchtab="${manifest.appShortName}"
2587
+ searchtablabel="${manifest.typeLabel}"
2588
+ buttonlabel="${manifest.typeLabel}"
2589
+ extends="article">
2590
+ ${renderPrimaryFields(studioApp.fields)}
2591
+ ${renderCustomFields(studioApp.fields)}
2592
+ </objecttype>
2593
+ ${renderDisplays(studioApp)}
2594
+ </Types>
2595
+ </Application>`;
2596
+ }
2597
+ function createAppManifest(manifest, views, audience, installFor) {
2598
+ var _a;
2599
+ return `<Manifest>
2600
+ <ShowImport>true</ShowImport>
2601
+ <AppShortName>${manifest.appShortName}</AppShortName>
2602
+ <AppName>${manifest.appName}</AppName>
2603
+ <Description>${manifest.description}</Description>
2604
+ <Version>${manifest.version}</Version>
2605
+ <ManifestVersion>1.0</ManifestVersion>
2606
+ <StudioVersion>2</StudioVersion>
2607
+ <DateCreation>${manifest.dateCreation.toString().split('T')[0]}</DateCreation>
2608
+ <CssClass>${(_a = manifest.cssClass) === null || _a === void 0 ? void 0 : _a.label}</CssClass>
2609
+ <CssColor>${manifest.cssColor}</CssColor>
2610
+ <Categories>N.A.</Categories>
2611
+ <Editor>Jamespot</Editor>
2612
+ <EditorUrl>https://www.fr.jamespot.com/</EditorUrl>
2613
+ <Type>${manifest.appShortName}</Type>
2614
+ ${renderAppView(manifest.viewSolr, views.list)}
2615
+ ${renderAppSearch(views.filter)}
2616
+ ${renderAudience(audience, installFor)}
2617
+ <Order>1</Order>
2618
+ </Manifest>`;
2619
+ }
2620
+ function renderAppView(viewSolr, listView) {
2621
+ if (viewSolr === 'solr') {
2622
+ let xml = '<AppView>solr</AppView>';
2623
+ const formItemIdInList = [];
2624
+ Object.entries(listView).forEach(([fieldId, field]) => {
2625
+ formItemIdInList.push(getAttrNameFormItem(field, fieldId));
2626
+ });
2627
+ xml += `<AppColumns>${formItemIdInList.join()}</AppColumns>`;
2628
+ return xml;
2629
+ }
2630
+ return '';
2631
+ }
2632
+ function renderAppSearch(searchView) {
2633
+ const formItemIdInFilter = [];
2634
+ Object.entries(searchView).forEach(([fieldId, field]) => {
2635
+ if (![exports.ExtraAppFieldsItemViews.TITLE, exports.AppFormItemTypes.IMAGE].includes(field.type))
2636
+ formItemIdInFilter.push(getAttrNameFormItem(field, fieldId));
2637
+ });
2638
+ return `<AttrExposed>${formItemIdInFilter.join()}</AttrExposed>`;
2639
+ }
2640
+ function getAttrNameFormItem(field, fieldId) {
2641
+ function fieldType() {
2642
+ if (field.type === exports.ExtraAppFieldsItemViews.USER)
2643
+ return 'idUser';
2644
+ if (field.type === exports.ExtraAppFieldsItemViews.CREATIONDATE)
2645
+ return 'dateCreation';
2646
+ return field.type;
2647
+ }
2648
+ return (AppColumnsDefaultTypes.includes(field.type) ? fieldType() : uuid2Alpha(fieldId)).toLowerCase();
2649
+ }
2650
+ function renderAudience(audience, installFor) {
2651
+ if (audience === AUDIENCE.ALL)
2652
+ return '<checkAccess>false</checkAccess>';
2653
+ else if (installFor.length > 0) {
2654
+ return `<checkAccess>true</checkAccess>
2655
+ <accessRightList>${installFor.map((user) => user.uri).join()}</accessRightList>`;
2656
+ }
2657
+ return '';
2658
+ }
2659
+ function renderPrimaryFields(fields) {
2660
+ const primaryFields = fields === null || fields === void 0 ? void 0 : fields.filter((field) => AppFormPrimaryList.includes(field.type));
2661
+ if (primaryFields.length === 0)
2662
+ return '';
2663
+ return `<primaryFields>${primaryFields.map((field) => formItem2xml(field)).join('')}</primaryFields>`;
2664
+ }
2665
+ function renderCustomFields(fields) {
2666
+ const customFields = fields === null || fields === void 0 ? void 0 : fields.filter((field) => !AppFormPrimaryList.includes(field.type));
2667
+ const filteredCustomFields = customFields === null || customFields === void 0 ? void 0 : customFields.filter((field) => field.type !== exports.AppFormItemTypes.IMAGE);
2668
+ if (filteredCustomFields.length === 0)
2669
+ return '';
2670
+ const articlesTablesItems = filteredCustomFields.filter((f) => f.type !== exports.AppFormItemTypes.TAGS);
2671
+ const linksTableItems = filteredCustomFields.filter((f) => f.type === exports.AppFormItemTypes.TAGS);
2672
+ return `<custom>
2673
+ ${articlesTablesItems.length > 0
2674
+ ? `<articlemstable>
2675
+ ${articlesTablesItems.map((field) => formItem2xml(field)).join('')}
2676
+ </articlemstable>`
2677
+ : ''}
2678
+ ${linksTableItems.length > 0
2679
+ ? `<linkstable>
2680
+ ${linksTableItems.map((field) => formItem2xml(field)).join('')}
2681
+ </linkstable>`
2682
+ : ''}</custom>`;
2683
+ }
2684
+ function formItem2xml(field) {
2685
+ return `<field
2686
+ type="${renderFieldTypeToXmlType(field.type)}"
2687
+ name="${getAttrNameFormItem(field, field.id)}"
2688
+ sqlname="${renderSqlName(field.type, field.id)}"
2689
+ ${field.properties && renderProperty(field.properties, exports.AppFieldFormPropertyTypes.LABEL)}
2690
+ ${field.properties && renderProperty(field.properties, exports.AppFieldFormPropertyTypes.DESCRIPTION)}
2691
+ mandatory="${field.mandatory}"
2692
+ solr.type="${renderSolrType(field.type)}"
2693
+ solr.used="true"
2694
+ solr.indexed="true"
2695
+ solr.stored="true"
2696
+ solr.searchable="true"
2697
+ solr.multiValued="${field.type === exports.AppFormItemTypes.TAGS || (field.type === exports.AppFormItemTypes.CHECKBOX && true) || false}"
2698
+ teaser="true"
2699
+ display="true"
2700
+ >
2701
+ ${renderWidget(field.type, field.properties)}
2702
+ </field>`;
2703
+ }
2704
+ function renderWidget(fieldType, fieldProperties) {
2705
+ var _a;
2706
+ switch (fieldType) {
2707
+ case exports.AppFormItemTypes.DESCRIPTION:
2708
+ return '<widget form="textarea"><params><param key="class" value="mceEditor"></param><param key="mention" value="1"></param></params></widget>';
2709
+ case exports.AppFormItemTypes.TEXT:
2710
+ return '<widget form="text"></widget>';
2711
+ case exports.AppFormItemTypes.TEXTAREA:
2712
+ return '<widget form="textarea"></widget>';
2713
+ case exports.AppFormItemTypes.TEXTAREAHTML:
2714
+ return '<widget form="textarea"><params><param key="class" value="mceEditor"></param></params></widget>';
2715
+ case exports.AppFormItemTypes.DATE:
2716
+ return '<widget form="date" format="d/m/Y"></widget>';
2717
+ case exports.AppFormItemTypes.DATETIME:
2718
+ return `<widget form="datetime" format="d/m/Y H:i:s"></widget>`;
2719
+ case exports.AppFormItemTypes.NUMBER: {
2720
+ const isFloat = ((_a = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.CHECKBOX)) === null || _a === void 0 ? void 0 : _a.value) === true;
2721
+ return `<widget form="number">
2722
+ ${isFloat ? `<params><param value="0.01" key="step"/></params>` : ''}
2723
+ </widget>`;
2724
+ }
2725
+ case exports.AppFormItemTypes.SELECT: {
2726
+ const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR);
2727
+ if (!optionEditor)
2728
+ return '';
2729
+ const isMultiple = optionEditor.value.canSelectMultiple;
2730
+ const options = optionEditor.value.propertyOptions;
2731
+ const hasDefaultValue = optionEditor.value.defaultSelectOption;
2732
+ const defaultValue = optionEditor.value.defaultSelectOptionValue;
2733
+ return `<widget form="select" ${isMultiple ? 'multiple="1"' : ''}>
2734
+ <options>
2735
+ ${options
2736
+ .map((option) => `<option value="${option.value}" label="${option.title}"></option>`)
2737
+ .join('')}
2738
+ </options>
2739
+ ${hasDefaultValue ? `<params><param key="defaultValue" value="${defaultValue}"/></params>` : ''}
2740
+ </widget>`;
2741
+ }
2742
+ case exports.AppFormItemTypes.RADIO: {
2743
+ const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.CHECKBOX);
2744
+ if (!optionEditor)
2745
+ return '';
2746
+ const options = optionEditor.value.propertyOptions;
2747
+ return `<widget form="radio">
2748
+ ${options
2749
+ .map((option) => `<option value="${option.value}" label="${option.title}"></option>`)
2750
+ .join('')}
2751
+ </widget>`;
2752
+ }
2753
+ case exports.AppFormItemTypes.TOGGLE:
2754
+ return `<widget form="checkbox">
2755
+ <options>
2756
+ <option value="1" label="GLOBAL_Yes"></option>
2757
+ </options>
2758
+ <params>
2759
+ <param key="jagCheckbox" value="1"></param>
2760
+ </params>
2761
+ </widget>`;
2762
+ case exports.AppFormItemTypes.TAGS: {
2763
+ const taxonomy = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.TAXONOMY);
2764
+ if (!taxonomy)
2765
+ return '';
2766
+ const taxonomyId = taxonomy.value.id;
2767
+ return `<widget form="taxonomy">
2768
+ <params><param key="idTaxonomy" value="${taxonomyId}"></param></params>
2769
+ </widget>`;
2770
+ }
2771
+ case exports.AppFormItemTypes.CHECKBOX: {
2772
+ const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.CHECKBOX);
2773
+ if (!optionEditor)
2774
+ return '';
2775
+ const options = optionEditor.value.propertyOptions;
2776
+ return `<widget form="checkbox" multiple="1">
2777
+ <options>
2778
+ ${options
2779
+ .map((option) => `<option value="${option.value}" label="${option.label}"></option>`)
2780
+ .join('')}
2781
+ </options>
2782
+ </widget>`;
2783
+ }
2784
+ case exports.AppFormItemTypes.ADDFILEATTACHMENT:
2785
+ return `<widget form="file" type="fileArticle" multiple="1"></widget>`;
2786
+ case exports.AppFormItemTypes.URL:
2787
+ return `<widget form="url"`;
2788
+ case exports.AppFormItemTypes.EMAIL:
2789
+ return `<widget form="email"></widget>`;
2790
+ case exports.ExtraAppFieldsItemViews.USER:
2791
+ return `<widget form="idUser"></widget>`;
2792
+ case exports.AppFormItemTypes.USERLINK:
2793
+ return `<widget form="uri">
2794
+ <params>
2795
+ <param key="mode" value="ng-view"></param>
2796
+ <param key="class" value="jcomplete"></param>
2797
+ <param key="namespace" value="jamespot"></param>
2798
+ <param key="types" value="user"></param>
2799
+ <param key="views" value="user"></param>
2800
+ <param key="jcomplete-url" value="/?action=ajax&amp;group=autocomplete&amp;export function=user"></param>
2801
+ </params>
2802
+ </widget>`;
2803
+ case exports.AppFormItemTypes.CONTENTLINK: {
2804
+ const contentType = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.CONTENTTYPE);
2805
+ if (!contentType)
2806
+ return '';
2807
+ const type = contentType.value.type;
2808
+ return `<widget form="uri">
2809
+ <params>
2810
+ <param key="mode" value="ng-view"></param>
2811
+ <param key="namespace" value="jamespot"></param>
2812
+ <param key="types" value="${type}"></param>
2813
+ <param key="views" value="article"></param>
2814
+ <param key="jcomplete-url" value="/?action=ajax&amp;group=autocomplete&amp;export function=article&amp;types=[]=${type}"></param>
2815
+ </params>
2816
+ </widget>`;
2817
+ }
2818
+ default:
2819
+ return '';
2820
+ }
2821
+ }
2822
+ function renderProperty(properties, propertyToFind) {
2823
+ const labelProperty = properties === null || properties === void 0 ? void 0 : properties.find((property) => property.propertyType === propertyToFind);
2824
+ if (labelProperty) {
2825
+ return `${propertyToFind.toLowerCase()}="${labelProperty.value}"`;
2826
+ }
2827
+ return '';
2828
+ }
2829
+ function renderSqlName(fieldType, fieldId) {
2830
+ switch (fieldType) {
2831
+ case exports.AppFormItemTypes.DESCRIPTION:
2832
+ return 'Description';
2833
+ case exports.ExtraAppFieldsItemViews.USER:
2834
+ return 'IdUser';
2835
+ default:
2836
+ return uuid2Alpha(fieldId);
2837
+ }
2838
+ }
2839
+ function renderSolrType(fieldType) {
2840
+ switch (fieldType) {
2841
+ case exports.AppFormItemTypes.DESCRIPTION:
2842
+ case exports.AppFormItemTypes.TEXT:
2843
+ case exports.AppFormItemTypes.TEXTAREA:
2844
+ case exports.AppFormItemTypes.TEXTAREAHTML:
2845
+ case exports.AppFormItemTypes.URL:
2846
+ case exports.AppFormItemTypes.EMAIL:
2847
+ case exports.AppFormItemTypes.USERLINK:
2848
+ case exports.AppFormItemTypes.CONTENTLINK:
2849
+ case exports.AppFormItemTypes.NUMBER:
2850
+ case exports.AppFormItemTypes.ADDFILEATTACHMENT:
2851
+ return 'text';
2852
+ case exports.AppFormItemTypes.DATE:
2853
+ case exports.AppFormItemTypes.DATETIME:
2854
+ return 'date';
2855
+ case exports.ExtraAppFieldsItemViews.USER:
2856
+ return 'integer';
2857
+ case exports.AppFormItemTypes.SELECT:
2858
+ case exports.AppFormItemTypes.RADIO:
2859
+ case exports.AppFormItemTypes.TOGGLE:
2860
+ case exports.AppFormItemTypes.CHECKBOX:
2861
+ case exports.AppFormItemTypes.TAGS:
2862
+ return 'string';
2863
+ default:
2864
+ return '';
2865
+ }
2866
+ }
2867
+ function renderFieldTypeToXmlType(fieldType) {
2868
+ switch (fieldType) {
2869
+ default:
2870
+ case exports.AppFormItemTypes.DESCRIPTION:
2871
+ case exports.AppFormItemTypes.TEXTAREAHTML:
2872
+ return 'html';
2873
+ case exports.AppFormItemTypes.TAGS:
2874
+ return 'taxonomy';
2875
+ case exports.AppFormItemTypes.TEXT:
2876
+ case exports.AppFormItemTypes.SELECT:
2877
+ case exports.AppFormItemTypes.RADIO:
2878
+ case exports.AppFormItemTypes.CHECKBOX:
2879
+ case exports.AppFormItemTypes.URL:
2880
+ case exports.AppFormItemTypes.EMAIL:
2881
+ case exports.AppFormItemTypes.ADDFILEATTACHMENT:
2882
+ case exports.ExtraAppFieldsItemViews.USER:
2883
+ case exports.AppFormItemTypes.USERLINK:
2884
+ case exports.AppFormItemTypes.CONTENTLINK:
2885
+ return 'text';
2886
+ case exports.AppFormItemTypes.TEXTAREA:
2887
+ return 'longtext';
2888
+ case exports.AppFormItemTypes.DATE:
2889
+ return 'date';
2890
+ case exports.AppFormItemTypes.DATETIME: {
2891
+ return 'date';
2892
+ }
2893
+ case exports.AppFormItemTypes.NUMBER:
2894
+ return 'float';
2895
+ }
2896
+ }
2897
+ const uuid2Alpha = (id) => {
2898
+ let alphaUuid = '';
2899
+ for (let i = 0; i < id.length; i++) {
2900
+ const c = id.charAt(i);
2901
+ if (c >= '0' && c <= '9')
2902
+ alphaUuid += numToAlpha(Number(c));
2903
+ else if (c >= 'a' && c <= 'z')
2904
+ alphaUuid += c;
2905
+ }
2906
+ return alphaUuid;
2907
+ };
2908
+ const numToAlpha = (num) => {
2909
+ let s = '', t;
2910
+ while (num > 0) {
2911
+ t = (num - 1) % 26;
2912
+ s = String.fromCharCode(97 + t) + s;
2913
+ num = ((num - t) / 26) | 0;
2914
+ }
2915
+ return s;
2916
+ };
2917
+ const internal2XmlView = {
2918
+ create: 'create',
2919
+ popup: 'create-popup',
2920
+ edit: 'edit',
2921
+ view: 'display',
2922
+ };
2923
+ function renderDisplays(studioApp) {
2924
+ let toRet = '';
2925
+ Object.entries(studioApp.views).forEach(([viewName, viewContent]) => {
2926
+ if (Object.prototype.hasOwnProperty.call(internal2XmlView, viewName)) {
2927
+ const viewField = Object.entries(viewContent);
2928
+ toRet += `<display view="${internal2XmlView[viewName]}" mode="${viewName === 'view' ? 'view' : 'form'}">
2929
+ ${viewField.map(([fieldId, view]) => renderDisplayAttr(fieldId, view)).join('')}
2930
+ </display>`;
2931
+ }
2932
+ });
2933
+ if (toRet.length > 0) {
2934
+ toRet = `<displays type="${studioApp.manifest.appShortName}">${toRet}</displays>`;
2935
+ }
2936
+ return toRet;
2937
+ }
2938
+ function getDisplayName(fieldId, view) {
2939
+ switch (view.type) {
2940
+ case exports.ExtraAppFieldsItemViews.TITLE:
2941
+ return 'title';
2942
+ case exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS:
2943
+ return 'sendAlert';
2944
+ case exports.ExtraAppFieldsItemViews.RECEIVEACOPY:
2945
+ return 'alertAuthor';
2946
+ case exports.ExtraAppFieldsItemViews.PUBLISHTO:
2947
+ return 'publishTo';
2948
+ case exports.ExtraAppFieldsItemViews.USER:
2949
+ return 'idUser';
2950
+ case exports.ExtraAppFieldsItemViews.CREATIONDATE:
2951
+ return 'dateCreation';
2952
+ default:
2953
+ return uuid2Alpha(fieldId);
2954
+ }
2955
+ }
2956
+ function renderDisplayAttr(fieldId, view) {
2957
+ var _a, _b, _c;
2958
+ let xml = '';
2959
+ const attrName = getDisplayName(fieldId, view);
2960
+ const isFixed = view.isLockedValue;
2961
+ if (isFixed) {
2962
+ const formItemRefWithName = {
2963
+ ref: attrName,
2964
+ fixedValue: view.value,
2965
+ };
2966
+ xml += `<html><![CDATA[ <!-- <JAMESPOT.STUDIO.FIXED>${JSON.stringify(formItemRefWithName)}</JAMESPOT.STUDIO.FIXED> -->`;
2967
+ if (view.type === exports.ExtraAppFieldsItemViews.PUBLISHTO) {
2968
+ const uris = view.value.map((user) => user.uri).join(',');
2969
+ xml += `<input type="hidden" name="publishTo" value="${uris}">`;
2970
+ }
2971
+ else if (view.type === exports.ExtraAppFieldsItemViews.USER ||
2972
+ view.type === exports.AppFormItemTypes.USERLINK ||
2973
+ view.type === exports.AppFormItemTypes.CONTENTLINK) {
2974
+ xml += `<input type="hidden" name="${attrName}[]" value=${JSON.stringify(view.value.uri)}>`;
2975
+ }
2976
+ else if (view.type === exports.AppFormItemTypes.SELECT) {
2977
+ const values = view.value;
2978
+ const canSelectMultiple = (_a = view.properties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR)) === null || _a === void 0 ? void 0 : _a.value.canSelectMultiple;
2979
+ values.forEach((value) => {
2980
+ xml += `<input type="hidden" name="${attrName}${canSelectMultiple ? '[]' : ''}" value="${value.value}">`;
2981
+ });
2982
+ }
2983
+ else if (view.type === exports.AppFormItemTypes.CHECKBOX) {
2984
+ const values = view.value;
2985
+ values.forEach((value) => {
2986
+ xml += `<input type="hidden" name="${attrName}[]" value="${value.value}">`;
2987
+ });
2988
+ }
2989
+ else if (view.type === exports.AppFormItemTypes.DATE) {
2990
+ const dateValue = new Date(view.value);
2991
+ const xmlFixedValue = [
2992
+ pad(dateValue.getDate()),
2993
+ pad(dateValue.getMonth() + 1),
2994
+ dateValue.getFullYear(),
2995
+ ].join('/');
2996
+ xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
2997
+ }
2998
+ else if (view.type === exports.AppFormItemTypes.DATETIME) {
2999
+ const dateValue = new Date(view.value);
3000
+ const xmlFixedValue = [
3001
+ pad(dateValue.getDate()),
3002
+ pad(dateValue.getMonth() + 1),
3003
+ dateValue.getFullYear(),
3004
+ pad(dateValue.getHours()),
3005
+ pad(dateValue.getMinutes()),
3006
+ pad(dateValue.getSeconds()),
3007
+ ].join('/');
3008
+ xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
3009
+ }
3010
+ else if (view.type === exports.AppFormItemTypes.TAGS) {
3011
+ xml += `<input type="hidden" name="${attrName}" value="${(_c = (_b = view.value) === null || _b === void 0 ? void 0 : _b.map((v) => v.uri)) === null || _c === void 0 ? void 0 : _c.join(',')}">`;
3012
+ }
3013
+ else if (view.type === exports.AppFormItemTypes.DESCRIPTION || view.type === exports.AppFormItemTypes.TEXTAREAHTML) {
3014
+ xml += `<input type="hidden" name="${attrName}" value="${view.value.html}">`;
3015
+ }
3016
+ else {
3017
+ xml += `<input type="hidden" name="${attrName}" value="${view.value}">`;
3018
+ }
3019
+ xml += ']]></html>';
3020
+ }
3021
+ else {
3022
+ switch (view.type) {
3023
+ case exports.AppFormItemTypes.CODEHTML: {
3024
+ const content = {
3025
+ ref: attrName,
3026
+ fixedValue: {
3027
+ html: view.value.html,
3028
+ text: view.value.text,
3029
+ },
3030
+ };
3031
+ xml += `<html><![CDATA[ <!-- <JAMESPOT.STUDIO.CODEHTML>${JSON.stringify(content)}</JAMESPOT.STUDIO.CODEHTML><JAMESPOT.STUDIO.FIELD_POS></JAMESPOT.STUDIO.FIELD_POS>-->]]></html>`;
3032
+ break;
3033
+ }
3034
+ case exports.AppFormItemTypes.IMAGE:
3035
+ xml += '<image />';
3036
+ break;
3037
+ case exports.ExtraAppFieldsItemViews.PUBLISHTO:
3038
+ xml += '<publishTo />';
3039
+ break;
3040
+ default:
3041
+ xml += "<attr name='" + attrName + "' />";
3042
+ break;
3043
+ }
3044
+ }
3045
+ return xml;
3046
+ }
3047
+ function pad(s) {
3048
+ return s < 10 ? '0' + s : s;
3049
+ }
3050
+
2141
3051
  const initialState$1 = {
2142
3052
  currentStudioApp: null,
2143
3053
  fetchCurrentStudioAppStatus: 'idle',
2144
3054
  saveCurrentStudioAppStatus: 'idle',
3055
+ installStudioAppStatus: 'idle',
3056
+ hasChanged: false,
2145
3057
  };
2146
3058
  const fetchCurrentStudioApp = toolkit.createAsyncThunk('studio/fetchCurrentStudioApp', ({ idApp, status }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
2147
3059
  const jApi = extra.jApi;
@@ -2176,6 +3088,24 @@ const saveCurrentStudioApp = toolkit.createAsyncThunk('studio/saveCurrentStudioA
2176
3088
  return rejectWithValue(error);
2177
3089
  }
2178
3090
  }));
3091
+ const installStudioApp = toolkit.createAsyncThunk('studio/installApp', (_, { extra, rejectWithValue, getState, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
3092
+ const jApi = extra.jApi;
3093
+ const error = { error: 1, errorMsg: 'Error saving application' };
3094
+ const currentStudioApp = getState().studio.currentStudioApp.currentStudioApp;
3095
+ if (!currentStudioApp) {
3096
+ return rejectWithValue(error);
3097
+ }
3098
+ const xml = appToXml(currentStudioApp);
3099
+ try {
3100
+ yield jApi.application.install(xml);
3101
+ dispatch(Toast.actions.success({ label: 'APPSTUDIO_AppItem_Edition_Saved' }));
3102
+ return;
3103
+ }
3104
+ catch (_) {
3105
+ dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
3106
+ return rejectWithValue(error);
3107
+ }
3108
+ }));
2179
3109
  const CurrentStudioAppSlice = toolkit.createSlice({
2180
3110
  name: 'currentStudioApp',
2181
3111
  initialState: initialState$1,
@@ -2186,6 +3116,9 @@ const CurrentStudioAppSlice = toolkit.createSlice({
2186
3116
  resetCurrentApp: (state) => {
2187
3117
  state.currentStudioApp = null;
2188
3118
  },
3119
+ setHasChanged: (state, action) => {
3120
+ state.hasChanged = action.payload;
3121
+ },
2189
3122
  },
2190
3123
  extraReducers: (builder) => {
2191
3124
  builder
@@ -2213,6 +3146,18 @@ const CurrentStudioAppSlice = toolkit.createSlice({
2213
3146
  .addCase(saveCurrentStudioApp.rejected, (state) => {
2214
3147
  if (state.saveCurrentStudioAppStatus === 'pending')
2215
3148
  state.saveCurrentStudioAppStatus = 'idle';
3149
+ })
3150
+ .addCase(installStudioApp.pending, (state) => {
3151
+ if (state.installStudioAppStatus === 'idle')
3152
+ state.installStudioAppStatus = 'pending';
3153
+ })
3154
+ .addCase(installStudioApp.fulfilled, (state) => {
3155
+ if (state.installStudioAppStatus === 'pending')
3156
+ state.installStudioAppStatus = 'idle';
3157
+ })
3158
+ .addCase(installStudioApp.rejected, (state) => {
3159
+ if (state.installStudioAppStatus === 'pending')
3160
+ state.installStudioAppStatus = 'idle';
2216
3161
  });
2217
3162
  },
2218
3163
  });
@@ -2268,6 +3213,7 @@ function createNewStudioApp$1({ author, appName }) {
2268
3213
  idApp: newAppId,
2269
3214
  status: APP_STATUS_TYPE.DRAFT,
2270
3215
  author: author || '',
3216
+ studioVersion: 2,
2271
3217
  manifest: {
2272
3218
  appShortName: appName,
2273
3219
  appName: appName,
@@ -2532,7 +3478,8 @@ const studio = {
2532
3478
  cloneStudioApp,
2533
3479
  createNewStudioApp,
2534
3480
  fetchCurrentStudioApp,
2535
- saveCurrentStudioApp }),
3481
+ saveCurrentStudioApp,
3482
+ installStudioApp }),
2536
3483
  selectors: {
2537
3484
  selectStudioAppsList,
2538
3485
  selectCurrentStudioApp,
@@ -2541,7 +3488,10 @@ const studio = {
2541
3488
 
2542
3489
  exports.APP_STATUS_TYPE = APP_STATUS_TYPE;
2543
3490
  exports.AUDIENCE = AUDIENCE;
2544
- exports.AppFormBannedFromViews = AppFormBannedFromViews;
3491
+ exports.Animations = Animations;
3492
+ exports.AppColumnsDefaultTypes = AppColumnsDefaultTypes;
3493
+ exports.AppFormBannedFromViews = AppFormBannedFromViews$1;
3494
+ exports.AppFormPrimaryList = AppFormPrimaryList;
2545
3495
  exports.AppFormUniqueList = AppFormUniqueList;
2546
3496
  exports.Application = Application;
2547
3497
  exports.AssetReservation = AssetReservation;
@@ -2564,9 +3514,16 @@ exports.WedocApp = WedocApp;
2564
3514
  exports.Widget = Widget;
2565
3515
  exports.WidgetEditor = WidgetEditor;
2566
3516
  exports.actions = actions;
3517
+ exports.animationsReducer = animationsReducer;
3518
+ exports.animationsSlice = animationsSlice;
3519
+ exports.deleteCurrentAnimation = deleteCurrentAnimation;
3520
+ exports.fetchCurrentAnimation = fetchCurrentAnimation;
3521
+ exports.fetchCurrentAnimationApp = fetchCurrentAnimationApp;
2567
3522
  exports.jland = jland;
3523
+ exports.saveCurrentAnimation = saveCurrentAnimation;
2568
3524
  exports.slice = slice;
2569
3525
  exports.studio = studio;
3526
+ exports.toggleAnimationIsActive = toggleAnimationIsActive;
2570
3527
  exports.updateWidgetContent = updateWidgetContent;
2571
3528
  exports.viewsList = viewsList;
2572
3529
  //# sourceMappingURL=cjs.js.map