jamespot-front-business 1.1.68 → 1.1.70

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