jamespot-front-business 1.1.68 → 1.1.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs.js CHANGED
@@ -2765,118 +2765,129 @@ const AUDIENCE = {
2765
2765
  ALL: '1',
2766
2766
  CUSTOM: '0',
2767
2767
  };
2768
- exports.StatusType = void 0;
2769
- (function (StatusType) {
2770
- StatusType["draft"] = "draft";
2771
- StatusType["installed"] = "installed";
2772
- StatusType["suspended"] = "suspended";
2773
- })(exports.StatusType || (exports.StatusType = {}));
2768
+ const StatusType$1 = {
2769
+ draft: 'draft',
2770
+ installed: 'installed',
2771
+ suspended: 'suspended',
2772
+ };
2774
2773
  const APP_STATUS_TYPE = {
2775
- DRAFT: exports.StatusType.draft,
2776
- INSTALLED: exports.StatusType.installed,
2777
- SUSPENDED: exports.StatusType.suspended,
2774
+ DRAFT: StatusType$1.draft,
2775
+ INSTALLED: StatusType$1.installed,
2776
+ SUSPENDED: StatusType$1.suspended,
2778
2777
  };
2779
2778
  const STUDIO_VIEW = {
2780
2779
  SOLR: '1',
2781
2780
  NOT_SOLR: '0',
2782
2781
  };
2783
2782
  const viewsList = ['create', 'popup', 'edit', 'filter', 'list', 'view'];
2784
- exports.AppFormItemTypes = void 0;
2785
- (function (AppFormItemTypes) {
2786
- AppFormItemTypes["IMAGE"] = "IMAGE";
2787
- AppFormItemTypes["DESCRIPTION"] = "DESCRIPTION";
2788
- AppFormItemTypes["TEXT"] = "TEXT";
2789
- AppFormItemTypes["TEXTAREA"] = "TEXTAREA";
2790
- AppFormItemTypes["TEXTAREAHTML"] = "TEXTAREAHTML";
2791
- AppFormItemTypes["DATE"] = "DATE";
2792
- AppFormItemTypes["DATETIME"] = "DATETIME";
2793
- AppFormItemTypes["NUMBER"] = "NUMBER";
2794
- AppFormItemTypes["URL"] = "URL";
2795
- AppFormItemTypes["EMAIL"] = "EMAIL";
2796
- AppFormItemTypes["SELECT"] = "SELECT";
2797
- AppFormItemTypes["CHECKBOX"] = "CHECKBOX";
2798
- AppFormItemTypes["TOGGLE"] = "TOGGLE";
2799
- AppFormItemTypes["RADIO"] = "RADIO";
2800
- AppFormItemTypes["TAGS"] = "TAGS";
2801
- AppFormItemTypes["ADDFILEATTACHMENT"] = "ADDFILEATTACHMENT";
2802
- AppFormItemTypes["CODEHTML"] = "CODEHTML";
2803
- AppFormItemTypes["USERLINK"] = "USERLINK";
2804
- AppFormItemTypes["CONTENTLINK"] = "CONTENTLINK";
2805
- AppFormItemTypes["RANGE"] = "RANGE";
2806
- })(exports.AppFormItemTypes || (exports.AppFormItemTypes = {}));
2807
- exports.ExtraAppFieldsItemViews = void 0;
2808
- (function (ExtraAppFieldsItemViews) {
2809
- ExtraAppFieldsItemViews["TITLE"] = "TITLE";
2810
- ExtraAppFieldsItemViews["USER"] = "USER";
2811
- ExtraAppFieldsItemViews["PUBLISHTO"] = "PUBLISHTO";
2812
- ExtraAppFieldsItemViews["SENDALERTTOSUBSCRIBERS"] = "SENDALERTTOSUBSCRIBERS";
2813
- ExtraAppFieldsItemViews["RECEIVEACOPY"] = "RECEIVEACOPY";
2814
- ExtraAppFieldsItemViews["CREATIONDATE"] = "CREATIONDATE";
2815
- })(exports.ExtraAppFieldsItemViews || (exports.ExtraAppFieldsItemViews = {}));
2816
- exports.AppFieldFormPropertyTypes = void 0;
2817
- (function (AppFieldFormPropertyTypes) {
2818
- AppFieldFormPropertyTypes["LABEL"] = "label";
2819
- AppFieldFormPropertyTypes["DESCRIPTION"] = "description";
2820
- AppFieldFormPropertyTypes["RICHTEXT"] = "richtext";
2821
- AppFieldFormPropertyTypes["CHECKBOX"] = "checkbox";
2822
- AppFieldFormPropertyTypes["OPTIONS_EDITOR"] = "options_editor";
2823
- AppFieldFormPropertyTypes["TAXONOMY"] = "taxonomy";
2824
- AppFieldFormPropertyTypes["CONTENTTYPE"] = "contenttype";
2825
- })(exports.AppFieldFormPropertyTypes || (exports.AppFieldFormPropertyTypes = {}));
2826
- const AppFormUniqueList = [exports.AppFormItemTypes.DESCRIPTION, exports.AppFormItemTypes.IMAGE];
2783
+ const AppFormItemTypes = {
2784
+ IMAGE: 'IMAGE',
2785
+ DESCRIPTION: 'DESCRIPTION',
2786
+ TEXT: 'TEXT',
2787
+ TEXTAREA: 'TEXTAREA',
2788
+ TEXTAREAHTML: 'TEXTAREAHTML',
2789
+ DATE: 'DATE',
2790
+ DATETIME: 'DATETIME',
2791
+ NUMBER: 'NUMBER',
2792
+ URL: 'URL',
2793
+ EMAIL: 'EMAIL',
2794
+ SELECT: 'SELECT',
2795
+ CHECKBOX: 'CHECKBOX',
2796
+ TOGGLE: 'TOGGLE',
2797
+ RADIO: 'RADIO',
2798
+ TAGS: 'TAGS',
2799
+ ADDFILEATTACHMENT: 'ADDFILEATTACHMENT',
2800
+ CODEHTML: 'CODEHTML',
2801
+ USERLINK: 'USERLINK',
2802
+ CONTENTLINK: 'CONTENTLINK',
2803
+ RANGE: 'RANGE',
2804
+ };
2805
+ const ExtraAppFieldsItemViews = {
2806
+ TITLE: 'TITLE',
2807
+ USER: 'USER',
2808
+ PUBLISHTO: 'PUBLISHTO',
2809
+ SENDALERTTOSUBSCRIBERS: 'SENDALERTTOSUBSCRIBERS',
2810
+ RECEIVEACOPY: 'RECEIVEACOPY',
2811
+ CREATIONDATE: 'CREATIONDATE',
2812
+ };
2813
+ const AppFieldFormPropertyTypes = {
2814
+ LABEL: 'label',
2815
+ DESCRIPTION: 'description',
2816
+ RICHTEXT: 'richtext',
2817
+ CHECKBOX: 'checkbox',
2818
+ OPTIONS_EDITOR: 'options_editor',
2819
+ TAXONOMY: 'taxonomy',
2820
+ CONTENTTYPE: 'contenttype',
2821
+ };
2822
+ const AppFormUniqueList = [AppFormItemTypes.DESCRIPTION, AppFormItemTypes.IMAGE];
2823
+ const AppFormUniqueListCheck = AppFormUniqueList;
2827
2824
  const AppFormBannedFromViews$1 = new Map();
2828
- AppFormBannedFromViews$1.set(exports.AppFormItemTypes.IMAGE, ['list', 'filter', 'view']);
2825
+ AppFormBannedFromViews$1.set(AppFormItemTypes.IMAGE, ['list', 'filter', 'view']);
2826
+ AppFormBannedFromViews$1.set(AppFormItemTypes.CODEHTML, ['list', 'filter', 'view']);
2829
2827
  const MapExtraFieldsWithView = {
2830
2828
  create: {
2831
- fixed: [exports.ExtraAppFieldsItemViews.TITLE],
2829
+ fixed: [ExtraAppFieldsItemViews.TITLE],
2832
2830
  optional: [
2833
- exports.ExtraAppFieldsItemViews.PUBLISHTO,
2834
- exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
2835
- exports.ExtraAppFieldsItemViews.RECEIVEACOPY,
2831
+ ExtraAppFieldsItemViews.PUBLISHTO,
2832
+ ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
2833
+ ExtraAppFieldsItemViews.RECEIVEACOPY,
2836
2834
  ],
2837
2835
  },
2838
2836
  popup: {
2839
- fixed: [exports.ExtraAppFieldsItemViews.TITLE],
2840
- optional: [exports.ExtraAppFieldsItemViews.PUBLISHTO],
2837
+ fixed: [ExtraAppFieldsItemViews.TITLE],
2838
+ optional: [ExtraAppFieldsItemViews.PUBLISHTO],
2841
2839
  },
2842
2840
  edit: {
2843
- fixed: [exports.ExtraAppFieldsItemViews.TITLE],
2844
- optional: [exports.ExtraAppFieldsItemViews.PUBLISHTO],
2841
+ fixed: [ExtraAppFieldsItemViews.TITLE],
2842
+ optional: [ExtraAppFieldsItemViews.PUBLISHTO],
2845
2843
  },
2846
2844
  list: {
2847
- fixed: [exports.ExtraAppFieldsItemViews.TITLE, exports.ExtraAppFieldsItemViews.USER],
2848
- optional: [exports.ExtraAppFieldsItemViews.CREATIONDATE],
2845
+ fixed: [ExtraAppFieldsItemViews.TITLE, ExtraAppFieldsItemViews.USER],
2846
+ optional: [ExtraAppFieldsItemViews.CREATIONDATE],
2849
2847
  },
2850
2848
  filter: {
2851
- fixed: [exports.ExtraAppFieldsItemViews.TITLE, exports.ExtraAppFieldsItemViews.USER],
2852
- optional: [exports.ExtraAppFieldsItemViews.CREATIONDATE],
2849
+ fixed: [ExtraAppFieldsItemViews.TITLE, ExtraAppFieldsItemViews.USER],
2850
+ optional: [ExtraAppFieldsItemViews.CREATIONDATE],
2853
2851
  },
2854
2852
  view: {
2855
- fixed: [exports.ExtraAppFieldsItemViews.TITLE],
2853
+ fixed: [ExtraAppFieldsItemViews.TITLE],
2856
2854
  optional: [],
2857
2855
  },
2858
2856
  };
2859
2857
  const AppColumnsDefaultTypes = [
2860
- exports.ExtraAppFieldsItemViews.TITLE,
2861
- exports.ExtraAppFieldsItemViews.USER,
2862
- exports.ExtraAppFieldsItemViews.CREATIONDATE,
2863
- exports.AppFormItemTypes.DESCRIPTION,
2858
+ ExtraAppFieldsItemViews.TITLE,
2859
+ ExtraAppFieldsItemViews.USER,
2860
+ ExtraAppFieldsItemViews.CREATIONDATE,
2861
+ AppFormItemTypes.DESCRIPTION,
2864
2862
  ];
2865
- const AppFormPrimaryList = [exports.AppFormItemTypes.DESCRIPTION];
2863
+ const AppFormPrimaryList = [AppFormItemTypes.DESCRIPTION];
2864
+ const AppFormPrimaryListValues = AppFormPrimaryList;
2866
2865
  const AppFormFixedList$1 = [
2867
- exports.ExtraAppFieldsItemViews.TITLE,
2868
- exports.ExtraAppFieldsItemViews.PUBLISHTO,
2869
- exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
2870
- exports.ExtraAppFieldsItemViews.RECEIVEACOPY,
2871
- exports.ExtraAppFieldsItemViews.USER,
2872
- exports.ExtraAppFieldsItemViews.CREATIONDATE,
2866
+ ExtraAppFieldsItemViews.TITLE,
2867
+ ExtraAppFieldsItemViews.PUBLISHTO,
2868
+ ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
2869
+ ExtraAppFieldsItemViews.RECEIVEACOPY,
2870
+ ExtraAppFieldsItemViews.USER,
2871
+ ExtraAppFieldsItemViews.CREATIONDATE,
2873
2872
  ];
2874
2873
  const AppFormNoAsFieldList = [
2875
- exports.ExtraAppFieldsItemViews.USER,
2876
- exports.ExtraAppFieldsItemViews.TITLE,
2874
+ ExtraAppFieldsItemViews.USER,
2875
+ ExtraAppFieldsItemViews.TITLE,
2877
2876
  ];
2878
- const AppFormFieldOnlyInView = [exports.AppFormItemTypes.CODEHTML];
2877
+ const AppFormFieldOnlyInView = [AppFormItemTypes.CODEHTML];
2879
2878
  const AppFormNonPrimaryList = AppFormNoAsFieldList.concat(AppFormFieldOnlyInView).concat(AppFormPrimaryList);
2879
+ exports.Element = void 0;
2880
+ (function (Element) {
2881
+ Element["Attr"] = "attr";
2882
+ Element["PublishTo"] = "publishTo";
2883
+ })(exports.Element || (exports.Element = {}));
2884
+ exports.Description = void 0;
2885
+ (function (Description) {
2886
+ Description["Empty"] = "";
2887
+ Description["FieldTagDescription"] = "Field_Tag_Description";
2888
+ Description["FieldTitleDescription"] = "Field_Title_Description";
2889
+ Description["WWWDescCOM"] = "www.desc.com";
2890
+ })(exports.Description || (exports.Description = {}));
2880
2891
 
2881
2892
  var StatusType;
2882
2893
  (function (StatusType) {
@@ -3037,7 +3048,7 @@ function migrateJson(v1Json) {
3037
3048
  return v2Fields;
3038
3049
  }
3039
3050
  function _matctTypes(v1Type) {
3040
- return exports.AppFormItemTypes[v1Type];
3051
+ return AppFormItemTypes[v1Type];
3041
3052
  }
3042
3053
  function _renderProperties(v1FormItemProperties) {
3043
3054
  var _a, _b, _c, _d, _e, _f, _g;
@@ -3046,11 +3057,11 @@ function migrateJson(v1Json) {
3046
3057
  Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'hasDefaultValue');
3047
3058
  const baseProperty = Object.assign({ isRequired: v1FormItemProperties.mandatory || false }, (isEnhancedOptionEditor && { isOptionsEditorEnhanced: true }));
3048
3059
  if (v1FormItemProperties.labels) {
3049
- v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.LABEL, value: ((_a = v1FormItemProperties.labels.label) === null || _a === void 0 ? void 0 : _a.content) || '' }, baseProperty));
3050
- v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.DESCRIPTION, value: ((_b = v1FormItemProperties.labels.description) === null || _b === void 0 ? void 0 : _b.content) || '' }, baseProperty));
3060
+ v2Properties.push(Object.assign({ propertyType: AppFieldFormPropertyTypes.LABEL, value: ((_a = v1FormItemProperties.labels.label) === null || _a === void 0 ? void 0 : _a.content) || '' }, baseProperty));
3061
+ v2Properties.push(Object.assign({ propertyType: AppFieldFormPropertyTypes.DESCRIPTION, value: ((_b = v1FormItemProperties.labels.description) === null || _b === void 0 ? void 0 : _b.content) || '' }, baseProperty));
3051
3062
  }
3052
3063
  if (v1FormItemProperties.options) {
3053
- v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR, value: isEnhancedOptionEditor
3064
+ v2Properties.push(Object.assign({ propertyType: AppFieldFormPropertyTypes.OPTIONS_EDITOR, value: isEnhancedOptionEditor
3054
3065
  ? {
3055
3066
  propertyOptions: _renderSelectOptions((_c = v1FormItemProperties.options) !== null && _c !== void 0 ? _c : []),
3056
3067
  defaultSelectOptionValue: v1FormItemProperties.defaultValue,
@@ -3061,16 +3072,16 @@ function migrateJson(v1Json) {
3061
3072
  : { propertyOptions: _renderSelectOptions((_g = v1FormItemProperties.options) !== null && _g !== void 0 ? _g : []) } }, baseProperty));
3062
3073
  }
3063
3074
  if (v1FormItemProperties.code) {
3064
- v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.RICHTEXT, value: { html: v1FormItemProperties.code.html, text: v1FormItemProperties.code.text } }, baseProperty));
3075
+ v2Properties.push(Object.assign({ propertyType: AppFieldFormPropertyTypes.RICHTEXT, value: { html: v1FormItemProperties.code.html, text: v1FormItemProperties.code.text } }, baseProperty));
3065
3076
  }
3066
3077
  if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'digits')) {
3067
- v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.CHECKBOX, value: v1FormItemProperties.digits || false, checkBoxOptions: [{ label: 'APPSTUDIO_FormEditProps_Digits', value: v1FormItemProperties.digits }] }, baseProperty));
3078
+ v2Properties.push(Object.assign({ propertyType: AppFieldFormPropertyTypes.CHECKBOX, value: v1FormItemProperties.digits || false, checkBoxOptions: [{ label: 'APPSTUDIO_FormEditProps_Digits', value: v1FormItemProperties.digits }] }, baseProperty));
3068
3079
  }
3069
3080
  if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'taxonomy')) {
3070
- v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.TAXONOMY, value: v1FormItemProperties.taxonomy || '' }, baseProperty));
3081
+ v2Properties.push(Object.assign({ propertyType: AppFieldFormPropertyTypes.TAXONOMY, value: v1FormItemProperties.taxonomy || '' }, baseProperty));
3071
3082
  }
3072
3083
  if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'contentType')) {
3073
- v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.CONTENTTYPE, value: v1FormItemProperties.contentType || '' }, baseProperty));
3084
+ v2Properties.push(Object.assign({ propertyType: AppFieldFormPropertyTypes.CONTENTTYPE, value: v1FormItemProperties.contentType || '' }, baseProperty));
3074
3085
  }
3075
3086
  return v2Properties;
3076
3087
  }
@@ -3107,19 +3118,19 @@ function migrateJson(v1Json) {
3107
3118
  value: v1FormItemRef.fixedValue || '',
3108
3119
  };
3109
3120
  if (v1FormItemRef.ref === AppFormItemType.TITLE) {
3110
- viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.TITLE, isFixed: true });
3121
+ viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: ExtraAppFieldsItemViews.TITLE, isFixed: true });
3111
3122
  }
3112
3123
  else if (v1FormItemRef.ref === AppFormItemType.IDUSER) {
3113
- viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.USER, isFixed: true });
3124
+ viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: ExtraAppFieldsItemViews.USER, isFixed: true });
3114
3125
  }
3115
3126
  else if (v1FormItemRef.ref === AppFormItemType.PUBLISHTO) {
3116
- viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.PUBLISHTO, isOptional: true });
3127
+ viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: ExtraAppFieldsItemViews.PUBLISHTO, isOptional: true });
3117
3128
  }
3118
3129
  else if (v1FormItemRef.ref === AppFormItemType.SENDALERTTOSUBSCRIBERS) {
3119
- viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS, isOptional: true });
3130
+ viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS, isOptional: true });
3120
3131
  }
3121
3132
  else if (v1FormItemRef.ref === AppFormItemType.RECEIVEACOPY) {
3122
- viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: exports.ExtraAppFieldsItemViews.RECEIVEACOPY, isOptional: true });
3133
+ viewItems[uuid.v4()] = Object.assign(Object.assign({}, viewBase), { type: ExtraAppFieldsItemViews.RECEIVEACOPY, isOptional: true });
3123
3134
  }
3124
3135
  else {
3125
3136
  const v2Field = _mapFormItemRefWithField(v1FormItemRef);
@@ -3140,23 +3151,761 @@ function migrateJson(v1Json) {
3140
3151
  return v2;
3141
3152
  }
3142
3153
 
3143
- function InstalledAppStudioAdapter(serverApp, serverApps) {
3154
+ function generateNewFormField(type, viewsDefault = true) {
3155
+ return {
3156
+ id: uuid.v4(),
3157
+ type,
3158
+ properties: _setFieldProperties(type),
3159
+ mandatory: false,
3160
+ views: {
3161
+ create: viewsDefault,
3162
+ popup: viewsDefault,
3163
+ edit: viewsDefault,
3164
+ list: viewsDefault,
3165
+ filter: viewsDefault,
3166
+ view: viewsDefault,
3167
+ },
3168
+ isActive: true,
3169
+ isFixed: false,
3170
+ isOptional: false,
3171
+ value: null,
3172
+ isLockedValue: false,
3173
+ };
3174
+ }
3175
+ const taxonomyDefaultValue = {
3176
+ type: 'taxonomyOpen',
3177
+ id: 1,
3178
+ title: 'Mots-clés',
3179
+ };
3180
+ const contentTypeDefaultValue = {
3181
+ type: 'mpArticle',
3182
+ label: 'Article',
3183
+ };
3184
+ function _setFieldProperties(type) {
3185
+ switch (type) {
3186
+ case AppFormItemTypes.TEXT:
3187
+ case AppFormItemTypes.DESCRIPTION:
3188
+ case AppFormItemTypes.TEXTAREAHTML:
3189
+ case AppFormItemTypes.DATE:
3190
+ case AppFormItemTypes.DATETIME:
3191
+ case AppFormItemTypes.URL:
3192
+ case AppFormItemTypes.EMAIL:
3193
+ case AppFormItemTypes.TOGGLE:
3194
+ case AppFormItemTypes.USERLINK:
3195
+ return [
3196
+ { propertyType: AppFieldFormPropertyTypes.LABEL, isRequired: true, value: '' },
3197
+ { propertyType: AppFieldFormPropertyTypes.DESCRIPTION, value: '' },
3198
+ ];
3199
+ case AppFormItemTypes.ADDFILEATTACHMENT:
3200
+ return [{ propertyType: AppFieldFormPropertyTypes.LABEL, isRequired: true, value: '' }];
3201
+ case AppFormItemTypes.CODEHTML:
3202
+ return [{ propertyType: AppFieldFormPropertyTypes.RICHTEXT, value: '' }];
3203
+ case AppFormItemTypes.TEXTAREA:
3204
+ return [
3205
+ { propertyType: AppFieldFormPropertyTypes.LABEL, isRequired: true, value: '' },
3206
+ { propertyType: AppFieldFormPropertyTypes.DESCRIPTION, value: '' },
3207
+ ];
3208
+ case AppFormItemTypes.NUMBER:
3209
+ return [
3210
+ { propertyType: AppFieldFormPropertyTypes.LABEL, isRequired: true, value: '' },
3211
+ { propertyType: AppFieldFormPropertyTypes.DESCRIPTION, value: '' },
3212
+ {
3213
+ propertyType: AppFieldFormPropertyTypes.CHECKBOX,
3214
+ value: false,
3215
+ checkBoxOptions: [{ label: 'APPSTUDIO_FormEditProps_Digits', value: false }],
3216
+ },
3217
+ ];
3218
+ case AppFormItemTypes.SELECT:
3219
+ return [
3220
+ { propertyType: AppFieldFormPropertyTypes.LABEL, isRequired: true, value: '' },
3221
+ { propertyType: AppFieldFormPropertyTypes.DESCRIPTION, value: '' },
3222
+ {
3223
+ propertyType: AppFieldFormPropertyTypes.OPTIONS_EDITOR,
3224
+ value: [],
3225
+ isOptionsEditorEnhanced: true,
3226
+ },
3227
+ ];
3228
+ case AppFormItemTypes.CHECKBOX:
3229
+ case AppFormItemTypes.RADIO:
3230
+ return [
3231
+ { propertyType: AppFieldFormPropertyTypes.LABEL, isRequired: true, value: '' },
3232
+ { propertyType: AppFieldFormPropertyTypes.DESCRIPTION, value: '' },
3233
+ {
3234
+ propertyType: AppFieldFormPropertyTypes.OPTIONS_EDITOR,
3235
+ value: [],
3236
+ },
3237
+ ];
3238
+ case AppFormItemTypes.TAGS:
3239
+ return [
3240
+ { propertyType: AppFieldFormPropertyTypes.LABEL, isRequired: true, value: '' },
3241
+ { propertyType: AppFieldFormPropertyTypes.DESCRIPTION, value: '' },
3242
+ {
3243
+ propertyType: AppFieldFormPropertyTypes.TAXONOMY,
3244
+ value: Object.assign({}, taxonomyDefaultValue),
3245
+ },
3246
+ ];
3247
+ case AppFormItemTypes.CONTENTLINK:
3248
+ return [
3249
+ { propertyType: AppFieldFormPropertyTypes.LABEL, isRequired: true, value: '' },
3250
+ { propertyType: AppFieldFormPropertyTypes.DESCRIPTION, value: '' },
3251
+ {
3252
+ propertyType: AppFieldFormPropertyTypes.CONTENTTYPE,
3253
+ value: Object.assign({}, contentTypeDefaultValue),
3254
+ },
3255
+ ];
3256
+ default:
3257
+ return [];
3258
+ }
3259
+ }
3260
+
3261
+ function _initField(type, installedField) {
3262
+ const field = Object.assign(Object.assign({}, generateNewFormField(type, false)), { id: installedField.name, mandatory: installedField.mandatory });
3263
+ field.properties[0].value = installedField.label;
3264
+ field.properties[1].value = installedField.description;
3265
+ return field;
3266
+ }
3267
+ function _getOptions(installedOptions) {
3268
+ const options = [];
3269
+ Object.keys(installedOptions).forEach((optionKey) => {
3270
+ options.push({
3271
+ title: installedOptions[optionKey],
3272
+ value: optionKey,
3273
+ });
3274
+ });
3275
+ return options;
3276
+ }
3277
+ function createAddfileattachmentField(installedField) {
3278
+ const field = Object.assign(Object.assign({}, generateNewFormField(AppFormItemTypes.ADDFILEATTACHMENT, false)), { id: installedField.name, mandatory: installedField.mandatory });
3279
+ field.properties[0].value = installedField.label;
3280
+ return field;
3281
+ }
3282
+ function createHtmlField(formItem) {
3283
+ const field = Object.assign(Object.assign({}, generateNewFormField(AppFormItemTypes.CODEHTML, false)), { id: formItem.name });
3284
+ field.properties[0].value = formItem.properties.code;
3285
+ return field;
3286
+ }
3287
+ function createImageField() {
3288
+ const field = generateNewFormField(AppFormItemTypes.IMAGE, false);
3289
+ return field;
3290
+ }
3291
+ function createNumberField(installedField) {
3292
+ var _a;
3293
+ const field = _initField(AppFormItemTypes.NUMBER, installedField);
3294
+ field.properties[2].value = ((_a = installedField.widget.params) === null || _a === void 0 ? void 0 : _a.step) === '0.01';
3295
+ return field;
3296
+ }
3297
+ function createTagsField(installedField) {
3298
+ var _a, _b;
3299
+ const field = _initField(AppFormItemTypes.TAGS, installedField);
3300
+ field.properties[2].value.id = +((_b = (_a = installedField.widget.params) === null || _a === void 0 ? void 0 : _a.idTaxonomy) !== null && _b !== void 0 ? _b : 1);
3301
+ return field;
3302
+ }
3303
+ function createSelectField(installedField) {
3304
+ var _a, _b, _c, _d, _e;
3305
+ const field = _initField(AppFormItemTypes.SELECT, installedField);
3306
+ const defaultValue = ((_a = installedField.widget.params) === null || _a === void 0 ? void 0 : _a.defaultValue)
3307
+ ? {
3308
+ title: installedField.widget.options[(_b = installedField.widget.params) === null || _b === void 0 ? void 0 : _b.defaultValue],
3309
+ value: (_c = installedField.widget.params) === null || _c === void 0 ? void 0 : _c.defaultValue,
3310
+ }
3311
+ : undefined;
3312
+ const optionsEditorValue = {
3313
+ propertyOptions: _getOptions(installedField.widget.options),
3314
+ canSelectMultiple: installedField.widget.multiple === '1',
3315
+ userCanModifiyByComment: ((_d = installedField.widget.params) === null || _d === void 0 ? void 0 : _d.explain) === '1',
3316
+ defaultSelectOption: !!((_e = installedField.widget.params) === null || _e === void 0 ? void 0 : _e.defaultValue),
3317
+ defaultSelectOptionValue: defaultValue,
3318
+ };
3319
+ field.properties[2].value = optionsEditorValue;
3320
+ return field;
3321
+ }
3322
+ function createRadioField(installedField) {
3323
+ const field = _initField(AppFormItemTypes.RADIO, installedField);
3324
+ const optionsEditorValue = {
3325
+ propertyOptions: _getOptions(installedField.widget.options),
3326
+ };
3327
+ field.properties[2].value = optionsEditorValue;
3328
+ return field;
3329
+ }
3330
+ function createCheckboxField(installedField) {
3331
+ const field = createRadioField(installedField);
3332
+ field.type = AppFormItemTypes.CHECKBOX;
3333
+ return field;
3334
+ }
3335
+ function createContentLinkField(installedField, state) {
3336
+ var _a, _b;
3337
+ const field = _initField(AppFormItemTypes.CONTENTLINK, installedField);
3338
+ field.properties[2].value.type = (_a = installedField.widget.params.types) !== null && _a !== void 0 ? _a : 'mpArticle';
3339
+ const modelState = state.entities === undefined ? undefined : { entities: state.entities };
3340
+ const model = modelState ? Model.selectors.selectById(modelState, field.properties[2].value.type) : undefined;
3341
+ field.properties[2].value.label = (_b = model === null || model === void 0 ? void 0 : model.label) !== null && _b !== void 0 ? _b : 'Article';
3342
+ return field;
3343
+ }
3344
+ function createTextField(installedField) {
3345
+ const field = _initField(AppFormItemTypes.TEXT, installedField);
3346
+ return field;
3347
+ }
3348
+ function createDescriptionField(installedField) {
3349
+ const field = _initField(AppFormItemTypes.DESCRIPTION, installedField);
3350
+ return field;
3351
+ }
3352
+ function createTextareaHTMLField(installedField) {
3353
+ const field = _initField(AppFormItemTypes.TEXTAREAHTML, installedField);
3354
+ return field;
3355
+ }
3356
+ function createDateField(installedField) {
3357
+ const field = _initField(AppFormItemTypes.DATE, installedField);
3358
+ return field;
3359
+ }
3360
+ function createDatetimeField(installedField) {
3361
+ const field = _initField(AppFormItemTypes.DATETIME, installedField);
3362
+ return field;
3363
+ }
3364
+ function createUrlField(installedField) {
3365
+ const field = _initField(AppFormItemTypes.URL, installedField);
3366
+ return field;
3367
+ }
3368
+ function createEmailField(installedField) {
3369
+ const field = _initField(AppFormItemTypes.EMAIL, installedField);
3370
+ return field;
3371
+ }
3372
+ function createToggleField(installedField) {
3373
+ const field = _initField(AppFormItemTypes.TOGGLE, installedField);
3374
+ return field;
3375
+ }
3376
+ function createUserLinkField(installedField) {
3377
+ const field = _initField(AppFormItemTypes.USERLINK, installedField);
3378
+ return field;
3379
+ }
3380
+ function createTextAreaField(installedField) {
3381
+ const field = _initField(AppFormItemTypes.TEXTAREA, installedField);
3382
+ return field;
3383
+ }
3384
+
3385
+ const installedToV2ViewNames = {
3386
+ 'create-popup': 'popup',
3387
+ create: 'create',
3388
+ edit: 'edit',
3389
+ display: 'view',
3390
+ };
3391
+ const specialAttrName = ['title', 'alertAuthor', 'sendAlert'];
3392
+ const ignoredFields = ['edito'];
3393
+ function updateViewsFromFields(clonedApp, appFields) {
3394
+ return Object.assign({}, ...viewsList.map((view) => {
3395
+ const viewItems = {};
3396
+ Object.entries(clonedApp.views[view]).forEach(([fieldId, field]) => {
3397
+ if (field.isFixed) {
3398
+ viewItems[fieldId] = field;
3399
+ }
3400
+ if (field.isOptional) {
3401
+ viewItems[fieldId] = field;
3402
+ }
3403
+ });
3404
+ appFields.forEach((field, idx) => {
3405
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3406
+ const isFieldUsedInView = field.views[view];
3407
+ const isExistingField = Object.keys(clonedApp.views[view]).includes(field.id);
3408
+ const fieldType = field.type;
3409
+ if (AppFormBannedFromViews$1.get(fieldType) && ((_a = AppFormBannedFromViews$1.get(fieldType)) === null || _a === void 0 ? void 0 : _a.includes(view))) {
3410
+ return;
3411
+ }
3412
+ let fieldValue = undefined;
3413
+ if (fieldType === AppFormItemTypes.CODEHTML) {
3414
+ const richTextProperty = (_b = field.properties) === null || _b === void 0 ? void 0 : _b.find((prop) => prop.propertyType === AppFieldFormPropertyTypes.RICHTEXT);
3415
+ if (richTextProperty === null || richTextProperty === void 0 ? void 0 : richTextProperty.value) {
3416
+ fieldValue = richTextProperty === null || richTextProperty === void 0 ? void 0 : richTextProperty.value;
3417
+ }
3418
+ }
3419
+ if (fieldType === AppFormItemTypes.SELECT) {
3420
+ const selectProperty = (_c = field.properties) === null || _c === void 0 ? void 0 : _c.find((prop) => prop.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
3421
+ if (isExistingField) {
3422
+ const exField = clonedApp.views[view][field.id];
3423
+ const exSelectProperty = (_d = exField.properties) === null || _d === void 0 ? void 0 : _d.find((prop) => prop.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
3424
+ const isMultivalued = !!((_e = selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.value) === null || _e === void 0 ? void 0 : _e.canSelectMultiple);
3425
+ const exIsMultivalued = !!((_f = exSelectProperty === null || exSelectProperty === void 0 ? void 0 : exSelectProperty.value) === null || _f === void 0 ? void 0 : _f.canSelectMultiple);
3426
+ if (isMultivalued === exIsMultivalued) {
3427
+ fieldValue = exField.value;
3428
+ }
3429
+ }
3430
+ else {
3431
+ const isEnhancedSelect = !!(selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.isOptionsEditorEnhanced);
3432
+ const defaultValue = isEnhancedSelect && !!(selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.value.defaultSelectOption)
3433
+ ? selectProperty === null || selectProperty === void 0 ? void 0 : selectProperty.value.defaultSelectOptionValue
3434
+ : '';
3435
+ if (defaultValue) {
3436
+ fieldValue = defaultValue;
3437
+ }
3438
+ }
3439
+ }
3440
+ if (isExistingField) {
3441
+ const exField = clonedApp.views[view][field.id];
3442
+ 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 });
3443
+ }
3444
+ else {
3445
+ const existingFieldsLen = Object.values(clonedApp.views[view]).filter((v) => !v.isFixed && !v.isOptional).length;
3446
+ viewItems[field.id] = {
3447
+ type: field.type,
3448
+ properties: field.properties || [],
3449
+ isUsed: isFieldUsedInView,
3450
+ isOptional: false,
3451
+ isLockedValue: false,
3452
+ isFixed: false,
3453
+ value: fieldValue !== null && fieldValue !== void 0 ? fieldValue : null,
3454
+ pos: ((_h = clonedApp.syncViewFieldOrder) === null || _h === void 0 ? void 0 : _h[view]) ? idx : existingFieldsLen + idx,
3455
+ };
3456
+ }
3457
+ });
3458
+ return {
3459
+ [view]: viewItems,
3460
+ };
3461
+ }));
3462
+ }
3463
+ function buildAudience(accessRightObjectList) {
3464
+ return accessRightObjectList.map((accessRightObject) => {
3465
+ return {
3466
+ id: `${accessRightObject.type}/${accessRightObject.id}`,
3467
+ uri: `${accessRightObject.type}/${accessRightObject.id}`,
3468
+ shortUri: `${accessRightObject.type}/${accessRightObject.id}`,
3469
+ title: accessRightObject.title,
3470
+ name: accessRightObject.title,
3471
+ mainType: accessRightObject.type,
3472
+ type: accessRightObject.mainType,
3473
+ label: accessRightObject.type,
3474
+ cssClass: accessRightObject._cssClass,
3475
+ cssColor: accessRightObject._cssColor,
3476
+ class: accessRightObject._cssClass,
3477
+ Pseudo: accessRightObject.title,
3478
+ _url: accessRightObject._url,
3479
+ };
3480
+ });
3481
+ }
3482
+ function populateFieldsAndViews(app, appS, state) {
3483
+ const tables = app.typeModel.tables;
3484
+ const displays = app.typeModel.displays;
3485
+ if (!displays) {
3486
+ return;
3487
+ }
3488
+ const registeredFields = new Map();
3489
+ Object.entries(displays).forEach((displaysEntry) => {
3490
+ const [displayName, displayValue] = displaysEntry;
3491
+ if (Object.keys(installedToV2ViewNames).includes(displayName)) {
3492
+ buildView(appS, registeredFields, displayName, displayValue, tables, state);
3493
+ }
3494
+ });
3495
+ buildListView(appS, registeredFields, app.columns, tables, state);
3496
+ buildFilterView(appS, registeredFields, app.attrExposed, tables, state);
3497
+ }
3498
+ function buildView(appS, registeredFields, displayName, displayValue, tables, state) {
3499
+ const newName = installedToV2ViewNames[displayName];
3500
+ appS.views[newName] = {};
3501
+ displayValue.composants.forEach((viewComponent, index) => {
3502
+ let field = undefined;
3503
+ if (viewComponent.name && ignoredFields.includes(viewComponent.name)) {
3504
+ return;
3505
+ }
3506
+ const [fieldIdx, fixedInfo] = createOrGetField(appS, registeredFields, viewComponent, tables, state);
3507
+ if (fieldIdx === -1 && fixedInfo) {
3508
+ switch (fixedInfo.ref) {
3509
+ case 'title':
3510
+ addTitleToView(newName, appS, fixedInfo);
3511
+ break;
3512
+ case 'alertAuthor':
3513
+ addAlertAuthorToView(newName, appS, fixedInfo);
3514
+ break;
3515
+ case 'sendAlert':
3516
+ addSendAlertToView(newName, appS, fixedInfo);
3517
+ break;
3518
+ case 'publishTo':
3519
+ addPublishToToView(newName, appS, fixedInfo);
3520
+ break;
3521
+ default:
3522
+ console.error('fixed field info with unsupported ref ', fixedInfo);
3523
+ break;
3524
+ }
3525
+ }
3526
+ else if (fieldIdx !== -1) {
3527
+ field = appS.fields[fieldIdx];
3528
+ if (!field || !field.views) {
3529
+ throw new Error(`error converting installed app to V2: created field not found in fields array: ${fieldIdx}, ${fixedInfo}`);
3530
+ }
3531
+ field.views[newName] = true;
3532
+ addFieldToView(newName, field, appS, index, fixedInfo);
3533
+ }
3534
+ });
3535
+ }
3536
+ function buildListView(appS, registeredFields, columns, tables, state) {
3537
+ if (!columns) {
3538
+ return;
3539
+ }
3540
+ Object.keys(columns).forEach((fieldRef, index) => {
3541
+ addFieldToViewFromRef(appS, registeredFields, tables, 'list', fieldRef, index, state);
3542
+ });
3543
+ }
3544
+ function buildFilterView(appS, registeredFields, attrExposed, tables, state) {
3545
+ attrExposed.forEach((fieldRef, index) => {
3546
+ addFieldToViewFromRef(appS, registeredFields, tables, 'filter', fieldRef, index, state);
3547
+ });
3548
+ }
3549
+ function addFieldToViewFromRef(appS, registeredFields, tables, viewName, fieldRef, index, state) {
3550
+ switch (fieldRef) {
3551
+ case 'title':
3552
+ addTitleToView(viewName, appS, { ref: 'title', fixedValue: undefined });
3553
+ break;
3554
+ case 'iduser':
3555
+ case 'idUser':
3556
+ addUserToView(viewName, appS);
3557
+ break;
3558
+ case 'datecreation':
3559
+ case 'dateCreation':
3560
+ addDateCreationToView(viewName, appS);
3561
+ break;
3562
+ default:
3563
+ defaultFieldCreation(appS, registeredFields, tables, viewName, fieldRef, index, state);
3564
+ break;
3565
+ }
3566
+ }
3567
+ function defaultFieldCreation(appS, registeredFields, tables, viewName, fieldRef, index, state) {
3568
+ const fieldIndex = createOrGetFieldFromRef(appS, registeredFields, tables, fieldRef, state);
3569
+ const field = appS.fields[fieldIndex];
3570
+ if (!field || !field.views) {
3571
+ throw new Error(`error converting installed app to V2: unable to handle ${fieldRef} in list view`);
3572
+ }
3573
+ field.views[viewName] = true;
3574
+ addFieldToView(viewName, field, appS, index, undefined);
3575
+ }
3576
+ function createOrGetFieldFromRef(appS, registeredFields, tables, fieldRef, state) {
3577
+ const knownIndex = registeredFields.get(fieldRef);
3578
+ if (knownIndex !== undefined) {
3579
+ return knownIndex;
3580
+ }
3581
+ const [ref, indexCreated] = createStudioDefinedField(appS, fieldRef, tables, state);
3582
+ registeredFields.set(ref, indexCreated);
3583
+ return indexCreated;
3584
+ }
3585
+ function createOrGetField(appS, registeredFields, viewComponent, tables, state) {
3586
+ if (viewComponent.name !== undefined && viewComponent.element === 'attr') {
3587
+ if (specialAttrName.includes(viewComponent.name)) {
3588
+ return [-1, { ref: viewComponent.name, fixedValue: undefined }];
3589
+ }
3590
+ const knownIndex = registeredFields.get(viewComponent.name);
3591
+ if (knownIndex !== undefined) {
3592
+ return [knownIndex, undefined];
3593
+ }
3594
+ const [ref, indexCreated] = createStudioDefinedField(appS, viewComponent.name, tables, state);
3595
+ registeredFields.set(ref, indexCreated);
3596
+ return [indexCreated, undefined];
3597
+ }
3598
+ else if (viewComponent.element === 'html') {
3599
+ const htmlCode = viewComponent.html;
3600
+ if (htmlCode === undefined) {
3601
+ console.error('error while parsing studio installed html attr in a view: no html code');
3602
+ return [-1, undefined];
3603
+ }
3604
+ if (htmlCode.includes('<JAMESPOT.STUDIO.FIXED>')) {
3605
+ const startPos = htmlCode.indexOf('<JAMESPOT.STUDIO.FIXED>') + '<JAMESPOT.STUDIO.FIXED>'.length;
3606
+ const endPos = htmlCode.indexOf('</JAMESPOT.STUDIO.FIXED>');
3607
+ const formItemRefString = htmlCode.substring(startPos, endPos);
3608
+ try {
3609
+ const formItemRef = JSON.parse(formItemRefString);
3610
+ if ((formItemRef === null || formItemRef === void 0 ? void 0 : formItemRef.ref.toUpperCase()) in ExtraAppFieldsItemViews ||
3611
+ specialAttrName.includes(formItemRef === null || formItemRef === void 0 ? void 0 : formItemRef.ref)) {
3612
+ return [-1, formItemRef];
3613
+ }
3614
+ const knownIndex = registeredFields.get(formItemRef === null || formItemRef === void 0 ? void 0 : formItemRef.ref);
3615
+ if (knownIndex !== undefined) {
3616
+ return [knownIndex, formItemRef];
3617
+ }
3618
+ const [ref, indexCreated] = createStudioDefinedField(appS, formItemRef.ref, tables, state);
3619
+ registeredFields.set(ref, indexCreated);
3620
+ return [indexCreated, formItemRef];
3621
+ }
3622
+ catch (_) {
3623
+ console.error('error while parsing studio installed fixed attr in a view: json parsing failed');
3624
+ return [-1, undefined];
3625
+ }
3626
+ }
3627
+ else if (htmlCode.includes('<JAMESPOT.STUDIO.CODEHTML>')) {
3628
+ try {
3629
+ const startPosCode = htmlCode.indexOf('<JAMESPOT.STUDIO.CODEHTML>') + '<JAMESPOT.STUDIO.CODEHTML>'.length;
3630
+ const endPosCode = htmlCode.indexOf('</JAMESPOT.STUDIO.CODEHTML>');
3631
+ const formItemString = htmlCode.substring(startPosCode, endPosCode);
3632
+ const formItem = JSON.parse(formItemString);
3633
+ const knownIndex = registeredFields.get(formItem === null || formItem === void 0 ? void 0 : formItem.name);
3634
+ if (knownIndex !== undefined) {
3635
+ return [knownIndex, undefined];
3636
+ }
3637
+ const htmlField = createHtmlField(formItem);
3638
+ const indexCreated = appS.fields.push(htmlField) - 1;
3639
+ registeredFields.set(htmlField.id, indexCreated);
3640
+ return [indexCreated, undefined];
3641
+ }
3642
+ catch (_) {
3643
+ console.error('error while parsing studio installed codehtml attr in a view: json parsing failed');
3644
+ return [-1, undefined];
3645
+ }
3646
+ }
3647
+ else {
3648
+ console.error('error while parsing studio installed html attr in a view: unknown html format');
3649
+ return [-1, undefined];
3650
+ }
3651
+ }
3652
+ else if (viewComponent.element === 'image') {
3653
+ const knownIndex = registeredFields.get('image');
3654
+ if (knownIndex !== undefined) {
3655
+ return [knownIndex, undefined];
3656
+ }
3657
+ const imageField = createImageField();
3658
+ const indexCreated = appS.fields.push(imageField) - 1;
3659
+ registeredFields.set('image', indexCreated);
3660
+ return [indexCreated, undefined];
3661
+ }
3662
+ else if (viewComponent.element === 'publishTo') {
3663
+ return [-1, { ref: 'publishTo', fixedValue: undefined }];
3664
+ }
3665
+ else {
3666
+ console.error('error while parsing studio installed attr in a view: unknown attr :O');
3667
+ return [-1, undefined];
3668
+ }
3669
+ }
3670
+ function createStudioDefinedField(appS, ref, tables, state) {
3671
+ const installedField = getInstalledField(ref, tables);
3672
+ const type = getFormItemType(installedField);
3673
+ const v2Field = (function createField() {
3674
+ switch (type) {
3675
+ case AppFormItemTypes.ADDFILEATTACHMENT:
3676
+ return createAddfileattachmentField(installedField);
3677
+ case AppFormItemTypes.NUMBER:
3678
+ return createNumberField(installedField);
3679
+ case AppFormItemTypes.TAGS:
3680
+ return createTagsField(installedField);
3681
+ case AppFormItemTypes.SELECT:
3682
+ return createSelectField(installedField);
3683
+ case AppFormItemTypes.RADIO:
3684
+ return createRadioField(installedField);
3685
+ case AppFormItemTypes.CHECKBOX:
3686
+ return createCheckboxField(installedField);
3687
+ case AppFormItemTypes.CONTENTLINK:
3688
+ return createContentLinkField(installedField, state);
3689
+ case AppFormItemTypes.DESCRIPTION:
3690
+ return createDescriptionField(installedField);
3691
+ case AppFormItemTypes.TEXTAREAHTML:
3692
+ return createTextareaHTMLField(installedField);
3693
+ case AppFormItemTypes.DATE:
3694
+ return createDateField(installedField);
3695
+ case AppFormItemTypes.DATETIME:
3696
+ return createDatetimeField(installedField);
3697
+ case AppFormItemTypes.URL:
3698
+ return createUrlField(installedField);
3699
+ case AppFormItemTypes.EMAIL:
3700
+ return createEmailField(installedField);
3701
+ case AppFormItemTypes.TOGGLE:
3702
+ return createToggleField(installedField);
3703
+ case AppFormItemTypes.USERLINK:
3704
+ return createUserLinkField(installedField);
3705
+ case AppFormItemTypes.TEXTAREA:
3706
+ return createTextAreaField(installedField);
3707
+ case AppFormItemTypes.TEXT:
3708
+ default:
3709
+ return createTextField(installedField);
3710
+ }
3711
+ })();
3712
+ const index = appS.fields.push(v2Field) - 1;
3713
+ return [ref, index];
3714
+ }
3715
+ function getInstalledField(ref, tables) {
3716
+ var _a;
3717
+ let foundField = undefined;
3718
+ for (let i = 0; i < tables.length && !foundField; i++) {
3719
+ foundField = (_a = tables[i]) === null || _a === void 0 ? void 0 : _a.attributes.find((attr) => {
3720
+ return attr.name === ref;
3721
+ });
3722
+ }
3723
+ if (!foundField) {
3724
+ throw new Error('error converting installed app to V2: installed field not found in tables ' + ref);
3725
+ }
3726
+ return foundField;
3727
+ }
3728
+ function addFieldToView(viewName, field, appS, index, fixedInfo) {
3729
+ var _a;
3730
+ if (field.views) {
3731
+ field.views[viewName] = true;
3732
+ appS.views[viewName][field.id] = {
3733
+ type: field.type,
3734
+ properties: field.properties || [],
3735
+ isUsed: true,
3736
+ isOptional: false,
3737
+ isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
3738
+ isFixed: false,
3739
+ value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : null,
3740
+ pos: index,
3741
+ };
3742
+ }
3743
+ }
3744
+ function getFormItemType(installedField) {
3745
+ var _a, _b, _c;
3746
+ switch (installedField.widget.type) {
3747
+ case 'number':
3748
+ return AppFormItemTypes.NUMBER;
3749
+ case 'taxonomy':
3750
+ return AppFormItemTypes.TAGS;
3751
+ case 'date':
3752
+ return AppFormItemTypes.DATE;
3753
+ case 'datetime':
3754
+ return AppFormItemTypes.DATETIME;
3755
+ case 'select':
3756
+ return AppFormItemTypes.SELECT;
3757
+ case 'radio':
3758
+ return AppFormItemTypes.RADIO;
3759
+ case 'url':
3760
+ return AppFormItemTypes.URL;
3761
+ case 'email':
3762
+ return AppFormItemTypes.EMAIL;
3763
+ case 'file':
3764
+ return AppFormItemTypes.ADDFILEATTACHMENT;
3765
+ case 'checkbox':
3766
+ if (((_a = installedField.widget.options) === null || _a === void 0 ? void 0 : _a['1']) === 'GLOBAL_Yes') {
3767
+ return AppFormItemTypes.TOGGLE;
3768
+ }
3769
+ return AppFormItemTypes.CHECKBOX;
3770
+ case 'uri':
3771
+ if (((_b = installedField.widget.params) === null || _b === void 0 ? void 0 : _b.views) === 'user') {
3772
+ return AppFormItemTypes.USERLINK;
3773
+ }
3774
+ if (((_c = installedField.widget.params) === null || _c === void 0 ? void 0 : _c.views) === 'article') {
3775
+ return AppFormItemTypes.CONTENTLINK;
3776
+ }
3777
+ break;
3778
+ case 'textarea':
3779
+ if (installedField.attrType === 'longtext') {
3780
+ return AppFormItemTypes.TEXTAREA;
3781
+ }
3782
+ if (installedField.attrType === 'html') {
3783
+ if (installedField.name === 'description') {
3784
+ return AppFormItemTypes.DESCRIPTION;
3785
+ }
3786
+ return AppFormItemTypes.TEXTAREAHTML;
3787
+ }
3788
+ break;
3789
+ case 'text':
3790
+ return AppFormItemTypes.TEXT;
3791
+ }
3792
+ throw new Error('error converting installed app to V2: installed field type not recognized for field ' + installedField.name);
3793
+ }
3794
+ function addTitleToView(newName, appS, fixedInfo) {
3795
+ var _a;
3796
+ const fieldId = 'title';
3797
+ appS.views[newName][fieldId] = {
3798
+ type: ExtraAppFieldsItemViews.TITLE,
3799
+ properties: [],
3800
+ isUsed: true,
3801
+ isOptional: false,
3802
+ isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
3803
+ isFixed: true,
3804
+ value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : null,
3805
+ pos: 0,
3806
+ };
3807
+ }
3808
+ function addAlertAuthorToView(newName, appS, fixedInfo) {
3809
+ const fieldId = 'alertAuthor';
3810
+ appS.views[newName][fieldId] = {
3811
+ type: ExtraAppFieldsItemViews.RECEIVEACOPY,
3812
+ properties: [],
3813
+ isUsed: true,
3814
+ isOptional: true,
3815
+ isLockedValue: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined,
3816
+ isFixed: false,
3817
+ value: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined ? fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue : true,
3818
+ pos: 300,
3819
+ };
3820
+ }
3821
+ function addSendAlertToView(newName, appS, fixedInfo) {
3822
+ const fieldId = 'sendAlert';
3823
+ appS.views[newName][fieldId] = {
3824
+ type: ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
3825
+ properties: [],
3826
+ isUsed: true,
3827
+ isOptional: true,
3828
+ isLockedValue: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined,
3829
+ isFixed: false,
3830
+ value: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined ? fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue : true,
3831
+ pos: 200,
3832
+ };
3833
+ }
3834
+ function addPublishToToView(newName, appS, fixedInfo) {
3835
+ var _a;
3836
+ const fieldId = 'publishTo';
3837
+ appS.views[newName][fieldId] = {
3838
+ type: ExtraAppFieldsItemViews.PUBLISHTO,
3839
+ properties: [],
3840
+ isUsed: true,
3841
+ isOptional: true,
3842
+ isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
3843
+ isFixed: false,
3844
+ value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : [],
3845
+ pos: 100,
3846
+ };
3847
+ }
3848
+ function addUserToView(newName, appS) {
3849
+ const fieldId = 'user';
3850
+ appS.views[newName][fieldId] = {
3851
+ type: ExtraAppFieldsItemViews.USER,
3852
+ properties: [],
3853
+ isUsed: true,
3854
+ isOptional: false,
3855
+ isLockedValue: false,
3856
+ isFixed: true,
3857
+ value: null,
3858
+ pos: 1,
3859
+ };
3860
+ }
3861
+ function addDateCreationToView(newName, appS) {
3862
+ const fieldId = 'dateCreation';
3863
+ appS.views[newName][fieldId] = {
3864
+ type: ExtraAppFieldsItemViews.CREATIONDATE,
3865
+ properties: [],
3866
+ isUsed: true,
3867
+ isOptional: true,
3868
+ isLockedValue: false,
3869
+ isFixed: false,
3870
+ value: null,
3871
+ pos: 100,
3872
+ };
3873
+ }
3874
+
3875
+ function InstalledAppStudioAdapter(serverApp, serverApps, state) {
3144
3876
  var _a, _b, _c, _d;
3145
3877
  const { version, dateCreation } = serverApp.manifest;
3146
3878
  const appTypeServer = serverApp.typeModel;
3147
3879
  const views = Object.assign({}, ...viewsList.map((view) => ({
3148
- [view]: [],
3880
+ [view]: {},
3149
3881
  })));
3150
3882
  const studioApp = {
3151
3883
  idApp: serverApp.idApp,
3152
3884
  status: _formatStatus(serverApp),
3153
3885
  studioVersion: 2,
3154
- manifest: Object.assign({ appShortName: serverApp.name, appName: serverApp.label, description: serverApp.description, author: serverApp.author, cssColor: (_a = appTypeServer.cssColor) !== null && _a !== void 0 ? _a : '#392994', cssClass: { label: (_b = appTypeServer.cssClass) !== null && _b !== void 0 ? _b : 'star', value: (_c = appTypeServer.cssClass) !== null && _c !== void 0 ? _c : 'star' }, version: version, dateCreation: dateCreation, checkAccess: serverApp.checkAccess, attrExposed: serverApp.attrExposed, viewSolr: serverApp.view, typeLabel: (_d = appTypeServer.typeLabel) !== null && _d !== void 0 ? _d : {} }, (serverApp.articlesCount && { articlesCount: serverApp.articlesCount })),
3886
+ manifest: {
3887
+ appShortName: serverApp.label,
3888
+ appName: serverApp.label,
3889
+ description: serverApp.description,
3890
+ author: serverApp.author,
3891
+ cssColor: (_a = appTypeServer.cssColor) !== null && _a !== void 0 ? _a : '#392994',
3892
+ cssClass: { label: (_b = appTypeServer.cssClass) !== null && _b !== void 0 ? _b : 'star', value: (_c = appTypeServer.cssClass) !== null && _c !== void 0 ? _c : 'star' },
3893
+ version: version,
3894
+ dateCreation: dateCreation,
3895
+ checkAccess: false,
3896
+ accessRightList: "",
3897
+ attrExposed: [],
3898
+ viewSolr: serverApp.view ? STUDIO_VIEW.SOLR : STUDIO_VIEW.NOT_SOLR,
3899
+ typeLabel: appTypeServer.typeLabel,
3900
+ articlesCount: (_d = serverApp.articlesCount) !== null && _d !== void 0 ? _d : 0,
3901
+ },
3155
3902
  fields: [],
3156
3903
  views,
3157
- installFor: serverApp.accessRightObjectList,
3904
+ installFor: serverApp.accessRightObjectList ? buildAudience(serverApp.accessRightObjectList) : [],
3158
3905
  audience: serverApp.checkAccess === false ? AUDIENCE.ALL : AUDIENCE.CUSTOM,
3159
3906
  };
3907
+ populateFieldsAndViews(serverApp, studioApp, state);
3908
+ studioApp.views = updateViewsFromFields(studioApp, studioApp.fields);
3160
3909
  const inWorkAppVersion = _findAssociatedDraft(serverApp.idApp, serverApps);
3161
3910
  if (!inWorkAppVersion)
3162
3911
  return studioApp;
@@ -3178,20 +3927,21 @@ function DraftAppStudioAdapter(serverApp) {
3178
3927
  manifest: parsedJson.manifest,
3179
3928
  fields: parsedJson.fields,
3180
3929
  views: parsedJson.views,
3930
+ syncViewFieldOrder: parsedJson.syncViewFieldOrder,
3181
3931
  audience: parsedJson.audience,
3182
3932
  installFor: parsedJson.installFor,
3183
3933
  };
3184
3934
  }
3185
3935
  else {
3186
- return Object.assign(Object.assign({}, migrateJson(JSON.parse(serverApp.value))), { status: _formatStatus(serverApp) });
3936
+ return Object.assign(Object.assign({}, migrateJson(parsedJson)), { status: _formatStatus(serverApp), migratedFrom: 1 });
3187
3937
  }
3188
3938
  }
3189
3939
  function _formatStatus(serverApp) {
3190
3940
  return serverApp.status === jamespot.StudioApplicationStatus.installed
3191
3941
  ? serverApp.suspended
3192
- ? exports.StatusType.suspended
3193
- : exports.StatusType.installed
3194
- : exports.StatusType.draft;
3942
+ ? StatusType$1.suspended
3943
+ : StatusType$1.installed
3944
+ : StatusType$1.draft;
3195
3945
  }
3196
3946
  function _findAssociatedDraft(idApp, serverApps) {
3197
3947
  const draft = serverApps.find((app) => app.idApp === idApp && app.status === jamespot.StudioApplicationStatus.saved);
@@ -3200,11 +3950,11 @@ function _findAssociatedDraft(idApp, serverApps) {
3200
3950
  function _findAssociatedInstalled(idApp, serverApps) {
3201
3951
  return !!serverApps.find((app) => app.idApp === idApp && app.status === jamespot.StudioApplicationStatus.installed);
3202
3952
  }
3203
- function serverAppsToStudioApps(serverApps) {
3953
+ function serverAppsToStudioApps(serverApps, state) {
3204
3954
  const studioApps = serverApps
3205
3955
  .map((serverApp) => {
3206
3956
  if (serverApp.status === jamespot.StudioApplicationStatus.installed) {
3207
- return InstalledAppStudioAdapter(serverApp, serverApps);
3957
+ return InstalledAppStudioAdapter(serverApp, serverApps, state);
3208
3958
  }
3209
3959
  else {
3210
3960
  if (_findAssociatedInstalled(serverApp.idApp, serverApps))
@@ -3270,7 +4020,13 @@ function renderAppView(viewSolr, listView) {
3270
4020
  if (viewSolr === STUDIO_VIEW.SOLR) {
3271
4021
  let xml = '<AppView>solr</AppView>';
3272
4022
  const formItemIdInList = [];
3273
- Object.entries(listView).forEach(([fieldId, field]) => {
4023
+ Object.entries(listView).sort((a, b) => a[1].pos - b[1].pos).forEach(([fieldId, field]) => {
4024
+ if (!field.isUsed) {
4025
+ return;
4026
+ }
4027
+ if ([AppFormItemTypes.IMAGE].includes(field.type)) {
4028
+ return;
4029
+ }
3274
4030
  formItemIdInList.push(getAttrNameFormItem(field, fieldId));
3275
4031
  });
3276
4032
  xml += `<AppColumns>${formItemIdInList.join()}</AppColumns>`;
@@ -3280,27 +4036,31 @@ function renderAppView(viewSolr, listView) {
3280
4036
  }
3281
4037
  function renderAppSearch(searchView) {
3282
4038
  const formItemIdInFilter = [];
3283
- Object.entries(searchView).forEach(([fieldId, field]) => {
3284
- if (![exports.ExtraAppFieldsItemViews.TITLE, exports.AppFormItemTypes.IMAGE].includes(field.type))
4039
+ Object.entries(searchView).sort((a, b) => a[1].pos - b[1].pos).forEach(([fieldId, field]) => {
4040
+ if (!field.isUsed) {
4041
+ return;
4042
+ }
4043
+ const list = [ExtraAppFieldsItemViews.TITLE, AppFormItemTypes.IMAGE];
4044
+ if (!list.includes(field.type))
3285
4045
  formItemIdInFilter.push(getAttrNameFormItem(field, fieldId));
3286
4046
  });
3287
4047
  return `<AttrExposed>${formItemIdInFilter.join()}</AttrExposed>`;
3288
4048
  }
3289
4049
  function getAttrNameFormItem(field, fieldId) {
3290
4050
  function fieldType() {
3291
- if (field.type === exports.ExtraAppFieldsItemViews.TITLE)
4051
+ if (field.type === ExtraAppFieldsItemViews.TITLE)
3292
4052
  return 'title';
3293
- if (field.type === exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS)
4053
+ if (field.type === ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS)
3294
4054
  return 'sendAlert';
3295
- if (field.type === exports.ExtraAppFieldsItemViews.RECEIVEACOPY)
4055
+ if (field.type === ExtraAppFieldsItemViews.RECEIVEACOPY)
3296
4056
  return 'alertAuthor';
3297
- if (field.type === exports.ExtraAppFieldsItemViews.PUBLISHTO)
4057
+ if (field.type === ExtraAppFieldsItemViews.PUBLISHTO)
3298
4058
  return 'publishTo';
3299
- if (field.type === exports.ExtraAppFieldsItemViews.USER)
4059
+ if (field.type === ExtraAppFieldsItemViews.USER)
3300
4060
  return 'idUser';
3301
- if (field.type === exports.ExtraAppFieldsItemViews.CREATIONDATE)
4061
+ if (field.type === ExtraAppFieldsItemViews.CREATIONDATE)
3302
4062
  return 'dateCreation';
3303
- if (field.type === exports.AppFormItemTypes.DESCRIPTION)
4063
+ if (field.type === AppFormItemTypes.DESCRIPTION)
3304
4064
  return 'description';
3305
4065
  return field.type;
3306
4066
  }
@@ -3316,18 +4076,18 @@ function renderAudience(audience, installFor) {
3316
4076
  return '';
3317
4077
  }
3318
4078
  function renderPrimaryFields(fields) {
3319
- const primaryFields = fields === null || fields === void 0 ? void 0 : fields.filter((field) => AppFormPrimaryList.includes(field.type));
4079
+ const primaryFields = fields === null || fields === void 0 ? void 0 : fields.filter((field) => AppFormPrimaryListValues.includes(field.type));
3320
4080
  if (primaryFields.length === 0)
3321
4081
  return '';
3322
4082
  return `<primaryFields>${primaryFields.map((field) => formItem2xml(field)).join('')}</primaryFields>`;
3323
4083
  }
3324
4084
  function renderCustomFields(fields) {
3325
- const customFields = fields === null || fields === void 0 ? void 0 : fields.filter((field) => !AppFormPrimaryList.includes(field.type));
3326
- const filteredCustomFields = customFields === null || customFields === void 0 ? void 0 : customFields.filter((field) => field.type !== exports.AppFormItemTypes.IMAGE);
4085
+ const customFields = fields === null || fields === void 0 ? void 0 : fields.filter((field) => !AppFormPrimaryListValues.includes(field.type));
4086
+ const filteredCustomFields = customFields === null || customFields === void 0 ? void 0 : customFields.filter((field) => field.type !== AppFormItemTypes.IMAGE);
3327
4087
  if (filteredCustomFields.length === 0)
3328
4088
  return '';
3329
- const articlesTablesItems = filteredCustomFields.filter((f) => f.type !== exports.AppFormItemTypes.TAGS && !AppFormNonPrimaryList.includes(f.type));
3330
- const linksTableItems = filteredCustomFields.filter((f) => f.type === exports.AppFormItemTypes.TAGS);
4089
+ const articlesTablesItems = filteredCustomFields.filter((f) => f.type !== AppFormItemTypes.TAGS && !AppFormNonPrimaryList.includes(f.type));
4090
+ const linksTableItems = filteredCustomFields.filter((f) => f.type === AppFormItemTypes.TAGS);
3331
4091
  return `<custom>
3332
4092
  ${articlesTablesItems.length > 0
3333
4093
  ? `<articlemstable>
@@ -3345,15 +4105,15 @@ function formItem2xml(field) {
3345
4105
  type="${renderFieldTypeToXmlType(field.type)}"
3346
4106
  name="${getAttrNameFormItem(field, field.id)}"
3347
4107
  sqlname="${renderSqlName(field.type, field.id)}"
3348
- ${field.properties && renderProperty(field.properties, exports.AppFieldFormPropertyTypes.LABEL)}
3349
- ${field.properties && renderProperty(field.properties, exports.AppFieldFormPropertyTypes.DESCRIPTION)}
4108
+ ${field.properties && renderProperty(field.properties, AppFieldFormPropertyTypes.LABEL)}
4109
+ ${field.properties && renderProperty(field.properties, AppFieldFormPropertyTypes.DESCRIPTION)}
3350
4110
  mandatory="${field.mandatory}"
3351
4111
  solr.type="${renderSolrType(field.type)}"
3352
4112
  solr.used="true"
3353
4113
  solr.indexed="true"
3354
4114
  solr.stored="true"
3355
4115
  solr.searchable="true"
3356
- solr.multiValued="${field.type === exports.AppFormItemTypes.TAGS || field.type === exports.AppFormItemTypes.CHECKBOX ? true : false}"
4116
+ solr.multiValued="${field.type === AppFormItemTypes.TAGS || field.type === AppFormItemTypes.CHECKBOX ? true : false}"
3357
4117
  teaser="true"
3358
4118
  display="true"
3359
4119
  >
@@ -3363,43 +4123,49 @@ function formItem2xml(field) {
3363
4123
  function renderWidget(fieldType, fieldProperties) {
3364
4124
  var _a;
3365
4125
  switch (fieldType) {
3366
- case exports.AppFormItemTypes.DESCRIPTION:
4126
+ case AppFormItemTypes.DESCRIPTION:
3367
4127
  return '<widget form="textarea"><params><param key="class" value="mceEditor"></param><param key="mention" value="1"></param></params></widget>';
3368
- case exports.AppFormItemTypes.TEXT:
4128
+ case AppFormItemTypes.TEXT:
3369
4129
  return '<widget form="text"></widget>';
3370
- case exports.AppFormItemTypes.TEXTAREA:
4130
+ case AppFormItemTypes.TEXTAREA:
3371
4131
  return '<widget form="textarea"></widget>';
3372
- case exports.AppFormItemTypes.TEXTAREAHTML:
4132
+ case AppFormItemTypes.TEXTAREAHTML:
3373
4133
  return '<widget form="textarea"><params><param key="class" value="mceEditor"></param></params></widget>';
3374
- case exports.AppFormItemTypes.DATE:
4134
+ case AppFormItemTypes.DATE:
3375
4135
  return '<widget form="date" format="d/m/Y"></widget>';
3376
- case exports.AppFormItemTypes.DATETIME:
4136
+ case AppFormItemTypes.DATETIME:
3377
4137
  return `<widget form="datetime" format="d/m/Y H:i:s"></widget>`;
3378
- case exports.AppFormItemTypes.NUMBER: {
3379
- const isFloat = ((_a = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.CHECKBOX)) === null || _a === void 0 ? void 0 : _a.value) === true;
4138
+ case AppFormItemTypes.NUMBER: {
4139
+ 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;
3380
4140
  return `<widget form="number">
3381
4141
  ${isFloat ? `<params><param value="0.01" key="step"/></params>` : ''}
3382
4142
  </widget>`;
3383
4143
  }
3384
- case exports.AppFormItemTypes.SELECT: {
3385
- const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR);
4144
+ case AppFormItemTypes.SELECT: {
4145
+ const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
3386
4146
  if (!optionEditor)
3387
4147
  return '';
3388
4148
  const isMultiple = optionEditor.value.canSelectMultiple;
3389
4149
  const options = optionEditor.value.propertyOptions;
3390
4150
  const hasDefaultValue = optionEditor.value.defaultSelectOption;
3391
- const defaultValue = optionEditor.value.defaultSelectOptionValue;
4151
+ const defaultValue = optionEditor.value.defaultSelectOptionValue.value;
4152
+ const userCanModifiyByComment = optionEditor.value.userCanModifiyByComment;
3392
4153
  return `<widget form="select" ${isMultiple ? 'multiple="1"' : ''}>
3393
4154
  <options>
3394
4155
  ${options
3395
4156
  .map((option) => `<option value="${option.value}" label="${option.title}"></option>`)
3396
4157
  .join('')}
3397
4158
  </options>
3398
- ${hasDefaultValue ? `<params><param key="defaultValue" value="${defaultValue}"/></params>` : ''}
4159
+ ${hasDefaultValue || userCanModifiyByComment
4160
+ ? `<params>
4161
+ ${hasDefaultValue ? `<param key="defaultValue" value="${defaultValue}"/>` : ''}
4162
+ ${userCanModifiyByComment ? `<param key="explain" value="1"/>` : ''}
4163
+ </params>`
4164
+ : ''}
3399
4165
  </widget>`;
3400
4166
  }
3401
- case exports.AppFormItemTypes.RADIO: {
3402
- const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR);
4167
+ case AppFormItemTypes.RADIO: {
4168
+ const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
3403
4169
  if (!optionEditor)
3404
4170
  return '';
3405
4171
  const options = optionEditor.value.propertyOptions;
@@ -3411,7 +4177,7 @@ function renderWidget(fieldType, fieldProperties) {
3411
4177
  </options>
3412
4178
  </widget>`;
3413
4179
  }
3414
- case exports.AppFormItemTypes.TOGGLE:
4180
+ case AppFormItemTypes.TOGGLE:
3415
4181
  return `<widget form="checkbox">
3416
4182
  <options>
3417
4183
  <option value="1" label="GLOBAL_Yes"></option>
@@ -3420,8 +4186,8 @@ function renderWidget(fieldType, fieldProperties) {
3420
4186
  <param key="jagCheckbox" value="1"></param>
3421
4187
  </params>
3422
4188
  </widget>`;
3423
- case exports.AppFormItemTypes.TAGS: {
3424
- const taxonomy = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.TAXONOMY);
4189
+ case AppFormItemTypes.TAGS: {
4190
+ const taxonomy = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === AppFieldFormPropertyTypes.TAXONOMY);
3425
4191
  if (!taxonomy)
3426
4192
  return '';
3427
4193
  const taxonomyId = taxonomy.value.id;
@@ -3429,8 +4195,8 @@ function renderWidget(fieldType, fieldProperties) {
3429
4195
  <params><param key="idTaxonomy" value="${taxonomyId}"></param></params>
3430
4196
  </widget>`;
3431
4197
  }
3432
- case exports.AppFormItemTypes.CHECKBOX: {
3433
- const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR);
4198
+ case AppFormItemTypes.CHECKBOX: {
4199
+ const optionEditor = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR);
3434
4200
  if (!optionEditor)
3435
4201
  return '';
3436
4202
  const options = optionEditor.value.propertyOptions;
@@ -3442,15 +4208,15 @@ function renderWidget(fieldType, fieldProperties) {
3442
4208
  </options>
3443
4209
  </widget>`;
3444
4210
  }
3445
- case exports.AppFormItemTypes.ADDFILEATTACHMENT:
4211
+ case AppFormItemTypes.ADDFILEATTACHMENT:
3446
4212
  return `<widget form="file" type="fileArticle" multiple="1"></widget>`;
3447
- case exports.AppFormItemTypes.URL:
4213
+ case AppFormItemTypes.URL:
3448
4214
  return `<widget form="url"></widget>`;
3449
- case exports.AppFormItemTypes.EMAIL:
4215
+ case AppFormItemTypes.EMAIL:
3450
4216
  return `<widget form="email"></widget>`;
3451
- case exports.ExtraAppFieldsItemViews.USER:
4217
+ case ExtraAppFieldsItemViews.USER:
3452
4218
  return `<widget form="idUser"></widget>`;
3453
- case exports.AppFormItemTypes.USERLINK:
4219
+ case AppFormItemTypes.USERLINK:
3454
4220
  return `<widget form="uri">
3455
4221
  <params>
3456
4222
  <param key="mode" value="ng-view"></param>
@@ -3461,8 +4227,8 @@ function renderWidget(fieldType, fieldProperties) {
3461
4227
  <param key="jcomplete-url" value="/?action=ajax&amp;group=autocomplete&amp;function=user"></param>
3462
4228
  </params>
3463
4229
  </widget>`;
3464
- case exports.AppFormItemTypes.CONTENTLINK: {
3465
- const contentType = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.CONTENTTYPE);
4230
+ case AppFormItemTypes.CONTENTLINK: {
4231
+ const contentType = fieldProperties === null || fieldProperties === void 0 ? void 0 : fieldProperties.find((property) => property.propertyType === AppFieldFormPropertyTypes.CONTENTTYPE);
3466
4232
  if (!contentType)
3467
4233
  return '';
3468
4234
  const type = contentType.value.type;
@@ -3489,9 +4255,9 @@ function renderProperty(properties, propertyToFind) {
3489
4255
  }
3490
4256
  function renderSqlName(fieldType, fieldId) {
3491
4257
  switch (fieldType) {
3492
- case exports.AppFormItemTypes.DESCRIPTION:
4258
+ case AppFormItemTypes.DESCRIPTION:
3493
4259
  return 'Description';
3494
- case exports.ExtraAppFieldsItemViews.USER:
4260
+ case ExtraAppFieldsItemViews.USER:
3495
4261
  return 'IdUser';
3496
4262
  default:
3497
4263
  return uuid2Alpha(fieldId);
@@ -3499,27 +4265,27 @@ function renderSqlName(fieldType, fieldId) {
3499
4265
  }
3500
4266
  function renderSolrType(fieldType) {
3501
4267
  switch (fieldType) {
3502
- case exports.AppFormItemTypes.DESCRIPTION:
3503
- case exports.AppFormItemTypes.TEXT:
3504
- case exports.AppFormItemTypes.TEXTAREA:
3505
- case exports.AppFormItemTypes.TEXTAREAHTML:
3506
- case exports.AppFormItemTypes.URL:
3507
- case exports.AppFormItemTypes.EMAIL:
3508
- case exports.AppFormItemTypes.USERLINK:
3509
- case exports.AppFormItemTypes.CONTENTLINK:
3510
- case exports.AppFormItemTypes.NUMBER:
3511
- case exports.AppFormItemTypes.ADDFILEATTACHMENT:
4268
+ case AppFormItemTypes.DESCRIPTION:
4269
+ case AppFormItemTypes.TEXT:
4270
+ case AppFormItemTypes.TEXTAREA:
4271
+ case AppFormItemTypes.TEXTAREAHTML:
4272
+ case AppFormItemTypes.URL:
4273
+ case AppFormItemTypes.EMAIL:
4274
+ case AppFormItemTypes.USERLINK:
4275
+ case AppFormItemTypes.CONTENTLINK:
4276
+ case AppFormItemTypes.NUMBER:
4277
+ case AppFormItemTypes.ADDFILEATTACHMENT:
3512
4278
  return 'text';
3513
- case exports.AppFormItemTypes.DATE:
3514
- case exports.AppFormItemTypes.DATETIME:
4279
+ case AppFormItemTypes.DATE:
4280
+ case AppFormItemTypes.DATETIME:
3515
4281
  return 'date';
3516
- case exports.ExtraAppFieldsItemViews.USER:
4282
+ case ExtraAppFieldsItemViews.USER:
3517
4283
  return 'integer';
3518
- case exports.AppFormItemTypes.SELECT:
3519
- case exports.AppFormItemTypes.RADIO:
3520
- case exports.AppFormItemTypes.TOGGLE:
3521
- case exports.AppFormItemTypes.CHECKBOX:
3522
- case exports.AppFormItemTypes.TAGS:
4284
+ case AppFormItemTypes.SELECT:
4285
+ case AppFormItemTypes.RADIO:
4286
+ case AppFormItemTypes.TOGGLE:
4287
+ case AppFormItemTypes.CHECKBOX:
4288
+ case AppFormItemTypes.TAGS:
3523
4289
  return 'string';
3524
4290
  default:
3525
4291
  return '';
@@ -3528,30 +4294,30 @@ function renderSolrType(fieldType) {
3528
4294
  function renderFieldTypeToXmlType(fieldType) {
3529
4295
  switch (fieldType) {
3530
4296
  default:
3531
- case exports.AppFormItemTypes.DESCRIPTION:
3532
- case exports.AppFormItemTypes.TEXTAREAHTML:
4297
+ case AppFormItemTypes.DESCRIPTION:
4298
+ case AppFormItemTypes.TEXTAREAHTML:
3533
4299
  return 'html';
3534
- case exports.AppFormItemTypes.TAGS:
4300
+ case AppFormItemTypes.TAGS:
3535
4301
  return 'taxonomy';
3536
- case exports.AppFormItemTypes.TEXT:
3537
- case exports.AppFormItemTypes.SELECT:
3538
- case exports.AppFormItemTypes.RADIO:
3539
- case exports.AppFormItemTypes.CHECKBOX:
3540
- case exports.AppFormItemTypes.URL:
3541
- case exports.AppFormItemTypes.EMAIL:
3542
- case exports.AppFormItemTypes.ADDFILEATTACHMENT:
3543
- case exports.ExtraAppFieldsItemViews.USER:
3544
- case exports.AppFormItemTypes.USERLINK:
3545
- case exports.AppFormItemTypes.CONTENTLINK:
4302
+ case AppFormItemTypes.TEXT:
4303
+ case AppFormItemTypes.RADIO:
4304
+ case AppFormItemTypes.URL:
4305
+ case AppFormItemTypes.EMAIL:
4306
+ case AppFormItemTypes.ADDFILEATTACHMENT:
4307
+ case ExtraAppFieldsItemViews.USER:
4308
+ case AppFormItemTypes.USERLINK:
4309
+ case AppFormItemTypes.CONTENTLINK:
3546
4310
  return 'text';
3547
- case exports.AppFormItemTypes.TEXTAREA:
4311
+ case AppFormItemTypes.TEXTAREA:
4312
+ case AppFormItemTypes.CHECKBOX:
4313
+ case AppFormItemTypes.SELECT:
3548
4314
  return 'longtext';
3549
- case exports.AppFormItemTypes.DATE:
4315
+ case AppFormItemTypes.DATE:
3550
4316
  return 'date';
3551
- case exports.AppFormItemTypes.DATETIME: {
4317
+ case AppFormItemTypes.DATETIME: {
3552
4318
  return 'date';
3553
4319
  }
3554
- case exports.AppFormItemTypes.NUMBER:
4320
+ case AppFormItemTypes.NUMBER:
3555
4321
  return 'float';
3556
4322
  }
3557
4323
  }
@@ -3585,7 +4351,9 @@ function renderDisplays(studioApp) {
3585
4351
  let toRet = '';
3586
4352
  Object.entries(studioApp.views).forEach(([viewName, viewContent]) => {
3587
4353
  if (Object.prototype.hasOwnProperty.call(internal2XmlView, viewName)) {
3588
- const viewField = Object.entries(viewContent);
4354
+ const viewField = Object.entries(viewContent)
4355
+ .filter((a) => a[1].isUsed)
4356
+ .sort((a, b) => a[1].pos - b[1].pos);
3589
4357
  toRet += `<display view="${internal2XmlView[viewName]}" mode="${viewName === 'view' ? 'view' : 'form'}">
3590
4358
  ${viewField.map(([fieldId, view]) => renderDisplayAttr(fieldId, view)).join('')}
3591
4359
  </display>`;
@@ -3598,19 +4366,19 @@ function renderDisplays(studioApp) {
3598
4366
  }
3599
4367
  function getDisplayName(fieldId, view) {
3600
4368
  switch (view.type) {
3601
- case exports.ExtraAppFieldsItemViews.TITLE:
4369
+ case ExtraAppFieldsItemViews.TITLE:
3602
4370
  return 'title';
3603
- case exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS:
4371
+ case ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS:
3604
4372
  return 'sendAlert';
3605
- case exports.ExtraAppFieldsItemViews.RECEIVEACOPY:
4373
+ case ExtraAppFieldsItemViews.RECEIVEACOPY:
3606
4374
  return 'alertAuthor';
3607
- case exports.ExtraAppFieldsItemViews.PUBLISHTO:
4375
+ case ExtraAppFieldsItemViews.PUBLISHTO:
3608
4376
  return 'publishTo';
3609
- case exports.ExtraAppFieldsItemViews.USER:
4377
+ case ExtraAppFieldsItemViews.USER:
3610
4378
  return 'idUser';
3611
- case exports.ExtraAppFieldsItemViews.CREATIONDATE:
4379
+ case ExtraAppFieldsItemViews.CREATIONDATE:
3612
4380
  return 'dateCreation';
3613
- case exports.AppFormItemTypes.DESCRIPTION:
4381
+ case AppFormItemTypes.DESCRIPTION:
3614
4382
  return 'description';
3615
4383
  default:
3616
4384
  return uuid2Alpha(fieldId);
@@ -3627,29 +4395,34 @@ function renderDisplayAttr(fieldId, view) {
3627
4395
  fixedValue: view.value,
3628
4396
  };
3629
4397
  xml += `<html><![CDATA[ <!-- <JAMESPOT.STUDIO.FIXED>${JSON.stringify(formItemRefWithName)}</JAMESPOT.STUDIO.FIXED> -->`;
3630
- if (view.type === exports.ExtraAppFieldsItemViews.PUBLISHTO) {
4398
+ if (view.type === ExtraAppFieldsItemViews.PUBLISHTO) {
3631
4399
  const uris = view.value.map((user) => user.uri).join(',');
3632
4400
  xml += `<input type="hidden" name="publishTo" value="${uris}">`;
3633
4401
  }
3634
- else if (view.type === exports.ExtraAppFieldsItemViews.USER ||
3635
- view.type === exports.AppFormItemTypes.USERLINK ||
3636
- view.type === exports.AppFormItemTypes.CONTENTLINK) {
4402
+ else if (view.type === ExtraAppFieldsItemViews.USER ||
4403
+ view.type === AppFormItemTypes.USERLINK ||
4404
+ view.type === AppFormItemTypes.CONTENTLINK) {
3637
4405
  xml += `<input type="hidden" name="${attrName}[]" value=${JSON.stringify(view.value.uri)}>`;
3638
4406
  }
3639
- else if (view.type === exports.AppFormItemTypes.SELECT) {
3640
- const values = view.value;
3641
- const canSelectMultiple = (_a = view.properties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR)) === null || _a === void 0 ? void 0 : _a.value.canSelectMultiple;
3642
- values.forEach((value) => {
3643
- xml += `<input type="hidden" name="${attrName}${canSelectMultiple ? '[]' : ''}" value="${value.value}">`;
3644
- });
4407
+ else if (view.type === AppFormItemTypes.SELECT) {
4408
+ const canSelectMultiple = (_a = view.properties.find((property) => property.propertyType === AppFieldFormPropertyTypes.OPTIONS_EDITOR)) === null || _a === void 0 ? void 0 : _a.value.canSelectMultiple;
4409
+ if (canSelectMultiple) {
4410
+ const values = view.value;
4411
+ values.forEach((value) => {
4412
+ xml += `<input type="hidden" name="${attrName}[]" value="${value.value}">`;
4413
+ });
4414
+ }
4415
+ else {
4416
+ xml += `<input type="hidden" name="${attrName}" value="${view.value.value}">`;
4417
+ }
3645
4418
  }
3646
- else if (view.type === exports.AppFormItemTypes.CHECKBOX) {
4419
+ else if (view.type === AppFormItemTypes.CHECKBOX) {
3647
4420
  const values = view.value;
3648
4421
  values.forEach((value) => {
3649
- xml += `<input type="hidden" name="${attrName}[]" value="${value.value}">`;
4422
+ xml += `<input type="hidden" name="${attrName}[]" value="${value}">`;
3650
4423
  });
3651
4424
  }
3652
- else if (view.type === exports.AppFormItemTypes.DATE) {
4425
+ else if (view.type === AppFormItemTypes.DATE) {
3653
4426
  const dateValue = new Date(view.value);
3654
4427
  const xmlFixedValue = [
3655
4428
  pad(dateValue.getDate()),
@@ -3658,23 +4431,30 @@ function renderDisplayAttr(fieldId, view) {
3658
4431
  ].join('/');
3659
4432
  xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
3660
4433
  }
3661
- else if (view.type === exports.AppFormItemTypes.DATETIME) {
4434
+ else if (view.type === AppFormItemTypes.DATETIME) {
3662
4435
  const dateValue = new Date(view.value);
3663
- const xmlFixedValue = [
4436
+ const xmlFixedValue = `${[
3664
4437
  pad(dateValue.getDate()),
3665
4438
  pad(dateValue.getMonth() + 1),
3666
4439
  dateValue.getFullYear(),
3667
- pad(dateValue.getHours()),
3668
- pad(dateValue.getMinutes()),
3669
- pad(dateValue.getSeconds()),
3670
- ].join('/');
4440
+ ].join('/')} ${pad(dateValue.getHours())}:${pad(dateValue.getMinutes())}:${pad(dateValue.getSeconds())}`;
3671
4441
  xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
3672
4442
  }
3673
- else if (view.type === exports.AppFormItemTypes.TAGS) {
4443
+ else if (view.type === AppFormItemTypes.TAGS) {
3674
4444
  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(',')}">`;
3675
4445
  }
3676
- else if (view.type === exports.AppFormItemTypes.DESCRIPTION || view.type === exports.AppFormItemTypes.TEXTAREAHTML) {
3677
- xml += `<input type="hidden" name="${attrName}" value="${view.value.html}">`;
4446
+ else if (view.type === AppFormItemTypes.DESCRIPTION || view.type === AppFormItemTypes.TEXTAREAHTML) {
4447
+ xml += `<input type="hidden" name="${attrName}" value="${view.value}">`;
4448
+ }
4449
+ else if (view.type === ExtraAppFieldsItemViews.RECEIVEACOPY) {
4450
+ if (view.value) {
4451
+ xml += `<input type="hidden" name="alertAuthor[jamespot]"><input type="hidden" name="alertAuthor[]" value="1">`;
4452
+ }
4453
+ }
4454
+ else if (view.type === ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS) {
4455
+ if (view.value) {
4456
+ xml += `<input type="hidden" name="sendAlert[jamespot]"><input type="hidden" name="sendAlert[]" value="1">`;
4457
+ }
3678
4458
  }
3679
4459
  else {
3680
4460
  xml += `<input type="hidden" name="${attrName}" value="${view.value}">`;
@@ -3683,14 +4463,21 @@ function renderDisplayAttr(fieldId, view) {
3683
4463
  }
3684
4464
  else {
3685
4465
  switch (view.type) {
3686
- case exports.AppFormItemTypes.CODEHTML: {
3687
- xml += `<html><![CDATA[ <!-- <JAMESPOT.STUDIO.CODEHTML>${view.value}</JAMESPOT.STUDIO.CODEHTML><JAMESPOT.STUDIO.FIELD_POS>${view.pos}</JAMESPOT.STUDIO.FIELD_POS>-->${view.value}]]></html>`;
4466
+ case AppFormItemTypes.CODEHTML: {
4467
+ const fieldToInclude = {
4468
+ id: fieldId,
4469
+ name: fieldId,
4470
+ properties: {
4471
+ code: view.value,
4472
+ },
4473
+ };
4474
+ 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>`;
3688
4475
  break;
3689
4476
  }
3690
- case exports.AppFormItemTypes.IMAGE:
4477
+ case AppFormItemTypes.IMAGE:
3691
4478
  xml += '<image />';
3692
4479
  break;
3693
- case exports.ExtraAppFieldsItemViews.PUBLISHTO:
4480
+ case ExtraAppFieldsItemViews.PUBLISHTO:
3694
4481
  xml += '<publishTo />';
3695
4482
  break;
3696
4483
  default:
@@ -3711,12 +4498,12 @@ const initialState$1 = {
3711
4498
  installStudioAppStatus: 'idle',
3712
4499
  hasChanged: false,
3713
4500
  };
3714
- const fetchCurrentStudioApp = toolkit.createAsyncThunk('studio/fetchCurrentStudioApp', ({ idApp, status }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
4501
+ const fetchCurrentStudioApp = toolkit.createAsyncThunk('studio/fetchCurrentStudioApp', ({ idApp, status }, { extra, rejectWithValue, getState }) => __awaiter(void 0, void 0, void 0, function* () {
3715
4502
  const jApi = extra.jApi;
3716
4503
  const error = { error: 1, errorMsg: 'Error fetching application' };
3717
4504
  try {
3718
4505
  const studioApplicationBase = (yield jApi.application.get(idApp, status)).result;
3719
- const studioApplication = serverAppsToStudioApps([studioApplicationBase])[0];
4506
+ const studioApplication = serverAppsToStudioApps([studioApplicationBase], getState())[0];
3720
4507
  if (!studioApplication) {
3721
4508
  return rejectWithValue(error);
3722
4509
  }
@@ -3820,16 +4607,22 @@ const CurrentStudioAppSlice = toolkit.createSlice({
3820
4607
  },
3821
4608
  });
3822
4609
 
3823
- function cloneStudioAppFromExistingApp(existingApp, author) {
3824
- const newApp = existingApp.inWorkVersion
3825
- ? JSON.parse(JSON.stringify(existingApp.inWorkVersion))
4610
+ function cloneStudioAppFromExistingApp(existingApp, author, inWorkVersion) {
4611
+ const newApp = existingApp.studioVersion !== 2
4612
+ ? JSON.parse(JSON.stringify(migrateJson(existingApp)))
3826
4613
  : JSON.parse(JSON.stringify(existingApp));
3827
- const newAppId = uuid.v4();
3828
- const newAppName = `${existingApp.manifest.appName} Copie`;
3829
- newApp.idApp = newAppId;
3830
- newApp.status = APP_STATUS_TYPE.DRAFT;
3831
- newApp.manifest = Object.assign(Object.assign({}, newApp.manifest), { appName: newAppName, appShortName: newAppName, author: author || '', dateCreation: new Date().toISOString(), version: 0.1, articlesCount: 0 });
3832
- return [newApp, newAppId];
4614
+ delete newApp.inWorkVersion;
4615
+ if (!inWorkVersion) {
4616
+ const newAppId = uuid.v4();
4617
+ const newAppName = `${existingApp.manifest.appName} Copie`;
4618
+ newApp.idApp = newAppId;
4619
+ newApp.status = APP_STATUS_TYPE.DRAFT;
4620
+ newApp.manifest = Object.assign(Object.assign({}, newApp.manifest), { appName: newAppName, appShortName: newAppName, author: author || newApp.manifest.author || '', dateCreation: new Date().toISOString(), version: 0.1, articlesCount: 0 });
4621
+ }
4622
+ else {
4623
+ newApp.manifest.version = newApp.manifest.version + 0.1;
4624
+ }
4625
+ return [newApp, newApp.idApp];
3833
4626
  }
3834
4627
 
3835
4628
  function createNewStudioApp$1({ author, appName }) {
@@ -3891,37 +4684,78 @@ function createNewStudioApp$1({ author, appName }) {
3891
4684
  attrExposed: [],
3892
4685
  articlesCount: 0,
3893
4686
  },
4687
+ syncViewFieldOrder: {
4688
+ create: true,
4689
+ popup: true,
4690
+ view: true,
4691
+ edit: true,
4692
+ list: true,
4693
+ filter: true,
4694
+ },
3894
4695
  fields: [],
3895
4696
  views,
3896
- audience: AUDIENCE.ALL,
4697
+ audience: AUDIENCE.CUSTOM,
3897
4698
  installFor: [],
3898
4699
  },
3899
4700
  };
3900
4701
  }
3901
4702
 
4703
+ function appLexicalSort(a, b) {
4704
+ return a.manifest.appName > b.manifest.appName ? 1 : -1;
4705
+ }
3902
4706
  const initialState = {
3903
4707
  loadingStudioAppsList: 'idle',
3904
4708
  deleteStudioAppStatus: 'idle',
3905
4709
  suspendStudioAppStatus: 'idle',
3906
4710
  restartStudioAppStatus: 'idle',
3907
4711
  cloneStudioAppStatus: 'idle',
4712
+ createInWorkAppStatus: 'idle',
3908
4713
  createNewStudioAppStatus: 'idle',
3909
4714
  };
3910
- const fetchStudioAppsList = toolkit.createAsyncThunk('studio/appsList', (_, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
4715
+ const fetchStudioAppsList = toolkit.createAsyncThunk('studio/appsList', (intl, { extra, rejectWithValue, dispatch, getState }) => __awaiter(void 0, void 0, void 0, function* () {
3911
4716
  const jApi = extra.jApi;
3912
4717
  try {
3913
4718
  const { result } = yield jApi.application.list();
3914
- return yield Promise.all(result.map((app) => __awaiter(void 0, void 0, void 0, function* () {
4719
+ const taxonomies = yield jApi.taxonomy.list();
4720
+ const apps = yield Promise.all(result.map((app) => __awaiter(void 0, void 0, void 0, function* () {
3915
4721
  const coreApp = (yield jApi.application.get(app.idApp, app.status)).result;
3916
4722
  const articlesCount = (yield jApi.article.count(app.idApp)).result;
3917
4723
  return Object.assign(Object.assign({}, coreApp), { articlesCount });
3918
4724
  })));
4725
+ const transformedApps = serverAppsToStudioApps(apps, getState());
4726
+ transformedApps.forEach((app) => __awaiter(void 0, void 0, void 0, function* () {
4727
+ app.fields = updateTaxonomies(app.fields, taxonomies, intl);
4728
+ if (app.inWorkVersion) {
4729
+ app.inWorkVersion.fields = updateTaxonomies(app.inWorkVersion.fields, taxonomies, intl);
4730
+ }
4731
+ }));
4732
+ return transformedApps;
3919
4733
  }
3920
4734
  catch (_) {
3921
4735
  dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
3922
4736
  throw rejectWithValue({ error: 1, errorMsg: 'Error retrieving applications' });
3923
4737
  }
3924
4738
  }));
4739
+ function updateTaxonomies(fields, taxonomies, intl) {
4740
+ return fields.map((field) => {
4741
+ var _a;
4742
+ if (field.type !== AppFormItemTypes.TAGS) {
4743
+ return field;
4744
+ }
4745
+ const newField = JSON.parse(JSON.stringify(field));
4746
+ const newFieldTaxoProp = (_a = newField.properties) === null || _a === void 0 ? void 0 : _a.find((prop) => {
4747
+ return prop.propertyType === AppFieldFormPropertyTypes.TAXONOMY;
4748
+ });
4749
+ const taxo = taxonomies.find((taxo) => {
4750
+ return taxo.id === (newFieldTaxoProp === null || newFieldTaxoProp === void 0 ? void 0 : newFieldTaxoProp.value.id);
4751
+ });
4752
+ if (taxo && newFieldTaxoProp) {
4753
+ newFieldTaxoProp.value.title = intl.formatMessage({ id: taxo.title });
4754
+ newFieldTaxoProp.value.type = taxo.type;
4755
+ }
4756
+ return newField;
4757
+ });
4758
+ }
3925
4759
  const createNewStudioApp = toolkit.createAsyncThunk('studio/createApp', ({ appName, callback }, { extra, dispatch, rejectWithValue, getState }) => __awaiter(void 0, void 0, void 0, function* () {
3926
4760
  var _a;
3927
4761
  const jApi = extra.jApi;
@@ -3974,12 +4808,20 @@ const restartStudioApp = toolkit.createAsyncThunk('studio/restartStudioApp', ({
3974
4808
  throw rejectWithValue({ error: 1, errorMsg: 'Error restarting application' });
3975
4809
  }
3976
4810
  }));
3977
- const cloneStudioApp = toolkit.createAsyncThunk('studio/cloneStudioApp', ({ idApp }, { extra, getState, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
4811
+ const cloneStudioApp = toolkit.createAsyncThunk('studio/cloneStudioApp', ({ idApp, inWork }, { extra, getState, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
3978
4812
  var _b, _c;
3979
4813
  const jApi = extra.jApi;
3980
- const existingStudioApp = (_b = getState().studio.studioAppsList.studioAppsList) === null || _b === void 0 ? void 0 : _b.find((app) => app.idApp === idApp);
4814
+ let existingStudioApp = (_b = getState().studio.studioAppsList.studioAppsList) === null || _b === void 0 ? void 0 : _b.find((app) => app.idApp === idApp);
3981
4815
  if (!existingStudioApp)
3982
4816
  return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
4817
+ if (inWork) {
4818
+ if (existingStudioApp.inWorkVersion !== undefined) {
4819
+ existingStudioApp = existingStudioApp.inWorkVersion;
4820
+ }
4821
+ else {
4822
+ return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
4823
+ }
4824
+ }
3983
4825
  const currentUser = (_c = getState().userCurrent) === null || _c === void 0 ? void 0 : _c.uri;
3984
4826
  const [clonedStudioApp, newAppId] = cloneStudioAppFromExistingApp(existingStudioApp, currentUser);
3985
4827
  const clonedStudioAppReady = JSON.stringify(clonedStudioApp);
@@ -3993,12 +4835,33 @@ const cloneStudioApp = toolkit.createAsyncThunk('studio/cloneStudioApp', ({ idAp
3993
4835
  return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
3994
4836
  }
3995
4837
  }));
4838
+ const createInWorkStudioApp = toolkit.createAsyncThunk('studio/createInWorkStudioApp', ({ idApp }, { extra, getState, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
4839
+ var _d, _e;
4840
+ const jApi = extra.jApi;
4841
+ const existingStudioApp = (_d = getState().studio.studioAppsList.studioAppsList) === null || _d === void 0 ? void 0 : _d.find((app) => app.idApp === idApp);
4842
+ if (!existingStudioApp ||
4843
+ ![APP_STATUS_TYPE.INSTALLED, APP_STATUS_TYPE.SUSPENDED].includes(existingStudioApp.status)) {
4844
+ return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
4845
+ }
4846
+ const currentUser = (_e = getState().userCurrent) === null || _e === void 0 ? void 0 : _e.uri;
4847
+ const [clonedStudioApp, newAppId] = cloneStudioAppFromExistingApp(existingStudioApp, currentUser, true);
4848
+ const clonedStudioAppReady = JSON.stringify(clonedStudioApp);
4849
+ try {
4850
+ yield jApi.application.save(newAppId, clonedStudioAppReady, 'saved');
4851
+ dispatch(Toast.actions.success({ label: 'APPSTUDIO_AppItem_CreateInWork' }));
4852
+ return clonedStudioApp;
4853
+ }
4854
+ catch (_) {
4855
+ dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
4856
+ return rejectWithValue({ error: 1, errorMsg: 'Error creating in work version for application' });
4857
+ }
4858
+ }));
3996
4859
  const StudioAppsListSlice = toolkit.createSlice({
3997
4860
  name: 'studioAppsList',
3998
4861
  initialState,
3999
4862
  reducers: {
4000
4863
  setAppsList: (state, action) => {
4001
- state.studioAppsList = action.payload;
4864
+ state.studioAppsList = [...action.payload].sort(appLexicalSort);
4002
4865
  },
4003
4866
  },
4004
4867
  extraReducers: (builder) => {
@@ -4011,7 +4874,7 @@ const StudioAppsListSlice = toolkit.createSlice({
4011
4874
  if (state.loadingStudioAppsList === 'pending') {
4012
4875
  state.loadingStudioAppsList = 'idle';
4013
4876
  }
4014
- state.studioAppsList = serverAppsToStudioApps(action.payload);
4877
+ state.studioAppsList = [...action.payload].sort(appLexicalSort);
4015
4878
  })
4016
4879
  .addCase(fetchStudioAppsList.rejected, (state) => {
4017
4880
  if (state.loadingStudioAppsList === 'pending')
@@ -4032,8 +4895,13 @@ const StudioAppsListSlice = toolkit.createSlice({
4032
4895
  let { status } = action.meta.arg;
4033
4896
  if (status === APP_STATUS_TYPE.INSTALLED)
4034
4897
  status = APP_STATUS_TYPE.SUSPENDED;
4035
- if (app.idApp === idApp && app.status === status)
4898
+ if (app.idApp === idApp && app.status === status) {
4899
+ if (app.inWorkVersion && app.status === APP_STATUS_TYPE.SUSPENDED) {
4900
+ app.inWorkVersion.status = APP_STATUS_TYPE.DRAFT;
4901
+ return [...acc, app.inWorkVersion];
4902
+ }
4036
4903
  return acc;
4904
+ }
4037
4905
  if (app.inWorkVersion &&
4038
4906
  app.inWorkVersion.idApp === idApp &&
4039
4907
  app.inWorkVersion.status === status) {
@@ -4089,38 +4957,65 @@ const StudioAppsListSlice = toolkit.createSlice({
4089
4957
  })) !== null && _b !== void 0 ? _b : [];
4090
4958
  })
4091
4959
  .addCase(restartStudioApp.rejected, (state) => {
4092
- if (state.restartStudioAppStatus === 'pending')
4960
+ if (state.restartStudioAppStatus === 'pending') {
4093
4961
  state.restartStudioAppStatus = 'idle';
4962
+ }
4094
4963
  })
4095
4964
  .addCase(cloneStudioApp.pending, (state) => {
4096
- if (state.cloneStudioAppStatus === 'idle')
4965
+ if (state.cloneStudioAppStatus === 'idle') {
4097
4966
  state.cloneStudioAppStatus = 'pending';
4967
+ }
4098
4968
  })
4099
4969
  .addCase(cloneStudioApp.fulfilled, (state, action) => {
4100
4970
  var _a;
4101
4971
  if (state.cloneStudioAppStatus === 'pending') {
4102
4972
  state.cloneStudioAppStatus = 'idle';
4103
4973
  }
4104
- state.studioAppsList = [...((_a = state.studioAppsList) !== null && _a !== void 0 ? _a : []), action.payload];
4974
+ state.studioAppsList = [...((_a = state.studioAppsList) !== null && _a !== void 0 ? _a : []), action.payload].sort(appLexicalSort);
4105
4975
  })
4106
4976
  .addCase(cloneStudioApp.rejected, (state) => {
4107
- if (state.cloneStudioAppStatus === 'pending')
4977
+ if (state.cloneStudioAppStatus === 'pending') {
4108
4978
  state.cloneStudioAppStatus = 'idle';
4979
+ }
4980
+ })
4981
+ .addCase(createInWorkStudioApp.pending, (state) => {
4982
+ if (state.createInWorkAppStatus === 'idle') {
4983
+ state.createInWorkAppStatus = 'pending';
4984
+ }
4985
+ })
4986
+ .addCase(createInWorkStudioApp.fulfilled, (state, action) => {
4987
+ var _a;
4988
+ if (state.createInWorkAppStatus === 'pending') {
4989
+ state.createInWorkAppStatus = 'idle';
4990
+ }
4991
+ const app = (_a = state.studioAppsList) === null || _a === void 0 ? void 0 : _a.find((app) => {
4992
+ return app.idApp === action.payload.idApp;
4993
+ });
4994
+ if (app) {
4995
+ app.inWorkVersion = action.payload;
4996
+ }
4997
+ })
4998
+ .addCase(createInWorkStudioApp.rejected, (state) => {
4999
+ if (state.createInWorkAppStatus === 'pending') {
5000
+ state.createInWorkAppStatus = 'idle';
5001
+ }
4109
5002
  })
4110
5003
  .addCase(createNewStudioApp.pending, (state) => {
4111
- if (state.createNewStudioAppStatus === 'idle')
5004
+ if (state.createNewStudioAppStatus === 'idle') {
4112
5005
  state.createNewStudioAppStatus = 'pending';
5006
+ }
4113
5007
  })
4114
5008
  .addCase(createNewStudioApp.fulfilled, (state, action) => {
4115
5009
  var _a;
4116
5010
  if (state.createNewStudioAppStatus === 'pending') {
4117
5011
  state.createNewStudioAppStatus = 'idle';
4118
5012
  }
4119
- state.studioAppsList = [...((_a = state.studioAppsList) !== null && _a !== void 0 ? _a : []), action.payload];
5013
+ state.studioAppsList = [...((_a = state.studioAppsList) !== null && _a !== void 0 ? _a : []), action.payload].sort(appLexicalSort);
4120
5014
  })
4121
5015
  .addCase(createNewStudioApp.rejected, (state) => {
4122
- if (state.createNewStudioAppStatus === 'pending')
5016
+ if (state.createNewStudioAppStatus === 'pending') {
4123
5017
  state.createNewStudioAppStatus = 'idle';
5018
+ }
4124
5019
  });
4125
5020
  },
4126
5021
  });
@@ -4149,28 +5044,38 @@ const studio = {
4149
5044
  createNewStudioApp,
4150
5045
  fetchCurrentStudioApp,
4151
5046
  saveCurrentStudioApp,
4152
- installStudioApp }),
5047
+ installStudioApp,
5048
+ createInWorkStudioApp }),
4153
5049
  selectors: {
4154
5050
  selectStudioAppsList,
4155
5051
  selectCurrentStudioApp,
4156
5052
  },
5053
+ utils: {
5054
+ updateViewsFromFields,
5055
+ generateNewFormField,
5056
+ }
4157
5057
  };
4158
5058
 
4159
5059
  exports.APP_STATUS_TYPE = APP_STATUS_TYPE;
4160
5060
  exports.AUDIENCE = AUDIENCE;
4161
5061
  exports.Animations = Animations;
4162
5062
  exports.AppColumnsDefaultTypes = AppColumnsDefaultTypes;
5063
+ exports.AppFieldFormPropertyTypes = AppFieldFormPropertyTypes;
4163
5064
  exports.AppFormBannedFromViews = AppFormBannedFromViews$1;
4164
5065
  exports.AppFormFieldOnlyInView = AppFormFieldOnlyInView;
4165
5066
  exports.AppFormFixedList = AppFormFixedList$1;
5067
+ exports.AppFormItemTypes = AppFormItemTypes;
4166
5068
  exports.AppFormNoAsFieldList = AppFormNoAsFieldList;
4167
5069
  exports.AppFormNonPrimaryList = AppFormNonPrimaryList;
4168
5070
  exports.AppFormPrimaryList = AppFormPrimaryList;
5071
+ exports.AppFormPrimaryListValues = AppFormPrimaryListValues;
4169
5072
  exports.AppFormUniqueList = AppFormUniqueList;
5073
+ exports.AppFormUniqueListCheck = AppFormUniqueListCheck;
4170
5074
  exports.Application = Application;
4171
5075
  exports.AssetReservation = AssetReservation;
4172
5076
  exports.Bookmark = Bookmark;
4173
5077
  exports.Comment = Comment;
5078
+ exports.ExtraAppFieldsItemViews = ExtraAppFieldsItemViews;
4174
5079
  exports.Faq = Faq;
4175
5080
  exports.Hook = Hook;
4176
5081
  exports.MODE_EDIT = MODE_EDIT;
@@ -4184,6 +5089,7 @@ exports.Platform = Platform;
4184
5089
  exports.STUDIO_VIEW = STUDIO_VIEW;
4185
5090
  exports.Share = Share;
4186
5091
  exports.SocialActions = SocialActions;
5092
+ exports.StatusType = StatusType$1;
4187
5093
  exports.TVDisplay = TVDisplay;
4188
5094
  exports.TinyMCE = TinyMCE;
4189
5095
  exports.Toast = Toast;