jamespot-front-business 1.1.73 → 1.1.75
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 +1059 -1036
- package/dist/cjs.js.map +1 -1
- package/dist/esm.js +1059 -1036
- package/dist/esm.js.map +1 -1
- package/package.json +2 -2
package/dist/esm.js
CHANGED
|
@@ -3393,1121 +3393,1135 @@ function createTextAreaField(installedField) {
|
|
|
3393
3393
|
return field;
|
|
3394
3394
|
}
|
|
3395
3395
|
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3396
|
+
function appToXml(studioApp) {
|
|
3397
|
+
const { manifest, views, audience, installFor } = studioApp;
|
|
3398
|
+
return `<?xml version='1.0' encoding='utf-8'?>
|
|
3399
|
+
<Application>
|
|
3400
|
+
${createAppManifest(manifest, views, audience, installFor, studioApp.idApp)}
|
|
3401
|
+
<Types>
|
|
3402
|
+
<objecttype
|
|
3403
|
+
label="${manifest.typeLabel}"
|
|
3404
|
+
labelPlural="${manifest.typeLabel}"
|
|
3405
|
+
labelLinkSingular="${manifest.typeLabel}"
|
|
3406
|
+
labelLinkPlural="${manifest.typeLabel}"
|
|
3407
|
+
name="${studioApp.idApp}"
|
|
3408
|
+
classImpl="JPBEContent"
|
|
3409
|
+
classCodeLocation="jamespot/jpro/objs/JPBEContent.php"
|
|
3410
|
+
cssClass="${manifest.cssClass.value}"
|
|
3411
|
+
cssColor="${manifest.cssColor}"
|
|
3412
|
+
searchtab="${studioApp.idApp}"
|
|
3413
|
+
searchtablabel="${manifest.typeLabel}"
|
|
3414
|
+
buttonlabel="${manifest.typeLabel}"
|
|
3415
|
+
extends="article">
|
|
3416
|
+
${renderPrimaryFields(studioApp.fields)}
|
|
3417
|
+
${renderCustomFields(studioApp.fields)}
|
|
3418
|
+
</objecttype>
|
|
3419
|
+
${renderDisplays(studioApp)}
|
|
3420
|
+
</Types>
|
|
3421
|
+
</Application>`;
|
|
3422
|
+
}
|
|
3423
|
+
function createAppManifest(manifest, views, audience, installFor, idApp) {
|
|
3424
|
+
var _a;
|
|
3425
|
+
return `<Manifest>
|
|
3426
|
+
<ShowImport>true</ShowImport>
|
|
3427
|
+
<AppShortName>${idApp}</AppShortName>
|
|
3428
|
+
<AppName>${manifest.appName}</AppName>
|
|
3429
|
+
<Description>${manifest.description}</Description>
|
|
3430
|
+
<Version>${manifest.version + 1}</Version>
|
|
3431
|
+
<ManifestVersion>1.0</ManifestVersion>
|
|
3432
|
+
<StudioVersion>2</StudioVersion>
|
|
3433
|
+
<DateCreation>${manifest.dateCreation.toString().split('T')[0]}</DateCreation>
|
|
3434
|
+
<CssClass>${(_a = manifest.cssClass) === null || _a === void 0 ? void 0 : _a.label}</CssClass>
|
|
3435
|
+
<CssColor>${manifest.cssColor}</CssColor>
|
|
3436
|
+
<Categories>N.A.</Categories>
|
|
3437
|
+
<Editor>Jamespot</Editor>
|
|
3438
|
+
<EditorUrl>https://www.fr.jamespot.com/</EditorUrl>
|
|
3439
|
+
<Type>${idApp}</Type>
|
|
3440
|
+
${renderAppView(manifest.viewSolr, views.list)}
|
|
3441
|
+
${renderAppSearch(views.filter)}
|
|
3442
|
+
${renderAudience(audience, installFor)}
|
|
3443
|
+
<Order>1</Order>
|
|
3444
|
+
</Manifest>`;
|
|
3445
|
+
}
|
|
3446
|
+
function renderAppView(viewSolr, listView) {
|
|
3447
|
+
if (viewSolr === STUDIO_VIEW.SOLR) {
|
|
3448
|
+
let xml = '<AppView>solr</AppView>';
|
|
3449
|
+
const formItemIdInList = [];
|
|
3450
|
+
Object.entries(listView)
|
|
3451
|
+
.sort((a, b) => a[1].pos - b[1].pos)
|
|
3452
|
+
.forEach(([fieldId, field]) => {
|
|
3453
|
+
if (!field.isUsed) {
|
|
3421
3454
|
return;
|
|
3422
3455
|
}
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
const richTextProperty = (_b = field.properties) === null || _b === void 0 ? void 0 : _b.find((prop) => prop.propertyType === AppFieldFormPropertyTypes.RICHTEXT);
|
|
3426
|
-
if (richTextProperty === null || richTextProperty === void 0 ? void 0 : richTextProperty.value) {
|
|
3427
|
-
fieldValue = richTextProperty === null || richTextProperty === void 0 ? void 0 : richTextProperty.value;
|
|
3428
|
-
}
|
|
3429
|
-
}
|
|
3430
|
-
if (fieldType === AppFormItemTypes.SELECT) {
|
|
3431
|
-
const selectProperty = (_c = field.properties) === null || _c === void 0 ? void 0 : _c.find((prop) => prop.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
|
|
3432
|
-
if (isExistingField) {
|
|
3433
|
-
const exField = clonedApp.views[view][field.id];
|
|
3434
|
-
const exSelectProperty = (_d = exField.properties) === null || _d === void 0 ? void 0 : _d.find((prop) => prop.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
|
|
3435
|
-
const isMultivalued = !!((_e = selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.value) === null || _e === void 0 ? void 0 : _e.canSelectMultiple);
|
|
3436
|
-
const exIsMultivalued = !!((_f = exSelectProperty === null || exSelectProperty === void 0 ? void 0 : exSelectProperty.value) === null || _f === void 0 ? void 0 : _f.canSelectMultiple);
|
|
3437
|
-
if (isMultivalued === exIsMultivalued) {
|
|
3438
|
-
fieldValue = exField.value;
|
|
3439
|
-
}
|
|
3440
|
-
}
|
|
3441
|
-
else {
|
|
3442
|
-
const isEnhancedSelect = !!(selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.isOptionsEditorEnhanced);
|
|
3443
|
-
const defaultValue = isEnhancedSelect && !!(selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.value.defaultSelectOption)
|
|
3444
|
-
? selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.value.defaultSelectOptionValue
|
|
3445
|
-
: '';
|
|
3446
|
-
if (defaultValue) {
|
|
3447
|
-
fieldValue = defaultValue;
|
|
3448
|
-
}
|
|
3449
|
-
}
|
|
3450
|
-
}
|
|
3451
|
-
if (isExistingField) {
|
|
3452
|
-
const exField = clonedApp.views[view][field.id];
|
|
3453
|
-
viewItems[field.id] = Object.assign(Object.assign(Object.assign(Object.assign({}, exField), { properties: field.properties || exField.properties || [] }), (fieldValue !== undefined && { value: fieldValue })), { isUsed: isFieldUsedInView, pos: ((_g = clonedApp.syncViewFieldOrder) === null || _g === void 0 ? void 0 : _g[view]) ? idx : exField.pos, isLockedValue: (fieldValue !== undefined || exField.value !== undefined) && exField.isLockedValue });
|
|
3454
|
-
}
|
|
3455
|
-
else {
|
|
3456
|
-
const existingFieldsLen = Object.values(clonedApp.views[view]).filter((v) => !v.isFixed && !v.isOptional).length;
|
|
3457
|
-
viewItems[field.id] = {
|
|
3458
|
-
type: field.type,
|
|
3459
|
-
properties: field.properties || [],
|
|
3460
|
-
isUsed: isFieldUsedInView,
|
|
3461
|
-
isOptional: false,
|
|
3462
|
-
isLockedValue: false,
|
|
3463
|
-
isFixed: false,
|
|
3464
|
-
value: fieldValue !== null && fieldValue !== void 0 ? fieldValue : null,
|
|
3465
|
-
pos: ((_h = clonedApp.syncViewFieldOrder) === null || _h === void 0 ? void 0 : _h[view]) ? idx : existingFieldsLen + idx,
|
|
3466
|
-
};
|
|
3456
|
+
if ([AppFormItemTypes.IMAGE].includes(field.type)) {
|
|
3457
|
+
return;
|
|
3467
3458
|
}
|
|
3459
|
+
formItemIdInList.push(getAttrNameFormItem(field, fieldId));
|
|
3468
3460
|
});
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
};
|
|
3472
|
-
}));
|
|
3473
|
-
}
|
|
3474
|
-
function buildAudience(accessRightObjectList) {
|
|
3475
|
-
return accessRightObjectList.map((accessRightObject) => {
|
|
3476
|
-
return {
|
|
3477
|
-
id: `${accessRightObject.type}/${accessRightObject.id}`,
|
|
3478
|
-
uri: `${accessRightObject.type}/${accessRightObject.id}`,
|
|
3479
|
-
shortUri: `${accessRightObject.type}/${accessRightObject.id}`,
|
|
3480
|
-
title: accessRightObject.title,
|
|
3481
|
-
name: accessRightObject.title,
|
|
3482
|
-
mainType: accessRightObject.type,
|
|
3483
|
-
type: accessRightObject.mainType,
|
|
3484
|
-
label: accessRightObject.type,
|
|
3485
|
-
cssClass: accessRightObject._cssClass,
|
|
3486
|
-
cssColor: accessRightObject._cssColor,
|
|
3487
|
-
class: accessRightObject._cssClass,
|
|
3488
|
-
Pseudo: accessRightObject.title,
|
|
3489
|
-
_url: accessRightObject._url,
|
|
3490
|
-
};
|
|
3491
|
-
});
|
|
3492
|
-
}
|
|
3493
|
-
function populateFieldsAndViews(app, appS, state) {
|
|
3494
|
-
const tables = app.typeModel.tables;
|
|
3495
|
-
const displays = app.typeModel.displays;
|
|
3496
|
-
if (!displays) {
|
|
3497
|
-
return;
|
|
3461
|
+
xml += `<AppColumns>${formItemIdInList.join()}</AppColumns>`;
|
|
3462
|
+
return xml;
|
|
3498
3463
|
}
|
|
3499
|
-
|
|
3500
|
-
Object.entries(displays).forEach((displaysEntry) => {
|
|
3501
|
-
const [displayName, displayValue] = displaysEntry;
|
|
3502
|
-
if (Object.keys(installedToV2ViewNames).includes(displayName)) {
|
|
3503
|
-
buildView(appS, registeredFields, displayName, displayValue, tables, state);
|
|
3504
|
-
}
|
|
3505
|
-
});
|
|
3506
|
-
buildListView(appS, registeredFields, app.columns, tables, state);
|
|
3507
|
-
buildFilterView(appS, registeredFields, app.attrExposed, tables, state);
|
|
3464
|
+
return '';
|
|
3508
3465
|
}
|
|
3509
|
-
function
|
|
3510
|
-
const
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
if (
|
|
3466
|
+
function renderAppSearch(searchView) {
|
|
3467
|
+
const formItemIdInFilter = [];
|
|
3468
|
+
Object.entries(searchView)
|
|
3469
|
+
.sort((a, b) => a[1].pos - b[1].pos)
|
|
3470
|
+
.forEach(([fieldId, field]) => {
|
|
3471
|
+
if (!field.isUsed) {
|
|
3515
3472
|
return;
|
|
3516
3473
|
}
|
|
3517
|
-
const
|
|
3518
|
-
if (
|
|
3519
|
-
|
|
3520
|
-
case 'title':
|
|
3521
|
-
addTitleToView(newName, appS, fixedInfo);
|
|
3522
|
-
break;
|
|
3523
|
-
case 'alertAuthor':
|
|
3524
|
-
addAlertAuthorToView(newName, appS, fixedInfo);
|
|
3525
|
-
break;
|
|
3526
|
-
case 'sendAlert':
|
|
3527
|
-
addSendAlertToView(newName, appS, fixedInfo);
|
|
3528
|
-
break;
|
|
3529
|
-
case 'publishTo':
|
|
3530
|
-
addPublishToToView(newName, appS, fixedInfo);
|
|
3531
|
-
break;
|
|
3532
|
-
default:
|
|
3533
|
-
console.error('fixed field info with unsupported ref ', fixedInfo);
|
|
3534
|
-
break;
|
|
3535
|
-
}
|
|
3536
|
-
}
|
|
3537
|
-
else if (fieldIdx !== -1) {
|
|
3538
|
-
field = appS.fields[fieldIdx];
|
|
3539
|
-
if (!field || !field.views) {
|
|
3540
|
-
throw new Error(`error converting installed app to V2: created field not found in fields array: ${fieldIdx}, ${fixedInfo}`);
|
|
3541
|
-
}
|
|
3542
|
-
field.views[newName] = true;
|
|
3543
|
-
addFieldToView(newName, field, appS, index, fixedInfo);
|
|
3544
|
-
}
|
|
3474
|
+
const list = [ExtraAppFieldsItemViews.TITLE, AppFormItemTypes.IMAGE];
|
|
3475
|
+
if (!list.includes(field.type))
|
|
3476
|
+
formItemIdInFilter.push(getAttrNameFormItem(field, fieldId));
|
|
3545
3477
|
});
|
|
3478
|
+
return `<AttrExposed>${formItemIdInFilter.join()}</AttrExposed>`;
|
|
3546
3479
|
}
|
|
3547
|
-
function
|
|
3548
|
-
if (
|
|
3549
|
-
return;
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3480
|
+
function fieldType(fieldType) {
|
|
3481
|
+
if (fieldType === ExtraAppFieldsItemViews.TITLE)
|
|
3482
|
+
return 'title';
|
|
3483
|
+
if (fieldType === ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS)
|
|
3484
|
+
return 'sendAlert';
|
|
3485
|
+
if (fieldType === ExtraAppFieldsItemViews.RECEIVEACOPY)
|
|
3486
|
+
return 'alertAuthor';
|
|
3487
|
+
if (fieldType === ExtraAppFieldsItemViews.PUBLISHTO)
|
|
3488
|
+
return 'publishTo';
|
|
3489
|
+
if (fieldType === ExtraAppFieldsItemViews.USER)
|
|
3490
|
+
return 'idUser';
|
|
3491
|
+
if (fieldType === ExtraAppFieldsItemViews.CREATIONDATE)
|
|
3492
|
+
return 'dateCreation';
|
|
3493
|
+
if (fieldType === AppFormItemTypes.DESCRIPTION)
|
|
3494
|
+
return 'description';
|
|
3495
|
+
return fieldType;
|
|
3554
3496
|
}
|
|
3555
|
-
function
|
|
3556
|
-
|
|
3557
|
-
addFieldToViewFromRef(appS, registeredFields, tables, 'filter', fieldRef, index, state);
|
|
3558
|
-
});
|
|
3497
|
+
function getAttrNameFormItem(field, fieldId) {
|
|
3498
|
+
return (AppColumnsDefaultTypes.includes(field.type) ? fieldType(field.type) : uuid2Alpha(fieldId)).toLowerCase();
|
|
3559
3499
|
}
|
|
3560
|
-
function
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
case 'idUser':
|
|
3567
|
-
addUserToView(viewName, appS);
|
|
3568
|
-
break;
|
|
3569
|
-
case 'datecreation':
|
|
3570
|
-
case 'dateCreation':
|
|
3571
|
-
addDateCreationToView(viewName, appS);
|
|
3572
|
-
break;
|
|
3573
|
-
default:
|
|
3574
|
-
defaultFieldCreation(appS, registeredFields, tables, viewName, fieldRef, index, state);
|
|
3575
|
-
break;
|
|
3500
|
+
function renderAudience(audience, installFor) {
|
|
3501
|
+
if (audience === AUDIENCE.ALL)
|
|
3502
|
+
return '<checkAccess>false</checkAccess>';
|
|
3503
|
+
else if (installFor.length > 0) {
|
|
3504
|
+
return `<checkAccess>true</checkAccess>
|
|
3505
|
+
<accessRightList>${installFor.map((user) => user.uri).join()}</accessRightList>`;
|
|
3576
3506
|
}
|
|
3507
|
+
return '';
|
|
3577
3508
|
}
|
|
3578
|
-
function
|
|
3579
|
-
const
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
}
|
|
3584
|
-
field.views[viewName] = true;
|
|
3585
|
-
addFieldToView(viewName, field, appS, index, undefined);
|
|
3509
|
+
function renderPrimaryFields(fields) {
|
|
3510
|
+
const primaryFields = fields === null || fields === void 0 ? void 0 : fields.filter((field) => AppFormPrimaryListValues.includes(field.type));
|
|
3511
|
+
if (primaryFields.length === 0)
|
|
3512
|
+
return '';
|
|
3513
|
+
return `<primaryFields>${primaryFields.map((field) => formItem2xml(field)).join('')}</primaryFields>`;
|
|
3586
3514
|
}
|
|
3587
|
-
function
|
|
3588
|
-
const
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
const
|
|
3593
|
-
|
|
3594
|
-
return
|
|
3515
|
+
function renderCustomFields(fields) {
|
|
3516
|
+
const customFields = fields === null || fields === void 0 ? void 0 : fields.filter((field) => !AppFormPrimaryListValues.includes(field.type));
|
|
3517
|
+
const filteredCustomFields = customFields === null || customFields === void 0 ? void 0 : customFields.filter((field) => field.type !== AppFormItemTypes.IMAGE);
|
|
3518
|
+
if (filteredCustomFields.length === 0)
|
|
3519
|
+
return '';
|
|
3520
|
+
const articlesTablesItems = filteredCustomFields.filter((f) => f.type !== AppFormItemTypes.TAGS && !AppFormNonPrimaryList.includes(f.type));
|
|
3521
|
+
const linksTableItems = filteredCustomFields.filter((f) => f.type === AppFormItemTypes.TAGS);
|
|
3522
|
+
return `<custom>
|
|
3523
|
+
${articlesTablesItems.length > 0
|
|
3524
|
+
? `<articlemstable>
|
|
3525
|
+
${articlesTablesItems.map((field) => formItem2xml(field)).join('')}
|
|
3526
|
+
</articlemstable>`
|
|
3527
|
+
: ''}
|
|
3528
|
+
${linksTableItems.length > 0
|
|
3529
|
+
? `<linkstable tablename="tag_links" sqlNameColumn="name" sqlSrcIdColumn="srcId" sqlSrcTypeColumn="srcType" sqlTargetIdColumn="targetId" sqlTargetTypeColumn="targetType">
|
|
3530
|
+
${linksTableItems.map((field) => formItem2xml(field)).join('')}
|
|
3531
|
+
</linkstable>`
|
|
3532
|
+
: ''}</custom>`;
|
|
3595
3533
|
}
|
|
3596
|
-
function
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
}
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3534
|
+
function formItem2xml(field) {
|
|
3535
|
+
return `<field
|
|
3536
|
+
type="${renderFieldTypeToXmlType(field.type)}"
|
|
3537
|
+
name="${getAttrNameFormItem(field, field.id)}"
|
|
3538
|
+
sqlname="${renderSqlName(field.type, field.id)}"
|
|
3539
|
+
${field.properties && renderProperty(field.properties, AppFieldFormPropertyTypes.LABEL)}
|
|
3540
|
+
${field.properties && renderProperty(field.properties, AppFieldFormPropertyTypes.DESCRIPTION)}
|
|
3541
|
+
mandatory="${field.mandatory}"
|
|
3542
|
+
solr.type="${renderSolrType(field.type)}"
|
|
3543
|
+
solr.used="true"
|
|
3544
|
+
solr.indexed="true"
|
|
3545
|
+
solr.stored="true"
|
|
3546
|
+
solr.searchable="true"
|
|
3547
|
+
solr.multiValued="${field.type === AppFormItemTypes.TAGS ||
|
|
3548
|
+
field.type === AppFormItemTypes.CHECKBOX ||
|
|
3549
|
+
field.type === AppFormItemTypes.SELECT
|
|
3550
|
+
? true
|
|
3551
|
+
: false}"
|
|
3552
|
+
teaser="true"
|
|
3553
|
+
display="true"
|
|
3554
|
+
>
|
|
3555
|
+
${renderWidget(field.type, field.properties)}
|
|
3556
|
+
</field>`;
|
|
3557
|
+
}
|
|
3558
|
+
function renderWidget(fieldType, fieldProperties) {
|
|
3559
|
+
var _a;
|
|
3560
|
+
switch (fieldType) {
|
|
3561
|
+
case AppFormItemTypes.DESCRIPTION:
|
|
3562
|
+
return '<widget form="textarea"><params><param key="class" value="mceEditor"></param><param key="mention" value="1"></param></params></widget>';
|
|
3563
|
+
case AppFormItemTypes.TEXT:
|
|
3564
|
+
return '<widget form="text"></widget>';
|
|
3565
|
+
case AppFormItemTypes.TEXTAREA:
|
|
3566
|
+
return '<widget form="textarea"></widget>';
|
|
3567
|
+
case AppFormItemTypes.TEXTAREAHTML:
|
|
3568
|
+
return '<widget form="textarea"><params><param key="class" value="mceEditor"></param></params></widget>';
|
|
3569
|
+
case AppFormItemTypes.DATE:
|
|
3570
|
+
return '<widget form="date" format="d/m/Y"></widget>';
|
|
3571
|
+
case AppFormItemTypes.DATETIME:
|
|
3572
|
+
return `<widget form="datetime" format="d/m/Y H:i:s"></widget>`;
|
|
3573
|
+
case AppFormItemTypes.NUMBER: {
|
|
3574
|
+
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;
|
|
3575
|
+
return `<widget form="number">
|
|
3576
|
+
${isFloat ? `<params><param value="0.01" key="step"/></params>` : ''}
|
|
3577
|
+
</widget>`;
|
|
3604
3578
|
}
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3579
|
+
case AppFormItemTypes.SELECT: {
|
|
3580
|
+
const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
|
|
3581
|
+
if (!optionEditor)
|
|
3582
|
+
return '';
|
|
3583
|
+
const isMultiple = optionEditor.value.canSelectMultiple;
|
|
3584
|
+
const options = optionEditor.value.propertyOptions;
|
|
3585
|
+
const hasDefaultValue = optionEditor.value.defaultSelectOption;
|
|
3586
|
+
const defaultValue = optionEditor.value.defaultSelectOptionValue.value;
|
|
3587
|
+
const userCanModifiyByComment = optionEditor.value.userCanModifiyByComment;
|
|
3588
|
+
return `<widget form="select" ${isMultiple ? 'multiple="1"' : ''}>
|
|
3589
|
+
<options>
|
|
3590
|
+
${options
|
|
3591
|
+
.map((option) => `<option value="${option.value}" label="${option.title}"></option>`)
|
|
3592
|
+
.join('')}
|
|
3593
|
+
</options>
|
|
3594
|
+
${hasDefaultValue || userCanModifiyByComment
|
|
3595
|
+
? `<params>
|
|
3596
|
+
${hasDefaultValue ? `<param key="defaultValue" value="${defaultValue}"/>` : ''}
|
|
3597
|
+
${userCanModifiyByComment ? `<param key="explain" value="1"/>` : ''}
|
|
3598
|
+
</params>`
|
|
3599
|
+
: ''}
|
|
3600
|
+
</widget>`;
|
|
3614
3601
|
}
|
|
3615
|
-
|
|
3616
|
-
const
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
}
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
return [knownIndex, formItemRef];
|
|
3628
|
-
}
|
|
3629
|
-
const [ref, indexCreated] = createStudioDefinedField(appS, formItemRef.ref, tables, state);
|
|
3630
|
-
registeredFields.set(ref, indexCreated);
|
|
3631
|
-
return [indexCreated, formItemRef];
|
|
3632
|
-
}
|
|
3633
|
-
catch (_) {
|
|
3634
|
-
console.error('error while parsing studio installed fixed attr in a view: json parsing failed');
|
|
3635
|
-
return [-1, undefined];
|
|
3636
|
-
}
|
|
3602
|
+
case AppFormItemTypes.RADIO: {
|
|
3603
|
+
const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
|
|
3604
|
+
if (!optionEditor)
|
|
3605
|
+
return '';
|
|
3606
|
+
const options = optionEditor.value.propertyOptions;
|
|
3607
|
+
return `<widget form="radio">
|
|
3608
|
+
<options>
|
|
3609
|
+
${options
|
|
3610
|
+
.map((option) => `<option value="${option.value}" label="${option.title}"></option>`)
|
|
3611
|
+
.join('')}
|
|
3612
|
+
</options>
|
|
3613
|
+
</widget>`;
|
|
3637
3614
|
}
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
return [-1, undefined];
|
|
3656
|
-
}
|
|
3615
|
+
case AppFormItemTypes.TOGGLE:
|
|
3616
|
+
return `<widget form="checkbox">
|
|
3617
|
+
<options>
|
|
3618
|
+
<option value="1" label="GLOBAL_Yes"></option>
|
|
3619
|
+
</options>
|
|
3620
|
+
<params>
|
|
3621
|
+
<param key="jagCheckbox" value="1"></param>
|
|
3622
|
+
</params>
|
|
3623
|
+
</widget>`;
|
|
3624
|
+
case AppFormItemTypes.TAGS: {
|
|
3625
|
+
const taxonomy = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === AppFieldFormPropertyTypes.TAXONOMY);
|
|
3626
|
+
if (!taxonomy)
|
|
3627
|
+
return '';
|
|
3628
|
+
const taxonomyId = taxonomy.value.id;
|
|
3629
|
+
return `<widget form="taxonomy">
|
|
3630
|
+
<params><param key="idTaxonomy" value="${taxonomyId}"></param></params>
|
|
3631
|
+
</widget>`;
|
|
3657
3632
|
}
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3633
|
+
case AppFormItemTypes.CHECKBOX: {
|
|
3634
|
+
const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
|
|
3635
|
+
if (!optionEditor)
|
|
3636
|
+
return '';
|
|
3637
|
+
const options = optionEditor.value.propertyOptions;
|
|
3638
|
+
return `<widget form="checkbox" multiple="1">
|
|
3639
|
+
<options>
|
|
3640
|
+
${options
|
|
3641
|
+
.map((option) => `<option value="${option.value}" label="${option.title}"></option>`)
|
|
3642
|
+
.join('')}
|
|
3643
|
+
</options>
|
|
3644
|
+
</widget>`;
|
|
3661
3645
|
}
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3646
|
+
case AppFormItemTypes.ADDFILEATTACHMENT:
|
|
3647
|
+
return `<widget form="file" type="fileArticle" multiple="1"></widget>`;
|
|
3648
|
+
case AppFormItemTypes.URL:
|
|
3649
|
+
return `<widget form="url"></widget>`;
|
|
3650
|
+
case AppFormItemTypes.EMAIL:
|
|
3651
|
+
return `<widget form="email"></widget>`;
|
|
3652
|
+
case ExtraAppFieldsItemViews.USER:
|
|
3653
|
+
return `<widget form="idUser"></widget>`;
|
|
3654
|
+
case AppFormItemTypes.USERLINK:
|
|
3655
|
+
return `<widget form="uri">
|
|
3656
|
+
<params>
|
|
3657
|
+
<param key="mode" value="ng-view"></param>
|
|
3658
|
+
<param key="class" value="jcomplete"></param>
|
|
3659
|
+
<param key="namespace" value="jamespot"></param>
|
|
3660
|
+
<param key="types" value="user"></param>
|
|
3661
|
+
<param key="views" value="user"></param>
|
|
3662
|
+
<param key="jcomplete-url" value="/?action=ajax&group=autocomplete&function=user"></param>
|
|
3663
|
+
</params>
|
|
3664
|
+
</widget>`;
|
|
3665
|
+
case AppFormItemTypes.CONTENTLINK: {
|
|
3666
|
+
const contentType = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === AppFieldFormPropertyTypes.CONTENTTYPE);
|
|
3667
|
+
if (!contentType)
|
|
3668
|
+
return '';
|
|
3669
|
+
const type = contentType.value.type;
|
|
3670
|
+
return `<widget form="uri">
|
|
3671
|
+
<params>
|
|
3672
|
+
<param key="mode" value="ng-view"></param>
|
|
3673
|
+
<param key="namespace" value="jamespot"></param>
|
|
3674
|
+
<param key="types" value="${type}"></param>
|
|
3675
|
+
<param key="views" value="article"></param>
|
|
3676
|
+
<param key="jcomplete-url" value="/?action=ajax&group=autocomplete&function=article&types=[]=${type}"></param>
|
|
3677
|
+
</params>
|
|
3678
|
+
</widget>`;
|
|
3667
3679
|
}
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
registeredFields.set('image', indexCreated);
|
|
3671
|
-
return [indexCreated, undefined];
|
|
3672
|
-
}
|
|
3673
|
-
else if (viewComponent.element === 'publishTo') {
|
|
3674
|
-
return [-1, { ref: 'publishTo', fixedValue: undefined }];
|
|
3680
|
+
default:
|
|
3681
|
+
return '';
|
|
3675
3682
|
}
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3683
|
+
}
|
|
3684
|
+
function renderProperty(properties, propertyToFind) {
|
|
3685
|
+
const labelProperty = properties === null || properties === void 0 ? void 0 : properties.find((property) => property.propertyType === propertyToFind);
|
|
3686
|
+
if (labelProperty) {
|
|
3687
|
+
return `${propertyToFind.toLowerCase()}="${labelProperty.value}"`;
|
|
3679
3688
|
}
|
|
3689
|
+
return '';
|
|
3680
3690
|
}
|
|
3681
|
-
function
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3691
|
+
function renderSqlName(fieldType, fieldId) {
|
|
3692
|
+
switch (fieldType) {
|
|
3693
|
+
case AppFormItemTypes.DESCRIPTION:
|
|
3694
|
+
return 'Description';
|
|
3695
|
+
case ExtraAppFieldsItemViews.USER:
|
|
3696
|
+
return 'IdUser';
|
|
3697
|
+
default:
|
|
3698
|
+
return uuid2Alpha(fieldId);
|
|
3699
|
+
}
|
|
3700
|
+
}
|
|
3701
|
+
function renderSolrType(fieldType) {
|
|
3702
|
+
switch (fieldType) {
|
|
3703
|
+
case AppFormItemTypes.DESCRIPTION:
|
|
3704
|
+
case AppFormItemTypes.TEXT:
|
|
3705
|
+
case AppFormItemTypes.TEXTAREA:
|
|
3706
|
+
case AppFormItemTypes.TEXTAREAHTML:
|
|
3707
|
+
case AppFormItemTypes.URL:
|
|
3708
|
+
case AppFormItemTypes.EMAIL:
|
|
3709
|
+
case AppFormItemTypes.USERLINK:
|
|
3710
|
+
case AppFormItemTypes.CONTENTLINK:
|
|
3711
|
+
case AppFormItemTypes.NUMBER:
|
|
3712
|
+
case AppFormItemTypes.ADDFILEATTACHMENT:
|
|
3713
|
+
return 'text';
|
|
3714
|
+
case AppFormItemTypes.DATE:
|
|
3715
|
+
case AppFormItemTypes.DATETIME:
|
|
3716
|
+
return 'date';
|
|
3717
|
+
case ExtraAppFieldsItemViews.USER:
|
|
3718
|
+
return 'integer';
|
|
3719
|
+
case AppFormItemTypes.SELECT:
|
|
3720
|
+
case AppFormItemTypes.RADIO:
|
|
3721
|
+
case AppFormItemTypes.TOGGLE:
|
|
3722
|
+
case AppFormItemTypes.CHECKBOX:
|
|
3723
|
+
case AppFormItemTypes.TAGS:
|
|
3724
|
+
return 'string';
|
|
3725
|
+
default:
|
|
3726
|
+
return '';
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
function renderFieldTypeToXmlType(fieldType) {
|
|
3730
|
+
switch (fieldType) {
|
|
3731
|
+
default:
|
|
3732
|
+
case AppFormItemTypes.DESCRIPTION:
|
|
3733
|
+
case AppFormItemTypes.TEXTAREAHTML:
|
|
3734
|
+
return 'html';
|
|
3735
|
+
case AppFormItemTypes.TAGS:
|
|
3736
|
+
return 'taxonomy';
|
|
3737
|
+
case AppFormItemTypes.TEXT:
|
|
3738
|
+
case AppFormItemTypes.RADIO:
|
|
3739
|
+
case AppFormItemTypes.URL:
|
|
3740
|
+
case AppFormItemTypes.EMAIL:
|
|
3741
|
+
case AppFormItemTypes.ADDFILEATTACHMENT:
|
|
3742
|
+
case ExtraAppFieldsItemViews.USER:
|
|
3743
|
+
case AppFormItemTypes.USERLINK:
|
|
3744
|
+
case AppFormItemTypes.CONTENTLINK:
|
|
3745
|
+
return 'text';
|
|
3746
|
+
case AppFormItemTypes.TEXTAREA:
|
|
3747
|
+
case AppFormItemTypes.CHECKBOX:
|
|
3748
|
+
case AppFormItemTypes.SELECT:
|
|
3749
|
+
return 'longtext';
|
|
3750
|
+
case AppFormItemTypes.DATE:
|
|
3751
|
+
return 'date';
|
|
3752
|
+
case AppFormItemTypes.DATETIME: {
|
|
3753
|
+
return 'date';
|
|
3721
3754
|
}
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3755
|
+
case AppFormItemTypes.NUMBER:
|
|
3756
|
+
return 'float';
|
|
3757
|
+
}
|
|
3725
3758
|
}
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
let
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3759
|
+
const uuid2Alpha = (id) => {
|
|
3760
|
+
let alphaUuid = '';
|
|
3761
|
+
for (let i = 0; i < id.length; i++) {
|
|
3762
|
+
const c = id.charAt(i);
|
|
3763
|
+
if (c >= '0' && c <= '9')
|
|
3764
|
+
alphaUuid += numToAlpha(Number(c));
|
|
3765
|
+
else if (c >= 'a' && c <= 'z')
|
|
3766
|
+
alphaUuid += c;
|
|
3733
3767
|
}
|
|
3734
|
-
|
|
3735
|
-
|
|
3768
|
+
return alphaUuid;
|
|
3769
|
+
};
|
|
3770
|
+
const numToAlpha = (num) => {
|
|
3771
|
+
let s = '', t;
|
|
3772
|
+
while (num > 0) {
|
|
3773
|
+
t = (num - 1) % 26;
|
|
3774
|
+
s = String.fromCharCode(97 + t) + s;
|
|
3775
|
+
num = ((num - t) / 26) | 0;
|
|
3736
3776
|
}
|
|
3737
|
-
return
|
|
3777
|
+
return s;
|
|
3778
|
+
};
|
|
3779
|
+
const internal2XmlView = {
|
|
3780
|
+
create: 'create',
|
|
3781
|
+
popup: 'create-popup',
|
|
3782
|
+
edit: 'edit',
|
|
3783
|
+
view: 'display',
|
|
3784
|
+
};
|
|
3785
|
+
function renderDisplays(studioApp) {
|
|
3786
|
+
let toRet = '';
|
|
3787
|
+
Object.entries(studioApp.views).forEach(([viewName, viewContent]) => {
|
|
3788
|
+
if (Object.prototype.hasOwnProperty.call(internal2XmlView, viewName)) {
|
|
3789
|
+
const viewField = Object.entries(viewContent)
|
|
3790
|
+
.filter((a) => a[1].isUsed)
|
|
3791
|
+
.sort((a, b) => a[1].pos - b[1].pos);
|
|
3792
|
+
toRet += `<display view="${internal2XmlView[viewName]}" mode="${viewName === 'view' ? 'view' : 'form'}">
|
|
3793
|
+
${viewField.map(([fieldId, view]) => renderDisplayAttr(fieldId, view)).join('')}
|
|
3794
|
+
</display>`;
|
|
3795
|
+
}
|
|
3796
|
+
});
|
|
3797
|
+
if (toRet.length > 0) {
|
|
3798
|
+
toRet = `<displays type="${studioApp.idApp}">${toRet}</displays>`;
|
|
3799
|
+
}
|
|
3800
|
+
return toRet;
|
|
3738
3801
|
}
|
|
3739
|
-
function
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3802
|
+
function getDisplayName(fieldId, view) {
|
|
3803
|
+
switch (view.type) {
|
|
3804
|
+
case ExtraAppFieldsItemViews.TITLE:
|
|
3805
|
+
return 'title';
|
|
3806
|
+
case ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS:
|
|
3807
|
+
return 'sendAlert';
|
|
3808
|
+
case ExtraAppFieldsItemViews.RECEIVEACOPY:
|
|
3809
|
+
return 'alertAuthor';
|
|
3810
|
+
case ExtraAppFieldsItemViews.PUBLISHTO:
|
|
3811
|
+
return 'publishTo';
|
|
3812
|
+
case ExtraAppFieldsItemViews.USER:
|
|
3813
|
+
return 'idUser';
|
|
3814
|
+
case ExtraAppFieldsItemViews.CREATIONDATE:
|
|
3815
|
+
return 'dateCreation';
|
|
3816
|
+
case AppFormItemTypes.DESCRIPTION:
|
|
3817
|
+
return 'description';
|
|
3818
|
+
default:
|
|
3819
|
+
return uuid2Alpha(fieldId);
|
|
3753
3820
|
}
|
|
3754
3821
|
}
|
|
3755
|
-
function
|
|
3822
|
+
function renderDisplayAttr(fieldId, view) {
|
|
3756
3823
|
var _a, _b, _c;
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
if (
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
if (((_b = installedField.widget.params) === null || _b === void 0 ? void 0 : _b.views) === 'user') {
|
|
3783
|
-
return AppFormItemTypes.USERLINK;
|
|
3784
|
-
}
|
|
3785
|
-
if (((_c = installedField.widget.params) === null || _c === void 0 ? void 0 : _c.views) === 'article') {
|
|
3786
|
-
return AppFormItemTypes.CONTENTLINK;
|
|
3824
|
+
let xml = '';
|
|
3825
|
+
const attrName = getDisplayName(fieldId, view);
|
|
3826
|
+
const isFixed = view.isLockedValue;
|
|
3827
|
+
if (isFixed) {
|
|
3828
|
+
const formItemRefWithName = {
|
|
3829
|
+
ref: attrName,
|
|
3830
|
+
fixedValue: view.value,
|
|
3831
|
+
};
|
|
3832
|
+
xml += `<html><![CDATA[ <!-- <JAMESPOT.STUDIO.FIXED>${JSON.stringify(formItemRefWithName)}</JAMESPOT.STUDIO.FIXED> -->`;
|
|
3833
|
+
if (view.type === ExtraAppFieldsItemViews.PUBLISHTO) {
|
|
3834
|
+
const uris = view.value.map((user) => user.uri).join(',');
|
|
3835
|
+
xml += `<input type="hidden" name="publishTo" value="${uris}">`;
|
|
3836
|
+
}
|
|
3837
|
+
else if (view.type === ExtraAppFieldsItemViews.USER ||
|
|
3838
|
+
view.type === AppFormItemTypes.USERLINK ||
|
|
3839
|
+
view.type === AppFormItemTypes.CONTENTLINK) {
|
|
3840
|
+
xml += `<input type="hidden" name="${attrName}[]" value=${JSON.stringify(view.value.uri)}>`;
|
|
3841
|
+
}
|
|
3842
|
+
else if (view.type === AppFormItemTypes.SELECT) {
|
|
3843
|
+
const canSelectMultiple = (_a = view.properties.find((property) => property.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR)) === null || _a === void 0 ? void 0 : _a.value.canSelectMultiple;
|
|
3844
|
+
if (canSelectMultiple) {
|
|
3845
|
+
const values = view.value;
|
|
3846
|
+
values.forEach((value) => {
|
|
3847
|
+
xml += `<input type="hidden" name="${attrName}[]" value="${value.value}">`;
|
|
3848
|
+
});
|
|
3787
3849
|
}
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
if (installedField.attrType === 'longtext') {
|
|
3791
|
-
return AppFormItemTypes.TEXTAREA;
|
|
3850
|
+
else {
|
|
3851
|
+
xml += `<input type="hidden" name="${attrName}" value="${view.value.value}">`;
|
|
3792
3852
|
}
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3853
|
+
}
|
|
3854
|
+
else if (view.type === AppFormItemTypes.CHECKBOX) {
|
|
3855
|
+
const values = view.value;
|
|
3856
|
+
values.forEach((value) => {
|
|
3857
|
+
xml += `<input type="hidden" name="${attrName}[]" value="${value}">`;
|
|
3858
|
+
});
|
|
3859
|
+
}
|
|
3860
|
+
else if (view.type === AppFormItemTypes.DATE) {
|
|
3861
|
+
const dateValue = new Date(view.value);
|
|
3862
|
+
const xmlFixedValue = [
|
|
3863
|
+
pad(dateValue.getDate()),
|
|
3864
|
+
pad(dateValue.getMonth() + 1),
|
|
3865
|
+
dateValue.getFullYear(),
|
|
3866
|
+
].join('/');
|
|
3867
|
+
xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
|
|
3868
|
+
}
|
|
3869
|
+
else if (view.type === AppFormItemTypes.DATETIME) {
|
|
3870
|
+
const dateValue = new Date(view.value);
|
|
3871
|
+
const xmlFixedValue = `${[
|
|
3872
|
+
pad(dateValue.getDate()),
|
|
3873
|
+
pad(dateValue.getMonth() + 1),
|
|
3874
|
+
dateValue.getFullYear(),
|
|
3875
|
+
].join('/')} ${pad(dateValue.getHours())}:${pad(dateValue.getMinutes())}:${pad(dateValue.getSeconds())}`;
|
|
3876
|
+
xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
|
|
3877
|
+
}
|
|
3878
|
+
else if (view.type === AppFormItemTypes.TAGS) {
|
|
3879
|
+
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(',')}">`;
|
|
3880
|
+
}
|
|
3881
|
+
else if (view.type === AppFormItemTypes.DESCRIPTION || view.type === AppFormItemTypes.TEXTAREAHTML) {
|
|
3882
|
+
xml += `<input type="hidden" name="${attrName}" value="${view.value}">`;
|
|
3883
|
+
}
|
|
3884
|
+
else if (view.type === ExtraAppFieldsItemViews.RECEIVEACOPY) {
|
|
3885
|
+
if (view.value) {
|
|
3886
|
+
xml += `<input type="hidden" name="alertAuthor[jamespot]"><input type="hidden" name="alertAuthor[]" value="1">`;
|
|
3798
3887
|
}
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
}
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
type: ExtraAppFieldsItemViews.TITLE,
|
|
3810
|
-
properties: [],
|
|
3811
|
-
isUsed: true,
|
|
3812
|
-
isOptional: false,
|
|
3813
|
-
isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
|
|
3814
|
-
isFixed: true,
|
|
3815
|
-
value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : null,
|
|
3816
|
-
pos: 0,
|
|
3817
|
-
};
|
|
3818
|
-
}
|
|
3819
|
-
function addAlertAuthorToView(newName, appS, fixedInfo) {
|
|
3820
|
-
const fieldId = 'alertAuthor';
|
|
3821
|
-
appS.views[newName][fieldId] = {
|
|
3822
|
-
type: ExtraAppFieldsItemViews.RECEIVEACOPY,
|
|
3823
|
-
properties: [],
|
|
3824
|
-
isUsed: true,
|
|
3825
|
-
isOptional: true,
|
|
3826
|
-
isLockedValue: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined,
|
|
3827
|
-
isFixed: false,
|
|
3828
|
-
value: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined ? fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue : true,
|
|
3829
|
-
pos: 300,
|
|
3830
|
-
};
|
|
3831
|
-
}
|
|
3832
|
-
function addSendAlertToView(newName, appS, fixedInfo) {
|
|
3833
|
-
const fieldId = 'sendAlert';
|
|
3834
|
-
appS.views[newName][fieldId] = {
|
|
3835
|
-
type: ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
|
|
3836
|
-
properties: [],
|
|
3837
|
-
isUsed: true,
|
|
3838
|
-
isOptional: true,
|
|
3839
|
-
isLockedValue: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined,
|
|
3840
|
-
isFixed: false,
|
|
3841
|
-
value: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined ? fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue : true,
|
|
3842
|
-
pos: 200,
|
|
3843
|
-
};
|
|
3844
|
-
}
|
|
3845
|
-
function addPublishToToView(newName, appS, fixedInfo) {
|
|
3846
|
-
var _a;
|
|
3847
|
-
const fieldId = 'publishTo';
|
|
3848
|
-
appS.views[newName][fieldId] = {
|
|
3849
|
-
type: ExtraAppFieldsItemViews.PUBLISHTO,
|
|
3850
|
-
properties: [],
|
|
3851
|
-
isUsed: true,
|
|
3852
|
-
isOptional: true,
|
|
3853
|
-
isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
|
|
3854
|
-
isFixed: false,
|
|
3855
|
-
value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : [],
|
|
3856
|
-
pos: 100,
|
|
3857
|
-
};
|
|
3858
|
-
}
|
|
3859
|
-
function addUserToView(newName, appS) {
|
|
3860
|
-
const fieldId = 'user';
|
|
3861
|
-
appS.views[newName][fieldId] = {
|
|
3862
|
-
type: ExtraAppFieldsItemViews.USER,
|
|
3863
|
-
properties: [],
|
|
3864
|
-
isUsed: true,
|
|
3865
|
-
isOptional: false,
|
|
3866
|
-
isLockedValue: false,
|
|
3867
|
-
isFixed: true,
|
|
3868
|
-
value: null,
|
|
3869
|
-
pos: 1,
|
|
3870
|
-
};
|
|
3871
|
-
}
|
|
3872
|
-
function addDateCreationToView(newName, appS) {
|
|
3873
|
-
const fieldId = 'dateCreation';
|
|
3874
|
-
appS.views[newName][fieldId] = {
|
|
3875
|
-
type: ExtraAppFieldsItemViews.CREATIONDATE,
|
|
3876
|
-
properties: [],
|
|
3877
|
-
isUsed: true,
|
|
3878
|
-
isOptional: true,
|
|
3879
|
-
isLockedValue: false,
|
|
3880
|
-
isFixed: false,
|
|
3881
|
-
value: null,
|
|
3882
|
-
pos: 100,
|
|
3883
|
-
};
|
|
3884
|
-
}
|
|
3885
|
-
|
|
3886
|
-
function InstalledAppStudioAdapter(serverApp, serverApps, state) {
|
|
3887
|
-
var _a, _b, _c, _d;
|
|
3888
|
-
const { version, dateCreation } = serverApp.manifest;
|
|
3889
|
-
const appTypeServer = serverApp.typeModel;
|
|
3890
|
-
const views = Object.assign({}, ...viewsList.map((view) => ({
|
|
3891
|
-
[view]: {},
|
|
3892
|
-
})));
|
|
3893
|
-
const studioApp = {
|
|
3894
|
-
idApp: serverApp.idApp,
|
|
3895
|
-
status: _formatStatus(serverApp),
|
|
3896
|
-
studioVersion: 2,
|
|
3897
|
-
manifest: {
|
|
3898
|
-
appShortName: serverApp.label,
|
|
3899
|
-
appName: serverApp.label,
|
|
3900
|
-
description: serverApp.description,
|
|
3901
|
-
author: serverApp.author,
|
|
3902
|
-
cssColor: (_a = appTypeServer.cssColor) !== null && _a !== void 0 ? _a : '#392994',
|
|
3903
|
-
cssClass: { label: (_b = appTypeServer.cssClass) !== null && _b !== void 0 ? _b : 'star', value: (_c = appTypeServer.cssClass) !== null && _c !== void 0 ? _c : 'star' },
|
|
3904
|
-
version: version,
|
|
3905
|
-
dateCreation: dateCreation,
|
|
3906
|
-
checkAccess: false,
|
|
3907
|
-
accessRightList: "",
|
|
3908
|
-
attrExposed: [],
|
|
3909
|
-
viewSolr: serverApp.view ? STUDIO_VIEW.SOLR : STUDIO_VIEW.NOT_SOLR,
|
|
3910
|
-
typeLabel: appTypeServer.typeLabel,
|
|
3911
|
-
articlesCount: (_d = serverApp.articlesCount) !== null && _d !== void 0 ? _d : 0,
|
|
3912
|
-
},
|
|
3913
|
-
fields: [],
|
|
3914
|
-
views,
|
|
3915
|
-
installFor: serverApp.accessRightObjectList ? buildAudience(serverApp.accessRightObjectList) : [],
|
|
3916
|
-
audience: serverApp.checkAccess === false ? AUDIENCE.ALL : AUDIENCE.CUSTOM,
|
|
3917
|
-
};
|
|
3918
|
-
populateFieldsAndViews(serverApp, studioApp, state);
|
|
3919
|
-
studioApp.views = updateViewsFromFields(studioApp, studioApp.fields);
|
|
3920
|
-
const inWorkAppVersion = _findAssociatedDraft(serverApp.idApp, serverApps);
|
|
3921
|
-
if (!inWorkAppVersion)
|
|
3922
|
-
return studioApp;
|
|
3923
|
-
const inWorkApp = DraftAppStudioAdapter(inWorkAppVersion);
|
|
3924
|
-
if (!inWorkApp)
|
|
3925
|
-
return studioApp;
|
|
3926
|
-
studioApp.inWorkVersion = inWorkApp;
|
|
3927
|
-
return studioApp;
|
|
3928
|
-
}
|
|
3929
|
-
function DraftAppStudioAdapter(serverApp) {
|
|
3930
|
-
if (!serverApp.value)
|
|
3931
|
-
return undefined;
|
|
3932
|
-
const parsedJson = JSON.parse(serverApp.value);
|
|
3933
|
-
if (parsedJson.studioVersion == 2) {
|
|
3934
|
-
return {
|
|
3935
|
-
idApp: serverApp.idApp,
|
|
3936
|
-
studioVersion: 2,
|
|
3937
|
-
status: _formatStatus(serverApp),
|
|
3938
|
-
manifest: parsedJson.manifest,
|
|
3939
|
-
fields: parsedJson.fields,
|
|
3940
|
-
views: parsedJson.views,
|
|
3941
|
-
syncViewFieldOrder: parsedJson.syncViewFieldOrder,
|
|
3942
|
-
audience: parsedJson.audience,
|
|
3943
|
-
installFor: parsedJson.installFor,
|
|
3944
|
-
};
|
|
3888
|
+
}
|
|
3889
|
+
else if (view.type === ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS) {
|
|
3890
|
+
if (view.value) {
|
|
3891
|
+
xml += `<input type="hidden" name="sendAlert[jamespot]"><input type="hidden" name="sendAlert[]" value="1">`;
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
else {
|
|
3895
|
+
xml += `<input type="hidden" name="${attrName}" value="${view.value}">`;
|
|
3896
|
+
}
|
|
3897
|
+
xml += ']]></html>';
|
|
3945
3898
|
}
|
|
3946
3899
|
else {
|
|
3947
|
-
|
|
3900
|
+
switch (view.type) {
|
|
3901
|
+
case AppFormItemTypes.CODEHTML: {
|
|
3902
|
+
const fieldToInclude = {
|
|
3903
|
+
id: fieldId,
|
|
3904
|
+
name: fieldId,
|
|
3905
|
+
properties: {
|
|
3906
|
+
code: view.value,
|
|
3907
|
+
},
|
|
3908
|
+
};
|
|
3909
|
+
xml += `<html><![CDATA[ <!-- <JAMESPOT.STUDIO.CODEHTML>${JSON.stringify(fieldToInclude)}</JAMESPOT.STUDIO.CODEHTML><JAMESPOT.STUDIO.FIELD_POS>${view.pos}</JAMESPOT.STUDIO.FIELD_POS>-->${view.value}]]></html>`;
|
|
3910
|
+
break;
|
|
3911
|
+
}
|
|
3912
|
+
case AppFormItemTypes.IMAGE:
|
|
3913
|
+
xml += '<image />';
|
|
3914
|
+
break;
|
|
3915
|
+
case ExtraAppFieldsItemViews.PUBLISHTO:
|
|
3916
|
+
xml += '<publishTo />';
|
|
3917
|
+
break;
|
|
3918
|
+
default:
|
|
3919
|
+
xml += "<attr name='" + attrName + "' />";
|
|
3920
|
+
break;
|
|
3921
|
+
}
|
|
3948
3922
|
}
|
|
3923
|
+
return xml;
|
|
3949
3924
|
}
|
|
3950
|
-
function
|
|
3951
|
-
return
|
|
3952
|
-
? serverApp.suspended
|
|
3953
|
-
? StatusType$1.suspended
|
|
3954
|
-
: StatusType$1.installed
|
|
3955
|
-
: StatusType$1.draft;
|
|
3956
|
-
}
|
|
3957
|
-
function _findAssociatedDraft(idApp, serverApps) {
|
|
3958
|
-
const draft = serverApps.find((app) => app.idApp === idApp && app.status === StudioApplicationStatus.saved);
|
|
3959
|
-
return draft;
|
|
3960
|
-
}
|
|
3961
|
-
function _findAssociatedInstalled(idApp, serverApps) {
|
|
3962
|
-
return !!serverApps.find((app) => app.idApp === idApp && app.status === StudioApplicationStatus.installed);
|
|
3963
|
-
}
|
|
3964
|
-
function serverAppsToStudioApps(serverApps, state) {
|
|
3965
|
-
const studioApps = serverApps
|
|
3966
|
-
.map((serverApp) => {
|
|
3967
|
-
if (serverApp.status === StudioApplicationStatus.installed) {
|
|
3968
|
-
return InstalledAppStudioAdapter(serverApp, serverApps, state);
|
|
3969
|
-
}
|
|
3970
|
-
else {
|
|
3971
|
-
if (_findAssociatedInstalled(serverApp.idApp, serverApps))
|
|
3972
|
-
return undefined;
|
|
3973
|
-
return DraftAppStudioAdapter(serverApp);
|
|
3974
|
-
}
|
|
3975
|
-
})
|
|
3976
|
-
.filter((app) => app !== undefined);
|
|
3977
|
-
return studioApps;
|
|
3925
|
+
function pad(s) {
|
|
3926
|
+
return s < 10 ? '0' + s : s;
|
|
3978
3927
|
}
|
|
3979
3928
|
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
cssClass="${manifest.cssClass.value}"
|
|
3995
|
-
cssColor="${manifest.cssColor}"
|
|
3996
|
-
searchtab="${studioApp.idApp}"
|
|
3997
|
-
searchtablabel="${manifest.typeLabel}"
|
|
3998
|
-
buttonlabel="${manifest.typeLabel}"
|
|
3999
|
-
extends="article">
|
|
4000
|
-
${renderPrimaryFields(studioApp.fields)}
|
|
4001
|
-
${renderCustomFields(studioApp.fields)}
|
|
4002
|
-
</objecttype>
|
|
4003
|
-
${renderDisplays(studioApp)}
|
|
4004
|
-
</Types>
|
|
4005
|
-
</Application>`;
|
|
4006
|
-
}
|
|
4007
|
-
function createAppManifest(manifest, views, audience, installFor, idApp) {
|
|
4008
|
-
var _a;
|
|
4009
|
-
return `<Manifest>
|
|
4010
|
-
<ShowImport>true</ShowImport>
|
|
4011
|
-
<AppShortName>${idApp}</AppShortName>
|
|
4012
|
-
<AppName>${manifest.appName}</AppName>
|
|
4013
|
-
<Description>${manifest.description}</Description>
|
|
4014
|
-
<Version>${manifest.version + 1}</Version>
|
|
4015
|
-
<ManifestVersion>1.0</ManifestVersion>
|
|
4016
|
-
<StudioVersion>2</StudioVersion>
|
|
4017
|
-
<DateCreation>${manifest.dateCreation.toString().split('T')[0]}</DateCreation>
|
|
4018
|
-
<CssClass>${(_a = manifest.cssClass) === null || _a === void 0 ? void 0 : _a.label}</CssClass>
|
|
4019
|
-
<CssColor>${manifest.cssColor}</CssColor>
|
|
4020
|
-
<Categories>N.A.</Categories>
|
|
4021
|
-
<Editor>Jamespot</Editor>
|
|
4022
|
-
<EditorUrl>https://www.fr.jamespot.com/</EditorUrl>
|
|
4023
|
-
<Type>${idApp}</Type>
|
|
4024
|
-
${renderAppView(manifest.viewSolr, views.list)}
|
|
4025
|
-
${renderAppSearch(views.filter)}
|
|
4026
|
-
${renderAudience(audience, installFor)}
|
|
4027
|
-
<Order>1</Order>
|
|
4028
|
-
</Manifest>`;
|
|
4029
|
-
}
|
|
4030
|
-
function renderAppView(viewSolr, listView) {
|
|
4031
|
-
if (viewSolr === STUDIO_VIEW.SOLR) {
|
|
4032
|
-
let xml = '<AppView>solr</AppView>';
|
|
4033
|
-
const formItemIdInList = [];
|
|
4034
|
-
Object.entries(listView)
|
|
4035
|
-
.sort((a, b) => a[1].pos - b[1].pos)
|
|
4036
|
-
.forEach(([fieldId, field]) => {
|
|
4037
|
-
if (!field.isUsed) {
|
|
4038
|
-
return;
|
|
3929
|
+
const installedToV2ViewNames = {
|
|
3930
|
+
'create-popup': 'popup',
|
|
3931
|
+
create: 'create',
|
|
3932
|
+
edit: 'edit',
|
|
3933
|
+
display: 'view',
|
|
3934
|
+
};
|
|
3935
|
+
const specialAttrName = ['title', 'alertAuthor', 'sendAlert'];
|
|
3936
|
+
const ignoredFields = ['edito'];
|
|
3937
|
+
function updateViewsFromFields(clonedApp, appFields) {
|
|
3938
|
+
return Object.assign({}, ...viewsList.map((view) => {
|
|
3939
|
+
const viewItems = {};
|
|
3940
|
+
Object.entries(clonedApp.views[view]).forEach(([fieldId, field]) => {
|
|
3941
|
+
if (field.isFixed) {
|
|
3942
|
+
viewItems[fieldId] = field;
|
|
4039
3943
|
}
|
|
4040
|
-
if (
|
|
3944
|
+
if (field.isOptional) {
|
|
3945
|
+
viewItems[fieldId] = field;
|
|
3946
|
+
}
|
|
3947
|
+
});
|
|
3948
|
+
appFields.forEach((field, idx) => {
|
|
3949
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3950
|
+
const isFieldUsedInView = field.views[view];
|
|
3951
|
+
const isExistingField = Object.keys(clonedApp.views[view]).includes(field.id);
|
|
3952
|
+
const fieldType = field.type;
|
|
3953
|
+
if (AppFormBannedFromViews$1.get(fieldType) && ((_a = AppFormBannedFromViews$1.get(fieldType)) === null || _a === void 0 ? void 0 : _a.includes(view))) {
|
|
4041
3954
|
return;
|
|
4042
3955
|
}
|
|
4043
|
-
|
|
3956
|
+
let fieldValue = undefined;
|
|
3957
|
+
if (fieldType === AppFormItemTypes.CODEHTML) {
|
|
3958
|
+
const richTextProperty = (_b = field.properties) === null || _b === void 0 ? void 0 : _b.find((prop) => prop.propertyType === AppFieldFormPropertyTypes.RICHTEXT);
|
|
3959
|
+
if (richTextProperty === null || richTextProperty === void 0 ? void 0 : richTextProperty.value) {
|
|
3960
|
+
fieldValue = richTextProperty === null || richTextProperty === void 0 ? void 0 : richTextProperty.value;
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
if (fieldType === AppFormItemTypes.SELECT) {
|
|
3964
|
+
const selectProperty = (_c = field.properties) === null || _c === void 0 ? void 0 : _c.find((prop) => prop.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
|
|
3965
|
+
if (isExistingField) {
|
|
3966
|
+
const exField = clonedApp.views[view][field.id];
|
|
3967
|
+
const exSelectProperty = (_d = exField.properties) === null || _d === void 0 ? void 0 : _d.find((prop) => prop.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
|
|
3968
|
+
const isMultivalued = !!((_e = selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.value) === null || _e === void 0 ? void 0 : _e.canSelectMultiple);
|
|
3969
|
+
const exIsMultivalued = !!((_f = exSelectProperty === null || exSelectProperty === void 0 ? void 0 : exSelectProperty.value) === null || _f === void 0 ? void 0 : _f.canSelectMultiple);
|
|
3970
|
+
if (isMultivalued === exIsMultivalued) {
|
|
3971
|
+
fieldValue = exField.value;
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
3974
|
+
else {
|
|
3975
|
+
const isEnhancedSelect = !!(selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.isOptionsEditorEnhanced);
|
|
3976
|
+
const defaultValue = isEnhancedSelect && !!(selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.value.defaultSelectOption)
|
|
3977
|
+
? selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.value.defaultSelectOptionValue
|
|
3978
|
+
: '';
|
|
3979
|
+
if (defaultValue) {
|
|
3980
|
+
fieldValue = defaultValue;
|
|
3981
|
+
}
|
|
3982
|
+
}
|
|
3983
|
+
}
|
|
3984
|
+
if (isExistingField) {
|
|
3985
|
+
const exField = clonedApp.views[view][field.id];
|
|
3986
|
+
viewItems[field.id] = Object.assign(Object.assign(Object.assign(Object.assign({}, exField), { properties: field.properties || exField.properties || [] }), (fieldValue !== undefined && { value: fieldValue })), { isUsed: isFieldUsedInView, pos: ((_g = clonedApp.syncViewFieldOrder) === null || _g === void 0 ? void 0 : _g[view]) ? idx : exField.pos, isLockedValue: (fieldValue !== undefined || exField.value !== undefined) && exField.isLockedValue });
|
|
3987
|
+
}
|
|
3988
|
+
else {
|
|
3989
|
+
const existingFieldsLen = Object.values(clonedApp.views[view]).filter((v) => !v.isFixed && !v.isOptional).length;
|
|
3990
|
+
viewItems[field.id] = {
|
|
3991
|
+
type: field.type,
|
|
3992
|
+
properties: field.properties || [],
|
|
3993
|
+
isUsed: isFieldUsedInView,
|
|
3994
|
+
isOptional: false,
|
|
3995
|
+
isLockedValue: false,
|
|
3996
|
+
isFixed: false,
|
|
3997
|
+
value: fieldValue !== null && fieldValue !== void 0 ? fieldValue : null,
|
|
3998
|
+
pos: ((_h = clonedApp.syncViewFieldOrder) === null || _h === void 0 ? void 0 : _h[view]) ? idx : existingFieldsLen + idx,
|
|
3999
|
+
};
|
|
4000
|
+
}
|
|
4044
4001
|
});
|
|
4045
|
-
|
|
4046
|
-
|
|
4002
|
+
return {
|
|
4003
|
+
[view]: viewItems,
|
|
4004
|
+
};
|
|
4005
|
+
}));
|
|
4006
|
+
}
|
|
4007
|
+
function buildAudience(accessRightObjectList) {
|
|
4008
|
+
return accessRightObjectList.map((accessRightObject) => {
|
|
4009
|
+
return {
|
|
4010
|
+
id: `${accessRightObject.type}/${accessRightObject.id}`,
|
|
4011
|
+
uri: `${accessRightObject.type}/${accessRightObject.id}`,
|
|
4012
|
+
shortUri: `${accessRightObject.type}/${accessRightObject.id}`,
|
|
4013
|
+
title: accessRightObject.title,
|
|
4014
|
+
name: accessRightObject.title,
|
|
4015
|
+
mainType: accessRightObject.type,
|
|
4016
|
+
type: accessRightObject.mainType,
|
|
4017
|
+
label: accessRightObject.type,
|
|
4018
|
+
cssClass: accessRightObject._cssClass,
|
|
4019
|
+
cssColor: accessRightObject._cssColor,
|
|
4020
|
+
class: accessRightObject._cssClass,
|
|
4021
|
+
Pseudo: accessRightObject.title,
|
|
4022
|
+
_url: accessRightObject._url,
|
|
4023
|
+
};
|
|
4024
|
+
});
|
|
4025
|
+
}
|
|
4026
|
+
function populateFieldsAndViews(app, appS, state) {
|
|
4027
|
+
const tables = app.typeModel.tables;
|
|
4028
|
+
const displays = app.typeModel.displays;
|
|
4029
|
+
if (!displays) {
|
|
4030
|
+
return;
|
|
4047
4031
|
}
|
|
4048
|
-
|
|
4032
|
+
const registeredFields = new Map();
|
|
4033
|
+
Object.entries(displays).forEach((displaysEntry) => {
|
|
4034
|
+
const [displayName, displayValue] = displaysEntry;
|
|
4035
|
+
if (Object.keys(installedToV2ViewNames).includes(displayName)) {
|
|
4036
|
+
buildView(appS, registeredFields, displayName, displayValue, tables, state);
|
|
4037
|
+
}
|
|
4038
|
+
});
|
|
4039
|
+
buildListView(appS, registeredFields, app.columns, tables, state);
|
|
4040
|
+
buildFilterView(appS, registeredFields, app.attrExposed, tables, state);
|
|
4049
4041
|
}
|
|
4050
|
-
function
|
|
4051
|
-
const
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
if (
|
|
4042
|
+
function buildView(appS, registeredFields, displayName, displayValue, tables, state) {
|
|
4043
|
+
const newName = installedToV2ViewNames[displayName];
|
|
4044
|
+
appS.views[newName] = {};
|
|
4045
|
+
displayValue.composants.forEach((viewComponent, index) => {
|
|
4046
|
+
let field = undefined;
|
|
4047
|
+
if (viewComponent.name && ignoredFields.includes(viewComponent.name)) {
|
|
4056
4048
|
return;
|
|
4057
4049
|
}
|
|
4058
|
-
const
|
|
4059
|
-
if (
|
|
4060
|
-
|
|
4050
|
+
const [fieldIdx, fixedInfo] = createOrGetField(appS, registeredFields, viewComponent, tables, state);
|
|
4051
|
+
if (fieldIdx === -1 && fixedInfo) {
|
|
4052
|
+
switch (fixedInfo.ref) {
|
|
4053
|
+
case 'title':
|
|
4054
|
+
addTitleToView(newName, appS, fixedInfo);
|
|
4055
|
+
break;
|
|
4056
|
+
case 'alertAuthor':
|
|
4057
|
+
addAlertAuthorToView(newName, appS, fixedInfo);
|
|
4058
|
+
break;
|
|
4059
|
+
case 'sendAlert':
|
|
4060
|
+
addSendAlertToView(newName, appS, fixedInfo);
|
|
4061
|
+
break;
|
|
4062
|
+
case 'publishTo':
|
|
4063
|
+
addPublishToToView(newName, appS, fixedInfo);
|
|
4064
|
+
break;
|
|
4065
|
+
default:
|
|
4066
|
+
console.error('fixed field info with unsupported ref ', fixedInfo);
|
|
4067
|
+
break;
|
|
4068
|
+
}
|
|
4069
|
+
}
|
|
4070
|
+
else if (fieldIdx !== -1) {
|
|
4071
|
+
field = appS.fields[fieldIdx];
|
|
4072
|
+
if (!field || !field.views) {
|
|
4073
|
+
throw new Error(`error converting installed app to V2: created field not found in fields array: ${fieldIdx}, ${fixedInfo}`);
|
|
4074
|
+
}
|
|
4075
|
+
field.views[newName] = true;
|
|
4076
|
+
addFieldToView(newName, field, appS, index, fixedInfo);
|
|
4077
|
+
}
|
|
4061
4078
|
});
|
|
4062
|
-
return `<AttrExposed>${formItemIdInFilter.join()}</AttrExposed>`;
|
|
4063
4079
|
}
|
|
4064
|
-
function
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
return 'title';
|
|
4068
|
-
if (field.type === ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS)
|
|
4069
|
-
return 'sendAlert';
|
|
4070
|
-
if (field.type === ExtraAppFieldsItemViews.RECEIVEACOPY)
|
|
4071
|
-
return 'alertAuthor';
|
|
4072
|
-
if (field.type === ExtraAppFieldsItemViews.PUBLISHTO)
|
|
4073
|
-
return 'publishTo';
|
|
4074
|
-
if (field.type === ExtraAppFieldsItemViews.USER)
|
|
4075
|
-
return 'idUser';
|
|
4076
|
-
if (field.type === ExtraAppFieldsItemViews.CREATIONDATE)
|
|
4077
|
-
return 'dateCreation';
|
|
4078
|
-
if (field.type === AppFormItemTypes.DESCRIPTION)
|
|
4079
|
-
return 'description';
|
|
4080
|
-
return field.type;
|
|
4080
|
+
function buildListView(appS, registeredFields, columns, tables, state) {
|
|
4081
|
+
if (!columns) {
|
|
4082
|
+
return;
|
|
4081
4083
|
}
|
|
4082
|
-
|
|
4084
|
+
Object.keys(columns).forEach((fieldRef, index) => {
|
|
4085
|
+
addFieldToViewFromRef(appS, registeredFields, tables, 'list', fieldRef, index, state);
|
|
4086
|
+
});
|
|
4083
4087
|
}
|
|
4084
|
-
function
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4088
|
+
function buildFilterView(appS, registeredFields, attrExposed, tables, state) {
|
|
4089
|
+
attrExposed.forEach((fieldRef, index) => {
|
|
4090
|
+
addFieldToViewFromRef(appS, registeredFields, tables, 'filter', fieldRef, index, state);
|
|
4091
|
+
});
|
|
4092
|
+
}
|
|
4093
|
+
function addFieldToViewFromRef(appS, registeredFields, tables, viewName, fieldRef, index, state) {
|
|
4094
|
+
switch (fieldRef) {
|
|
4095
|
+
case 'title':
|
|
4096
|
+
addTitleToView(viewName, appS, { ref: 'title', fixedValue: undefined });
|
|
4097
|
+
break;
|
|
4098
|
+
case 'iduser':
|
|
4099
|
+
case 'idUser':
|
|
4100
|
+
addUserToView(viewName, appS);
|
|
4101
|
+
break;
|
|
4102
|
+
case 'datecreation':
|
|
4103
|
+
case 'dateCreation':
|
|
4104
|
+
addDateCreationToView(viewName, appS);
|
|
4105
|
+
break;
|
|
4106
|
+
default:
|
|
4107
|
+
defaultFieldCreation(appS, registeredFields, tables, viewName, fieldRef, index, state);
|
|
4108
|
+
break;
|
|
4090
4109
|
}
|
|
4091
|
-
return '';
|
|
4092
4110
|
}
|
|
4093
|
-
function
|
|
4094
|
-
const
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4111
|
+
function defaultFieldCreation(appS, registeredFields, tables, viewName, fieldRef, index, state) {
|
|
4112
|
+
const fieldIndex = createOrGetFieldFromRef(appS, registeredFields, tables, fieldRef, state);
|
|
4113
|
+
const field = appS.fields[fieldIndex];
|
|
4114
|
+
if (!field || !field.views) {
|
|
4115
|
+
throw new Error(`error converting installed app to V2: unable to handle ${fieldRef} in list view`);
|
|
4116
|
+
}
|
|
4117
|
+
field.views[viewName] = true;
|
|
4118
|
+
addFieldToView(viewName, field, appS, index, undefined);
|
|
4098
4119
|
}
|
|
4099
|
-
function
|
|
4100
|
-
const
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
const
|
|
4105
|
-
|
|
4106
|
-
return
|
|
4107
|
-
${articlesTablesItems.length > 0
|
|
4108
|
-
? `<articlemstable>
|
|
4109
|
-
${articlesTablesItems.map((field) => formItem2xml(field)).join('')}
|
|
4110
|
-
</articlemstable>`
|
|
4111
|
-
: ''}
|
|
4112
|
-
${linksTableItems.length > 0
|
|
4113
|
-
? `<linkstable tablename="tag_links" sqlNameColumn="name" sqlSrcIdColumn="srcId" sqlSrcTypeColumn="srcType" sqlTargetIdColumn="targetId" sqlTargetTypeColumn="targetType">
|
|
4114
|
-
${linksTableItems.map((field) => formItem2xml(field)).join('')}
|
|
4115
|
-
</linkstable>`
|
|
4116
|
-
: ''}</custom>`;
|
|
4117
|
-
}
|
|
4118
|
-
function formItem2xml(field) {
|
|
4119
|
-
return `<field
|
|
4120
|
-
type="${renderFieldTypeToXmlType(field.type)}"
|
|
4121
|
-
name="${getAttrNameFormItem(field, field.id)}"
|
|
4122
|
-
sqlname="${renderSqlName(field.type, field.id)}"
|
|
4123
|
-
${field.properties && renderProperty(field.properties, AppFieldFormPropertyTypes.LABEL)}
|
|
4124
|
-
${field.properties && renderProperty(field.properties, AppFieldFormPropertyTypes.DESCRIPTION)}
|
|
4125
|
-
mandatory="${field.mandatory}"
|
|
4126
|
-
solr.type="${renderSolrType(field.type)}"
|
|
4127
|
-
solr.used="true"
|
|
4128
|
-
solr.indexed="true"
|
|
4129
|
-
solr.stored="true"
|
|
4130
|
-
solr.searchable="true"
|
|
4131
|
-
solr.multiValued="${field.type === AppFormItemTypes.TAGS ||
|
|
4132
|
-
field.type === AppFormItemTypes.CHECKBOX ||
|
|
4133
|
-
field.type === AppFormItemTypes.SELECT
|
|
4134
|
-
? true
|
|
4135
|
-
: false}"
|
|
4136
|
-
teaser="true"
|
|
4137
|
-
display="true"
|
|
4138
|
-
>
|
|
4139
|
-
${renderWidget(field.type, field.properties)}
|
|
4140
|
-
</field>`;
|
|
4120
|
+
function createOrGetFieldFromRef(appS, registeredFields, tables, fieldRef, state) {
|
|
4121
|
+
const knownIndex = registeredFields.get(fieldRef);
|
|
4122
|
+
if (knownIndex !== undefined) {
|
|
4123
|
+
return knownIndex;
|
|
4124
|
+
}
|
|
4125
|
+
const [ref, indexCreated] = createStudioDefinedField(appS, fieldRef, tables, state);
|
|
4126
|
+
registeredFields.set(ref, indexCreated);
|
|
4127
|
+
return indexCreated;
|
|
4141
4128
|
}
|
|
4142
|
-
function
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
return '<widget form="textarea"><params><param key="class" value="mceEditor"></param><param key="mention" value="1"></param></params></widget>';
|
|
4147
|
-
case AppFormItemTypes.TEXT:
|
|
4148
|
-
return '<widget form="text"></widget>';
|
|
4149
|
-
case AppFormItemTypes.TEXTAREA:
|
|
4150
|
-
return '<widget form="textarea"></widget>';
|
|
4151
|
-
case AppFormItemTypes.TEXTAREAHTML:
|
|
4152
|
-
return '<widget form="textarea"><params><param key="class" value="mceEditor"></param></params></widget>';
|
|
4153
|
-
case AppFormItemTypes.DATE:
|
|
4154
|
-
return '<widget form="date" format="d/m/Y"></widget>';
|
|
4155
|
-
case AppFormItemTypes.DATETIME:
|
|
4156
|
-
return `<widget form="datetime" format="d/m/Y H:i:s"></widget>`;
|
|
4157
|
-
case AppFormItemTypes.NUMBER: {
|
|
4158
|
-
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;
|
|
4159
|
-
return `<widget form="number">
|
|
4160
|
-
${isFloat ? `<params><param value="0.01" key="step"/></params>` : ''}
|
|
4161
|
-
</widget>`;
|
|
4129
|
+
function createOrGetField(appS, registeredFields, viewComponent, tables, state) {
|
|
4130
|
+
if (viewComponent.name !== undefined && viewComponent.element === 'attr') {
|
|
4131
|
+
if (specialAttrName.includes(viewComponent.name)) {
|
|
4132
|
+
return [-1, { ref: viewComponent.name, fixedValue: undefined }];
|
|
4162
4133
|
}
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
return '';
|
|
4167
|
-
const isMultiple = optionEditor.value.canSelectMultiple;
|
|
4168
|
-
const options = optionEditor.value.propertyOptions;
|
|
4169
|
-
const hasDefaultValue = optionEditor.value.defaultSelectOption;
|
|
4170
|
-
const defaultValue = optionEditor.value.defaultSelectOptionValue.value;
|
|
4171
|
-
const userCanModifiyByComment = optionEditor.value.userCanModifiyByComment;
|
|
4172
|
-
return `<widget form="select" ${isMultiple ? 'multiple="1"' : ''}>
|
|
4173
|
-
<options>
|
|
4174
|
-
${options
|
|
4175
|
-
.map((option) => `<option value="${option.value}" label="${option.title}"></option>`)
|
|
4176
|
-
.join('')}
|
|
4177
|
-
</options>
|
|
4178
|
-
${hasDefaultValue || userCanModifiyByComment
|
|
4179
|
-
? `<params>
|
|
4180
|
-
${hasDefaultValue ? `<param key="defaultValue" value="${defaultValue}"/>` : ''}
|
|
4181
|
-
${userCanModifiyByComment ? `<param key="explain" value="1"/>` : ''}
|
|
4182
|
-
</params>`
|
|
4183
|
-
: ''}
|
|
4184
|
-
</widget>`;
|
|
4134
|
+
const knownIndex = registeredFields.get(viewComponent.name);
|
|
4135
|
+
if (knownIndex !== undefined) {
|
|
4136
|
+
return [knownIndex, undefined];
|
|
4185
4137
|
}
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
.join('')}
|
|
4196
|
-
</options>
|
|
4197
|
-
</widget>`;
|
|
4138
|
+
const [ref, indexCreated] = createStudioDefinedField(appS, viewComponent.name, tables, state);
|
|
4139
|
+
registeredFields.set(ref, indexCreated);
|
|
4140
|
+
return [indexCreated, undefined];
|
|
4141
|
+
}
|
|
4142
|
+
else if (viewComponent.element === 'html') {
|
|
4143
|
+
const htmlCode = viewComponent.html;
|
|
4144
|
+
if (htmlCode === undefined) {
|
|
4145
|
+
console.error('error while parsing studio installed html attr in a view: no html code');
|
|
4146
|
+
return [-1, undefined];
|
|
4198
4147
|
}
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4148
|
+
if (htmlCode.includes('<JAMESPOT.STUDIO.FIXED>')) {
|
|
4149
|
+
const startPos = htmlCode.indexOf('<JAMESPOT.STUDIO.FIXED>') + '<JAMESPOT.STUDIO.FIXED>'.length;
|
|
4150
|
+
const endPos = htmlCode.indexOf('</JAMESPOT.STUDIO.FIXED>');
|
|
4151
|
+
const formItemRefString = htmlCode.substring(startPos, endPos);
|
|
4152
|
+
try {
|
|
4153
|
+
const formItemRef = JSON.parse(formItemRefString);
|
|
4154
|
+
if ((formItemRef === null || formItemRef === void 0 ? void 0 : formItemRef.ref.toUpperCase()) in ExtraAppFieldsItemViews) {
|
|
4155
|
+
const ref = formItemRef.ref.toUpperCase();
|
|
4156
|
+
return [-1, Object.assign(Object.assign({}, formItemRef), { ref: fieldType(ref) })];
|
|
4157
|
+
}
|
|
4158
|
+
if (specialAttrName.includes(formItemRef === null || formItemRef === void 0 ? void 0 : formItemRef.ref)) {
|
|
4159
|
+
return [-1, formItemRef];
|
|
4160
|
+
}
|
|
4161
|
+
const knownIndex = registeredFields.get(formItemRef === null || formItemRef === void 0 ? void 0 : formItemRef.ref);
|
|
4162
|
+
if (knownIndex !== undefined) {
|
|
4163
|
+
return [knownIndex, formItemRef];
|
|
4164
|
+
}
|
|
4165
|
+
const [ref, indexCreated] = createStudioDefinedField(appS, formItemRef.ref, tables, state);
|
|
4166
|
+
registeredFields.set(ref, indexCreated);
|
|
4167
|
+
return [indexCreated, formItemRef];
|
|
4168
|
+
}
|
|
4169
|
+
catch (_) {
|
|
4170
|
+
console.error('error while parsing studio installed fixed attr in a view: json parsing failed');
|
|
4171
|
+
return [-1, undefined];
|
|
4172
|
+
}
|
|
4216
4173
|
}
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4174
|
+
else if (htmlCode.includes('<JAMESPOT.STUDIO.CODEHTML>')) {
|
|
4175
|
+
try {
|
|
4176
|
+
const startPosCode = htmlCode.indexOf('<JAMESPOT.STUDIO.CODEHTML>') + '<JAMESPOT.STUDIO.CODEHTML>'.length;
|
|
4177
|
+
const endPosCode = htmlCode.indexOf('</JAMESPOT.STUDIO.CODEHTML>');
|
|
4178
|
+
const formItemString = htmlCode.substring(startPosCode, endPosCode);
|
|
4179
|
+
const formItem = JSON.parse(formItemString);
|
|
4180
|
+
const knownIndex = registeredFields.get(formItem === null || formItem === void 0 ? void 0 : formItem.name);
|
|
4181
|
+
if (knownIndex !== undefined) {
|
|
4182
|
+
return [knownIndex, undefined];
|
|
4183
|
+
}
|
|
4184
|
+
const htmlField = createHtmlField(formItem);
|
|
4185
|
+
const indexCreated = appS.fields.push(htmlField) - 1;
|
|
4186
|
+
registeredFields.set(htmlField.id, indexCreated);
|
|
4187
|
+
return [indexCreated, undefined];
|
|
4188
|
+
}
|
|
4189
|
+
catch (_) {
|
|
4190
|
+
console.error('error while parsing studio installed codehtml attr in a view: json parsing failed');
|
|
4191
|
+
return [-1, undefined];
|
|
4192
|
+
}
|
|
4229
4193
|
}
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
return `<widget form="url"></widget>`;
|
|
4234
|
-
case AppFormItemTypes.EMAIL:
|
|
4235
|
-
return `<widget form="email"></widget>`;
|
|
4236
|
-
case ExtraAppFieldsItemViews.USER:
|
|
4237
|
-
return `<widget form="idUser"></widget>`;
|
|
4238
|
-
case AppFormItemTypes.USERLINK:
|
|
4239
|
-
return `<widget form="uri">
|
|
4240
|
-
<params>
|
|
4241
|
-
<param key="mode" value="ng-view"></param>
|
|
4242
|
-
<param key="class" value="jcomplete"></param>
|
|
4243
|
-
<param key="namespace" value="jamespot"></param>
|
|
4244
|
-
<param key="types" value="user"></param>
|
|
4245
|
-
<param key="views" value="user"></param>
|
|
4246
|
-
<param key="jcomplete-url" value="/?action=ajax&group=autocomplete&function=user"></param>
|
|
4247
|
-
</params>
|
|
4248
|
-
</widget>`;
|
|
4249
|
-
case AppFormItemTypes.CONTENTLINK: {
|
|
4250
|
-
const contentType = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === AppFieldFormPropertyTypes.CONTENTTYPE);
|
|
4251
|
-
if (!contentType)
|
|
4252
|
-
return '';
|
|
4253
|
-
const type = contentType.value.type;
|
|
4254
|
-
return `<widget form="uri">
|
|
4255
|
-
<params>
|
|
4256
|
-
<param key="mode" value="ng-view"></param>
|
|
4257
|
-
<param key="namespace" value="jamespot"></param>
|
|
4258
|
-
<param key="types" value="${type}"></param>
|
|
4259
|
-
<param key="views" value="article"></param>
|
|
4260
|
-
<param key="jcomplete-url" value="/?action=ajax&group=autocomplete&function=article&types=[]=${type}"></param>
|
|
4261
|
-
</params>
|
|
4262
|
-
</widget>`;
|
|
4194
|
+
else {
|
|
4195
|
+
console.error('error while parsing studio installed html attr in a view: unknown html format');
|
|
4196
|
+
return [-1, undefined];
|
|
4263
4197
|
}
|
|
4264
|
-
|
|
4265
|
-
|
|
4198
|
+
}
|
|
4199
|
+
else if (viewComponent.element === 'image') {
|
|
4200
|
+
const knownIndex = registeredFields.get('image');
|
|
4201
|
+
if (knownIndex !== undefined) {
|
|
4202
|
+
return [knownIndex, undefined];
|
|
4203
|
+
}
|
|
4204
|
+
const imageField = createImageField();
|
|
4205
|
+
const indexCreated = appS.fields.push(imageField) - 1;
|
|
4206
|
+
registeredFields.set('image', indexCreated);
|
|
4207
|
+
return [indexCreated, undefined];
|
|
4208
|
+
}
|
|
4209
|
+
else if (viewComponent.element === 'publishTo') {
|
|
4210
|
+
return [-1, { ref: 'publishTo', fixedValue: undefined }];
|
|
4211
|
+
}
|
|
4212
|
+
else {
|
|
4213
|
+
console.error('error while parsing studio installed attr in a view: unknown attr :O');
|
|
4214
|
+
return [-1, undefined];
|
|
4266
4215
|
}
|
|
4267
4216
|
}
|
|
4268
|
-
function
|
|
4269
|
-
const
|
|
4270
|
-
|
|
4271
|
-
|
|
4217
|
+
function createStudioDefinedField(appS, ref, tables, state) {
|
|
4218
|
+
const installedField = getInstalledField(ref, tables);
|
|
4219
|
+
const type = getFormItemType(installedField);
|
|
4220
|
+
const v2Field = (function createField() {
|
|
4221
|
+
switch (type) {
|
|
4222
|
+
case AppFormItemTypes.ADDFILEATTACHMENT:
|
|
4223
|
+
return createAddfileattachmentField(installedField);
|
|
4224
|
+
case AppFormItemTypes.NUMBER:
|
|
4225
|
+
return createNumberField(installedField);
|
|
4226
|
+
case AppFormItemTypes.TAGS:
|
|
4227
|
+
return createTagsField(installedField);
|
|
4228
|
+
case AppFormItemTypes.SELECT:
|
|
4229
|
+
return createSelectField(installedField);
|
|
4230
|
+
case AppFormItemTypes.RADIO:
|
|
4231
|
+
return createRadioField(installedField);
|
|
4232
|
+
case AppFormItemTypes.CHECKBOX:
|
|
4233
|
+
return createCheckboxField(installedField);
|
|
4234
|
+
case AppFormItemTypes.CONTENTLINK:
|
|
4235
|
+
return createContentLinkField(installedField, state);
|
|
4236
|
+
case AppFormItemTypes.DESCRIPTION:
|
|
4237
|
+
return createDescriptionField(installedField);
|
|
4238
|
+
case AppFormItemTypes.TEXTAREAHTML:
|
|
4239
|
+
return createTextareaHTMLField(installedField);
|
|
4240
|
+
case AppFormItemTypes.DATE:
|
|
4241
|
+
return createDateField(installedField);
|
|
4242
|
+
case AppFormItemTypes.DATETIME:
|
|
4243
|
+
return createDatetimeField(installedField);
|
|
4244
|
+
case AppFormItemTypes.URL:
|
|
4245
|
+
return createUrlField(installedField);
|
|
4246
|
+
case AppFormItemTypes.EMAIL:
|
|
4247
|
+
return createEmailField(installedField);
|
|
4248
|
+
case AppFormItemTypes.TOGGLE:
|
|
4249
|
+
return createToggleField(installedField);
|
|
4250
|
+
case AppFormItemTypes.USERLINK:
|
|
4251
|
+
return createUserLinkField(installedField);
|
|
4252
|
+
case AppFormItemTypes.TEXTAREA:
|
|
4253
|
+
return createTextAreaField(installedField);
|
|
4254
|
+
case AppFormItemTypes.TEXT:
|
|
4255
|
+
default:
|
|
4256
|
+
return createTextField(installedField);
|
|
4257
|
+
}
|
|
4258
|
+
})();
|
|
4259
|
+
const index = appS.fields.push(v2Field) - 1;
|
|
4260
|
+
return [ref, index];
|
|
4261
|
+
}
|
|
4262
|
+
function getInstalledField(ref, tables) {
|
|
4263
|
+
var _a;
|
|
4264
|
+
let foundField = undefined;
|
|
4265
|
+
for (let i = 0; i < tables.length && !foundField; i++) {
|
|
4266
|
+
foundField = (_a = tables[i]) === null || _a === void 0 ? void 0 : _a.attributes.find((attr) => {
|
|
4267
|
+
return attr.name === ref;
|
|
4268
|
+
});
|
|
4272
4269
|
}
|
|
4273
|
-
|
|
4270
|
+
if (!foundField) {
|
|
4271
|
+
throw new Error('error converting installed app to V2: installed field not found in tables ' + ref);
|
|
4272
|
+
}
|
|
4273
|
+
return foundField;
|
|
4274
4274
|
}
|
|
4275
|
-
function
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4275
|
+
function addFieldToView(viewName, field, appS, index, fixedInfo) {
|
|
4276
|
+
var _a;
|
|
4277
|
+
if (field.views) {
|
|
4278
|
+
field.views[viewName] = true;
|
|
4279
|
+
appS.views[viewName][field.id] = {
|
|
4280
|
+
type: field.type,
|
|
4281
|
+
properties: field.properties || [],
|
|
4282
|
+
isUsed: true,
|
|
4283
|
+
isOptional: false,
|
|
4284
|
+
isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
|
|
4285
|
+
isFixed: false,
|
|
4286
|
+
value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : null,
|
|
4287
|
+
pos: index,
|
|
4288
|
+
};
|
|
4289
|
+
}
|
|
4290
|
+
}
|
|
4291
|
+
function getFormItemType(installedField) {
|
|
4292
|
+
var _a, _b, _c;
|
|
4293
|
+
switch (installedField.widget.type) {
|
|
4294
|
+
case 'number':
|
|
4295
|
+
return AppFormItemTypes.NUMBER;
|
|
4296
|
+
case 'taxonomy':
|
|
4297
|
+
return AppFormItemTypes.TAGS;
|
|
4298
|
+
case 'date':
|
|
4299
|
+
return AppFormItemTypes.DATE;
|
|
4300
|
+
case 'datetime':
|
|
4301
|
+
return AppFormItemTypes.DATETIME;
|
|
4302
|
+
case 'select':
|
|
4303
|
+
return AppFormItemTypes.SELECT;
|
|
4304
|
+
case 'radio':
|
|
4305
|
+
return AppFormItemTypes.RADIO;
|
|
4306
|
+
case 'url':
|
|
4307
|
+
return AppFormItemTypes.URL;
|
|
4308
|
+
case 'email':
|
|
4309
|
+
return AppFormItemTypes.EMAIL;
|
|
4310
|
+
case 'file':
|
|
4311
|
+
return AppFormItemTypes.ADDFILEATTACHMENT;
|
|
4312
|
+
case 'checkbox':
|
|
4313
|
+
if (((_a = installedField.widget.options) === null || _a === void 0 ? void 0 : _a['1']) === 'GLOBAL_Yes') {
|
|
4314
|
+
return AppFormItemTypes.TOGGLE;
|
|
4315
|
+
}
|
|
4316
|
+
return AppFormItemTypes.CHECKBOX;
|
|
4317
|
+
case 'uri':
|
|
4318
|
+
if (((_b = installedField.widget.params) === null || _b === void 0 ? void 0 : _b.views) === 'user') {
|
|
4319
|
+
return AppFormItemTypes.USERLINK;
|
|
4320
|
+
}
|
|
4321
|
+
if (((_c = installedField.widget.params) === null || _c === void 0 ? void 0 : _c.views) === 'article') {
|
|
4322
|
+
return AppFormItemTypes.CONTENTLINK;
|
|
4323
|
+
}
|
|
4324
|
+
break;
|
|
4325
|
+
case 'textarea':
|
|
4326
|
+
if (installedField.attrType === 'longtext' || installedField.attrType === 'text') {
|
|
4327
|
+
return AppFormItemTypes.TEXTAREA;
|
|
4328
|
+
}
|
|
4329
|
+
if (installedField.attrType === 'html') {
|
|
4330
|
+
if (installedField.name === 'description') {
|
|
4331
|
+
return AppFormItemTypes.DESCRIPTION;
|
|
4332
|
+
}
|
|
4333
|
+
return AppFormItemTypes.TEXTAREAHTML;
|
|
4334
|
+
}
|
|
4335
|
+
break;
|
|
4336
|
+
case 'text':
|
|
4337
|
+
return AppFormItemTypes.TEXT;
|
|
4283
4338
|
}
|
|
4339
|
+
throw new Error('error converting installed app to V2: installed field type not recognized for field ' +
|
|
4340
|
+
installedField.name +
|
|
4341
|
+
':' +
|
|
4342
|
+
JSON.stringify(installedField));
|
|
4343
|
+
}
|
|
4344
|
+
function addTitleToView(newName, appS, fixedInfo) {
|
|
4345
|
+
var _a;
|
|
4346
|
+
const fieldId = 'title';
|
|
4347
|
+
appS.views[newName][fieldId] = {
|
|
4348
|
+
type: ExtraAppFieldsItemViews.TITLE,
|
|
4349
|
+
properties: [],
|
|
4350
|
+
isUsed: true,
|
|
4351
|
+
isOptional: false,
|
|
4352
|
+
isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
|
|
4353
|
+
isFixed: true,
|
|
4354
|
+
value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : null,
|
|
4355
|
+
pos: 0,
|
|
4356
|
+
};
|
|
4357
|
+
}
|
|
4358
|
+
function addAlertAuthorToView(newName, appS, fixedInfo) {
|
|
4359
|
+
const fieldId = 'alertAuthor';
|
|
4360
|
+
appS.views[newName][fieldId] = {
|
|
4361
|
+
type: ExtraAppFieldsItemViews.RECEIVEACOPY,
|
|
4362
|
+
properties: [],
|
|
4363
|
+
isUsed: true,
|
|
4364
|
+
isOptional: true,
|
|
4365
|
+
isLockedValue: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined,
|
|
4366
|
+
isFixed: false,
|
|
4367
|
+
value: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined ? fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue : true,
|
|
4368
|
+
pos: 300,
|
|
4369
|
+
};
|
|
4370
|
+
}
|
|
4371
|
+
function addSendAlertToView(newName, appS, fixedInfo) {
|
|
4372
|
+
const fieldId = 'sendAlert';
|
|
4373
|
+
appS.views[newName][fieldId] = {
|
|
4374
|
+
type: ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
|
|
4375
|
+
properties: [],
|
|
4376
|
+
isUsed: true,
|
|
4377
|
+
isOptional: true,
|
|
4378
|
+
isLockedValue: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined,
|
|
4379
|
+
isFixed: false,
|
|
4380
|
+
value: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined ? fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue : true,
|
|
4381
|
+
pos: 200,
|
|
4382
|
+
};
|
|
4383
|
+
}
|
|
4384
|
+
function addPublishToToView(newName, appS, fixedInfo) {
|
|
4385
|
+
var _a;
|
|
4386
|
+
const fieldId = 'publishTo';
|
|
4387
|
+
appS.views[newName][fieldId] = {
|
|
4388
|
+
type: ExtraAppFieldsItemViews.PUBLISHTO,
|
|
4389
|
+
properties: [],
|
|
4390
|
+
isUsed: true,
|
|
4391
|
+
isOptional: true,
|
|
4392
|
+
isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
|
|
4393
|
+
isFixed: false,
|
|
4394
|
+
value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : [],
|
|
4395
|
+
pos: 100,
|
|
4396
|
+
};
|
|
4397
|
+
}
|
|
4398
|
+
function addUserToView(newName, appS) {
|
|
4399
|
+
const fieldId = 'user';
|
|
4400
|
+
appS.views[newName][fieldId] = {
|
|
4401
|
+
type: ExtraAppFieldsItemViews.USER,
|
|
4402
|
+
properties: [],
|
|
4403
|
+
isUsed: true,
|
|
4404
|
+
isOptional: false,
|
|
4405
|
+
isLockedValue: false,
|
|
4406
|
+
isFixed: true,
|
|
4407
|
+
value: null,
|
|
4408
|
+
pos: 1,
|
|
4409
|
+
};
|
|
4410
|
+
}
|
|
4411
|
+
function addDateCreationToView(newName, appS) {
|
|
4412
|
+
const fieldId = 'dateCreation';
|
|
4413
|
+
appS.views[newName][fieldId] = {
|
|
4414
|
+
type: ExtraAppFieldsItemViews.CREATIONDATE,
|
|
4415
|
+
properties: [],
|
|
4416
|
+
isUsed: true,
|
|
4417
|
+
isOptional: true,
|
|
4418
|
+
isLockedValue: false,
|
|
4419
|
+
isFixed: false,
|
|
4420
|
+
value: null,
|
|
4421
|
+
pos: 100,
|
|
4422
|
+
};
|
|
4423
|
+
}
|
|
4424
|
+
|
|
4425
|
+
function InstalledAppStudioAdapter(serverApp, serverApps, state) {
|
|
4426
|
+
var _a, _b, _c, _d;
|
|
4427
|
+
const { version, dateCreation } = serverApp.manifest;
|
|
4428
|
+
const appTypeServer = serverApp.typeModel;
|
|
4429
|
+
const views = Object.assign({}, ...viewsList.map((view) => ({
|
|
4430
|
+
[view]: {},
|
|
4431
|
+
})));
|
|
4432
|
+
const studioApp = {
|
|
4433
|
+
idApp: serverApp.idApp,
|
|
4434
|
+
status: _formatStatus(serverApp),
|
|
4435
|
+
studioVersion: 2,
|
|
4436
|
+
manifest: {
|
|
4437
|
+
appShortName: serverApp.label,
|
|
4438
|
+
appName: serverApp.label,
|
|
4439
|
+
description: serverApp.description,
|
|
4440
|
+
author: serverApp.author,
|
|
4441
|
+
cssColor: (_a = appTypeServer.cssColor) !== null && _a !== void 0 ? _a : '#392994',
|
|
4442
|
+
cssClass: { label: (_b = appTypeServer.cssClass) !== null && _b !== void 0 ? _b : 'star', value: (_c = appTypeServer.cssClass) !== null && _c !== void 0 ? _c : 'star' },
|
|
4443
|
+
version: version,
|
|
4444
|
+
dateCreation: dateCreation,
|
|
4445
|
+
checkAccess: false,
|
|
4446
|
+
accessRightList: '',
|
|
4447
|
+
attrExposed: [],
|
|
4448
|
+
viewSolr: serverApp.view ? STUDIO_VIEW.SOLR : STUDIO_VIEW.NOT_SOLR,
|
|
4449
|
+
typeLabel: appTypeServer.typeLabel,
|
|
4450
|
+
articlesCount: (_d = serverApp.articlesCount) !== null && _d !== void 0 ? _d : 0,
|
|
4451
|
+
},
|
|
4452
|
+
fields: [],
|
|
4453
|
+
views,
|
|
4454
|
+
installFor: serverApp.accessRightObjectList
|
|
4455
|
+
? buildAudience(serverApp.accessRightObjectList)
|
|
4456
|
+
: [],
|
|
4457
|
+
audience: serverApp.checkAccess === false ? AUDIENCE.ALL : AUDIENCE.CUSTOM,
|
|
4458
|
+
};
|
|
4459
|
+
populateFieldsAndViews(serverApp, studioApp, state);
|
|
4460
|
+
studioApp.views = updateViewsFromFields(studioApp, studioApp.fields);
|
|
4461
|
+
const inWorkAppVersion = _findAssociatedDraft(serverApp.idApp, serverApps);
|
|
4462
|
+
if (!inWorkAppVersion)
|
|
4463
|
+
return studioApp;
|
|
4464
|
+
const inWorkApp = DraftAppStudioAdapter(inWorkAppVersion);
|
|
4465
|
+
if (!inWorkApp)
|
|
4466
|
+
return studioApp;
|
|
4467
|
+
studioApp.inWorkVersion = inWorkApp;
|
|
4468
|
+
return studioApp;
|
|
4284
4469
|
}
|
|
4285
|
-
function
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
case ExtraAppFieldsItemViews.USER:
|
|
4302
|
-
return 'integer';
|
|
4303
|
-
case AppFormItemTypes.SELECT:
|
|
4304
|
-
case AppFormItemTypes.RADIO:
|
|
4305
|
-
case AppFormItemTypes.TOGGLE:
|
|
4306
|
-
case AppFormItemTypes.CHECKBOX:
|
|
4307
|
-
case AppFormItemTypes.TAGS:
|
|
4308
|
-
return 'string';
|
|
4309
|
-
default:
|
|
4310
|
-
return '';
|
|
4470
|
+
function DraftAppStudioAdapter(serverApp) {
|
|
4471
|
+
if (!serverApp.value)
|
|
4472
|
+
return undefined;
|
|
4473
|
+
const parsedJson = JSON.parse(serverApp.value);
|
|
4474
|
+
if (parsedJson.studioVersion == 2) {
|
|
4475
|
+
return {
|
|
4476
|
+
idApp: serverApp.idApp,
|
|
4477
|
+
studioVersion: 2,
|
|
4478
|
+
status: _formatStatus(serverApp),
|
|
4479
|
+
manifest: parsedJson.manifest,
|
|
4480
|
+
fields: parsedJson.fields,
|
|
4481
|
+
views: parsedJson.views,
|
|
4482
|
+
syncViewFieldOrder: parsedJson.syncViewFieldOrder,
|
|
4483
|
+
audience: parsedJson.audience,
|
|
4484
|
+
installFor: parsedJson.installFor,
|
|
4485
|
+
};
|
|
4311
4486
|
}
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
switch (fieldType) {
|
|
4315
|
-
default:
|
|
4316
|
-
case AppFormItemTypes.DESCRIPTION:
|
|
4317
|
-
case AppFormItemTypes.TEXTAREAHTML:
|
|
4318
|
-
return 'html';
|
|
4319
|
-
case AppFormItemTypes.TAGS:
|
|
4320
|
-
return 'taxonomy';
|
|
4321
|
-
case AppFormItemTypes.TEXT:
|
|
4322
|
-
case AppFormItemTypes.RADIO:
|
|
4323
|
-
case AppFormItemTypes.URL:
|
|
4324
|
-
case AppFormItemTypes.EMAIL:
|
|
4325
|
-
case AppFormItemTypes.ADDFILEATTACHMENT:
|
|
4326
|
-
case ExtraAppFieldsItemViews.USER:
|
|
4327
|
-
case AppFormItemTypes.USERLINK:
|
|
4328
|
-
case AppFormItemTypes.CONTENTLINK:
|
|
4329
|
-
return 'text';
|
|
4330
|
-
case AppFormItemTypes.TEXTAREA:
|
|
4331
|
-
case AppFormItemTypes.CHECKBOX:
|
|
4332
|
-
case AppFormItemTypes.SELECT:
|
|
4333
|
-
return 'longtext';
|
|
4334
|
-
case AppFormItemTypes.DATE:
|
|
4335
|
-
return 'date';
|
|
4336
|
-
case AppFormItemTypes.DATETIME: {
|
|
4337
|
-
return 'date';
|
|
4338
|
-
}
|
|
4339
|
-
case AppFormItemTypes.NUMBER:
|
|
4340
|
-
return 'float';
|
|
4487
|
+
else {
|
|
4488
|
+
return Object.assign(Object.assign({}, migrateJson(parsedJson)), { status: _formatStatus(serverApp), migratedFrom: 1 });
|
|
4341
4489
|
}
|
|
4342
4490
|
}
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
else if (c >= 'a' && c <= 'z')
|
|
4350
|
-
alphaUuid += c;
|
|
4351
|
-
}
|
|
4352
|
-
return alphaUuid;
|
|
4353
|
-
};
|
|
4354
|
-
const numToAlpha = (num) => {
|
|
4355
|
-
let s = '', t;
|
|
4356
|
-
while (num > 0) {
|
|
4357
|
-
t = (num - 1) % 26;
|
|
4358
|
-
s = String.fromCharCode(97 + t) + s;
|
|
4359
|
-
num = ((num - t) / 26) | 0;
|
|
4360
|
-
}
|
|
4361
|
-
return s;
|
|
4362
|
-
};
|
|
4363
|
-
const internal2XmlView = {
|
|
4364
|
-
create: 'create',
|
|
4365
|
-
popup: 'create-popup',
|
|
4366
|
-
edit: 'edit',
|
|
4367
|
-
view: 'display',
|
|
4368
|
-
};
|
|
4369
|
-
function renderDisplays(studioApp) {
|
|
4370
|
-
let toRet = '';
|
|
4371
|
-
Object.entries(studioApp.views).forEach(([viewName, viewContent]) => {
|
|
4372
|
-
if (Object.prototype.hasOwnProperty.call(internal2XmlView, viewName)) {
|
|
4373
|
-
const viewField = Object.entries(viewContent)
|
|
4374
|
-
.filter((a) => a[1].isUsed)
|
|
4375
|
-
.sort((a, b) => a[1].pos - b[1].pos);
|
|
4376
|
-
toRet += `<display view="${internal2XmlView[viewName]}" mode="${viewName === 'view' ? 'view' : 'form'}">
|
|
4377
|
-
${viewField.map(([fieldId, view]) => renderDisplayAttr(fieldId, view)).join('')}
|
|
4378
|
-
</display>`;
|
|
4379
|
-
}
|
|
4380
|
-
});
|
|
4381
|
-
if (toRet.length > 0) {
|
|
4382
|
-
toRet = `<displays type="${studioApp.idApp}">${toRet}</displays>`;
|
|
4383
|
-
}
|
|
4384
|
-
return toRet;
|
|
4491
|
+
function _formatStatus(serverApp) {
|
|
4492
|
+
return serverApp.status === StudioApplicationStatus.installed
|
|
4493
|
+
? serverApp.suspended
|
|
4494
|
+
? StatusType$1.suspended
|
|
4495
|
+
: StatusType$1.installed
|
|
4496
|
+
: StatusType$1.draft;
|
|
4385
4497
|
}
|
|
4386
|
-
function
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
return 'title';
|
|
4390
|
-
case ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS:
|
|
4391
|
-
return 'sendAlert';
|
|
4392
|
-
case ExtraAppFieldsItemViews.RECEIVEACOPY:
|
|
4393
|
-
return 'alertAuthor';
|
|
4394
|
-
case ExtraAppFieldsItemViews.PUBLISHTO:
|
|
4395
|
-
return 'publishTo';
|
|
4396
|
-
case ExtraAppFieldsItemViews.USER:
|
|
4397
|
-
return 'idUser';
|
|
4398
|
-
case ExtraAppFieldsItemViews.CREATIONDATE:
|
|
4399
|
-
return 'dateCreation';
|
|
4400
|
-
case AppFormItemTypes.DESCRIPTION:
|
|
4401
|
-
return 'description';
|
|
4402
|
-
default:
|
|
4403
|
-
return uuid2Alpha(fieldId);
|
|
4404
|
-
}
|
|
4498
|
+
function _findAssociatedDraft(idApp, serverApps) {
|
|
4499
|
+
const draft = serverApps.find((app) => app.idApp === idApp && app.status === StudioApplicationStatus.saved);
|
|
4500
|
+
return draft;
|
|
4405
4501
|
}
|
|
4406
|
-
function
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
const
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
};
|
|
4416
|
-
xml += `<html><![CDATA[ <!-- <JAMESPOT.STUDIO.FIXED>${JSON.stringify(formItemRefWithName)}</JAMESPOT.STUDIO.FIXED> -->`;
|
|
4417
|
-
if (view.type === ExtraAppFieldsItemViews.PUBLISHTO) {
|
|
4418
|
-
const uris = view.value.map((user) => user.uri).join(',');
|
|
4419
|
-
xml += `<input type="hidden" name="publishTo" value="${uris}">`;
|
|
4420
|
-
}
|
|
4421
|
-
else if (view.type === ExtraAppFieldsItemViews.USER ||
|
|
4422
|
-
view.type === AppFormItemTypes.USERLINK ||
|
|
4423
|
-
view.type === AppFormItemTypes.CONTENTLINK) {
|
|
4424
|
-
xml += `<input type="hidden" name="${attrName}[]" value=${JSON.stringify(view.value.uri)}>`;
|
|
4425
|
-
}
|
|
4426
|
-
else if (view.type === AppFormItemTypes.SELECT) {
|
|
4427
|
-
const canSelectMultiple = (_a = view.properties.find((property) => property.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR)) === null || _a === void 0 ? void 0 : _a.value.canSelectMultiple;
|
|
4428
|
-
if (canSelectMultiple) {
|
|
4429
|
-
const values = view.value;
|
|
4430
|
-
values.forEach((value) => {
|
|
4431
|
-
xml += `<input type="hidden" name="${attrName}[]" value="${value.value}">`;
|
|
4432
|
-
});
|
|
4502
|
+
function _findAssociatedInstalled(idApp, serverApps) {
|
|
4503
|
+
return !!serverApps.find((app) => app.idApp === idApp && app.status === StudioApplicationStatus.installed);
|
|
4504
|
+
}
|
|
4505
|
+
function serverAppsToStudioApps(serverApps, state) {
|
|
4506
|
+
const studioApps = serverApps
|
|
4507
|
+
.map((serverApp) => {
|
|
4508
|
+
try {
|
|
4509
|
+
if (serverApp.status === StudioApplicationStatus.installed) {
|
|
4510
|
+
return InstalledAppStudioAdapter(serverApp, serverApps, state);
|
|
4433
4511
|
}
|
|
4434
4512
|
else {
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
else if (view.type === AppFormItemTypes.CHECKBOX) {
|
|
4439
|
-
const values = view.value;
|
|
4440
|
-
values.forEach((value) => {
|
|
4441
|
-
xml += `<input type="hidden" name="${attrName}[]" value="${value}">`;
|
|
4442
|
-
});
|
|
4443
|
-
}
|
|
4444
|
-
else if (view.type === AppFormItemTypes.DATE) {
|
|
4445
|
-
const dateValue = new Date(view.value);
|
|
4446
|
-
const xmlFixedValue = [
|
|
4447
|
-
pad(dateValue.getDate()),
|
|
4448
|
-
pad(dateValue.getMonth() + 1),
|
|
4449
|
-
dateValue.getFullYear(),
|
|
4450
|
-
].join('/');
|
|
4451
|
-
xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
|
|
4452
|
-
}
|
|
4453
|
-
else if (view.type === AppFormItemTypes.DATETIME) {
|
|
4454
|
-
const dateValue = new Date(view.value);
|
|
4455
|
-
const xmlFixedValue = `${[
|
|
4456
|
-
pad(dateValue.getDate()),
|
|
4457
|
-
pad(dateValue.getMonth() + 1),
|
|
4458
|
-
dateValue.getFullYear(),
|
|
4459
|
-
].join('/')} ${pad(dateValue.getHours())}:${pad(dateValue.getMinutes())}:${pad(dateValue.getSeconds())}`;
|
|
4460
|
-
xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
|
|
4461
|
-
}
|
|
4462
|
-
else if (view.type === AppFormItemTypes.TAGS) {
|
|
4463
|
-
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(',')}">`;
|
|
4464
|
-
}
|
|
4465
|
-
else if (view.type === AppFormItemTypes.DESCRIPTION || view.type === AppFormItemTypes.TEXTAREAHTML) {
|
|
4466
|
-
xml += `<input type="hidden" name="${attrName}" value="${view.value}">`;
|
|
4467
|
-
}
|
|
4468
|
-
else if (view.type === ExtraAppFieldsItemViews.RECEIVEACOPY) {
|
|
4469
|
-
if (view.value) {
|
|
4470
|
-
xml += `<input type="hidden" name="alertAuthor[jamespot]"><input type="hidden" name="alertAuthor[]" value="1">`;
|
|
4471
|
-
}
|
|
4472
|
-
}
|
|
4473
|
-
else if (view.type === ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS) {
|
|
4474
|
-
if (view.value) {
|
|
4475
|
-
xml += `<input type="hidden" name="sendAlert[jamespot]"><input type="hidden" name="sendAlert[]" value="1">`;
|
|
4513
|
+
if (_findAssociatedInstalled(serverApp.idApp, serverApps))
|
|
4514
|
+
return undefined;
|
|
4515
|
+
return DraftAppStudioAdapter(serverApp);
|
|
4476
4516
|
}
|
|
4477
4517
|
}
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
xml += ']]></html>';
|
|
4482
|
-
}
|
|
4483
|
-
else {
|
|
4484
|
-
switch (view.type) {
|
|
4485
|
-
case AppFormItemTypes.CODEHTML: {
|
|
4486
|
-
const fieldToInclude = {
|
|
4487
|
-
id: fieldId,
|
|
4488
|
-
name: fieldId,
|
|
4489
|
-
properties: {
|
|
4490
|
-
code: view.value,
|
|
4491
|
-
},
|
|
4492
|
-
};
|
|
4493
|
-
xml += `<html><![CDATA[ <!-- <JAMESPOT.STUDIO.CODEHTML>${JSON.stringify(fieldToInclude)}</JAMESPOT.STUDIO.CODEHTML><JAMESPOT.STUDIO.FIELD_POS>${view.pos}</JAMESPOT.STUDIO.FIELD_POS>-->${view.value}]]></html>`;
|
|
4494
|
-
break;
|
|
4495
|
-
}
|
|
4496
|
-
case AppFormItemTypes.IMAGE:
|
|
4497
|
-
xml += '<image />';
|
|
4498
|
-
break;
|
|
4499
|
-
case ExtraAppFieldsItemViews.PUBLISHTO:
|
|
4500
|
-
xml += '<publishTo />';
|
|
4501
|
-
break;
|
|
4502
|
-
default:
|
|
4503
|
-
xml += "<attr name='" + attrName + "' />";
|
|
4504
|
-
break;
|
|
4518
|
+
catch (e) {
|
|
4519
|
+
console.error(e);
|
|
4520
|
+
return undefined;
|
|
4505
4521
|
}
|
|
4506
|
-
}
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
function pad(s) {
|
|
4510
|
-
return s < 10 ? '0' + s : s;
|
|
4522
|
+
})
|
|
4523
|
+
.filter((app) => app !== undefined);
|
|
4524
|
+
return studioApps;
|
|
4511
4525
|
}
|
|
4512
4526
|
|
|
4513
4527
|
const initialState$1 = {
|
|
@@ -4736,11 +4750,19 @@ const fetchStudioAppsList = createAsyncThunk('studio/appsList', (intl, { extra,
|
|
|
4736
4750
|
try {
|
|
4737
4751
|
const { result } = yield jApi.application.list();
|
|
4738
4752
|
const taxonomies = yield jApi.taxonomy.list();
|
|
4739
|
-
const
|
|
4753
|
+
const appsPromisesResult = yield Promise.allSettled(result.map((app) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4740
4754
|
const coreApp = (yield jApi.application.get(app.idApp, app.status)).result;
|
|
4741
4755
|
const articlesCount = (yield jApi.article.count(app.idApp)).result;
|
|
4742
4756
|
return Object.assign(Object.assign({}, coreApp), { articlesCount });
|
|
4743
4757
|
})));
|
|
4758
|
+
const apps = appsPromisesResult.map((result) => {
|
|
4759
|
+
return result.status === "fulfilled" ? result.value : null;
|
|
4760
|
+
}).reduce((prev, curr) => {
|
|
4761
|
+
if (curr !== null) {
|
|
4762
|
+
return prev.concat([curr]);
|
|
4763
|
+
}
|
|
4764
|
+
return prev;
|
|
4765
|
+
}, []);
|
|
4744
4766
|
const transformedApps = serverAppsToStudioApps(apps, getState());
|
|
4745
4767
|
transformedApps.forEach((app) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4746
4768
|
app.fields = updateTaxonomies(app.fields, taxonomies, intl);
|
|
@@ -4751,6 +4773,7 @@ const fetchStudioAppsList = createAsyncThunk('studio/appsList', (intl, { extra,
|
|
|
4751
4773
|
return transformedApps;
|
|
4752
4774
|
}
|
|
4753
4775
|
catch (_) {
|
|
4776
|
+
console.error(_);
|
|
4754
4777
|
dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
|
|
4755
4778
|
throw rejectWithValue({ error: 1, errorMsg: 'Error retrieving applications' });
|
|
4756
4779
|
}
|