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