jamespot-front-business 1.1.67 → 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
@@ -484,6 +484,36 @@ const CommentListSlice = toolkit.createSlice({
484
484
  discardComments: (state, action) => {
485
485
  state.comments = state.comments.filter((c) => c.idArticle !== action.payload.idArticle);
486
486
  },
487
+ hydrateComment: (state, action) => {
488
+ const { idArticle, list } = action.payload;
489
+ const hasList = state.comments.find((c) => c.idArticle === idArticle);
490
+ if (!hasList) {
491
+ state.comments = [
492
+ ...state.comments.filter((c) => c.idArticle !== idArticle),
493
+ {
494
+ idArticle,
495
+ list,
496
+ },
497
+ ];
498
+ return;
499
+ }
500
+ const initialUris = [];
501
+ const allUris = state.comments.reduce((uris, c) => {
502
+ return [...uris, ...c.list.map((el) => el.uri)];
503
+ }, initialUris);
504
+ const safeList = list.filter((el) => !allUris.includes(el.uri));
505
+ state.comments = state.comments.map((c) => {
506
+ return c.idArticle === idArticle
507
+ ? Object.assign(Object.assign({}, c), { list: [...c.list, ...safeList] }) : c;
508
+ });
509
+ },
510
+ updateComment: (state, action) => {
511
+ state.comments = state.comments.map((c) => {
512
+ const { idArticle, idComment, data } = action.payload;
513
+ return c.idArticle === idArticle
514
+ ? Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === idComment ? Object.assign(Object.assign({}, comment), { description: data.description }) : comment) }) : c;
515
+ });
516
+ },
487
517
  },
488
518
  extraReducers: (builder) => {
489
519
  builder
@@ -2735,118 +2765,129 @@ const AUDIENCE = {
2735
2765
  ALL: '1',
2736
2766
  CUSTOM: '0',
2737
2767
  };
2738
- exports.StatusType = void 0;
2739
- (function (StatusType) {
2740
- StatusType["draft"] = "draft";
2741
- StatusType["installed"] = "installed";
2742
- StatusType["suspended"] = "suspended";
2743
- })(exports.StatusType || (exports.StatusType = {}));
2768
+ const StatusType$1 = {
2769
+ draft: 'draft',
2770
+ installed: 'installed',
2771
+ suspended: 'suspended',
2772
+ };
2744
2773
  const APP_STATUS_TYPE = {
2745
- DRAFT: exports.StatusType.draft,
2746
- INSTALLED: exports.StatusType.installed,
2747
- SUSPENDED: exports.StatusType.suspended,
2774
+ DRAFT: StatusType$1.draft,
2775
+ INSTALLED: StatusType$1.installed,
2776
+ SUSPENDED: StatusType$1.suspended,
2748
2777
  };
2749
2778
  const STUDIO_VIEW = {
2750
2779
  SOLR: '1',
2751
2780
  NOT_SOLR: '0',
2752
2781
  };
2753
2782
  const viewsList = ['create', 'popup', 'edit', 'filter', 'list', 'view'];
2754
- exports.AppFormItemTypes = void 0;
2755
- (function (AppFormItemTypes) {
2756
- AppFormItemTypes["IMAGE"] = "IMAGE";
2757
- AppFormItemTypes["DESCRIPTION"] = "DESCRIPTION";
2758
- AppFormItemTypes["TEXT"] = "TEXT";
2759
- AppFormItemTypes["TEXTAREA"] = "TEXTAREA";
2760
- AppFormItemTypes["TEXTAREAHTML"] = "TEXTAREAHTML";
2761
- AppFormItemTypes["DATE"] = "DATE";
2762
- AppFormItemTypes["DATETIME"] = "DATETIME";
2763
- AppFormItemTypes["NUMBER"] = "NUMBER";
2764
- AppFormItemTypes["URL"] = "URL";
2765
- AppFormItemTypes["EMAIL"] = "EMAIL";
2766
- AppFormItemTypes["SELECT"] = "SELECT";
2767
- AppFormItemTypes["CHECKBOX"] = "CHECKBOX";
2768
- AppFormItemTypes["TOGGLE"] = "TOGGLE";
2769
- AppFormItemTypes["RADIO"] = "RADIO";
2770
- AppFormItemTypes["TAGS"] = "TAGS";
2771
- AppFormItemTypes["ADDFILEATTACHMENT"] = "ADDFILEATTACHMENT";
2772
- AppFormItemTypes["CODEHTML"] = "CODEHTML";
2773
- AppFormItemTypes["USERLINK"] = "USERLINK";
2774
- AppFormItemTypes["CONTENTLINK"] = "CONTENTLINK";
2775
- AppFormItemTypes["RANGE"] = "RANGE";
2776
- })(exports.AppFormItemTypes || (exports.AppFormItemTypes = {}));
2777
- exports.ExtraAppFieldsItemViews = void 0;
2778
- (function (ExtraAppFieldsItemViews) {
2779
- ExtraAppFieldsItemViews["TITLE"] = "TITLE";
2780
- ExtraAppFieldsItemViews["USER"] = "USER";
2781
- ExtraAppFieldsItemViews["PUBLISHTO"] = "PUBLISHTO";
2782
- ExtraAppFieldsItemViews["SENDALERTTOSUBSCRIBERS"] = "SENDALERTTOSUBSCRIBERS";
2783
- ExtraAppFieldsItemViews["RECEIVEACOPY"] = "RECEIVEACOPY";
2784
- ExtraAppFieldsItemViews["CREATIONDATE"] = "CREATIONDATE";
2785
- })(exports.ExtraAppFieldsItemViews || (exports.ExtraAppFieldsItemViews = {}));
2786
- exports.AppFieldFormPropertyTypes = void 0;
2787
- (function (AppFieldFormPropertyTypes) {
2788
- AppFieldFormPropertyTypes["LABEL"] = "label";
2789
- AppFieldFormPropertyTypes["DESCRIPTION"] = "description";
2790
- AppFieldFormPropertyTypes["RICHTEXT"] = "richtext";
2791
- AppFieldFormPropertyTypes["CHECKBOX"] = "checkbox";
2792
- AppFieldFormPropertyTypes["OPTIONS_EDITOR"] = "options_editor";
2793
- AppFieldFormPropertyTypes["TAXONOMY"] = "taxonomy";
2794
- AppFieldFormPropertyTypes["CONTENTTYPE"] = "contenttype";
2795
- })(exports.AppFieldFormPropertyTypes || (exports.AppFieldFormPropertyTypes = {}));
2796
- 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;
2797
2824
  const AppFormBannedFromViews$1 = new Map();
2798
- 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']);
2799
2827
  const MapExtraFieldsWithView = {
2800
2828
  create: {
2801
- fixed: [exports.ExtraAppFieldsItemViews.TITLE],
2829
+ fixed: [ExtraAppFieldsItemViews.TITLE],
2802
2830
  optional: [
2803
- exports.ExtraAppFieldsItemViews.PUBLISHTO,
2804
- exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
2805
- exports.ExtraAppFieldsItemViews.RECEIVEACOPY,
2831
+ ExtraAppFieldsItemViews.PUBLISHTO,
2832
+ ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
2833
+ ExtraAppFieldsItemViews.RECEIVEACOPY,
2806
2834
  ],
2807
2835
  },
2808
2836
  popup: {
2809
- fixed: [exports.ExtraAppFieldsItemViews.TITLE],
2810
- optional: [exports.ExtraAppFieldsItemViews.PUBLISHTO],
2837
+ fixed: [ExtraAppFieldsItemViews.TITLE],
2838
+ optional: [ExtraAppFieldsItemViews.PUBLISHTO],
2811
2839
  },
2812
2840
  edit: {
2813
- fixed: [exports.ExtraAppFieldsItemViews.TITLE],
2814
- optional: [exports.ExtraAppFieldsItemViews.PUBLISHTO],
2841
+ fixed: [ExtraAppFieldsItemViews.TITLE],
2842
+ optional: [ExtraAppFieldsItemViews.PUBLISHTO],
2815
2843
  },
2816
2844
  list: {
2817
- fixed: [exports.ExtraAppFieldsItemViews.TITLE, exports.ExtraAppFieldsItemViews.USER],
2818
- optional: [exports.ExtraAppFieldsItemViews.CREATIONDATE],
2845
+ fixed: [ExtraAppFieldsItemViews.TITLE, ExtraAppFieldsItemViews.USER],
2846
+ optional: [ExtraAppFieldsItemViews.CREATIONDATE],
2819
2847
  },
2820
2848
  filter: {
2821
- fixed: [exports.ExtraAppFieldsItemViews.TITLE, exports.ExtraAppFieldsItemViews.USER],
2822
- optional: [exports.ExtraAppFieldsItemViews.CREATIONDATE],
2849
+ fixed: [ExtraAppFieldsItemViews.TITLE, ExtraAppFieldsItemViews.USER],
2850
+ optional: [ExtraAppFieldsItemViews.CREATIONDATE],
2823
2851
  },
2824
2852
  view: {
2825
- fixed: [exports.ExtraAppFieldsItemViews.TITLE],
2853
+ fixed: [ExtraAppFieldsItemViews.TITLE],
2826
2854
  optional: [],
2827
2855
  },
2828
2856
  };
2829
2857
  const AppColumnsDefaultTypes = [
2830
- exports.ExtraAppFieldsItemViews.TITLE,
2831
- exports.ExtraAppFieldsItemViews.USER,
2832
- exports.ExtraAppFieldsItemViews.CREATIONDATE,
2833
- exports.AppFormItemTypes.DESCRIPTION,
2858
+ ExtraAppFieldsItemViews.TITLE,
2859
+ ExtraAppFieldsItemViews.USER,
2860
+ ExtraAppFieldsItemViews.CREATIONDATE,
2861
+ AppFormItemTypes.DESCRIPTION,
2834
2862
  ];
2835
- const AppFormPrimaryList = [exports.AppFormItemTypes.DESCRIPTION];
2863
+ const AppFormPrimaryList = [AppFormItemTypes.DESCRIPTION];
2864
+ const AppFormPrimaryListValues = AppFormPrimaryList;
2836
2865
  const AppFormFixedList$1 = [
2837
- exports.ExtraAppFieldsItemViews.TITLE,
2838
- exports.ExtraAppFieldsItemViews.PUBLISHTO,
2839
- exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
2840
- exports.ExtraAppFieldsItemViews.RECEIVEACOPY,
2841
- exports.ExtraAppFieldsItemViews.USER,
2842
- exports.ExtraAppFieldsItemViews.CREATIONDATE,
2866
+ ExtraAppFieldsItemViews.TITLE,
2867
+ ExtraAppFieldsItemViews.PUBLISHTO,
2868
+ ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
2869
+ ExtraAppFieldsItemViews.RECEIVEACOPY,
2870
+ ExtraAppFieldsItemViews.USER,
2871
+ ExtraAppFieldsItemViews.CREATIONDATE,
2843
2872
  ];
2844
2873
  const AppFormNoAsFieldList = [
2845
- exports.ExtraAppFieldsItemViews.USER,
2846
- exports.ExtraAppFieldsItemViews.TITLE,
2874
+ ExtraAppFieldsItemViews.USER,
2875
+ ExtraAppFieldsItemViews.TITLE,
2847
2876
  ];
2848
- const AppFormFieldOnlyInView = [exports.AppFormItemTypes.CODEHTML];
2877
+ const AppFormFieldOnlyInView = [AppFormItemTypes.CODEHTML];
2849
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 = {}));
2850
2891
 
2851
2892
  var StatusType;
2852
2893
  (function (StatusType) {
@@ -3007,7 +3048,7 @@ function migrateJson(v1Json) {
3007
3048
  return v2Fields;
3008
3049
  }
3009
3050
  function _matctTypes(v1Type) {
3010
- return exports.AppFormItemTypes[v1Type];
3051
+ return AppFormItemTypes[v1Type];
3011
3052
  }
3012
3053
  function _renderProperties(v1FormItemProperties) {
3013
3054
  var _a, _b, _c, _d, _e, _f, _g;
@@ -3016,11 +3057,11 @@ function migrateJson(v1Json) {
3016
3057
  Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'hasDefaultValue');
3017
3058
  const baseProperty = Object.assign({ isRequired: v1FormItemProperties.mandatory || false }, (isEnhancedOptionEditor && { isOptionsEditorEnhanced: true }));
3018
3059
  if (v1FormItemProperties.labels) {
3019
- v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.LABEL, value: ((_a = v1FormItemProperties.labels.label) === null || _a === void 0 ? void 0 : _a.content) || '' }, baseProperty));
3020
- 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));
3021
3062
  }
3022
3063
  if (v1FormItemProperties.options) {
3023
- v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR, value: isEnhancedOptionEditor
3064
+ v2Properties.push(Object.assign({ propertyType: AppFieldFormPropertyTypes.OPTIONS_EDITOR, value: isEnhancedOptionEditor
3024
3065
  ? {
3025
3066
  propertyOptions: _renderSelectOptions((_c = v1FormItemProperties.options) !== null && _c !== void 0 ? _c : []),
3026
3067
  defaultSelectOptionValue: v1FormItemProperties.defaultValue,
@@ -3031,16 +3072,16 @@ function migrateJson(v1Json) {
3031
3072
  : { propertyOptions: _renderSelectOptions((_g = v1FormItemProperties.options) !== null && _g !== void 0 ? _g : []) } }, baseProperty));
3032
3073
  }
3033
3074
  if (v1FormItemProperties.code) {
3034
- 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));
3035
3076
  }
3036
3077
  if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'digits')) {
3037
- 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));
3038
3079
  }
3039
3080
  if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'taxonomy')) {
3040
- v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.TAXONOMY, value: v1FormItemProperties.taxonomy || '' }, baseProperty));
3081
+ v2Properties.push(Object.assign({ propertyType: AppFieldFormPropertyTypes.TAXONOMY, value: v1FormItemProperties.taxonomy || '' }, baseProperty));
3041
3082
  }
3042
3083
  if (Object.prototype.hasOwnProperty.call(v1FormItemProperties, 'contentType')) {
3043
- v2Properties.push(Object.assign({ propertyType: exports.AppFieldFormPropertyTypes.CONTENTTYPE, value: v1FormItemProperties.contentType || '' }, baseProperty));
3084
+ v2Properties.push(Object.assign({ propertyType: AppFieldFormPropertyTypes.CONTENTTYPE, value: v1FormItemProperties.contentType || '' }, baseProperty));
3044
3085
  }
3045
3086
  return v2Properties;
3046
3087
  }
@@ -3077,19 +3118,19 @@ function migrateJson(v1Json) {
3077
3118
  value: v1FormItemRef.fixedValue || '',
3078
3119
  };
3079
3120
  if (v1FormItemRef.ref === AppFormItemType.TITLE) {
3080
- 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 });
3081
3122
  }
3082
3123
  else if (v1FormItemRef.ref === AppFormItemType.IDUSER) {
3083
- 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 });
3084
3125
  }
3085
3126
  else if (v1FormItemRef.ref === AppFormItemType.PUBLISHTO) {
3086
- 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 });
3087
3128
  }
3088
3129
  else if (v1FormItemRef.ref === AppFormItemType.SENDALERTTOSUBSCRIBERS) {
3089
- 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 });
3090
3131
  }
3091
3132
  else if (v1FormItemRef.ref === AppFormItemType.RECEIVEACOPY) {
3092
- 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 });
3093
3134
  }
3094
3135
  else {
3095
3136
  const v2Field = _mapFormItemRefWithField(v1FormItemRef);
@@ -3110,23 +3151,761 @@ function migrateJson(v1Json) {
3110
3151
  return v2;
3111
3152
  }
3112
3153
 
3113
- 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) {
3114
3876
  var _a, _b, _c, _d;
3115
3877
  const { version, dateCreation } = serverApp.manifest;
3116
3878
  const appTypeServer = serverApp.typeModel;
3117
3879
  const views = Object.assign({}, ...viewsList.map((view) => ({
3118
- [view]: [],
3880
+ [view]: {},
3119
3881
  })));
3120
3882
  const studioApp = {
3121
3883
  idApp: serverApp.idApp,
3122
3884
  status: _formatStatus(serverApp),
3123
3885
  studioVersion: 2,
3124
- 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
+ },
3125
3902
  fields: [],
3126
3903
  views,
3127
- installFor: serverApp.accessRightObjectList,
3904
+ installFor: serverApp.accessRightObjectList ? buildAudience(serverApp.accessRightObjectList) : [],
3128
3905
  audience: serverApp.checkAccess === false ? AUDIENCE.ALL : AUDIENCE.CUSTOM,
3129
3906
  };
3907
+ populateFieldsAndViews(serverApp, studioApp, state);
3908
+ studioApp.views = updateViewsFromFields(studioApp, studioApp.fields);
3130
3909
  const inWorkAppVersion = _findAssociatedDraft(serverApp.idApp, serverApps);
3131
3910
  if (!inWorkAppVersion)
3132
3911
  return studioApp;
@@ -3148,20 +3927,21 @@ function DraftAppStudioAdapter(serverApp) {
3148
3927
  manifest: parsedJson.manifest,
3149
3928
  fields: parsedJson.fields,
3150
3929
  views: parsedJson.views,
3930
+ syncViewFieldOrder: parsedJson.syncViewFieldOrder,
3151
3931
  audience: parsedJson.audience,
3152
3932
  installFor: parsedJson.installFor,
3153
3933
  };
3154
3934
  }
3155
3935
  else {
3156
- 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 });
3157
3937
  }
3158
3938
  }
3159
3939
  function _formatStatus(serverApp) {
3160
3940
  return serverApp.status === jamespot.StudioApplicationStatus.installed
3161
3941
  ? serverApp.suspended
3162
- ? exports.StatusType.suspended
3163
- : exports.StatusType.installed
3164
- : exports.StatusType.draft;
3942
+ ? StatusType$1.suspended
3943
+ : StatusType$1.installed
3944
+ : StatusType$1.draft;
3165
3945
  }
3166
3946
  function _findAssociatedDraft(idApp, serverApps) {
3167
3947
  const draft = serverApps.find((app) => app.idApp === idApp && app.status === jamespot.StudioApplicationStatus.saved);
@@ -3170,11 +3950,11 @@ function _findAssociatedDraft(idApp, serverApps) {
3170
3950
  function _findAssociatedInstalled(idApp, serverApps) {
3171
3951
  return !!serverApps.find((app) => app.idApp === idApp && app.status === jamespot.StudioApplicationStatus.installed);
3172
3952
  }
3173
- function serverAppsToStudioApps(serverApps) {
3953
+ function serverAppsToStudioApps(serverApps, state) {
3174
3954
  const studioApps = serverApps
3175
3955
  .map((serverApp) => {
3176
3956
  if (serverApp.status === jamespot.StudioApplicationStatus.installed) {
3177
- return InstalledAppStudioAdapter(serverApp, serverApps);
3957
+ return InstalledAppStudioAdapter(serverApp, serverApps, state);
3178
3958
  }
3179
3959
  else {
3180
3960
  if (_findAssociatedInstalled(serverApp.idApp, serverApps))
@@ -3240,7 +4020,13 @@ function renderAppView(viewSolr, listView) {
3240
4020
  if (viewSolr === STUDIO_VIEW.SOLR) {
3241
4021
  let xml = '<AppView>solr</AppView>';
3242
4022
  const formItemIdInList = [];
3243
- 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
+ }
3244
4030
  formItemIdInList.push(getAttrNameFormItem(field, fieldId));
3245
4031
  });
3246
4032
  xml += `<AppColumns>${formItemIdInList.join()}</AppColumns>`;
@@ -3250,27 +4036,31 @@ function renderAppView(viewSolr, listView) {
3250
4036
  }
3251
4037
  function renderAppSearch(searchView) {
3252
4038
  const formItemIdInFilter = [];
3253
- Object.entries(searchView).forEach(([fieldId, field]) => {
3254
- 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))
3255
4045
  formItemIdInFilter.push(getAttrNameFormItem(field, fieldId));
3256
4046
  });
3257
4047
  return `<AttrExposed>${formItemIdInFilter.join()}</AttrExposed>`;
3258
4048
  }
3259
4049
  function getAttrNameFormItem(field, fieldId) {
3260
4050
  function fieldType() {
3261
- if (field.type === exports.ExtraAppFieldsItemViews.TITLE)
4051
+ if (field.type === ExtraAppFieldsItemViews.TITLE)
3262
4052
  return 'title';
3263
- if (field.type === exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS)
4053
+ if (field.type === ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS)
3264
4054
  return 'sendAlert';
3265
- if (field.type === exports.ExtraAppFieldsItemViews.RECEIVEACOPY)
4055
+ if (field.type === ExtraAppFieldsItemViews.RECEIVEACOPY)
3266
4056
  return 'alertAuthor';
3267
- if (field.type === exports.ExtraAppFieldsItemViews.PUBLISHTO)
4057
+ if (field.type === ExtraAppFieldsItemViews.PUBLISHTO)
3268
4058
  return 'publishTo';
3269
- if (field.type === exports.ExtraAppFieldsItemViews.USER)
4059
+ if (field.type === ExtraAppFieldsItemViews.USER)
3270
4060
  return 'idUser';
3271
- if (field.type === exports.ExtraAppFieldsItemViews.CREATIONDATE)
4061
+ if (field.type === ExtraAppFieldsItemViews.CREATIONDATE)
3272
4062
  return 'dateCreation';
3273
- if (field.type === exports.AppFormItemTypes.DESCRIPTION)
4063
+ if (field.type === AppFormItemTypes.DESCRIPTION)
3274
4064
  return 'description';
3275
4065
  return field.type;
3276
4066
  }
@@ -3286,18 +4076,18 @@ function renderAudience(audience, installFor) {
3286
4076
  return '';
3287
4077
  }
3288
4078
  function renderPrimaryFields(fields) {
3289
- 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));
3290
4080
  if (primaryFields.length === 0)
3291
4081
  return '';
3292
4082
  return `<primaryFields>${primaryFields.map((field) => formItem2xml(field)).join('')}</primaryFields>`;
3293
4083
  }
3294
4084
  function renderCustomFields(fields) {
3295
- const customFields = fields === null || fields === void 0 ? void 0 : fields.filter((field) => !AppFormPrimaryList.includes(field.type));
3296
- 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);
3297
4087
  if (filteredCustomFields.length === 0)
3298
4088
  return '';
3299
- const articlesTablesItems = filteredCustomFields.filter((f) => f.type !== exports.AppFormItemTypes.TAGS && !AppFormNonPrimaryList.includes(f.type));
3300
- 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);
3301
4091
  return `<custom>
3302
4092
  ${articlesTablesItems.length > 0
3303
4093
  ? `<articlemstable>
@@ -3315,15 +4105,15 @@ function formItem2xml(field) {
3315
4105
  type="${renderFieldTypeToXmlType(field.type)}"
3316
4106
  name="${getAttrNameFormItem(field, field.id)}"
3317
4107
  sqlname="${renderSqlName(field.type, field.id)}"
3318
- ${field.properties && renderProperty(field.properties, exports.AppFieldFormPropertyTypes.LABEL)}
3319
- ${field.properties && renderProperty(field.properties, exports.AppFieldFormPropertyTypes.DESCRIPTION)}
4108
+ ${field.properties && renderProperty(field.properties, AppFieldFormPropertyTypes.LABEL)}
4109
+ ${field.properties && renderProperty(field.properties, AppFieldFormPropertyTypes.DESCRIPTION)}
3320
4110
  mandatory="${field.mandatory}"
3321
4111
  solr.type="${renderSolrType(field.type)}"
3322
4112
  solr.used="true"
3323
4113
  solr.indexed="true"
3324
4114
  solr.stored="true"
3325
4115
  solr.searchable="true"
3326
- 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}"
3327
4117
  teaser="true"
3328
4118
  display="true"
3329
4119
  >
@@ -3333,43 +4123,49 @@ function formItem2xml(field) {
3333
4123
  function renderWidget(fieldType, fieldProperties) {
3334
4124
  var _a;
3335
4125
  switch (fieldType) {
3336
- case exports.AppFormItemTypes.DESCRIPTION:
4126
+ case AppFormItemTypes.DESCRIPTION:
3337
4127
  return '<widget form="textarea"><params><param key="class" value="mceEditor"></param><param key="mention" value="1"></param></params></widget>';
3338
- case exports.AppFormItemTypes.TEXT:
4128
+ case AppFormItemTypes.TEXT:
3339
4129
  return '<widget form="text"></widget>';
3340
- case exports.AppFormItemTypes.TEXTAREA:
4130
+ case AppFormItemTypes.TEXTAREA:
3341
4131
  return '<widget form="textarea"></widget>';
3342
- case exports.AppFormItemTypes.TEXTAREAHTML:
4132
+ case AppFormItemTypes.TEXTAREAHTML:
3343
4133
  return '<widget form="textarea"><params><param key="class" value="mceEditor"></param></params></widget>';
3344
- case exports.AppFormItemTypes.DATE:
4134
+ case AppFormItemTypes.DATE:
3345
4135
  return '<widget form="date" format="d/m/Y"></widget>';
3346
- case exports.AppFormItemTypes.DATETIME:
4136
+ case AppFormItemTypes.DATETIME:
3347
4137
  return `<widget form="datetime" format="d/m/Y H:i:s"></widget>`;
3348
- case exports.AppFormItemTypes.NUMBER: {
3349
- 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;
3350
4140
  return `<widget form="number">
3351
4141
  ${isFloat ? `<params><param value="0.01" key="step"/></params>` : ''}
3352
4142
  </widget>`;
3353
4143
  }
3354
- case exports.AppFormItemTypes.SELECT: {
3355
- 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);
3356
4146
  if (!optionEditor)
3357
4147
  return '';
3358
4148
  const isMultiple = optionEditor.value.canSelectMultiple;
3359
4149
  const options = optionEditor.value.propertyOptions;
3360
4150
  const hasDefaultValue = optionEditor.value.defaultSelectOption;
3361
- const defaultValue = optionEditor.value.defaultSelectOptionValue;
4151
+ const defaultValue = optionEditor.value.defaultSelectOptionValue.value;
4152
+ const userCanModifiyByComment = optionEditor.value.userCanModifiyByComment;
3362
4153
  return `<widget form="select" ${isMultiple ? 'multiple="1"' : ''}>
3363
4154
  <options>
3364
4155
  ${options
3365
4156
  .map((option) => `<option value="${option.value}" label="${option.title}"></option>`)
3366
4157
  .join('')}
3367
4158
  </options>
3368
- ${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
+ : ''}
3369
4165
  </widget>`;
3370
4166
  }
3371
- case exports.AppFormItemTypes.RADIO: {
3372
- 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);
3373
4169
  if (!optionEditor)
3374
4170
  return '';
3375
4171
  const options = optionEditor.value.propertyOptions;
@@ -3381,7 +4177,7 @@ function renderWidget(fieldType, fieldProperties) {
3381
4177
  </options>
3382
4178
  </widget>`;
3383
4179
  }
3384
- case exports.AppFormItemTypes.TOGGLE:
4180
+ case AppFormItemTypes.TOGGLE:
3385
4181
  return `<widget form="checkbox">
3386
4182
  <options>
3387
4183
  <option value="1" label="GLOBAL_Yes"></option>
@@ -3390,8 +4186,8 @@ function renderWidget(fieldType, fieldProperties) {
3390
4186
  <param key="jagCheckbox" value="1"></param>
3391
4187
  </params>
3392
4188
  </widget>`;
3393
- case exports.AppFormItemTypes.TAGS: {
3394
- 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);
3395
4191
  if (!taxonomy)
3396
4192
  return '';
3397
4193
  const taxonomyId = taxonomy.value.id;
@@ -3399,8 +4195,8 @@ function renderWidget(fieldType, fieldProperties) {
3399
4195
  <params><param key="idTaxonomy" value="${taxonomyId}"></param></params>
3400
4196
  </widget>`;
3401
4197
  }
3402
- case exports.AppFormItemTypes.CHECKBOX: {
3403
- 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);
3404
4200
  if (!optionEditor)
3405
4201
  return '';
3406
4202
  const options = optionEditor.value.propertyOptions;
@@ -3412,15 +4208,15 @@ function renderWidget(fieldType, fieldProperties) {
3412
4208
  </options>
3413
4209
  </widget>`;
3414
4210
  }
3415
- case exports.AppFormItemTypes.ADDFILEATTACHMENT:
4211
+ case AppFormItemTypes.ADDFILEATTACHMENT:
3416
4212
  return `<widget form="file" type="fileArticle" multiple="1"></widget>`;
3417
- case exports.AppFormItemTypes.URL:
4213
+ case AppFormItemTypes.URL:
3418
4214
  return `<widget form="url"></widget>`;
3419
- case exports.AppFormItemTypes.EMAIL:
4215
+ case AppFormItemTypes.EMAIL:
3420
4216
  return `<widget form="email"></widget>`;
3421
- case exports.ExtraAppFieldsItemViews.USER:
4217
+ case ExtraAppFieldsItemViews.USER:
3422
4218
  return `<widget form="idUser"></widget>`;
3423
- case exports.AppFormItemTypes.USERLINK:
4219
+ case AppFormItemTypes.USERLINK:
3424
4220
  return `<widget form="uri">
3425
4221
  <params>
3426
4222
  <param key="mode" value="ng-view"></param>
@@ -3431,8 +4227,8 @@ function renderWidget(fieldType, fieldProperties) {
3431
4227
  <param key="jcomplete-url" value="/?action=ajax&amp;group=autocomplete&amp;function=user"></param>
3432
4228
  </params>
3433
4229
  </widget>`;
3434
- case exports.AppFormItemTypes.CONTENTLINK: {
3435
- 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);
3436
4232
  if (!contentType)
3437
4233
  return '';
3438
4234
  const type = contentType.value.type;
@@ -3459,9 +4255,9 @@ function renderProperty(properties, propertyToFind) {
3459
4255
  }
3460
4256
  function renderSqlName(fieldType, fieldId) {
3461
4257
  switch (fieldType) {
3462
- case exports.AppFormItemTypes.DESCRIPTION:
4258
+ case AppFormItemTypes.DESCRIPTION:
3463
4259
  return 'Description';
3464
- case exports.ExtraAppFieldsItemViews.USER:
4260
+ case ExtraAppFieldsItemViews.USER:
3465
4261
  return 'IdUser';
3466
4262
  default:
3467
4263
  return uuid2Alpha(fieldId);
@@ -3469,27 +4265,27 @@ function renderSqlName(fieldType, fieldId) {
3469
4265
  }
3470
4266
  function renderSolrType(fieldType) {
3471
4267
  switch (fieldType) {
3472
- case exports.AppFormItemTypes.DESCRIPTION:
3473
- case exports.AppFormItemTypes.TEXT:
3474
- case exports.AppFormItemTypes.TEXTAREA:
3475
- case exports.AppFormItemTypes.TEXTAREAHTML:
3476
- case exports.AppFormItemTypes.URL:
3477
- case exports.AppFormItemTypes.EMAIL:
3478
- case exports.AppFormItemTypes.USERLINK:
3479
- case exports.AppFormItemTypes.CONTENTLINK:
3480
- case exports.AppFormItemTypes.NUMBER:
3481
- 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:
3482
4278
  return 'text';
3483
- case exports.AppFormItemTypes.DATE:
3484
- case exports.AppFormItemTypes.DATETIME:
4279
+ case AppFormItemTypes.DATE:
4280
+ case AppFormItemTypes.DATETIME:
3485
4281
  return 'date';
3486
- case exports.ExtraAppFieldsItemViews.USER:
4282
+ case ExtraAppFieldsItemViews.USER:
3487
4283
  return 'integer';
3488
- case exports.AppFormItemTypes.SELECT:
3489
- case exports.AppFormItemTypes.RADIO:
3490
- case exports.AppFormItemTypes.TOGGLE:
3491
- case exports.AppFormItemTypes.CHECKBOX:
3492
- case exports.AppFormItemTypes.TAGS:
4284
+ case AppFormItemTypes.SELECT:
4285
+ case AppFormItemTypes.RADIO:
4286
+ case AppFormItemTypes.TOGGLE:
4287
+ case AppFormItemTypes.CHECKBOX:
4288
+ case AppFormItemTypes.TAGS:
3493
4289
  return 'string';
3494
4290
  default:
3495
4291
  return '';
@@ -3498,30 +4294,30 @@ function renderSolrType(fieldType) {
3498
4294
  function renderFieldTypeToXmlType(fieldType) {
3499
4295
  switch (fieldType) {
3500
4296
  default:
3501
- case exports.AppFormItemTypes.DESCRIPTION:
3502
- case exports.AppFormItemTypes.TEXTAREAHTML:
4297
+ case AppFormItemTypes.DESCRIPTION:
4298
+ case AppFormItemTypes.TEXTAREAHTML:
3503
4299
  return 'html';
3504
- case exports.AppFormItemTypes.TAGS:
4300
+ case AppFormItemTypes.TAGS:
3505
4301
  return 'taxonomy';
3506
- case exports.AppFormItemTypes.TEXT:
3507
- case exports.AppFormItemTypes.SELECT:
3508
- case exports.AppFormItemTypes.RADIO:
3509
- case exports.AppFormItemTypes.CHECKBOX:
3510
- case exports.AppFormItemTypes.URL:
3511
- case exports.AppFormItemTypes.EMAIL:
3512
- case exports.AppFormItemTypes.ADDFILEATTACHMENT:
3513
- case exports.ExtraAppFieldsItemViews.USER:
3514
- case exports.AppFormItemTypes.USERLINK:
3515
- 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:
3516
4310
  return 'text';
3517
- case exports.AppFormItemTypes.TEXTAREA:
4311
+ case AppFormItemTypes.TEXTAREA:
4312
+ case AppFormItemTypes.CHECKBOX:
4313
+ case AppFormItemTypes.SELECT:
3518
4314
  return 'longtext';
3519
- case exports.AppFormItemTypes.DATE:
4315
+ case AppFormItemTypes.DATE:
3520
4316
  return 'date';
3521
- case exports.AppFormItemTypes.DATETIME: {
4317
+ case AppFormItemTypes.DATETIME: {
3522
4318
  return 'date';
3523
4319
  }
3524
- case exports.AppFormItemTypes.NUMBER:
4320
+ case AppFormItemTypes.NUMBER:
3525
4321
  return 'float';
3526
4322
  }
3527
4323
  }
@@ -3555,7 +4351,9 @@ function renderDisplays(studioApp) {
3555
4351
  let toRet = '';
3556
4352
  Object.entries(studioApp.views).forEach(([viewName, viewContent]) => {
3557
4353
  if (Object.prototype.hasOwnProperty.call(internal2XmlView, viewName)) {
3558
- 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);
3559
4357
  toRet += `<display view="${internal2XmlView[viewName]}" mode="${viewName === 'view' ? 'view' : 'form'}">
3560
4358
  ${viewField.map(([fieldId, view]) => renderDisplayAttr(fieldId, view)).join('')}
3561
4359
  </display>`;
@@ -3568,19 +4366,19 @@ function renderDisplays(studioApp) {
3568
4366
  }
3569
4367
  function getDisplayName(fieldId, view) {
3570
4368
  switch (view.type) {
3571
- case exports.ExtraAppFieldsItemViews.TITLE:
4369
+ case ExtraAppFieldsItemViews.TITLE:
3572
4370
  return 'title';
3573
- case exports.ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS:
4371
+ case ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS:
3574
4372
  return 'sendAlert';
3575
- case exports.ExtraAppFieldsItemViews.RECEIVEACOPY:
4373
+ case ExtraAppFieldsItemViews.RECEIVEACOPY:
3576
4374
  return 'alertAuthor';
3577
- case exports.ExtraAppFieldsItemViews.PUBLISHTO:
4375
+ case ExtraAppFieldsItemViews.PUBLISHTO:
3578
4376
  return 'publishTo';
3579
- case exports.ExtraAppFieldsItemViews.USER:
4377
+ case ExtraAppFieldsItemViews.USER:
3580
4378
  return 'idUser';
3581
- case exports.ExtraAppFieldsItemViews.CREATIONDATE:
4379
+ case ExtraAppFieldsItemViews.CREATIONDATE:
3582
4380
  return 'dateCreation';
3583
- case exports.AppFormItemTypes.DESCRIPTION:
4381
+ case AppFormItemTypes.DESCRIPTION:
3584
4382
  return 'description';
3585
4383
  default:
3586
4384
  return uuid2Alpha(fieldId);
@@ -3597,29 +4395,34 @@ function renderDisplayAttr(fieldId, view) {
3597
4395
  fixedValue: view.value,
3598
4396
  };
3599
4397
  xml += `<html><![CDATA[ <!-- <JAMESPOT.STUDIO.FIXED>${JSON.stringify(formItemRefWithName)}</JAMESPOT.STUDIO.FIXED> -->`;
3600
- if (view.type === exports.ExtraAppFieldsItemViews.PUBLISHTO) {
4398
+ if (view.type === ExtraAppFieldsItemViews.PUBLISHTO) {
3601
4399
  const uris = view.value.map((user) => user.uri).join(',');
3602
4400
  xml += `<input type="hidden" name="publishTo" value="${uris}">`;
3603
4401
  }
3604
- else if (view.type === exports.ExtraAppFieldsItemViews.USER ||
3605
- view.type === exports.AppFormItemTypes.USERLINK ||
3606
- view.type === exports.AppFormItemTypes.CONTENTLINK) {
4402
+ else if (view.type === ExtraAppFieldsItemViews.USER ||
4403
+ view.type === AppFormItemTypes.USERLINK ||
4404
+ view.type === AppFormItemTypes.CONTENTLINK) {
3607
4405
  xml += `<input type="hidden" name="${attrName}[]" value=${JSON.stringify(view.value.uri)}>`;
3608
4406
  }
3609
- else if (view.type === exports.AppFormItemTypes.SELECT) {
3610
- const values = view.value;
3611
- const canSelectMultiple = (_a = view.properties.find((property) => property.propertyType === exports.AppFieldFormPropertyTypes.OPTIONS_EDITOR)) === null || _a === void 0 ? void 0 : _a.value.canSelectMultiple;
3612
- values.forEach((value) => {
3613
- xml += `<input type="hidden" name="${attrName}${canSelectMultiple ? '[]' : ''}" value="${value.value}">`;
3614
- });
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
+ }
3615
4418
  }
3616
- else if (view.type === exports.AppFormItemTypes.CHECKBOX) {
4419
+ else if (view.type === AppFormItemTypes.CHECKBOX) {
3617
4420
  const values = view.value;
3618
4421
  values.forEach((value) => {
3619
- xml += `<input type="hidden" name="${attrName}[]" value="${value.value}">`;
4422
+ xml += `<input type="hidden" name="${attrName}[]" value="${value}">`;
3620
4423
  });
3621
4424
  }
3622
- else if (view.type === exports.AppFormItemTypes.DATE) {
4425
+ else if (view.type === AppFormItemTypes.DATE) {
3623
4426
  const dateValue = new Date(view.value);
3624
4427
  const xmlFixedValue = [
3625
4428
  pad(dateValue.getDate()),
@@ -3628,23 +4431,30 @@ function renderDisplayAttr(fieldId, view) {
3628
4431
  ].join('/');
3629
4432
  xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
3630
4433
  }
3631
- else if (view.type === exports.AppFormItemTypes.DATETIME) {
4434
+ else if (view.type === AppFormItemTypes.DATETIME) {
3632
4435
  const dateValue = new Date(view.value);
3633
- const xmlFixedValue = [
4436
+ const xmlFixedValue = `${[
3634
4437
  pad(dateValue.getDate()),
3635
4438
  pad(dateValue.getMonth() + 1),
3636
4439
  dateValue.getFullYear(),
3637
- pad(dateValue.getHours()),
3638
- pad(dateValue.getMinutes()),
3639
- pad(dateValue.getSeconds()),
3640
- ].join('/');
4440
+ ].join('/')} ${pad(dateValue.getHours())}:${pad(dateValue.getMinutes())}:${pad(dateValue.getSeconds())}`;
3641
4441
  xml += '<input type="hidden" name="' + attrName + '" value="' + xmlFixedValue + '">';
3642
4442
  }
3643
- else if (view.type === exports.AppFormItemTypes.TAGS) {
4443
+ else if (view.type === AppFormItemTypes.TAGS) {
3644
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(',')}">`;
3645
4445
  }
3646
- else if (view.type === exports.AppFormItemTypes.DESCRIPTION || view.type === exports.AppFormItemTypes.TEXTAREAHTML) {
3647
- 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
+ }
3648
4458
  }
3649
4459
  else {
3650
4460
  xml += `<input type="hidden" name="${attrName}" value="${view.value}">`;
@@ -3653,14 +4463,21 @@ function renderDisplayAttr(fieldId, view) {
3653
4463
  }
3654
4464
  else {
3655
4465
  switch (view.type) {
3656
- case exports.AppFormItemTypes.CODEHTML: {
3657
- 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>`;
3658
4475
  break;
3659
4476
  }
3660
- case exports.AppFormItemTypes.IMAGE:
4477
+ case AppFormItemTypes.IMAGE:
3661
4478
  xml += '<image />';
3662
4479
  break;
3663
- case exports.ExtraAppFieldsItemViews.PUBLISHTO:
4480
+ case ExtraAppFieldsItemViews.PUBLISHTO:
3664
4481
  xml += '<publishTo />';
3665
4482
  break;
3666
4483
  default:
@@ -3681,12 +4498,12 @@ const initialState$1 = {
3681
4498
  installStudioAppStatus: 'idle',
3682
4499
  hasChanged: false,
3683
4500
  };
3684
- 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* () {
3685
4502
  const jApi = extra.jApi;
3686
4503
  const error = { error: 1, errorMsg: 'Error fetching application' };
3687
4504
  try {
3688
4505
  const studioApplicationBase = (yield jApi.application.get(idApp, status)).result;
3689
- const studioApplication = serverAppsToStudioApps([studioApplicationBase])[0];
4506
+ const studioApplication = serverAppsToStudioApps([studioApplicationBase], getState())[0];
3690
4507
  if (!studioApplication) {
3691
4508
  return rejectWithValue(error);
3692
4509
  }
@@ -3790,16 +4607,22 @@ const CurrentStudioAppSlice = toolkit.createSlice({
3790
4607
  },
3791
4608
  });
3792
4609
 
3793
- function cloneStudioAppFromExistingApp(existingApp, author) {
3794
- const newApp = existingApp.inWorkVersion
3795
- ? 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)))
3796
4613
  : JSON.parse(JSON.stringify(existingApp));
3797
- const newAppId = uuid.v4();
3798
- const newAppName = `${existingApp.manifest.appName} Copie`;
3799
- newApp.idApp = newAppId;
3800
- newApp.status = APP_STATUS_TYPE.DRAFT;
3801
- newApp.manifest = Object.assign(Object.assign({}, newApp.manifest), { appName: newAppName, appShortName: newAppName, author: author || '', dateCreation: new Date().toISOString(), version: 0.1, articlesCount: 0 });
3802
- 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];
3803
4626
  }
3804
4627
 
3805
4628
  function createNewStudioApp$1({ author, appName }) {
@@ -3861,37 +4684,78 @@ function createNewStudioApp$1({ author, appName }) {
3861
4684
  attrExposed: [],
3862
4685
  articlesCount: 0,
3863
4686
  },
4687
+ syncViewFieldOrder: {
4688
+ create: true,
4689
+ popup: true,
4690
+ view: true,
4691
+ edit: true,
4692
+ list: true,
4693
+ filter: true,
4694
+ },
3864
4695
  fields: [],
3865
4696
  views,
3866
- audience: AUDIENCE.ALL,
4697
+ audience: AUDIENCE.CUSTOM,
3867
4698
  installFor: [],
3868
4699
  },
3869
4700
  };
3870
4701
  }
3871
4702
 
4703
+ function appLexicalSort(a, b) {
4704
+ return a.manifest.appName > b.manifest.appName ? 1 : -1;
4705
+ }
3872
4706
  const initialState = {
3873
4707
  loadingStudioAppsList: 'idle',
3874
4708
  deleteStudioAppStatus: 'idle',
3875
4709
  suspendStudioAppStatus: 'idle',
3876
4710
  restartStudioAppStatus: 'idle',
3877
4711
  cloneStudioAppStatus: 'idle',
4712
+ createInWorkAppStatus: 'idle',
3878
4713
  createNewStudioAppStatus: 'idle',
3879
4714
  };
3880
- 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* () {
3881
4716
  const jApi = extra.jApi;
3882
4717
  try {
3883
4718
  const { result } = yield jApi.application.list();
3884
- 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* () {
3885
4721
  const coreApp = (yield jApi.application.get(app.idApp, app.status)).result;
3886
4722
  const articlesCount = (yield jApi.article.count(app.idApp)).result;
3887
4723
  return Object.assign(Object.assign({}, coreApp), { articlesCount });
3888
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;
3889
4733
  }
3890
4734
  catch (_) {
3891
4735
  dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
3892
4736
  throw rejectWithValue({ error: 1, errorMsg: 'Error retrieving applications' });
3893
4737
  }
3894
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
+ }
3895
4759
  const createNewStudioApp = toolkit.createAsyncThunk('studio/createApp', ({ appName, callback }, { extra, dispatch, rejectWithValue, getState }) => __awaiter(void 0, void 0, void 0, function* () {
3896
4760
  var _a;
3897
4761
  const jApi = extra.jApi;
@@ -3944,12 +4808,20 @@ const restartStudioApp = toolkit.createAsyncThunk('studio/restartStudioApp', ({
3944
4808
  throw rejectWithValue({ error: 1, errorMsg: 'Error restarting application' });
3945
4809
  }
3946
4810
  }));
3947
- 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* () {
3948
4812
  var _b, _c;
3949
4813
  const jApi = extra.jApi;
3950
- 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);
3951
4815
  if (!existingStudioApp)
3952
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
+ }
3953
4825
  const currentUser = (_c = getState().userCurrent) === null || _c === void 0 ? void 0 : _c.uri;
3954
4826
  const [clonedStudioApp, newAppId] = cloneStudioAppFromExistingApp(existingStudioApp, currentUser);
3955
4827
  const clonedStudioAppReady = JSON.stringify(clonedStudioApp);
@@ -3963,12 +4835,33 @@ const cloneStudioApp = toolkit.createAsyncThunk('studio/cloneStudioApp', ({ idAp
3963
4835
  return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
3964
4836
  }
3965
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
+ }));
3966
4859
  const StudioAppsListSlice = toolkit.createSlice({
3967
4860
  name: 'studioAppsList',
3968
4861
  initialState,
3969
4862
  reducers: {
3970
4863
  setAppsList: (state, action) => {
3971
- state.studioAppsList = action.payload;
4864
+ state.studioAppsList = [...action.payload].sort(appLexicalSort);
3972
4865
  },
3973
4866
  },
3974
4867
  extraReducers: (builder) => {
@@ -3981,7 +4874,7 @@ const StudioAppsListSlice = toolkit.createSlice({
3981
4874
  if (state.loadingStudioAppsList === 'pending') {
3982
4875
  state.loadingStudioAppsList = 'idle';
3983
4876
  }
3984
- state.studioAppsList = serverAppsToStudioApps(action.payload);
4877
+ state.studioAppsList = [...action.payload].sort(appLexicalSort);
3985
4878
  })
3986
4879
  .addCase(fetchStudioAppsList.rejected, (state) => {
3987
4880
  if (state.loadingStudioAppsList === 'pending')
@@ -4002,8 +4895,13 @@ const StudioAppsListSlice = toolkit.createSlice({
4002
4895
  let { status } = action.meta.arg;
4003
4896
  if (status === APP_STATUS_TYPE.INSTALLED)
4004
4897
  status = APP_STATUS_TYPE.SUSPENDED;
4005
- 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
+ }
4006
4903
  return acc;
4904
+ }
4007
4905
  if (app.inWorkVersion &&
4008
4906
  app.inWorkVersion.idApp === idApp &&
4009
4907
  app.inWorkVersion.status === status) {
@@ -4059,38 +4957,65 @@ const StudioAppsListSlice = toolkit.createSlice({
4059
4957
  })) !== null && _b !== void 0 ? _b : [];
4060
4958
  })
4061
4959
  .addCase(restartStudioApp.rejected, (state) => {
4062
- if (state.restartStudioAppStatus === 'pending')
4960
+ if (state.restartStudioAppStatus === 'pending') {
4063
4961
  state.restartStudioAppStatus = 'idle';
4962
+ }
4064
4963
  })
4065
4964
  .addCase(cloneStudioApp.pending, (state) => {
4066
- if (state.cloneStudioAppStatus === 'idle')
4965
+ if (state.cloneStudioAppStatus === 'idle') {
4067
4966
  state.cloneStudioAppStatus = 'pending';
4967
+ }
4068
4968
  })
4069
4969
  .addCase(cloneStudioApp.fulfilled, (state, action) => {
4070
4970
  var _a;
4071
4971
  if (state.cloneStudioAppStatus === 'pending') {
4072
4972
  state.cloneStudioAppStatus = 'idle';
4073
4973
  }
4074
- 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);
4075
4975
  })
4076
4976
  .addCase(cloneStudioApp.rejected, (state) => {
4077
- if (state.cloneStudioAppStatus === 'pending')
4977
+ if (state.cloneStudioAppStatus === 'pending') {
4078
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
+ }
4079
5002
  })
4080
5003
  .addCase(createNewStudioApp.pending, (state) => {
4081
- if (state.createNewStudioAppStatus === 'idle')
5004
+ if (state.createNewStudioAppStatus === 'idle') {
4082
5005
  state.createNewStudioAppStatus = 'pending';
5006
+ }
4083
5007
  })
4084
5008
  .addCase(createNewStudioApp.fulfilled, (state, action) => {
4085
5009
  var _a;
4086
5010
  if (state.createNewStudioAppStatus === 'pending') {
4087
5011
  state.createNewStudioAppStatus = 'idle';
4088
5012
  }
4089
- 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);
4090
5014
  })
4091
5015
  .addCase(createNewStudioApp.rejected, (state) => {
4092
- if (state.createNewStudioAppStatus === 'pending')
5016
+ if (state.createNewStudioAppStatus === 'pending') {
4093
5017
  state.createNewStudioAppStatus = 'idle';
5018
+ }
4094
5019
  });
4095
5020
  },
4096
5021
  });
@@ -4119,28 +5044,38 @@ const studio = {
4119
5044
  createNewStudioApp,
4120
5045
  fetchCurrentStudioApp,
4121
5046
  saveCurrentStudioApp,
4122
- installStudioApp }),
5047
+ installStudioApp,
5048
+ createInWorkStudioApp }),
4123
5049
  selectors: {
4124
5050
  selectStudioAppsList,
4125
5051
  selectCurrentStudioApp,
4126
5052
  },
5053
+ utils: {
5054
+ updateViewsFromFields,
5055
+ generateNewFormField,
5056
+ }
4127
5057
  };
4128
5058
 
4129
5059
  exports.APP_STATUS_TYPE = APP_STATUS_TYPE;
4130
5060
  exports.AUDIENCE = AUDIENCE;
4131
5061
  exports.Animations = Animations;
4132
5062
  exports.AppColumnsDefaultTypes = AppColumnsDefaultTypes;
5063
+ exports.AppFieldFormPropertyTypes = AppFieldFormPropertyTypes;
4133
5064
  exports.AppFormBannedFromViews = AppFormBannedFromViews$1;
4134
5065
  exports.AppFormFieldOnlyInView = AppFormFieldOnlyInView;
4135
5066
  exports.AppFormFixedList = AppFormFixedList$1;
5067
+ exports.AppFormItemTypes = AppFormItemTypes;
4136
5068
  exports.AppFormNoAsFieldList = AppFormNoAsFieldList;
4137
5069
  exports.AppFormNonPrimaryList = AppFormNonPrimaryList;
4138
5070
  exports.AppFormPrimaryList = AppFormPrimaryList;
5071
+ exports.AppFormPrimaryListValues = AppFormPrimaryListValues;
4139
5072
  exports.AppFormUniqueList = AppFormUniqueList;
5073
+ exports.AppFormUniqueListCheck = AppFormUniqueListCheck;
4140
5074
  exports.Application = Application;
4141
5075
  exports.AssetReservation = AssetReservation;
4142
5076
  exports.Bookmark = Bookmark;
4143
5077
  exports.Comment = Comment;
5078
+ exports.ExtraAppFieldsItemViews = ExtraAppFieldsItemViews;
4144
5079
  exports.Faq = Faq;
4145
5080
  exports.Hook = Hook;
4146
5081
  exports.MODE_EDIT = MODE_EDIT;
@@ -4154,6 +5089,7 @@ exports.Platform = Platform;
4154
5089
  exports.STUDIO_VIEW = STUDIO_VIEW;
4155
5090
  exports.Share = Share;
4156
5091
  exports.SocialActions = SocialActions;
5092
+ exports.StatusType = StatusType$1;
4157
5093
  exports.TVDisplay = TVDisplay;
4158
5094
  exports.TinyMCE = TinyMCE;
4159
5095
  exports.Toast = Toast;