jamespot-front-business 1.1.37 → 1.1.39
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 +810 -13
- package/dist/cjs.js.map +1 -1
- package/dist/esm.js +816 -21
- package/dist/esm.js.map +1 -1
- package/dist/types.d.ts +22 -2
- package/package.json +2 -2
package/dist/cjs.js
CHANGED
|
@@ -2016,6 +2016,7 @@ exports.AppFormItemTypes = void 0;
|
|
|
2016
2016
|
AppFormItemTypes["CODEHTML"] = "CODEHTML";
|
|
2017
2017
|
AppFormItemTypes["USERLINK"] = "USERLINK";
|
|
2018
2018
|
AppFormItemTypes["CONTENTLINK"] = "CONTENTLINK";
|
|
2019
|
+
AppFormItemTypes["RANGE"] = "RANGE";
|
|
2019
2020
|
})(exports.AppFormItemTypes || (exports.AppFormItemTypes = {}));
|
|
2020
2021
|
exports.ExtraAppFieldsItemViews = void 0;
|
|
2021
2022
|
(function (ExtraAppFieldsItemViews) {
|
|
@@ -2037,8 +2038,8 @@ exports.AppFieldFormPropertyTypes = void 0;
|
|
|
2037
2038
|
AppFieldFormPropertyTypes["CONTENTTYPE"] = "contenttype";
|
|
2038
2039
|
})(exports.AppFieldFormPropertyTypes || (exports.AppFieldFormPropertyTypes = {}));
|
|
2039
2040
|
const AppFormUniqueList = [exports.AppFormItemTypes.DESCRIPTION, exports.AppFormItemTypes.IMAGE];
|
|
2040
|
-
const AppFormBannedFromViews = new Map();
|
|
2041
|
-
AppFormBannedFromViews.set(exports.AppFormItemTypes.IMAGE, ['list', 'filter', 'view']);
|
|
2041
|
+
const AppFormBannedFromViews$1 = new Map();
|
|
2042
|
+
AppFormBannedFromViews$1.set(exports.AppFormItemTypes.IMAGE, ['list', 'filter', 'view']);
|
|
2042
2043
|
const MapExtraFieldsWithView = {
|
|
2043
2044
|
create: {
|
|
2044
2045
|
fixed: [exports.ExtraAppFieldsItemViews.TITLE],
|
|
@@ -2069,6 +2070,275 @@ const MapExtraFieldsWithView = {
|
|
|
2069
2070
|
optional: [],
|
|
2070
2071
|
},
|
|
2071
2072
|
};
|
|
2073
|
+
const AppColumnsDefaultTypes = [
|
|
2074
|
+
exports.ExtraAppFieldsItemViews.TITLE,
|
|
2075
|
+
exports.ExtraAppFieldsItemViews.USER,
|
|
2076
|
+
exports.ExtraAppFieldsItemViews.CREATIONDATE,
|
|
2077
|
+
exports.AppFormItemTypes.DESCRIPTION,
|
|
2078
|
+
];
|
|
2079
|
+
const AppFormPrimaryList = [exports.AppFormItemTypes.DESCRIPTION];
|
|
2080
|
+
|
|
2081
|
+
var StatusType;
|
|
2082
|
+
(function (StatusType) {
|
|
2083
|
+
StatusType["draft"] = "draft";
|
|
2084
|
+
StatusType["installed"] = "installed";
|
|
2085
|
+
StatusType["suspended"] = "suspended";
|
|
2086
|
+
})(StatusType || (StatusType = {}));
|
|
2087
|
+
({
|
|
2088
|
+
DRAFT: StatusType.draft,
|
|
2089
|
+
INSTALLED: StatusType.installed,
|
|
2090
|
+
SUSPENDED: StatusType.suspended,
|
|
2091
|
+
});
|
|
2092
|
+
var AppFormItemType;
|
|
2093
|
+
(function (AppFormItemType) {
|
|
2094
|
+
AppFormItemType["TITLE"] = "TITLE";
|
|
2095
|
+
AppFormItemType["IMAGE"] = "IMAGE";
|
|
2096
|
+
AppFormItemType["DESCRIPTION"] = "DESCRIPTION";
|
|
2097
|
+
AppFormItemType["IDUSER"] = "IDUSER";
|
|
2098
|
+
AppFormItemType["PUBLISHTO"] = "PUBLISHTO";
|
|
2099
|
+
AppFormItemType["SENDALERTTOSUBSCRIBERS"] = "SENDALERTTOSUBSCRIBERS";
|
|
2100
|
+
AppFormItemType["RECEIVEACOPY"] = "RECEIVEACOPY";
|
|
2101
|
+
AppFormItemType["TEXT"] = "TEXT";
|
|
2102
|
+
AppFormItemType["TEXTAREA"] = "TEXTAREA";
|
|
2103
|
+
AppFormItemType["TEXTAREAHTML"] = "TEXTAREAHTML";
|
|
2104
|
+
AppFormItemType["DATE"] = "DATE";
|
|
2105
|
+
AppFormItemType["DATETIME"] = "DATETIME";
|
|
2106
|
+
AppFormItemType["RANGE"] = "RANGE";
|
|
2107
|
+
AppFormItemType["NUMBER"] = "NUMBER";
|
|
2108
|
+
AppFormItemType["URL"] = "URL";
|
|
2109
|
+
AppFormItemType["EMAIL"] = "EMAIL";
|
|
2110
|
+
AppFormItemType["SELECT"] = "SELECT";
|
|
2111
|
+
AppFormItemType["CHECKBOX"] = "CHECKBOX";
|
|
2112
|
+
AppFormItemType["TOGGLE"] = "TOGGLE";
|
|
2113
|
+
AppFormItemType["RADIO"] = "RADIO";
|
|
2114
|
+
AppFormItemType["TAGS"] = "TAGS";
|
|
2115
|
+
AppFormItemType["ADDFILEATTACHMENT"] = "ADDFILEATTACHMENT";
|
|
2116
|
+
AppFormItemType["AUDIENCE"] = "AUDIENCE";
|
|
2117
|
+
AppFormItemType["CODEHTML"] = "CODEHTML";
|
|
2118
|
+
AppFormItemType["DATECREATION"] = "DATECREATION";
|
|
2119
|
+
AppFormItemType["USERLINK"] = "USERLINK";
|
|
2120
|
+
AppFormItemType["CONTENTLINK"] = "CONTENTLINK";
|
|
2121
|
+
})(AppFormItemType || (AppFormItemType = {}));
|
|
2122
|
+
[AppFormItemType.DESCRIPTION];
|
|
2123
|
+
const AppFormNotFields = [AppFormItemType.AUDIENCE, AppFormItemType.RANGE];
|
|
2124
|
+
({
|
|
2125
|
+
create: [AppFormItemType.TITLE],
|
|
2126
|
+
popup: [AppFormItemType.TITLE],
|
|
2127
|
+
edit: [AppFormItemType.TITLE],
|
|
2128
|
+
list: [AppFormItemType.TITLE, AppFormItemType.IDUSER],
|
|
2129
|
+
filter: [AppFormItemType.TITLE, AppFormItemType.IDUSER],
|
|
2130
|
+
view: [AppFormItemType.TITLE],
|
|
2131
|
+
});
|
|
2132
|
+
({
|
|
2133
|
+
create: [AppFormItemType.PUBLISHTO, AppFormItemType.SENDALERTTOSUBSCRIBERS, AppFormItemType.RECEIVEACOPY],
|
|
2134
|
+
popup: [AppFormItemType.PUBLISHTO],
|
|
2135
|
+
edit: [AppFormItemType.PUBLISHTO],
|
|
2136
|
+
list: [AppFormItemType.DATECREATION],
|
|
2137
|
+
filter: [AppFormItemType.DATECREATION],
|
|
2138
|
+
view: [],
|
|
2139
|
+
});
|
|
2140
|
+
const AppFormFixedList = [
|
|
2141
|
+
AppFormItemType.TITLE,
|
|
2142
|
+
AppFormItemType.PUBLISHTO,
|
|
2143
|
+
AppFormItemType.SENDALERTTOSUBSCRIBERS,
|
|
2144
|
+
AppFormItemType.RECEIVEACOPY,
|
|
2145
|
+
AppFormItemType.IDUSER,
|
|
2146
|
+
AppFormItemType.DATECREATION,
|
|
2147
|
+
];
|
|
2148
|
+
[AppFormItemType.DESCRIPTION, AppFormItemType.IMAGE];
|
|
2149
|
+
const AppFormBannedFromViews = new Map();
|
|
2150
|
+
AppFormBannedFromViews.set(AppFormItemType.IMAGE, ['list', 'filter', 'view']);
|
|
2151
|
+
const AppListFilter = [
|
|
2152
|
+
AppFormItemType.TITLE,
|
|
2153
|
+
AppFormItemType.DESCRIPTION,
|
|
2154
|
+
AppFormItemType.TEXT,
|
|
2155
|
+
AppFormItemType.TEXTAREA,
|
|
2156
|
+
AppFormItemType.TEXTAREAHTML,
|
|
2157
|
+
AppFormItemType.DATE,
|
|
2158
|
+
AppFormItemType.DATETIME,
|
|
2159
|
+
AppFormItemType.RANGE,
|
|
2160
|
+
AppFormItemType.NUMBER,
|
|
2161
|
+
AppFormItemType.URL,
|
|
2162
|
+
AppFormItemType.EMAIL,
|
|
2163
|
+
AppFormItemType.SELECT,
|
|
2164
|
+
AppFormItemType.TOGGLE,
|
|
2165
|
+
AppFormItemType.CHECKBOX,
|
|
2166
|
+
AppFormItemType.RADIO,
|
|
2167
|
+
AppFormItemType.TAGS,
|
|
2168
|
+
AppFormItemType.PUBLISHTO,
|
|
2169
|
+
AppFormItemType.SENDALERTTOSUBSCRIBERS,
|
|
2170
|
+
AppFormItemType.RECEIVEACOPY,
|
|
2171
|
+
AppFormItemType.ADDFILEATTACHMENT,
|
|
2172
|
+
AppFormItemType.CODEHTML,
|
|
2173
|
+
AppFormItemType.IDUSER,
|
|
2174
|
+
AppFormItemType.DATECREATION,
|
|
2175
|
+
AppFormItemType.USERLINK,
|
|
2176
|
+
AppFormItemType.CONTENTLINK,
|
|
2177
|
+
];
|
|
2178
|
+
({
|
|
2179
|
+
create: [AppFormItemType.IMAGE, AppFormItemType.ADDFILEATTACHMENT, AppFormItemType.CODEHTML],
|
|
2180
|
+
popup: [AppFormItemType.IMAGE, AppFormItemType.ADDFILEATTACHMENT, AppFormItemType.CODEHTML],
|
|
2181
|
+
edit: [AppFormItemType.IMAGE, AppFormItemType.ADDFILEATTACHMENT, AppFormItemType.CODEHTML],
|
|
2182
|
+
list: AppListFilter,
|
|
2183
|
+
filter: AppListFilter,
|
|
2184
|
+
view: AppListFilter,
|
|
2185
|
+
});
|
|
2186
|
+
AppFormFixedList.concat(AppFormNotFields)
|
|
2187
|
+
.concat(AppFormItemType.IDUSER)
|
|
2188
|
+
.concat(AppFormItemType.TITLE);
|
|
2189
|
+
[AppFormItemType.CODEHTML];
|
|
2190
|
+
|
|
2191
|
+
function migrateJson(v1Json) {
|
|
2192
|
+
const v1 = v1Json;
|
|
2193
|
+
const v1Manifest = v1.manifest;
|
|
2194
|
+
const newFields = _renderFields();
|
|
2195
|
+
const v2 = {
|
|
2196
|
+
idApp: v1.idApp,
|
|
2197
|
+
status: v1.status,
|
|
2198
|
+
studioVersion: 2,
|
|
2199
|
+
author: v1.author || '',
|
|
2200
|
+
manifest: {
|
|
2201
|
+
appShortName: v1Manifest.appShortName,
|
|
2202
|
+
appName: v1Manifest.appName,
|
|
2203
|
+
description: v1Manifest.description,
|
|
2204
|
+
author: v1Manifest.author || '',
|
|
2205
|
+
typeLabel: v1Manifest.typeLabel,
|
|
2206
|
+
cssColor: v1Manifest.cssColor,
|
|
2207
|
+
cssClass: v1Manifest.cssClass,
|
|
2208
|
+
version: v1Manifest.version,
|
|
2209
|
+
dateCreation: new Date(v1Manifest.dateCreation).toISOString(),
|
|
2210
|
+
viewSolr: v1Manifest.viewSolr,
|
|
2211
|
+
checkAccess: v1Manifest.checkAccess,
|
|
2212
|
+
accessRightList: v1Manifest.accessRightList || '',
|
|
2213
|
+
attrExposed: v1Manifest.attrExposed,
|
|
2214
|
+
},
|
|
2215
|
+
fields: newFields,
|
|
2216
|
+
views: _renderViews(),
|
|
2217
|
+
audience: v1.audience || '1',
|
|
2218
|
+
installFor: v1.installFor || [],
|
|
2219
|
+
};
|
|
2220
|
+
function _renderFields() {
|
|
2221
|
+
var _a;
|
|
2222
|
+
const v2Fields = [];
|
|
2223
|
+
for (const v1FormItem of v1.form.formItems) {
|
|
2224
|
+
const type = _matctTypes(v1FormItem.type);
|
|
2225
|
+
v2Fields.push({
|
|
2226
|
+
id: v1FormItem.id,
|
|
2227
|
+
type,
|
|
2228
|
+
properties: _renderProperties((_a = v1FormItem.properties) !== null && _a !== void 0 ? _a : {}),
|
|
2229
|
+
mandatory: v1FormItem.mandatory || false,
|
|
2230
|
+
views: v1FormItem.views,
|
|
2231
|
+
isActive: true,
|
|
2232
|
+
isFixed: false,
|
|
2233
|
+
isOptional: false,
|
|
2234
|
+
value: null,
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
return v2Fields;
|
|
2238
|
+
}
|
|
2239
|
+
function _matctTypes(v1Type) {
|
|
2240
|
+
return exports.AppFormItemTypes[v1Type];
|
|
2241
|
+
}
|
|
2242
|
+
function _renderProperties(v1FormItemProperties) {
|
|
2243
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2244
|
+
const v2Properties = [];
|
|
2245
|
+
const isEnhancedOptionEditor = v1FormItemProperties.options &&
|
|
2246
|
+
Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'hasDefaultValue');
|
|
2247
|
+
const baseProperty = Object.assign({ isRequired: v1FormItemProperties.mandatory || false }, (isEnhancedOptionEditor && { isOptionsEditorEnhanced: true }));
|
|
2248
|
+
if (v1FormItemProperties.labels) {
|
|
2249
|
+
v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.LABEL, value: ((_a = v1FormItemProperties.labels.label) === null || _a === void 0 ? void 0 : _a.content) || '' }, baseProperty));
|
|
2250
|
+
v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.DESCRIPTION, value: ((_b = v1FormItemProperties.labels.description) === null || _b === void 0 ? void 0 : _b.content) || '' }, baseProperty));
|
|
2251
|
+
}
|
|
2252
|
+
if (v1FormItemProperties.options) {
|
|
2253
|
+
v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR, value: isEnhancedOptionEditor
|
|
2254
|
+
? {
|
|
2255
|
+
propertyOptions: _renderSelectOptions((_c = v1FormItemProperties.options) !== null && _c !== void 0 ? _c : []),
|
|
2256
|
+
defaultSelectOptionValue: v1FormItemProperties.defaultValue,
|
|
2257
|
+
defaultSelectOption: (_d = v1FormItemProperties.hasDefaultValue) !== null && _d !== void 0 ? _d : false,
|
|
2258
|
+
canSelectMultiple: (_e = v1FormItemProperties.multiple) !== null && _e !== void 0 ? _e : false,
|
|
2259
|
+
userCanModifiyByComment: (_f = v1FormItemProperties.explain) !== null && _f !== void 0 ? _f : false,
|
|
2260
|
+
}
|
|
2261
|
+
: { propertyOptions: _renderSelectOptions((_g = v1FormItemProperties.options) !== null && _g !== void 0 ? _g : []) } }, baseProperty));
|
|
2262
|
+
}
|
|
2263
|
+
if (v1FormItemProperties.code) {
|
|
2264
|
+
v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.RICHTEXT, value: v1FormItemProperties.code.html || v1FormItemProperties.code.text || '' }, baseProperty));
|
|
2265
|
+
}
|
|
2266
|
+
if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'digits')) {
|
|
2267
|
+
v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.CHECKBOX, value: v1FormItemProperties.digits || false, checkBoxOptions: [{ label: 'APPSTUDIO_FormEditProps_Digits', value: v1FormItemProperties.digits }] }, baseProperty));
|
|
2268
|
+
}
|
|
2269
|
+
if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'taxonomy')) {
|
|
2270
|
+
v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.TAXONOMY, value: v1FormItemProperties.taxonomy || '' }, baseProperty));
|
|
2271
|
+
}
|
|
2272
|
+
if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'contentType')) {
|
|
2273
|
+
v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.CONTENTTYPE, value: v1FormItemProperties.contentType || '' }, baseProperty));
|
|
2274
|
+
}
|
|
2275
|
+
return v2Properties;
|
|
2276
|
+
}
|
|
2277
|
+
function _renderSelectOptions(v1Options) {
|
|
2278
|
+
const v2Options = [];
|
|
2279
|
+
for (const option of v1Options) {
|
|
2280
|
+
v2Options.push({
|
|
2281
|
+
title: option.label,
|
|
2282
|
+
value: option.value,
|
|
2283
|
+
});
|
|
2284
|
+
}
|
|
2285
|
+
return v2Options;
|
|
2286
|
+
}
|
|
2287
|
+
function _renderViews() {
|
|
2288
|
+
return {
|
|
2289
|
+
create: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'create').formItemRefs),
|
|
2290
|
+
popup: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'popup').formItemRefs),
|
|
2291
|
+
edit: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'edit').formItemRefs),
|
|
2292
|
+
list: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'list').formItemRefs),
|
|
2293
|
+
filter: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'filter').formItemRefs),
|
|
2294
|
+
view: _renderViewFields(v1.formItemsViewList.find((view) => view.view == 'view').formItemRefs),
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
function _renderViewFields(v1FormItemRefs) {
|
|
2298
|
+
const viewItems = {};
|
|
2299
|
+
v1FormItemRefs.forEach((v1FormItemRef) => {
|
|
2300
|
+
const viewBase = {
|
|
2301
|
+
isUsed: true,
|
|
2302
|
+
isFixed: false,
|
|
2303
|
+
isOptional: false,
|
|
2304
|
+
properties: [],
|
|
2305
|
+
pos: 0,
|
|
2306
|
+
isLockedValue: !!v1FormItemRef.fixedValue || false,
|
|
2307
|
+
value: v1FormItemRef.fixedValue || '',
|
|
2308
|
+
};
|
|
2309
|
+
if (v1FormItemRef.ref === AppFormItemType.TITLE) {
|
|
2310
|
+
viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.TITLE, isFixed: true });
|
|
2311
|
+
}
|
|
2312
|
+
else if (v1FormItemRef.ref === AppFormItemType.IDUSER) {
|
|
2313
|
+
viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.USER, isFixed: true });
|
|
2314
|
+
}
|
|
2315
|
+
else if (v1FormItemRef.ref === AppFormItemType.PUBLISHTO) {
|
|
2316
|
+
viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.PUBLISHTO, isOptional: true });
|
|
2317
|
+
}
|
|
2318
|
+
else if (v1FormItemRef.ref === AppFormItemType.SENDALERTTOSUBSCRIBERS) {
|
|
2319
|
+
viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS, isOptional: true });
|
|
2320
|
+
}
|
|
2321
|
+
else if (v1FormItemRef.ref === AppFormItemType.RECEIVEACOPY) {
|
|
2322
|
+
viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.RECEIVEACOPY, isOptional: true });
|
|
2323
|
+
}
|
|
2324
|
+
else {
|
|
2325
|
+
const v2Field = _mapFormItemRefWithField(v1FormItemRef);
|
|
2326
|
+
if (v2Field) {
|
|
2327
|
+
viewItems[v2Field.id] = Object.assign(Object.assign({ type: v2Field.type }, viewBase), { properties: v2Field.properties || [] });
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
});
|
|
2331
|
+
return viewItems;
|
|
2332
|
+
}
|
|
2333
|
+
function _mapFormItemRefWithField(v1FormItemRef) {
|
|
2334
|
+
const v1Field = v1.form.formItems.find((field) => v1FormItemRef.ref === field.id || v1FormItemRef.ref === field.name);
|
|
2335
|
+
if (v1Field) {
|
|
2336
|
+
return newFields.find((field) => field.id === v1Field.id);
|
|
2337
|
+
}
|
|
2338
|
+
return null;
|
|
2339
|
+
}
|
|
2340
|
+
return v2;
|
|
2341
|
+
}
|
|
2072
2342
|
|
|
2073
2343
|
function InstalledAppStudioAdapter(serverApp, serverApps) {
|
|
2074
2344
|
const { version, dateCreation } = serverApp.manifest;
|
|
@@ -2079,6 +2349,7 @@ function InstalledAppStudioAdapter(serverApp, serverApps) {
|
|
|
2079
2349
|
const studioApp = {
|
|
2080
2350
|
idApp: serverApp.idApp,
|
|
2081
2351
|
status: _formatStatus(serverApp),
|
|
2352
|
+
studioVersion: 2,
|
|
2082
2353
|
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
2354
|
fields: [],
|
|
2084
2355
|
views,
|
|
@@ -2098,15 +2369,21 @@ function DraftAppStudioAdapter(serverApp) {
|
|
|
2098
2369
|
if (!serverApp.value)
|
|
2099
2370
|
return undefined;
|
|
2100
2371
|
const parsedJson = JSON.parse(serverApp.value);
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2372
|
+
if (parsedJson.studioVersion == 2) {
|
|
2373
|
+
return {
|
|
2374
|
+
idApp: serverApp.idApp,
|
|
2375
|
+
studioVersion: 2,
|
|
2376
|
+
status: _formatStatus(serverApp),
|
|
2377
|
+
manifest: parsedJson.manifest,
|
|
2378
|
+
fields: parsedJson.fields,
|
|
2379
|
+
views: parsedJson.views,
|
|
2380
|
+
audience: parsedJson.audience,
|
|
2381
|
+
installFor: parsedJson.installFor,
|
|
2382
|
+
};
|
|
2383
|
+
}
|
|
2384
|
+
else {
|
|
2385
|
+
return Object.assign(Object.assign({}, migrateJson(JSON.parse(serverApp.value))), { status: _formatStatus(serverApp) });
|
|
2386
|
+
}
|
|
2110
2387
|
}
|
|
2111
2388
|
function _formatStatus(serverApp) {
|
|
2112
2389
|
return serverApp.status === jamespot.StudioApplicationStatus.installed
|
|
@@ -2138,10 +2415,493 @@ function serverAppsToStudioApps(serverApps) {
|
|
|
2138
2415
|
return studioApps;
|
|
2139
2416
|
}
|
|
2140
2417
|
|
|
2418
|
+
function appToXml(studioApp) {
|
|
2419
|
+
const { manifest, views, audience, installFor } = studioApp;
|
|
2420
|
+
return `<?xml version='1.0' encoding='utf-8'?>
|
|
2421
|
+
<Application>
|
|
2422
|
+
${createAppManifest(manifest, views, audience, installFor)}
|
|
2423
|
+
<Types>
|
|
2424
|
+
<objecttype
|
|
2425
|
+
label="${manifest.typeLabel}"
|
|
2426
|
+
labelPlural="${manifest.typeLabel}"
|
|
2427
|
+
labelLinkSingular="${manifest.typeLabel}"
|
|
2428
|
+
labelLinkPlural="${manifest.typeLabel}"
|
|
2429
|
+
name="${manifest.appShortName}"
|
|
2430
|
+
classImpl="JPBEContent"
|
|
2431
|
+
classCodeLocation="jamespot/jpro/objs/JPBEContent.php"
|
|
2432
|
+
cssClass="${manifest.cssClass.value}"
|
|
2433
|
+
cssColor="${manifest.cssColor}"
|
|
2434
|
+
searchtab="${manifest.appShortName}"
|
|
2435
|
+
searchtablabel="${manifest.typeLabel}"
|
|
2436
|
+
buttonlabel="${manifest.typeLabel}"
|
|
2437
|
+
extends="article">
|
|
2438
|
+
${renderPrimaryFields(studioApp.fields)}
|
|
2439
|
+
${renderCustomFields(studioApp.fields)}
|
|
2440
|
+
</objecttype>
|
|
2441
|
+
${renderDisplays(studioApp)}
|
|
2442
|
+
</Types>
|
|
2443
|
+
</Application>`;
|
|
2444
|
+
}
|
|
2445
|
+
function createAppManifest(manifest, views, audience, installFor) {
|
|
2446
|
+
var _a;
|
|
2447
|
+
return `<Manifest>
|
|
2448
|
+
<ShowImport>true</ShowImport>
|
|
2449
|
+
<AppShortName>${manifest.appShortName}</AppShortName>
|
|
2450
|
+
<AppName>${manifest.appName}</AppName>
|
|
2451
|
+
<Description>${manifest.description}</Description>
|
|
2452
|
+
<Version>${manifest.version}</Version>
|
|
2453
|
+
<ManifestVersion>1.0</ManifestVersion>
|
|
2454
|
+
<StudioVersion>2</StudioVersion>
|
|
2455
|
+
<DateCreation>${manifest.dateCreation.toString().split('T')[0]}</DateCreation>
|
|
2456
|
+
<CssClass>${(_a = manifest.cssClass) === null || _a === void 0 ? void 0 : _a.label}</CssClass>
|
|
2457
|
+
<CssColor>${manifest.cssColor}</CssColor>
|
|
2458
|
+
<Categories>N.A.</Categories>
|
|
2459
|
+
<Editor>Jamespot</Editor>
|
|
2460
|
+
<EditorUrl>https://www.fr.jamespot.com/</EditorUrl>
|
|
2461
|
+
<Type>${manifest.appShortName}</Type>
|
|
2462
|
+
${renderAppView(manifest.viewSolr, views.list)}
|
|
2463
|
+
${renderAppSearch(views.filter)}
|
|
2464
|
+
${renderAudience(audience, installFor)}
|
|
2465
|
+
<Order>1</Order>
|
|
2466
|
+
</Manifest>`;
|
|
2467
|
+
}
|
|
2468
|
+
function renderAppView(viewSolr, listView) {
|
|
2469
|
+
if (viewSolr === 'solr') {
|
|
2470
|
+
let xml = '<AppView>solr</AppView>';
|
|
2471
|
+
const formItemIdInList = [];
|
|
2472
|
+
Object.entries(listView).forEach(([fieldId, field]) => {
|
|
2473
|
+
formItemIdInList.push(getAttrNameFormItem(field, fieldId));
|
|
2474
|
+
});
|
|
2475
|
+
xml += `<AppColumns>${formItemIdInList.join()}</AppColumns>`;
|
|
2476
|
+
return xml;
|
|
2477
|
+
}
|
|
2478
|
+
return '';
|
|
2479
|
+
}
|
|
2480
|
+
function renderAppSearch(searchView) {
|
|
2481
|
+
const formItemIdInFilter = [];
|
|
2482
|
+
Object.entries(searchView).forEach(([fieldId, field]) => {
|
|
2483
|
+
if (![exports.ExtraAppFieldsItemViews.TITLE, exports.AppFormItemTypes.IMAGE].includes(field.type))
|
|
2484
|
+
formItemIdInFilter.push(getAttrNameFormItem(field, fieldId));
|
|
2485
|
+
});
|
|
2486
|
+
return `<AttrExposed>${formItemIdInFilter.join()}</AttrExposed>`;
|
|
2487
|
+
}
|
|
2488
|
+
function getAttrNameFormItem(field, fieldId) {
|
|
2489
|
+
function fieldType() {
|
|
2490
|
+
if (field.type === exports.ExtraAppFieldsItemViews.USER)
|
|
2491
|
+
return 'idUser';
|
|
2492
|
+
if (field.type === exports.ExtraAppFieldsItemViews.CREATIONDATE)
|
|
2493
|
+
return 'dateCreation';
|
|
2494
|
+
return field.type;
|
|
2495
|
+
}
|
|
2496
|
+
return (AppColumnsDefaultTypes.includes(field.type) ? fieldType() : uuid2Alpha(fieldId)).toLowerCase();
|
|
2497
|
+
}
|
|
2498
|
+
function renderAudience(audience, installFor) {
|
|
2499
|
+
if (audience === AUDIENCE.ALL)
|
|
2500
|
+
return '<checkAccess>false</checkAccess>';
|
|
2501
|
+
else if (installFor.length > 0) {
|
|
2502
|
+
return `<checkAccess>true</checkAccess>
|
|
2503
|
+
<accessRightList>${installFor.map((user) => user.uri).join()}</accessRightList>`;
|
|
2504
|
+
}
|
|
2505
|
+
return '';
|
|
2506
|
+
}
|
|
2507
|
+
function renderPrimaryFields(fields) {
|
|
2508
|
+
const primaryFields = fields === null || fields === void 0 ? void 0 : fields.filter((field) => AppFormPrimaryList.includes(field.type));
|
|
2509
|
+
if (primaryFields.length === 0)
|
|
2510
|
+
return '';
|
|
2511
|
+
return `<primaryFields>${primaryFields.map((field) => formItem2xml(field)).join('')}</primaryFields>`;
|
|
2512
|
+
}
|
|
2513
|
+
function renderCustomFields(fields) {
|
|
2514
|
+
const customFields = fields === null || fields === void 0 ? void 0 : fields.filter((field) => !AppFormPrimaryList.includes(field.type));
|
|
2515
|
+
const filteredCustomFields = customFields === null || customFields === void 0 ? void 0 : customFields.filter((field) => field.type !== exports.AppFormItemTypes.IMAGE);
|
|
2516
|
+
if (filteredCustomFields.length === 0)
|
|
2517
|
+
return '';
|
|
2518
|
+
const articlesTablesItems = filteredCustomFields.filter((f) => f.type !== exports.AppFormItemTypes.TAGS);
|
|
2519
|
+
const linksTableItems = filteredCustomFields.filter((f) => f.type === exports.AppFormItemTypes.TAGS);
|
|
2520
|
+
return `<custom>
|
|
2521
|
+
${articlesTablesItems.length > 0
|
|
2522
|
+
? `<articlemstable>
|
|
2523
|
+
${articlesTablesItems.map((field) => formItem2xml(field)).join('')}
|
|
2524
|
+
</articlemstable>`
|
|
2525
|
+
: ''}
|
|
2526
|
+
${linksTableItems.length > 0
|
|
2527
|
+
? `<linkstable>
|
|
2528
|
+
${linksTableItems.map((field) => formItem2xml(field)).join('')}
|
|
2529
|
+
</linkstable>`
|
|
2530
|
+
: ''}</custom>`;
|
|
2531
|
+
}
|
|
2532
|
+
function formItem2xml(field) {
|
|
2533
|
+
return `<field
|
|
2534
|
+
type="${renderFieldTypeToXmlType(field.type)}"
|
|
2535
|
+
name="${getAttrNameFormItem(field, field.id)}"
|
|
2536
|
+
sqlname="${renderSqlName(field.type, field.id)}"
|
|
2537
|
+
${field.properties && renderProperty(field.properties, exports.AppFieldFormPropertyTypes.LABEL)}
|
|
2538
|
+
${field.properties && renderProperty(field.properties, exports.AppFieldFormPropertyTypes.DESCRIPTION)}
|
|
2539
|
+
mandatory="${field.mandatory}"
|
|
2540
|
+
solr.type="${renderSolrType(field.type)}"
|
|
2541
|
+
solr.used="true"
|
|
2542
|
+
solr.indexed="true"
|
|
2543
|
+
solr.stored="true"
|
|
2544
|
+
solr.searchable="true"
|
|
2545
|
+
solr.multiValued="${field.type === exports.AppFormItemTypes.TAGS || (field.type === exports.AppFormItemTypes.CHECKBOX && true) || false}"
|
|
2546
|
+
teaser="true"
|
|
2547
|
+
display="true"
|
|
2548
|
+
>
|
|
2549
|
+
${renderWidget(field.type, field.properties)}
|
|
2550
|
+
</field>`;
|
|
2551
|
+
}
|
|
2552
|
+
function renderWidget(fieldType, fieldProperties) {
|
|
2553
|
+
var _a;
|
|
2554
|
+
switch (fieldType) {
|
|
2555
|
+
case exports.AppFormItemTypes.DESCRIPTION:
|
|
2556
|
+
return '<widget form="textarea"><params><param key="class" value="mceEditor"></param><param key="mention" value="1"></param></params></widget>';
|
|
2557
|
+
case exports.AppFormItemTypes.TEXT:
|
|
2558
|
+
return '<widget form="text"></widget>';
|
|
2559
|
+
case exports.AppFormItemTypes.TEXTAREA:
|
|
2560
|
+
return '<widget form="textarea"></widget>';
|
|
2561
|
+
case exports.AppFormItemTypes.TEXTAREAHTML:
|
|
2562
|
+
return '<widget form="textarea"><params><param key="class" value="mceEditor"></param></params></widget>';
|
|
2563
|
+
case exports.AppFormItemTypes.DATE:
|
|
2564
|
+
return '<widget form="date" format="d/m/Y"></widget>';
|
|
2565
|
+
case exports.AppFormItemTypes.DATETIME:
|
|
2566
|
+
return `<widget form="datetime" format="d/m/Y H:i:s"></widget>`;
|
|
2567
|
+
case exports.AppFormItemTypes.NUMBER: {
|
|
2568
|
+
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;
|
|
2569
|
+
return `<widget form="number">
|
|
2570
|
+
${isFloat ? `<params><param value="0.01" key="step"/></params>` : ''}
|
|
2571
|
+
</widget>`;
|
|
2572
|
+
}
|
|
2573
|
+
case exports.AppFormItemTypes.SELECT: {
|
|
2574
|
+
const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR);
|
|
2575
|
+
if (!optionEditor)
|
|
2576
|
+
return '';
|
|
2577
|
+
const isMultiple = optionEditor.value.canSelectMultiple;
|
|
2578
|
+
const options = optionEditor.value.propertyOptions;
|
|
2579
|
+
const hasDefaultValue = optionEditor.value.defaultSelectOption;
|
|
2580
|
+
const defaultValue = optionEditor.value.defaultSelectOptionValue;
|
|
2581
|
+
return `<widget form="select" ${isMultiple ? 'multiple="1"' : ''}>
|
|
2582
|
+
<options>
|
|
2583
|
+
${options
|
|
2584
|
+
.map((option) => `<option value="${option.value}" label="${option.title}"></option>`)
|
|
2585
|
+
.join('')}
|
|
2586
|
+
</options>
|
|
2587
|
+
${hasDefaultValue ? `<params><param key="defaultValue" value="${defaultValue}"/></params>` : ''}
|
|
2588
|
+
</widget>`;
|
|
2589
|
+
}
|
|
2590
|
+
case exports.AppFormItemTypes.RADIO: {
|
|
2591
|
+
const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.CHECKBOX);
|
|
2592
|
+
if (!optionEditor)
|
|
2593
|
+
return '';
|
|
2594
|
+
const options = optionEditor.value.propertyOptions;
|
|
2595
|
+
return `<widget form="radio">
|
|
2596
|
+
${options
|
|
2597
|
+
.map((option) => `<option value="${option.value}" label="${option.title}"></option>`)
|
|
2598
|
+
.join('')}
|
|
2599
|
+
</widget>`;
|
|
2600
|
+
}
|
|
2601
|
+
case exports.AppFormItemTypes.TOGGLE:
|
|
2602
|
+
return `<widget form="checkbox">
|
|
2603
|
+
<options>
|
|
2604
|
+
<option value="1" label="GLOBAL_Yes"></option>
|
|
2605
|
+
</options>
|
|
2606
|
+
<params>
|
|
2607
|
+
<param key="jagCheckbox" value="1"></param>
|
|
2608
|
+
</params>
|
|
2609
|
+
</widget>`;
|
|
2610
|
+
case exports.AppFormItemTypes.TAGS: {
|
|
2611
|
+
const taxonomy = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.TAXONOMY);
|
|
2612
|
+
if (!taxonomy)
|
|
2613
|
+
return '';
|
|
2614
|
+
const taxonomyId = taxonomy.value.id;
|
|
2615
|
+
return `<widget form="taxonomy">
|
|
2616
|
+
<params><param key="idTaxonomy" value="${taxonomyId}"></param></params>
|
|
2617
|
+
</widget>`;
|
|
2618
|
+
}
|
|
2619
|
+
case exports.AppFormItemTypes.CHECKBOX: {
|
|
2620
|
+
const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.CHECKBOX);
|
|
2621
|
+
if (!optionEditor)
|
|
2622
|
+
return '';
|
|
2623
|
+
const options = optionEditor.value.propertyOptions;
|
|
2624
|
+
return `<widget form="checkbox" multiple="1">
|
|
2625
|
+
<options>
|
|
2626
|
+
${options
|
|
2627
|
+
.map((option) => `<option value="${option.value}" label="${option.label}"></option>`)
|
|
2628
|
+
.join('')}
|
|
2629
|
+
</options>
|
|
2630
|
+
</widget>`;
|
|
2631
|
+
}
|
|
2632
|
+
case exports.AppFormItemTypes.ADDFILEATTACHMENT:
|
|
2633
|
+
return `<widget form="file" type="fileArticle" multiple="1"></widget>`;
|
|
2634
|
+
case exports.AppFormItemTypes.URL:
|
|
2635
|
+
return `<widget form="url"`;
|
|
2636
|
+
case exports.AppFormItemTypes.EMAIL:
|
|
2637
|
+
return `<widget form="email"></widget>`;
|
|
2638
|
+
case exports.ExtraAppFieldsItemViews.USER:
|
|
2639
|
+
return `<widget form="idUser"></widget>`;
|
|
2640
|
+
case exports.AppFormItemTypes.USERLINK:
|
|
2641
|
+
return `<widget form="uri">
|
|
2642
|
+
<params>
|
|
2643
|
+
<param key="mode" value="ng-view"></param>
|
|
2644
|
+
<param key="class" value="jcomplete"></param>
|
|
2645
|
+
<param key="namespace" value="jamespot"></param>
|
|
2646
|
+
<param key="types" value="user"></param>
|
|
2647
|
+
<param key="views" value="user"></param>
|
|
2648
|
+
<param key="jcomplete-url" value="/?action=ajax&group=autocomplete&export function=user"></param>
|
|
2649
|
+
</params>
|
|
2650
|
+
</widget>`;
|
|
2651
|
+
case exports.AppFormItemTypes.CONTENTLINK: {
|
|
2652
|
+
const contentType = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.CONTENTTYPE);
|
|
2653
|
+
if (!contentType)
|
|
2654
|
+
return '';
|
|
2655
|
+
const type = contentType.value.type;
|
|
2656
|
+
return `<widget form="uri">
|
|
2657
|
+
<params>
|
|
2658
|
+
<param key="mode" value="ng-view"></param>
|
|
2659
|
+
<param key="namespace" value="jamespot"></param>
|
|
2660
|
+
<param key="types" value="${type}"></param>
|
|
2661
|
+
<param key="views" value="article"></param>
|
|
2662
|
+
<param key="jcomplete-url" value="/?action=ajax&group=autocomplete&export function=article&types=[]=${type}"></param>
|
|
2663
|
+
</params>
|
|
2664
|
+
</widget>`;
|
|
2665
|
+
}
|
|
2666
|
+
default:
|
|
2667
|
+
return '';
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
function renderProperty(properties, propertyToFind) {
|
|
2671
|
+
const labelProperty = properties === null || properties === void 0 ? void 0 : properties.find((property) => property.propertyType === propertyToFind);
|
|
2672
|
+
if (labelProperty) {
|
|
2673
|
+
return `${propertyToFind.toLowerCase()}="${labelProperty.value}"`;
|
|
2674
|
+
}
|
|
2675
|
+
return '';
|
|
2676
|
+
}
|
|
2677
|
+
function renderSqlName(fieldType, fieldId) {
|
|
2678
|
+
switch (fieldType) {
|
|
2679
|
+
case exports.AppFormItemTypes.DESCRIPTION:
|
|
2680
|
+
return 'Description';
|
|
2681
|
+
case exports.ExtraAppFieldsItemViews.USER:
|
|
2682
|
+
return 'IdUser';
|
|
2683
|
+
default:
|
|
2684
|
+
return uuid2Alpha(fieldId);
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
function renderSolrType(fieldType) {
|
|
2688
|
+
switch (fieldType) {
|
|
2689
|
+
case exports.AppFormItemTypes.DESCRIPTION:
|
|
2690
|
+
case exports.AppFormItemTypes.TEXT:
|
|
2691
|
+
case exports.AppFormItemTypes.TEXTAREA:
|
|
2692
|
+
case exports.AppFormItemTypes.TEXTAREAHTML:
|
|
2693
|
+
case exports.AppFormItemTypes.URL:
|
|
2694
|
+
case exports.AppFormItemTypes.EMAIL:
|
|
2695
|
+
case exports.AppFormItemTypes.USERLINK:
|
|
2696
|
+
case exports.AppFormItemTypes.CONTENTLINK:
|
|
2697
|
+
case exports.AppFormItemTypes.NUMBER:
|
|
2698
|
+
case exports.AppFormItemTypes.ADDFILEATTACHMENT:
|
|
2699
|
+
return 'text';
|
|
2700
|
+
case exports.AppFormItemTypes.DATE:
|
|
2701
|
+
case exports.AppFormItemTypes.DATETIME:
|
|
2702
|
+
return 'date';
|
|
2703
|
+
case exports.ExtraAppFieldsItemViews.USER:
|
|
2704
|
+
return 'integer';
|
|
2705
|
+
case exports.AppFormItemTypes.SELECT:
|
|
2706
|
+
case exports.AppFormItemTypes.RADIO:
|
|
2707
|
+
case exports.AppFormItemTypes.TOGGLE:
|
|
2708
|
+
case exports.AppFormItemTypes.CHECKBOX:
|
|
2709
|
+
case exports.AppFormItemTypes.TAGS:
|
|
2710
|
+
return 'string';
|
|
2711
|
+
default:
|
|
2712
|
+
return '';
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
function renderFieldTypeToXmlType(fieldType) {
|
|
2716
|
+
switch (fieldType) {
|
|
2717
|
+
default:
|
|
2718
|
+
case exports.AppFormItemTypes.DESCRIPTION:
|
|
2719
|
+
case exports.AppFormItemTypes.TEXTAREAHTML:
|
|
2720
|
+
return 'html';
|
|
2721
|
+
case exports.AppFormItemTypes.TAGS:
|
|
2722
|
+
return 'taxonomy';
|
|
2723
|
+
case exports.AppFormItemTypes.TEXT:
|
|
2724
|
+
case exports.AppFormItemTypes.SELECT:
|
|
2725
|
+
case exports.AppFormItemTypes.RADIO:
|
|
2726
|
+
case exports.AppFormItemTypes.CHECKBOX:
|
|
2727
|
+
case exports.AppFormItemTypes.URL:
|
|
2728
|
+
case exports.AppFormItemTypes.EMAIL:
|
|
2729
|
+
case exports.AppFormItemTypes.ADDFILEATTACHMENT:
|
|
2730
|
+
case exports.ExtraAppFieldsItemViews.USER:
|
|
2731
|
+
case exports.AppFormItemTypes.USERLINK:
|
|
2732
|
+
case exports.AppFormItemTypes.CONTENTLINK:
|
|
2733
|
+
return 'text';
|
|
2734
|
+
case exports.AppFormItemTypes.TEXTAREA:
|
|
2735
|
+
return 'longtext';
|
|
2736
|
+
case exports.AppFormItemTypes.DATE:
|
|
2737
|
+
return 'date';
|
|
2738
|
+
case exports.AppFormItemTypes.DATETIME: {
|
|
2739
|
+
return 'date';
|
|
2740
|
+
}
|
|
2741
|
+
case exports.AppFormItemTypes.NUMBER:
|
|
2742
|
+
return 'float';
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
const uuid2Alpha = (id) => {
|
|
2746
|
+
let alphaUuid = '';
|
|
2747
|
+
for (let i = 0; i < id.length; i++) {
|
|
2748
|
+
const c = id.charAt(i);
|
|
2749
|
+
if (c >= '0' && c <= '9')
|
|
2750
|
+
alphaUuid += numToAlpha(Number(c));
|
|
2751
|
+
else if (c >= 'a' && c <= 'z')
|
|
2752
|
+
alphaUuid += c;
|
|
2753
|
+
}
|
|
2754
|
+
return alphaUuid;
|
|
2755
|
+
};
|
|
2756
|
+
const numToAlpha = (num) => {
|
|
2757
|
+
let s = '', t;
|
|
2758
|
+
while (num > 0) {
|
|
2759
|
+
t = (num - 1) % 26;
|
|
2760
|
+
s = String.fromCharCode(97 + t) + s;
|
|
2761
|
+
num = ((num - t) / 26) | 0;
|
|
2762
|
+
}
|
|
2763
|
+
return s;
|
|
2764
|
+
};
|
|
2765
|
+
const internal2XmlView = {
|
|
2766
|
+
create: 'create',
|
|
2767
|
+
popup: 'create-popup',
|
|
2768
|
+
edit: 'edit',
|
|
2769
|
+
view: 'display',
|
|
2770
|
+
};
|
|
2771
|
+
function renderDisplays(studioApp) {
|
|
2772
|
+
let toRet = '';
|
|
2773
|
+
Object.entries(studioApp.views).forEach(([viewName, viewContent]) => {
|
|
2774
|
+
if (Object.prototype.hasOwnProperty.call(internal2XmlView, viewName)) {
|
|
2775
|
+
const viewField = Object.entries(viewContent);
|
|
2776
|
+
toRet += `<display view="${internal2XmlView[viewName]}" mode="${viewName === 'view' ? 'view' : 'form'}">
|
|
2777
|
+
${viewField.map(([fieldId, view]) => renderDisplayAttr(fieldId, view)).join('')}
|
|
2778
|
+
</display>`;
|
|
2779
|
+
}
|
|
2780
|
+
});
|
|
2781
|
+
if (toRet.length > 0) {
|
|
2782
|
+
toRet = `<displays type="${studioApp.manifest.appShortName}">${toRet}</displays>`;
|
|
2783
|
+
}
|
|
2784
|
+
return toRet;
|
|
2785
|
+
}
|
|
2786
|
+
function getDisplayName(fieldId, view) {
|
|
2787
|
+
switch (view.type) {
|
|
2788
|
+
case exports.ExtraAppFieldsItemViews.TITLE:
|
|
2789
|
+
return 'title';
|
|
2790
|
+
case exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS:
|
|
2791
|
+
return 'sendAlert';
|
|
2792
|
+
case exports.ExtraAppFieldsItemViews.RECEIVEACOPY:
|
|
2793
|
+
return 'alertAuthor';
|
|
2794
|
+
case exports.ExtraAppFieldsItemViews.PUBLISHTO:
|
|
2795
|
+
return 'publishTo';
|
|
2796
|
+
case exports.ExtraAppFieldsItemViews.USER:
|
|
2797
|
+
return 'idUser';
|
|
2798
|
+
case exports.ExtraAppFieldsItemViews.CREATIONDATE:
|
|
2799
|
+
return 'dateCreation';
|
|
2800
|
+
default:
|
|
2801
|
+
return uuid2Alpha(fieldId);
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
function renderDisplayAttr(fieldId, view) {
|
|
2805
|
+
var _a, _b, _c;
|
|
2806
|
+
let xml = '';
|
|
2807
|
+
const attrName = getDisplayName(fieldId, view);
|
|
2808
|
+
const isFixed = view.isLockedValue;
|
|
2809
|
+
if (isFixed) {
|
|
2810
|
+
const formItemRefWithName = {
|
|
2811
|
+
ref: attrName,
|
|
2812
|
+
fixedValue: view.value,
|
|
2813
|
+
};
|
|
2814
|
+
xml += `<html><![CDATA[ <!-- <JAMESPOT.STUDIO.FIXED>${JSON.stringify(formItemRefWithName)}</JAMESPOT.STUDIO.FIXED> -->`;
|
|
2815
|
+
if (view.type === exports.ExtraAppFieldsItemViews.PUBLISHTO) {
|
|
2816
|
+
const uris = view.value.map((user) => user.uri).join(',');
|
|
2817
|
+
xml += `<input type="hidden" name="publishTo" value="${uris}">`;
|
|
2818
|
+
}
|
|
2819
|
+
else if (view.type === exports.ExtraAppFieldsItemViews.USER ||
|
|
2820
|
+
view.type === exports.AppFormItemTypes.USERLINK ||
|
|
2821
|
+
view.type === exports.AppFormItemTypes.CONTENTLINK) {
|
|
2822
|
+
xml += `<input type="hidden" name="${attrName}[]" value=${JSON.stringify(view.value.uri)}>`;
|
|
2823
|
+
}
|
|
2824
|
+
else if (view.type === exports.AppFormItemTypes.SELECT) {
|
|
2825
|
+
const values = view.value;
|
|
2826
|
+
const canSelectMultiple = (_a = view.properties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR)) === null || _a === void 0 ? void 0 : _a.value.canSelectMultiple;
|
|
2827
|
+
values.forEach((value) => {
|
|
2828
|
+
xml += `<input type="hidden" name="${attrName}${canSelectMultiple ? '[]' : ''}" value="${value.value}">`;
|
|
2829
|
+
});
|
|
2830
|
+
}
|
|
2831
|
+
else if (view.type === exports.AppFormItemTypes.CHECKBOX) {
|
|
2832
|
+
const values = view.value;
|
|
2833
|
+
values.forEach((value) => {
|
|
2834
|
+
xml += `<input type="hidden" name="${attrName}[]" value="${value.value}">`;
|
|
2835
|
+
});
|
|
2836
|
+
}
|
|
2837
|
+
else if (view.type === exports.AppFormItemTypes.DATE) {
|
|
2838
|
+
const dateValue = new Date(view.value);
|
|
2839
|
+
const xmlFixedValue = [
|
|
2840
|
+
pad(dateValue.getDate()),
|
|
2841
|
+
pad(dateValue.getMonth() + 1),
|
|
2842
|
+
dateValue.getFullYear(),
|
|
2843
|
+
].join('/');
|
|
2844
|
+
xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
|
|
2845
|
+
}
|
|
2846
|
+
else if (view.type === exports.AppFormItemTypes.DATETIME) {
|
|
2847
|
+
const dateValue = new Date(view.value);
|
|
2848
|
+
const xmlFixedValue = [
|
|
2849
|
+
pad(dateValue.getDate()),
|
|
2850
|
+
pad(dateValue.getMonth() + 1),
|
|
2851
|
+
dateValue.getFullYear(),
|
|
2852
|
+
pad(dateValue.getHours()),
|
|
2853
|
+
pad(dateValue.getMinutes()),
|
|
2854
|
+
pad(dateValue.getSeconds()),
|
|
2855
|
+
].join('/');
|
|
2856
|
+
xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
|
|
2857
|
+
}
|
|
2858
|
+
else if (view.type === exports.AppFormItemTypes.TAGS) {
|
|
2859
|
+
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(',')}">`;
|
|
2860
|
+
}
|
|
2861
|
+
else if (view.type === exports.AppFormItemTypes.DESCRIPTION || view.type === exports.AppFormItemTypes.TEXTAREAHTML) {
|
|
2862
|
+
xml += `<input type="hidden" name="${attrName}" value="${view.value.html}">`;
|
|
2863
|
+
}
|
|
2864
|
+
else {
|
|
2865
|
+
xml += `<input type="hidden" name="${attrName}" value="${view.value}">`;
|
|
2866
|
+
}
|
|
2867
|
+
xml += ']]></html>';
|
|
2868
|
+
}
|
|
2869
|
+
else {
|
|
2870
|
+
switch (view.type) {
|
|
2871
|
+
case exports.AppFormItemTypes.CODEHTML: {
|
|
2872
|
+
const content = {
|
|
2873
|
+
ref: attrName,
|
|
2874
|
+
fixedValue: {
|
|
2875
|
+
html: view.value.html,
|
|
2876
|
+
text: view.value.text,
|
|
2877
|
+
},
|
|
2878
|
+
};
|
|
2879
|
+
xml += `<html><![CDATA[ <!-- <JAMESPOT.STUDIO.CODEHTML>${JSON.stringify(content)}</JAMESPOT.STUDIO.CODEHTML><JAMESPOT.STUDIO.FIELD_POS></JAMESPOT.STUDIO.FIELD_POS>-->]]></html>`;
|
|
2880
|
+
break;
|
|
2881
|
+
}
|
|
2882
|
+
case exports.AppFormItemTypes.IMAGE:
|
|
2883
|
+
xml += '<image />';
|
|
2884
|
+
break;
|
|
2885
|
+
case exports.ExtraAppFieldsItemViews.PUBLISHTO:
|
|
2886
|
+
xml += '<publishTo />';
|
|
2887
|
+
break;
|
|
2888
|
+
default:
|
|
2889
|
+
xml += "<attr name='" + attrName + "' />";
|
|
2890
|
+
break;
|
|
2891
|
+
}
|
|
2892
|
+
}
|
|
2893
|
+
return xml;
|
|
2894
|
+
}
|
|
2895
|
+
function pad(s) {
|
|
2896
|
+
return s < 10 ? '0' + s : s;
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2141
2899
|
const initialState$1 = {
|
|
2142
2900
|
currentStudioApp: null,
|
|
2143
2901
|
fetchCurrentStudioAppStatus: 'idle',
|
|
2144
2902
|
saveCurrentStudioAppStatus: 'idle',
|
|
2903
|
+
installStudioAppStatus: 'idle',
|
|
2904
|
+
hasChanged: false,
|
|
2145
2905
|
};
|
|
2146
2906
|
const fetchCurrentStudioApp = toolkit.createAsyncThunk('studio/fetchCurrentStudioApp', ({ idApp, status }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2147
2907
|
const jApi = extra.jApi;
|
|
@@ -2176,6 +2936,24 @@ const saveCurrentStudioApp = toolkit.createAsyncThunk('studio/saveCurrentStudioA
|
|
|
2176
2936
|
return rejectWithValue(error);
|
|
2177
2937
|
}
|
|
2178
2938
|
}));
|
|
2939
|
+
const installStudioApp = toolkit.createAsyncThunk('studio/installApp', (_, { extra, rejectWithValue, getState, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2940
|
+
const jApi = extra.jApi;
|
|
2941
|
+
const error = { error: 1, errorMsg: 'Error saving application' };
|
|
2942
|
+
const currentStudioApp = getState().studio.currentStudioApp.currentStudioApp;
|
|
2943
|
+
if (!currentStudioApp) {
|
|
2944
|
+
return rejectWithValue(error);
|
|
2945
|
+
}
|
|
2946
|
+
const xml = appToXml(currentStudioApp);
|
|
2947
|
+
try {
|
|
2948
|
+
yield jApi.application.install(xml);
|
|
2949
|
+
dispatch(Toast.actions.success({ label: 'APPSTUDIO_AppItem_Edition_Saved' }));
|
|
2950
|
+
return;
|
|
2951
|
+
}
|
|
2952
|
+
catch (_) {
|
|
2953
|
+
dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
|
|
2954
|
+
return rejectWithValue(error);
|
|
2955
|
+
}
|
|
2956
|
+
}));
|
|
2179
2957
|
const CurrentStudioAppSlice = toolkit.createSlice({
|
|
2180
2958
|
name: 'currentStudioApp',
|
|
2181
2959
|
initialState: initialState$1,
|
|
@@ -2186,6 +2964,9 @@ const CurrentStudioAppSlice = toolkit.createSlice({
|
|
|
2186
2964
|
resetCurrentApp: (state) => {
|
|
2187
2965
|
state.currentStudioApp = null;
|
|
2188
2966
|
},
|
|
2967
|
+
setHasChanged: (state, action) => {
|
|
2968
|
+
state.hasChanged = action.payload;
|
|
2969
|
+
},
|
|
2189
2970
|
},
|
|
2190
2971
|
extraReducers: (builder) => {
|
|
2191
2972
|
builder
|
|
@@ -2213,6 +2994,18 @@ const CurrentStudioAppSlice = toolkit.createSlice({
|
|
|
2213
2994
|
.addCase(saveCurrentStudioApp.rejected, (state) => {
|
|
2214
2995
|
if (state.saveCurrentStudioAppStatus === 'pending')
|
|
2215
2996
|
state.saveCurrentStudioAppStatus = 'idle';
|
|
2997
|
+
})
|
|
2998
|
+
.addCase(installStudioApp.pending, (state) => {
|
|
2999
|
+
if (state.installStudioAppStatus === 'idle')
|
|
3000
|
+
state.installStudioAppStatus = 'pending';
|
|
3001
|
+
})
|
|
3002
|
+
.addCase(installStudioApp.fulfilled, (state) => {
|
|
3003
|
+
if (state.installStudioAppStatus === 'pending')
|
|
3004
|
+
state.installStudioAppStatus = 'idle';
|
|
3005
|
+
})
|
|
3006
|
+
.addCase(installStudioApp.rejected, (state) => {
|
|
3007
|
+
if (state.installStudioAppStatus === 'pending')
|
|
3008
|
+
state.installStudioAppStatus = 'idle';
|
|
2216
3009
|
});
|
|
2217
3010
|
},
|
|
2218
3011
|
});
|
|
@@ -2268,6 +3061,7 @@ function createNewStudioApp$1({ author, appName }) {
|
|
|
2268
3061
|
idApp: newAppId,
|
|
2269
3062
|
status: APP_STATUS_TYPE.DRAFT,
|
|
2270
3063
|
author: author || '',
|
|
3064
|
+
studioVersion: 2,
|
|
2271
3065
|
manifest: {
|
|
2272
3066
|
appShortName: appName,
|
|
2273
3067
|
appName: appName,
|
|
@@ -2532,7 +3326,8 @@ const studio = {
|
|
|
2532
3326
|
cloneStudioApp,
|
|
2533
3327
|
createNewStudioApp,
|
|
2534
3328
|
fetchCurrentStudioApp,
|
|
2535
|
-
saveCurrentStudioApp
|
|
3329
|
+
saveCurrentStudioApp,
|
|
3330
|
+
installStudioApp }),
|
|
2536
3331
|
selectors: {
|
|
2537
3332
|
selectStudioAppsList,
|
|
2538
3333
|
selectCurrentStudioApp,
|
|
@@ -2541,7 +3336,9 @@ const studio = {
|
|
|
2541
3336
|
|
|
2542
3337
|
exports.APP_STATUS_TYPE = APP_STATUS_TYPE;
|
|
2543
3338
|
exports.AUDIENCE = AUDIENCE;
|
|
2544
|
-
exports.
|
|
3339
|
+
exports.AppColumnsDefaultTypes = AppColumnsDefaultTypes;
|
|
3340
|
+
exports.AppFormBannedFromViews = AppFormBannedFromViews$1;
|
|
3341
|
+
exports.AppFormPrimaryList = AppFormPrimaryList;
|
|
2545
3342
|
exports.AppFormUniqueList = AppFormUniqueList;
|
|
2546
3343
|
exports.Application = Application;
|
|
2547
3344
|
exports.AssetReservation = AssetReservation;
|