@qrvey/utils 1.2.9-18 → 1.2.9-19
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 +54 -54
- package/dist/cjs/format/localization.d.ts +1 -0
- package/dist/cjs/format/localization.js +10 -1
- package/dist/cjs/services/api/getDatasetColumns.api.js +1 -3
- package/dist/format/localization.d.ts +1 -0
- package/dist/format/localization.js +8 -0
- package/dist/services/api/getDatasetColumns.api.js +2 -4
- package/package.json +1 -1
- package/src/format/localization.ts +10 -0
- package/src/services/api/getDatasetColumns.api.ts +2 -3
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.2.9-
|
|
1
|
+
# [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.2.9-19*
|
|
2
2
|
|
|
3
3
|
> Helper, Utils for all Qrvey Projects
|
|
4
4
|
|
|
@@ -2722,50 +2722,47 @@ Gets the format config
|
|
|
2722
2722
|
|
|
2723
2723
|
|
|
2724
2724
|
|
|
2725
|
-
### dist/
|
|
2726
|
-
|
|
2725
|
+
### dist/stencil/decorators/Config.js
|
|
2727
2726
|
|
|
2728
|
-
#### getAllDatasets(config, pickDatasets)
|
|
2729
2727
|
|
|
2730
|
-
|
|
2728
|
+
#### Config()
|
|
2731
2729
|
|
|
2730
|
+
Stencil.js - Prop Decorator
|
|
2731
|
+
Get and Parse the Widget Configuration Object and also provide the ability to get properties in different case styles such as: lower, upper, camel and pascal
|
|
2732
|
+
But for this, is required ask for a property in `snake_case` style
|
|
2732
2733
|
|
|
2733
2734
|
|
|
2734
2735
|
|
|
2735
|
-
##### Parameters
|
|
2736
2736
|
|
|
2737
|
-
| Name | Type | Description | |
|
|
2738
|
-
| ---- | ---- | ----------- | -------- |
|
|
2739
|
-
| config | | the widget config. Includes the appid and others configuration properties | |
|
|
2740
|
-
| pickDatasets | | Collection of Qrvey IDs for filtering the request | |
|
|
2741
2737
|
|
|
2742
2738
|
|
|
2739
|
+
##### Examples
|
|
2743
2740
|
|
|
2741
|
+
```javascript
|
|
2742
|
+
\ @Config() @Prop() settings;
|
|
2744
2743
|
|
|
2745
|
-
|
|
2744
|
+
someMethod() {
|
|
2745
|
+
this.settings.snake_case //it search for: obj.snake_case || obj.snakeCase || obj.SnakeCase || obj.snakecase || obj.SNAKECASE
|
|
2746
|
+
}
|
|
2747
|
+
```
|
|
2746
2748
|
|
|
2747
2749
|
|
|
2748
|
-
|
|
2750
|
+
##### Returns
|
|
2749
2751
|
|
|
2750
2752
|
|
|
2753
|
+
- `Void`
|
|
2751
2754
|
|
|
2752
2755
|
|
|
2753
|
-
### dist/services/api/getAllQrveys.api.js
|
|
2754
2756
|
|
|
2755
2757
|
|
|
2756
|
-
|
|
2758
|
+
### dist/stencil/util/createRef.js
|
|
2757
2759
|
|
|
2758
|
-
POST Request for getting Qrveys such as Web Forms and Datasets. Use params for getting precise data
|
|
2759
2760
|
|
|
2761
|
+
#### createRef()
|
|
2760
2762
|
|
|
2763
|
+
lit implementation of React createRef (https://reactjs.org/docs/refs-and-the-dom.html)
|
|
2761
2764
|
|
|
2762
2765
|
|
|
2763
|
-
##### Parameters
|
|
2764
|
-
|
|
2765
|
-
| Name | Type | Description | |
|
|
2766
|
-
| ---- | ---- | ----------- | -------- |
|
|
2767
|
-
| config | | Configuration | |
|
|
2768
|
-
| params | | Object for getting precise data | |
|
|
2769
2766
|
|
|
2770
2767
|
|
|
2771
2768
|
|
|
@@ -2773,17 +2770,21 @@ POST Request for getting Qrveys such as Web Forms and Datasets. Use params for g
|
|
|
2773
2770
|
##### Returns
|
|
2774
2771
|
|
|
2775
2772
|
|
|
2776
|
-
-
|
|
2773
|
+
- function - Function to use in ref prop in html elements
|
|
2777
2774
|
|
|
2778
2775
|
|
|
2779
2776
|
|
|
2780
2777
|
|
|
2781
|
-
### dist/
|
|
2778
|
+
### dist/stencil/util/getConfig.js
|
|
2782
2779
|
|
|
2783
2780
|
|
|
2784
|
-
####
|
|
2781
|
+
#### getConfig(cfg)
|
|
2785
2782
|
|
|
2786
|
-
|
|
2783
|
+
verify the Config object type and try to return a parsed Object
|
|
2784
|
+
- In case _cfg_ is a string, first try to make a JSON parse in other case
|
|
2785
|
+
try to find this string as a variable on Windows object
|
|
2786
|
+
- If _cfg_ is a fuction, tis is invoked and parsed
|
|
2787
|
+
- Finally, if is an object, _cfg_ is inmediatly returned
|
|
2787
2788
|
|
|
2788
2789
|
|
|
2789
2790
|
|
|
@@ -2792,7 +2793,7 @@ Get a dataset by Qrvey ID
|
|
|
2792
2793
|
|
|
2793
2794
|
| Name | Type | Description | |
|
|
2794
2795
|
| ---- | ---- | ----------- | -------- |
|
|
2795
|
-
|
|
|
2796
|
+
| cfg | | | |
|
|
2796
2797
|
|
|
2797
2798
|
|
|
2798
2799
|
|
|
@@ -2800,74 +2801,73 @@ Get a dataset by Qrvey ID
|
|
|
2800
2801
|
##### Returns
|
|
2801
2802
|
|
|
2802
2803
|
|
|
2803
|
-
-
|
|
2804
|
-
|
|
2804
|
+
- `Void`
|
|
2805
2805
|
|
|
2806
2806
|
|
|
2807
2807
|
|
|
2808
|
-
### dist/stencil/decorators/Config.js
|
|
2809
2808
|
|
|
2809
|
+
### dist/services/api/getAllDatasets.api.js
|
|
2810
2810
|
|
|
2811
|
-
#### Config()
|
|
2812
2811
|
|
|
2813
|
-
|
|
2814
|
-
Get and Parse the Widget Configuration Object and also provide the ability to get properties in different case styles such as: lower, upper, camel and pascal
|
|
2815
|
-
But for this, is required ask for a property in `snake_case` style
|
|
2812
|
+
#### getAllDatasets(config, pickDatasets)
|
|
2816
2813
|
|
|
2814
|
+
Get a dataset list from a collection of Qrvey IDs
|
|
2817
2815
|
|
|
2818
2816
|
|
|
2819
2817
|
|
|
2820
2818
|
|
|
2819
|
+
##### Parameters
|
|
2821
2820
|
|
|
2822
|
-
|
|
2821
|
+
| Name | Type | Description | |
|
|
2822
|
+
| ---- | ---- | ----------- | -------- |
|
|
2823
|
+
| config | | the widget config. Includes the appid and others configuration properties | |
|
|
2824
|
+
| pickDatasets | | Collection of Qrvey IDs for filtering the request | |
|
|
2823
2825
|
|
|
2824
|
-
```javascript
|
|
2825
|
-
\ @Config() @Prop() settings;
|
|
2826
2826
|
|
|
2827
|
-
someMethod() {
|
|
2828
|
-
this.settings.snake_case //it search for: obj.snake_case || obj.snakeCase || obj.SnakeCase || obj.snakecase || obj.SNAKECASE
|
|
2829
|
-
}
|
|
2830
|
-
```
|
|
2831
2827
|
|
|
2832
2828
|
|
|
2833
2829
|
##### Returns
|
|
2834
2830
|
|
|
2835
2831
|
|
|
2836
|
-
-
|
|
2832
|
+
- a promise
|
|
2837
2833
|
|
|
2838
2834
|
|
|
2839
2835
|
|
|
2840
2836
|
|
|
2841
|
-
### dist/
|
|
2837
|
+
### dist/services/api/getAllQrveys.api.js
|
|
2842
2838
|
|
|
2843
2839
|
|
|
2844
|
-
####
|
|
2840
|
+
#### getAllQrveys(config, params)
|
|
2845
2841
|
|
|
2846
|
-
|
|
2842
|
+
POST Request for getting Qrveys such as Web Forms and Datasets. Use params for getting precise data
|
|
2847
2843
|
|
|
2848
2844
|
|
|
2849
2845
|
|
|
2850
2846
|
|
|
2847
|
+
##### Parameters
|
|
2848
|
+
|
|
2849
|
+
| Name | Type | Description | |
|
|
2850
|
+
| ---- | ---- | ----------- | -------- |
|
|
2851
|
+
| config | | Configuration | |
|
|
2852
|
+
| params | | Object for getting precise data | |
|
|
2853
|
+
|
|
2854
|
+
|
|
2851
2855
|
|
|
2852
2856
|
|
|
2853
2857
|
##### Returns
|
|
2854
2858
|
|
|
2855
2859
|
|
|
2856
|
-
-
|
|
2860
|
+
- `Void`
|
|
2857
2861
|
|
|
2858
2862
|
|
|
2859
2863
|
|
|
2860
2864
|
|
|
2861
|
-
### dist/
|
|
2865
|
+
### dist/services/api/getDatasetColumns.api.js
|
|
2862
2866
|
|
|
2863
2867
|
|
|
2864
|
-
####
|
|
2868
|
+
#### getDatasetColumns(qrveyid)
|
|
2865
2869
|
|
|
2866
|
-
|
|
2867
|
-
- In case _cfg_ is a string, first try to make a JSON parse in other case
|
|
2868
|
-
try to find this string as a variable on Windows object
|
|
2869
|
-
- If _cfg_ is a fuction, tis is invoked and parsed
|
|
2870
|
-
- Finally, if is an object, _cfg_ is inmediatly returned
|
|
2870
|
+
Get a dataset by Qrvey ID
|
|
2871
2871
|
|
|
2872
2872
|
|
|
2873
2873
|
|
|
@@ -2876,7 +2876,7 @@ try to find this string as a variable on Windows object
|
|
|
2876
2876
|
|
|
2877
2877
|
| Name | Type | Description | |
|
|
2878
2878
|
| ---- | ---- | ----------- | -------- |
|
|
2879
|
-
|
|
|
2879
|
+
| qrveyid | | The Qrvey ID | |
|
|
2880
2880
|
|
|
2881
2881
|
|
|
2882
2882
|
|
|
@@ -2884,7 +2884,7 @@ try to find this string as a variable on Windows object
|
|
|
2884
2884
|
##### Returns
|
|
2885
2885
|
|
|
2886
2886
|
|
|
2887
|
-
-
|
|
2887
|
+
- a promise
|
|
2888
2888
|
|
|
2889
2889
|
|
|
2890
2890
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { IFormatConfig, IFormatOutputFormat } from '../interfaces';
|
|
2
2
|
export declare const getLang: (locale: string | Record<string, any>) => Record<string, any>;
|
|
3
|
+
export declare const chooseLang: (config: Record<string, any>) => string;
|
|
3
4
|
export declare const formatWithLocale: (value: any, outputFormat: IFormatOutputFormat, config?: IFormatConfig) => any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatWithLocale = exports.getLang = void 0;
|
|
3
|
+
exports.formatWithLocale = exports.chooseLang = exports.getLang = void 0;
|
|
4
4
|
const definition_1 = require("./definition");
|
|
5
5
|
const getLang = (locale) => {
|
|
6
6
|
if (!locale)
|
|
@@ -11,6 +11,15 @@ const getLang = (locale) => {
|
|
|
11
11
|
return { lang: locale === "browser" ? window.navigator.language : locale };
|
|
12
12
|
};
|
|
13
13
|
exports.getLang = getLang;
|
|
14
|
+
const chooseLang = (config) => {
|
|
15
|
+
var _a, _b, _c, _d, _e;
|
|
16
|
+
const lang = (((_a = config === null || config === void 0 ? void 0 : config.i18n) === null || _a === void 0 ? void 0 : _a.lang) ||
|
|
17
|
+
((_c = (_b = config === null || config === void 0 ? void 0 : config.i18n) === null || _b === void 0 ? void 0 : _b.locale) === null || _c === void 0 ? void 0 : _c.lang) ||
|
|
18
|
+
((_d = config === null || config === void 0 ? void 0 : config.locale) === null || _d === void 0 ? void 0 : _d.lang) ||
|
|
19
|
+
config.lang);
|
|
20
|
+
return ((_e = lang) === null || _e === void 0 ? void 0 : _e.lang) || lang || definition_1.LANG_DEFAULT;
|
|
21
|
+
};
|
|
22
|
+
exports.chooseLang = chooseLang;
|
|
14
23
|
const formatWithLocale = (value, outputFormat, config = {}) => {
|
|
15
24
|
switch (outputFormat.type) {
|
|
16
25
|
case 'DATE':
|
|
@@ -7,7 +7,6 @@ exports.getDatasetColumns = void 0;
|
|
|
7
7
|
const CHART_ENDPOINT_1 = require("../constants/CHART_ENDPOINT");
|
|
8
8
|
const Request_1 = __importDefault(require("../helpers/Request"));
|
|
9
9
|
const BDatasetsToUIDatasets_adapter_1 = require("../adapters/BDatasetsToUIDatasets.adapter");
|
|
10
|
-
const definition_1 = require("../../format/definition");
|
|
11
10
|
const __1 = require("../..");
|
|
12
11
|
/**
|
|
13
12
|
* Get a dataset by Qrvey ID
|
|
@@ -15,8 +14,7 @@ const __1 = require("../..");
|
|
|
15
14
|
* @returns a promise
|
|
16
15
|
*/
|
|
17
16
|
function getDatasetColumns(config, qrveyid) {
|
|
18
|
-
|
|
19
|
-
const lang = (0, __1.getLang)(config.lang || ((_a = config.locale) === null || _a === void 0 ? void 0 : _a.lang) || config.locale || definition_1.LANG_DEFAULT).lang;
|
|
17
|
+
const lang = (0, __1.chooseLang)(config);
|
|
20
18
|
return Request_1.default.post(Object.assign(Object.assign({}, config), { qrveyid, endpoint: CHART_ENDPOINT_1.CHART_ENDPOINT }), '/question/list', {
|
|
21
19
|
'optionsAttributes': ['id', 'text', 'type', 'property', 'linked', 'linkid', 'qrveyid', 'bucketId', 'formulaId', 'formulaType', 'geogroup', 'outputFormat'],
|
|
22
20
|
'extend': true
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { IFormatConfig, IFormatOutputFormat } from '../interfaces';
|
|
2
2
|
export declare const getLang: (locale: string | Record<string, any>) => Record<string, any>;
|
|
3
|
+
export declare const chooseLang: (config: Record<string, any>) => string;
|
|
3
4
|
export declare const formatWithLocale: (value: any, outputFormat: IFormatOutputFormat, config?: IFormatConfig) => any;
|
|
@@ -7,6 +7,14 @@ export const getLang = (locale) => {
|
|
|
7
7
|
else
|
|
8
8
|
return { lang: locale === "browser" ? window.navigator.language : locale };
|
|
9
9
|
};
|
|
10
|
+
export const chooseLang = (config) => {
|
|
11
|
+
var _a, _b, _c, _d, _e;
|
|
12
|
+
const lang = (((_a = config === null || config === void 0 ? void 0 : config.i18n) === null || _a === void 0 ? void 0 : _a.lang) ||
|
|
13
|
+
((_c = (_b = config === null || config === void 0 ? void 0 : config.i18n) === null || _b === void 0 ? void 0 : _b.locale) === null || _c === void 0 ? void 0 : _c.lang) ||
|
|
14
|
+
((_d = config === null || config === void 0 ? void 0 : config.locale) === null || _d === void 0 ? void 0 : _d.lang) ||
|
|
15
|
+
config.lang);
|
|
16
|
+
return ((_e = lang) === null || _e === void 0 ? void 0 : _e.lang) || lang || LANG_DEFAULT;
|
|
17
|
+
};
|
|
10
18
|
export const formatWithLocale = (value, outputFormat, config = {}) => {
|
|
11
19
|
switch (outputFormat.type) {
|
|
12
20
|
case 'DATE':
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { CHART_ENDPOINT } from "../constants/CHART_ENDPOINT";
|
|
2
2
|
import Request from "../helpers/Request";
|
|
3
3
|
import { BDatasetsToUIDatasets } from "../adapters/BDatasetsToUIDatasets.adapter";
|
|
4
|
-
import {
|
|
5
|
-
import { getLang } from "../..";
|
|
4
|
+
import { chooseLang } from "../..";
|
|
6
5
|
/**
|
|
7
6
|
* Get a dataset by Qrvey ID
|
|
8
7
|
* @param qrveyid The Qrvey ID
|
|
9
8
|
* @returns a promise
|
|
10
9
|
*/
|
|
11
10
|
export function getDatasetColumns(config, qrveyid) {
|
|
12
|
-
|
|
13
|
-
const lang = getLang(config.lang || ((_a = config.locale) === null || _a === void 0 ? void 0 : _a.lang) || config.locale || LANG_DEFAULT).lang;
|
|
11
|
+
const lang = chooseLang(config);
|
|
14
12
|
return Request.post(Object.assign(Object.assign({}, config), { qrveyid, endpoint: CHART_ENDPOINT }), '/question/list', {
|
|
15
13
|
'optionsAttributes': ['id', 'text', 'type', 'property', 'linked', 'linkid', 'qrveyid', 'bucketId', 'formulaId', 'formulaType', 'geogroup', 'outputFormat'],
|
|
16
14
|
'extend': true
|
package/package.json
CHANGED
|
@@ -7,6 +7,16 @@ export const getLang = (locale: string | Record<string, any>) => {
|
|
|
7
7
|
else return { lang: locale === "browser" ? window.navigator.language : locale };
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
+
export const chooseLang = (config: Record<string, any>): string => {
|
|
11
|
+
const lang: string | Record<string, any> = (
|
|
12
|
+
config?.i18n?.lang ||
|
|
13
|
+
config?.i18n?.locale?.lang ||
|
|
14
|
+
config?.locale?.lang ||
|
|
15
|
+
config.lang
|
|
16
|
+
);
|
|
17
|
+
return (<any>lang)?.lang || lang || LANG_DEFAULT;
|
|
18
|
+
};
|
|
19
|
+
|
|
10
20
|
export const formatWithLocale = (value: any, outputFormat: IFormatOutputFormat, config: IFormatConfig = {}): any => {
|
|
11
21
|
switch (outputFormat.type) {
|
|
12
22
|
case 'DATE':
|
|
@@ -3,8 +3,7 @@ import { IDataset } from "../../qrvey/interfaces/IDataset";
|
|
|
3
3
|
import { CHART_ENDPOINT } from "../constants/CHART_ENDPOINT";
|
|
4
4
|
import Request from "../helpers/Request";
|
|
5
5
|
import { BDatasetsToUIDatasets } from "../adapters/BDatasetsToUIDatasets.adapter";
|
|
6
|
-
import {
|
|
7
|
-
import { getLang } from "../..";
|
|
6
|
+
import { chooseLang } from "../..";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Get a dataset by Qrvey ID
|
|
@@ -12,7 +11,7 @@ import { getLang } from "../..";
|
|
|
12
11
|
* @returns a promise
|
|
13
12
|
*/
|
|
14
13
|
export function getDatasetColumns(config: IGeneralWidgetConfig, qrveyid?: string): Promise<IDataset[]> {
|
|
15
|
-
const lang =
|
|
14
|
+
const lang = chooseLang(config);
|
|
16
15
|
return Request.post({ ...config, qrveyid, endpoint: CHART_ENDPOINT }, '/question/list', {
|
|
17
16
|
'optionsAttributes': ['id', 'text', 'type', 'property', 'linked', 'linkid', 'qrveyid', 'bucketId', 'formulaId', 'formulaType', 'geogroup', 'outputFormat'],
|
|
18
17
|
'extend': true
|