@qrvey/utils 1.4.0 → 1.4.1

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.4.0*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.4.1*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -85,6 +85,7 @@ Get a text and evaluate if it matchs with a token box label.
85
85
 
86
86
  #### getColumnLabels(column)
87
87
 
88
+ [TODO: Finish the function]
88
89
  Get an string of the properties of the given column.
89
90
 
90
91
 
@@ -373,7 +374,7 @@ Transforms String Date from a [mm/dd/yyyy] format to Date object.
373
374
  ##### Returns
374
375
 
375
376
 
376
- - The date object or the date in milliseconds
377
+ - The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value
377
378
 
378
379
 
379
380
 
@@ -401,7 +402,7 @@ Transforms String Date from a [Month Year] format to Date object.
401
402
  ##### Returns
402
403
 
403
404
 
404
- - The date object or the date in milliseconds
405
+ - The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value
405
406
 
406
407
 
407
408
 
@@ -429,7 +430,7 @@ Transforms String Date from a [Quarter Year] format to Date object.
429
430
  ##### Returns
430
431
 
431
432
 
432
- - The date object or the date in milliseconds
433
+ - The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
433
434
 
434
435
 
435
436
 
@@ -457,7 +458,7 @@ Transforms String Date from a [Week Year] format to Date object.
457
458
  ##### Returns
458
459
 
459
460
 
460
- - The date object or the date in milliseconds
461
+ - The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
461
462
 
462
463
 
463
464
 
@@ -485,7 +486,7 @@ Transforms String Date from a [Year] format to Date object.
485
486
  ##### Returns
486
487
 
487
488
 
488
- - The date object or the date in milliseconds
489
+ - The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
489
490
 
490
491
 
491
492
 
@@ -551,7 +552,8 @@ Gets the date format by the given property
551
552
 
552
553
  #### getDateFormatRegularExpressionInArray(dateFormat)
553
554
 
554
- Gets an array of regular expressions by the given date format
555
+ Gets an array of regular expressions by the given date format.
556
+ Day date format is the default
555
557
 
556
558
 
557
559
 
@@ -712,15 +714,12 @@ Undefined date is returning false.
712
714
 
713
715
 
714
716
 
715
- ### dist/dates/helpers/validateDate.js
717
+ ### dist/dates/helpers/isValidDateObject.js
716
718
 
717
719
 
718
- #### validateDate(date, format)
720
+ #### isValidDateObject(date)
719
721
 
720
- Validate a string date depending on giving format
721
- - If the string is a token label, the function lets it pass.
722
- - Otherwise depends of the format
723
- - Some escenarios the string is a mix of token labels and dates
722
+ If the date is a valid Date object, return true, otherwise return false.
724
723
 
725
724
 
726
725
 
@@ -729,8 +728,7 @@ Validate a string date depending on giving format
729
728
 
730
729
  | Name | Type | Description | |
731
730
  | ---- | ---- | ----------- | -------- |
732
- | date | | String of date |   |
733
- | format | | String of the format to validate |   |
731
+ | date | `Date` | - The date object to check. |   |
734
732
 
735
733
 
736
734
 
@@ -738,17 +736,20 @@ Validate a string date depending on giving format
738
736
  ##### Returns
739
737
 
740
738
 
741
- - True if it is valid or not. Undefined if date is undefined
739
+ - A boolean value.
742
740
 
743
741
 
744
742
 
745
743
 
746
- ### dist/dates/helpers/validateDateByDateFormat.js
744
+ ### dist/dates/helpers/validateDate.js
747
745
 
748
746
 
749
- #### validateDateByDateFormat(date, dateForma)
747
+ #### validateDate(date, format)
750
748
 
751
- Validates the given string as Date by its date format.
749
+ Validate a string date depending on giving format
750
+ - If the string is a token label, the function lets it pass.
751
+ - Otherwise depends of the format
752
+ - Some escenarios the string is a mix of token labels and dates
752
753
 
753
754
 
754
755
 
@@ -757,8 +758,8 @@ Validates the given string as Date by its date format.
757
758
 
758
759
  | Name | Type | Description | |
759
760
  | ---- | ---- | ----------- | -------- |
760
- | date | | a string to validate as date form |   |
761
- | dateForma | | the format of the date to validate the string |   |
761
+ | date | | String of date |   |
762
+ | format | | String of the format to validate |   |
762
763
 
763
764
 
764
765
 
@@ -766,7 +767,7 @@ Validates the given string as Date by its date format.
766
767
  ##### Returns
767
768
 
768
769
 
769
- - true: the string is a valida date
770
+ - True if it is valid or not. Undefined if date is undefined
770
771
 
771
772
 
772
773
 
@@ -828,8 +829,31 @@ getDateRange('Oct 2020', 'MONTH');
828
829
 
829
830
 
830
831
 
832
+ #### getStringDate(dt)
833
+
834
+ It takes a Date object as an argument and returns a string in the format of MM/DD/YYYY
835
+
836
+
837
+
838
+
839
+ ##### Parameters
840
+
841
+ | Name | Type | Description | |
842
+ | ---- | ---- | ----------- | -------- |
843
+ | dt | `Date` | - Date - The date object to convert to a string |   |
844
+
845
+
846
+
847
+
848
+ ##### Returns
849
+
850
+
851
+ - A string in the format of MM/DD/YYYY
852
+
831
853
 
832
- ### dist/dates/relative/Adapter.js
854
+
855
+
856
+ ### dist/dates/relative/RelativeStatementAdapter.js
833
857
 
834
858
 
835
859
  #### value()
@@ -2285,9 +2309,9 @@ Gets request body structure
2285
2309
 
2286
2310
  | Name | Type | Description | |
2287
2311
  | ---- | ---- | ----------- | -------- |
2288
- | uFilter | | The filter Builder filter |   |
2289
- | filterLogic | | Additional filter logic to apply in the preview |   |
2290
- | chartSettings | | The settings of the chart. For Aggregate Columns. |   |
2312
+ | uFilter | `IFUFlattenedFilter` | The filter object |   |
2313
+ | filterLogic | `Array.<IFBLogic>` | Additional filter logic to apply in the preview | &nbsp; |
2314
+ | chartSettings | `IFUChartSettings` | The settings of the chart. For Aggregate Columns. | &nbsp; |
2291
2315
 
2292
2316
 
2293
2317
 
@@ -2513,6 +2537,54 @@ Gets summaries from preview response
2513
2537
 
2514
2538
 
2515
2539
 
2540
+ #### _getSearchLogic(uFilter)
2541
+
2542
+ Gets the filter object structure for the searching text
2543
+
2544
+
2545
+
2546
+
2547
+ ##### Parameters
2548
+
2549
+ | Name | Type | Description | |
2550
+ | ---- | ---- | ----------- | -------- |
2551
+ | uFilter | `IFUFlattenedFilter` | The filter object | &nbsp; |
2552
+
2553
+
2554
+
2555
+
2556
+ ##### Returns
2557
+
2558
+
2559
+ - the filter object structure
2560
+
2561
+
2562
+
2563
+ #### _getFilterCharts(uFilter, searchLogic, chartSettings)
2564
+
2565
+ Gets the filters from the chart settings
2566
+
2567
+
2568
+
2569
+
2570
+ ##### Parameters
2571
+
2572
+ | Name | Type | Description | |
2573
+ | ---- | ---- | ----------- | -------- |
2574
+ | uFilter | `IFUFlattenedFilter` | The filter object | &nbsp; |
2575
+ | searchLogic | `OLD_IFilterData` | Additional filter object for the searching text | &nbsp; |
2576
+ | chartSettings | `IFUChartSettings` | The settings of the chart. For Aggregate Columns. | &nbsp; |
2577
+
2578
+
2579
+
2580
+
2581
+ ##### Returns
2582
+
2583
+
2584
+ - the filters from the chart settings
2585
+
2586
+
2587
+
2516
2588
 
2517
2589
  ### dist/filters/services/UChartPaginationApi.js
2518
2590
 
@@ -2570,9 +2642,9 @@ Gets request body structure
2570
2642
 
2571
2643
  | Name | Type | Description | |
2572
2644
  | ---- | ---- | ----------- | -------- |
2573
- | uFilter | | The filter Builder filter | &nbsp; |
2574
- | filterLogic | | Additional filter logic to apply in the preview | &nbsp; |
2575
- | chartSettings | | The settings of the chart. For Aggregate Columns. | &nbsp; |
2645
+ | uFilter | `IFUFlattenedFilter` | The filter object | &nbsp; |
2646
+ | filterLogic | `Array.<IFBLogic>` | Additional filter logic to apply in the preview | &nbsp; |
2647
+ | chartSettings | `IFUChartSettings` | The settings of the chart. For Aggregate Columns. | &nbsp; |
2576
2648
 
2577
2649
 
2578
2650
 
@@ -2889,6 +2961,267 @@ Checks if two filter columns are the same.
2889
2961
 
2890
2962
 
2891
2963
 
2964
+ #### _getSearchLogic(uFilter)
2965
+
2966
+ Gets the filter object structure for the searching text
2967
+
2968
+
2969
+
2970
+
2971
+ ##### Parameters
2972
+
2973
+ | Name | Type | Description | |
2974
+ | ---- | ---- | ----------- | -------- |
2975
+ | uFilter | `IFUFlattenedFilter` | The filter object | &nbsp; |
2976
+
2977
+
2978
+
2979
+
2980
+ ##### Returns
2981
+
2982
+
2983
+ - the filter object structure
2984
+
2985
+
2986
+
2987
+ #### _getFilterCharts(uFilter, searchLogic, chartSettings)
2988
+
2989
+ Gets the filters from the chart settings
2990
+
2991
+
2992
+
2993
+
2994
+ ##### Parameters
2995
+
2996
+ | Name | Type | Description | |
2997
+ | ---- | ---- | ----------- | -------- |
2998
+ | uFilter | `IFUFlattenedFilter` | The filter object | &nbsp; |
2999
+ | searchLogic | `OLD_IFilterData` | Additional filter object for the searching text | &nbsp; |
3000
+ | chartSettings | `IFUChartSettings` | The settings of the chart. For Aggregate Columns. | &nbsp; |
3001
+
3002
+
3003
+
3004
+
3005
+ ##### Returns
3006
+
3007
+
3008
+ - the filters from the chart settings
3009
+
3010
+
3011
+
3012
+
3013
+ ### dist/format/duration/addDurationFormat.js
3014
+
3015
+
3016
+ #### addDurationFormat(number, format[, locale, fractionDigits])
3017
+
3018
+ [TODO: The decimals dots are not working correctly, we need to reviewing (fractionDigits)]
3019
+ "Convert a number of seconds to a human readable string."
3020
+
3021
+ `addDurationFormat` is a function that takes a number, a format, an optional locale, and an optional
3022
+ number of fraction digits, and returns a string
3023
+
3024
+
3025
+
3026
+
3027
+ ##### Parameters
3028
+
3029
+ | Name | Type | Description | |
3030
+ | ---- | ---- | ----------- | -------- |
3031
+ | number | `number` | - The number of milliseconds to format. | &nbsp; |
3032
+ | format | `string` | - The format string. | &nbsp; |
3033
+ | locale | `string` | - The locale to use for formatting. If not specified, the default locale is used. | *Optional* |
3034
+ | fractionDigits | `number` | - The number of digits to show after the decimal point. | *Optional* |
3035
+
3036
+
3037
+
3038
+
3039
+ ##### Returns
3040
+
3041
+
3042
+ - A string
3043
+
3044
+
3045
+
3046
+
3047
+ ### dist/format/duration/durationFormatter.js
3048
+
3049
+
3050
+ #### setLocaleFormatter()
3051
+
3052
+ It sets the locale formatter for the number.
3053
+
3054
+
3055
+
3056
+
3057
+
3058
+
3059
+ ##### Returns
3060
+
3061
+
3062
+ - `Void`
3063
+
3064
+
3065
+
3066
+ #### getNewNumberFormat(locale)
3067
+
3068
+ It returns a new instance of the Intl.NumberFormat class, which is a built-in JavaScript class
3069
+ that formats numbers
3070
+
3071
+
3072
+
3073
+
3074
+ ##### Parameters
3075
+
3076
+ | Name | Type | Description | |
3077
+ | ---- | ---- | ----------- | -------- |
3078
+ | locale | `string` `Array.<string>` | - string | string[] | &nbsp; |
3079
+
3080
+
3081
+
3082
+
3083
+ ##### Returns
3084
+
3085
+
3086
+ - A new instance of the Intl.NumberFormat class.
3087
+
3088
+
3089
+
3090
+ #### setParts(template)
3091
+
3092
+ It takes a template string and sets the parts property to the result of calling the
3093
+ parseFormatTemplate function with the template string as an argument
3094
+
3095
+
3096
+
3097
+
3098
+ ##### Parameters
3099
+
3100
+ | Name | Type | Description | |
3101
+ | ---- | ---- | ----------- | -------- |
3102
+ | template | `string` | - The format template string. | &nbsp; |
3103
+
3104
+
3105
+
3106
+
3107
+ ##### Returns
3108
+
3109
+
3110
+ - `Void`
3111
+
3112
+
3113
+
3114
+ #### matchFormatsReplace(template)
3115
+
3116
+ It replaces the H and D characters in the template with h and d respectively
3117
+
3118
+
3119
+
3120
+
3121
+ ##### Parameters
3122
+
3123
+ | Name | Type | Description | |
3124
+ | ---- | ---- | ----------- | -------- |
3125
+ | template | `string` | - The template string to be used for the date format. | &nbsp; |
3126
+
3127
+
3128
+
3129
+
3130
+ ##### Returns
3131
+
3132
+
3133
+ - The template string with all instances of H replaced with h and all instances of D replaced with d.
3134
+
3135
+
3136
+
3137
+ #### setNumberFactor()
3138
+
3139
+ It sets the numberFactor to the value of the duration part that matches the unit.
3140
+
3141
+
3142
+
3143
+
3144
+
3145
+
3146
+ ##### Returns
3147
+
3148
+
3149
+ - `Void`
3150
+
3151
+
3152
+
3153
+ #### parseFormatTemplate(template)
3154
+
3155
+ It takes a string, splits it into an array of strings, then maps each string to a config object,
3156
+ then filters out any falsy values, then reverses the array
3157
+
3158
+
3159
+
3160
+
3161
+ ##### Parameters
3162
+
3163
+ | Name | Type | Description | |
3164
+ | ---- | ---- | ----------- | -------- |
3165
+ | template | `string` | - string - the template string that we want to parse | &nbsp; |
3166
+
3167
+
3168
+
3169
+
3170
+ ##### Returns
3171
+
3172
+
3173
+ - An array of objects that have the order and the name of the part of the duration.
3174
+
3175
+
3176
+
3177
+ #### format(number)
3178
+
3179
+ It takes a number, multiplies it by a factor, then uses the parts array to calculate the number
3180
+ of each part in the number, then uses the template to format the number
3181
+
3182
+
3183
+
3184
+
3185
+ ##### Parameters
3186
+
3187
+ | Name | Type | Description | |
3188
+ | ---- | ---- | ----------- | -------- |
3189
+ | number | `number` | - The number of milliseconds to format. | &nbsp; |
3190
+
3191
+
3192
+
3193
+
3194
+ ##### Returns
3195
+
3196
+
3197
+ - The template string with the values replaced.
3198
+
3199
+
3200
+
3201
+ #### formatValue(parts, part)
3202
+
3203
+ It takes a dictionary of values and a list of keys, and returns a formatted string
3204
+
3205
+
3206
+
3207
+
3208
+ ##### Parameters
3209
+
3210
+ | Name | Type | Description | |
3211
+ | ---- | ---- | ----------- | -------- |
3212
+ | parts | | - { [x: string]: any; } | &nbsp; |
3213
+ | part | `string` `Array.<string|number>` | - This is the part of the date that we're formatting. | &nbsp; |
3214
+
3215
+
3216
+
3217
+
3218
+ ##### Returns
3219
+
3220
+
3221
+ - The value of the part of the date that is being formatted.
3222
+
3223
+
3224
+
2892
3225
 
2893
3226
  ### dist/general/array/addPropertyToArrayOfObjects.js
2894
3227
 
@@ -3363,8 +3696,14 @@ Validates if the given argument is empty
3363
3696
  #### isNaNV2(variable)
3364
3697
 
3365
3698
  Validates if the recieved number is NaN type.
3366
- This function recieves any variable but will return false.
3367
- Validates if variable is null, undefined, or an empty string, also, the function uses isNaN native function.
3699
+
3700
+ Conditions:
3701
+ - This function recieves any variable but will return true if it is different to number.
3702
+ - Empty variables as undefined, null, empty string will return true.
3703
+
3704
+ Special case for isNaN
3705
+ - The isNaN('') is considered as false statement. The empty string is converted to 0 which is not NaN.
3706
+ - Boolean variables is considered as false statement.
3368
3707
 
3369
3708
 
3370
3709
 
@@ -3381,7 +3720,7 @@ Validates if variable is null, undefined, or an empty string, also, the function
3381
3720
  ##### Returns
3382
3721
 
3383
3722
 
3384
- - True if variable is a NaN or false otherwise
3723
+ - True: variable is a NaN; False: The variable is a number
3385
3724
 
3386
3725
 
3387
3726
 
@@ -5018,8 +5357,8 @@ If an qrveyid is not provided in the expression the filter passes normally
5018
5357
 
5019
5358
  | Name | Type | Description | |
5020
5359
  | ---- | ---- | ----------- | -------- |
5021
- | logic | | The logic of the filter | &nbsp; |
5022
- | datasets | | The collection of datasets | &nbsp; |
5360
+ | logic | `Array.<IFBLogic>` | The logic of the filters | &nbsp; |
5361
+ | datasets | `Array.<IDataset>` | The collection of datasets | &nbsp; |
5023
5362
 
5024
5363
 
5025
5364
 
@@ -5031,6 +5370,103 @@ If an qrveyid is not provided in the expression the filter passes normally
5031
5370
 
5032
5371
 
5033
5372
 
5373
+ #### filterCallback(settings, datasets)
5374
+
5375
+ Runs the function for the callback
5376
+
5377
+
5378
+
5379
+
5380
+ ##### Parameters
5381
+
5382
+ | Name | Type | Description | |
5383
+ | ---- | ---- | ----------- | -------- |
5384
+ | settings | `IFFGetLogicByDatasetsColumns` | the settings for the helper | &nbsp; |
5385
+ | datasets | `Array.<IDataset>` | The dataset collection | &nbsp; |
5386
+
5387
+
5388
+
5389
+
5390
+ ##### Returns
5391
+
5392
+
5393
+ -
5394
+
5395
+
5396
+
5397
+ #### getLetQrveyidPass(expression, settings)
5398
+
5399
+ Gets the letQrveyidPass flag
5400
+
5401
+
5402
+
5403
+
5404
+ ##### Parameters
5405
+
5406
+ | Name | Type | Description | |
5407
+ | ---- | ---- | ----------- | -------- |
5408
+ | expression | `IFBExpression` | the logic expression of the filter | &nbsp; |
5409
+ | settings | `IFFGetLogicByDatasetsColumns` | the settings for the helper | &nbsp; |
5410
+
5411
+
5412
+
5413
+
5414
+ ##### Returns
5415
+
5416
+
5417
+ - `boolean` true: the qrveyid will be passed
5418
+
5419
+
5420
+
5421
+ #### getLetQuestionidPass(expression, settings)
5422
+
5423
+ Gets the letQuestionidPass flag
5424
+
5425
+
5426
+
5427
+
5428
+ ##### Parameters
5429
+
5430
+ | Name | Type | Description | |
5431
+ | ---- | ---- | ----------- | -------- |
5432
+ | expression | `IFBExpression` | the logic expression of the filter | &nbsp; |
5433
+ | settings | `IFFGetLogicByDatasetsColumns` | the settings for the helper | &nbsp; |
5434
+
5435
+
5436
+
5437
+
5438
+ ##### Returns
5439
+
5440
+
5441
+ - `boolean` true: the questionid will be passed
5442
+
5443
+
5444
+
5445
+ #### getDataset(expression, letQrveyidPass, datasets)
5446
+
5447
+ Gets the dataset related to the expression
5448
+
5449
+
5450
+
5451
+
5452
+ ##### Parameters
5453
+
5454
+ | Name | Type | Description | |
5455
+ | ---- | ---- | ----------- | -------- |
5456
+ | expression | `IFBExpression` | the logic expression of the filter | &nbsp; |
5457
+ | letQrveyidPass | `boolean` | flag that allows perform the condition to compare the qrveyid with the datasets | &nbsp; |
5458
+ | datasets | `Array.<IDataset>` | The dataset collection | &nbsp; |
5459
+
5460
+
5461
+
5462
+
5463
+ ##### Returns
5464
+
5465
+
5466
+ - `IDataset` the dataset object
5467
+
5468
+
5469
+
5034
5470
  #### getGetLogicByDatasetsSettings(settings)
5035
5471
 
5036
5472
  Gets the default settings for the getLogicByDatasetsColumn function
@@ -5042,7 +5478,7 @@ Gets the default settings for the getLogicByDatasetsColumn function
5042
5478
 
5043
5479
  | Name | Type | Description | |
5044
5480
  | ---- | ---- | ----------- | -------- |
5045
- | settings | | the settings given by the implementer | &nbsp; |
5481
+ | settings | `IFFGetLogicByDatasetsColumns` | the settings for the helper given by the implementer | &nbsp; |
5046
5482
 
5047
5483
 
5048
5484
 
@@ -5050,7 +5486,7 @@ Gets the default settings for the getLogicByDatasetsColumn function
5050
5486
  ##### Returns
5051
5487
 
5052
5488
 
5053
- - an object with all properties set
5489
+ - `IFFGetLogicByDatasetsColumns` an object with all properties set
5054
5490
 
5055
5491
 
5056
5492
 
@@ -9,13 +9,14 @@ const STRING_FORMAT_1 = require("../constants/STRING_FORMAT");
9
9
  const TABLE_TYPE_1 = require("../constants/TABLE_TYPE");
10
10
  const columnTypeByChart_1 = require("./columnTypeByChart");
11
11
  const CALCULATION_LABEL_1 = require("../../qrvey/constants/CALCULATION_LABEL");
12
+ const DATEGROUP_UNSUPPORT_FORMAT_1 = require("../constants/DATEGROUP_UNSUPPORT_FORMAT");
12
13
  /**
13
14
  * It returns the format of a column based on the column type, the chart type, and the chart settings
14
15
  * @param {IChartColumn} column - IChartColumn
15
16
  * @param {IColumnFormatSettings} settings - IColumnFormatSettings
16
17
  */
17
18
  const defineTableChartFormat = (column, settings) => {
18
- const { aggregate, defaultFormat, outputFormat, selectedFormat, calculation, } = column;
19
+ const { aggregate, defaultFormat, outputFormat, selectedFormat, calculation, dateGroup, } = column;
19
20
  const { tableType, shelfType } = settings;
20
21
  //Defaults
21
22
  const defaultText = "Default";
@@ -26,6 +27,8 @@ const defineTableChartFormat = (column, settings) => {
26
27
  };
27
28
  const isGroupedTable = tableType === TABLE_TYPE_1.TABLE_TYPE.GROUPED;
28
29
  const columnType = (0, columnTypeByChart_1.columnTypeByChart)(column, shelfType, CHART_GROUP_1.CHART_GROUPS.TABLES, isGroupedTable);
30
+ const noFormatSupported = dateGroup &&
31
+ DATEGROUP_UNSUPPORT_FORMAT_1.DATEGROUP_UNSUPPORT_FORMAT.some((gp) => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
29
32
  const hasDefaultFormat = (0, isEmpty_1.isEmpty)(selectedFormat) ||
30
33
  (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText ||
31
34
  (selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText;
@@ -42,18 +45,23 @@ const defineTableChartFormat = (column, settings) => {
42
45
  case COLUMN_1.COLUMN.TEXT_LABEL:
43
46
  return STRING_FORMAT_1.STRING_FORMAT.NONE;
44
47
  case COLUMN_1.COLUMN.DATE: {
48
+ if (selectedFormat)
49
+ return selectedFormat;
50
+ if (noFormatSupported) {
51
+ return STRING_FORMAT_1.STRING_FORMAT.NONE;
52
+ }
45
53
  if (hasDefaultFormat) {
46
54
  const columnDefaultFormat = defaultFormat ||
47
55
  outputFormat || { type: "DATE", format: "MM/DD/YYYY" };
48
56
  return Object.assign(Object.assign({}, defaultFormat), { format: defaultText, originalFormat: Object.assign({}, columnDefaultFormat), type: "DATE" });
49
57
  }
50
- else {
51
- return selectedFormat;
52
- }
58
+ return;
53
59
  }
54
60
  case COLUMN_1.COLUMN.NUMERIC:
55
61
  case COLUMN_1.COLUMN.RATING:
56
62
  case COLUMN_1.COLUMN.SLIDEBAR: {
63
+ if (selectedFormat)
64
+ return selectedFormat;
57
65
  if ((calculation === null || calculation === void 0 ? void 0 : calculation.value) === CALCULATION_LABEL_1.CALCULATION_LABEL.PDIFF)
58
66
  return defaultPercentage;
59
67
  if (hasDefaultFormat) {
@@ -62,7 +70,7 @@ const defineTableChartFormat = (column, settings) => {
62
70
  return defaultNumeric;
63
71
  return defaultFormat || defaultNumeric;
64
72
  }
65
- return selectedFormat;
73
+ return;
66
74
  }
67
75
  }
68
76
  };
@@ -53,7 +53,7 @@ exports.I18N_FORMULA_BUILDER = {
53
53
  no_columns_available: "No Columns Available",
54
54
  create_toast: "Formula Created Successfully.",
55
55
  update_toast: "Formula Updated Successfully",
56
- required_name_toast: "Formula Name is Required.",
56
+ required_name_toast: "Formula Name is required.",
57
57
  parameters: "Parameters",
58
58
  example: "Example",
59
59
  },
@@ -6,13 +6,14 @@ import { STRING_FORMAT } from "../constants/STRING_FORMAT";
6
6
  import { TABLE_TYPE } from "../constants/TABLE_TYPE";
7
7
  import { columnTypeByChart } from "./columnTypeByChart";
8
8
  import { CALCULATION_LABEL } from "../../qrvey/constants/CALCULATION_LABEL";
9
+ import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
9
10
  /**
10
11
  * It returns the format of a column based on the column type, the chart type, and the chart settings
11
12
  * @param {IChartColumn} column - IChartColumn
12
13
  * @param {IColumnFormatSettings} settings - IColumnFormatSettings
13
14
  */
14
15
  export const defineTableChartFormat = (column, settings) => {
15
- const { aggregate, defaultFormat, outputFormat, selectedFormat, calculation, } = column;
16
+ const { aggregate, defaultFormat, outputFormat, selectedFormat, calculation, dateGroup, } = column;
16
17
  const { tableType, shelfType } = settings;
17
18
  //Defaults
18
19
  const defaultText = "Default";
@@ -23,6 +24,8 @@ export const defineTableChartFormat = (column, settings) => {
23
24
  };
24
25
  const isGroupedTable = tableType === TABLE_TYPE.GROUPED;
25
26
  const columnType = columnTypeByChart(column, shelfType, CHART_GROUPS.TABLES, isGroupedTable);
27
+ const noFormatSupported = dateGroup &&
28
+ DATEGROUP_UNSUPPORT_FORMAT.some((gp) => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
26
29
  const hasDefaultFormat = isEmpty(selectedFormat) ||
27
30
  (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText ||
28
31
  (selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText;
@@ -39,18 +42,23 @@ export const defineTableChartFormat = (column, settings) => {
39
42
  case COLUMN.TEXT_LABEL:
40
43
  return STRING_FORMAT.NONE;
41
44
  case COLUMN.DATE: {
45
+ if (selectedFormat)
46
+ return selectedFormat;
47
+ if (noFormatSupported) {
48
+ return STRING_FORMAT.NONE;
49
+ }
42
50
  if (hasDefaultFormat) {
43
51
  const columnDefaultFormat = defaultFormat ||
44
52
  outputFormat || { type: "DATE", format: "MM/DD/YYYY" };
45
53
  return Object.assign(Object.assign({}, defaultFormat), { format: defaultText, originalFormat: Object.assign({}, columnDefaultFormat), type: "DATE" });
46
54
  }
47
- else {
48
- return selectedFormat;
49
- }
55
+ return;
50
56
  }
51
57
  case COLUMN.NUMERIC:
52
58
  case COLUMN.RATING:
53
59
  case COLUMN.SLIDEBAR: {
60
+ if (selectedFormat)
61
+ return selectedFormat;
54
62
  if ((calculation === null || calculation === void 0 ? void 0 : calculation.value) === CALCULATION_LABEL.PDIFF)
55
63
  return defaultPercentage;
56
64
  if (hasDefaultFormat) {
@@ -59,7 +67,7 @@ export const defineTableChartFormat = (column, settings) => {
59
67
  return defaultNumeric;
60
68
  return defaultFormat || defaultNumeric;
61
69
  }
62
- return selectedFormat;
70
+ return;
63
71
  }
64
72
  }
65
73
  };
@@ -50,7 +50,7 @@ export const I18N_FORMULA_BUILDER = {
50
50
  no_columns_available: "No Columns Available",
51
51
  create_toast: "Formula Created Successfully.",
52
52
  update_toast: "Formula Updated Successfully",
53
- required_name_toast: "Formula Name is Required.",
53
+ required_name_toast: "Formula Name is required.",
54
54
  parameters: "Parameters",
55
55
  example: "Example",
56
56
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",