query-layers-expression 1.0.2 → 1.0.3

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/build/index.d.ts CHANGED
@@ -1,43 +1,21 @@
1
- import FeatureLayer from "@arcgis/core/layers/FeatureLayer";
2
1
  interface queryExpressionType {
3
- q1Value?: any;
4
- q1Field?: any;
5
- q2Value?: any;
6
- q2Field?: any;
7
- q3Value?: any;
8
- q3Field?: any;
2
+ qValues?: [any?, any?, any?];
3
+ qFields?: [any?, any?, any?];
9
4
  chartCategory?: any;
10
5
  chartCategoryField?: any;
11
6
  status?: number;
12
7
  statusField?: any;
13
8
  qExpression?: any;
14
9
  }
15
- interface queryDefinitionExpressionType {
16
- queryExpression?: string;
17
- featureLayer?: [FeatureLayer, FeatureLayer?, FeatureLayer?, FeatureLayer?, FeatureLayer?] | any;
18
- }
19
- declare class QueryExpressionLayers {
20
- featureLayers: [
21
- FeatureLayer,
22
- FeatureLayer?,
23
- FeatureLayer?,
24
- FeatureLayer?,
25
- FeatureLayer?,
26
- FeatureLayer?
27
- ] | any;
28
- q1Value?: any;
29
- q1Field?: any;
30
- q2Value?: any;
31
- q2Field?: any;
32
- q3Value?: any;
33
- q3Field?: any;
10
+ declare class QueryExpressionLayers implements queryExpressionType {
11
+ qValues?: [any?, any?, any?] | any;
12
+ qFields?: [any?, any?, any?] | any;
34
13
  chartCategory?: any;
35
14
  chartCategoryField?: any;
36
15
  status?: number;
37
16
  statusField?: any;
38
17
  qExpression?: any;
39
- constructor(featureLayers: any, q1Value: any, q1Field: any, q2Value: any, q2Field: any, q3Value: any, q3Field: any, chartCategory: any, chartCategoryField: any, status: number, statusField: any, qExpression: any);
40
- queryExpression: ({ q1Value, q1Field, q2Value, q2Field, q3Value, q3Field, chartCategory, chartCategoryField, status, statusField, qExpression, }: queryExpressionType) => string;
41
- queryDefinitionExpression: ({ queryExpression, featureLayer, }: queryDefinitionExpressionType) => void;
18
+ constructor(qValues: any, qFields: any, chartCategory: any, chartCategoryField: any, status: number, statusField: any, qExpression: any);
19
+ queryExpression: ({ qValues, qFields, chartCategory, chartCategoryField, status, statusField, qExpression, }: queryExpressionType) => string;
42
20
  }
43
21
  export default QueryExpressionLayers;
package/build/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class QueryExpressionLayers {
4
- constructor(featureLayers, q1Value, q1Field, q2Value, q2Field, q3Value, q3Field, chartCategory, chartCategoryField, status, statusField, qExpression) {
4
+ constructor(qValues, qFields, chartCategory, chartCategoryField, status, statusField, qExpression) {
5
5
  //--- Method ---//
6
6
  //--- Query Expression
7
- this.queryExpression = ({ q1Value, q1Field, q2Value, q2Field, q3Value, q3Field, chartCategory, chartCategoryField, status, statusField, qExpression, }) => {
7
+ this.queryExpression = ({ qValues, qFields, chartCategory, chartCategoryField, status, statusField, qExpression, }) => {
8
8
  //--- Basic query expression
9
- const query1 = `${q1Field} = '${q1Value}'`;
10
- const query2 = `${q2Field} = '${q2Value}'`;
11
- const query3 = `${q3Field} = '${q3Value}'`;
9
+ const query1 = `${qFields?.[0]} = '${qValues?.[0]}'`;
10
+ const query2 = `${qFields?.[1]} = '${qValues?.[1]}'`;
11
+ const query3 = `${qFields?.[2]} = '${qValues?.[2]}'`;
12
12
  const query12 = `${query1} AND ${query2}`;
13
13
  const query123 = `${query1} AND ${query2} AND ${query3}`;
14
14
  const q_status = `${statusField} = ${status}`;
@@ -43,60 +43,60 @@ class QueryExpressionLayers {
43
43
  if (qExpression) {
44
44
  if (chartCategoryField) {
45
45
  if (statusField) {
46
- if (!q1Value && !q2Value && !q3Value) {
46
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
47
47
  expression = q_status_chartC_qE;
48
48
  }
49
- else if (q1Value && !q2Value && !q3Value) {
49
+ else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
50
50
  expression = query1_status_chartC_qE;
51
51
  }
52
- else if (q1Value && q2Value && !q3Value) {
52
+ else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
53
53
  expression = query12_status_chartC_qE;
54
54
  }
55
- else if (q1Value && q2Value && q3Value) {
55
+ else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
56
56
  expression = query123_status_chartC_qE;
57
57
  }
58
58
  }
59
59
  else if (!statusField) {
60
- if (!q1Value && !q2Value && !q3Value) {
60
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
61
61
  expression = q_chartC_qE;
62
62
  }
63
- else if (q1Value && !q2Value && !q3Value) {
63
+ else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
64
64
  expression = query1_chartC_qE;
65
65
  }
66
- else if (q1Value && q2Value && !q3Value) {
66
+ else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
67
67
  expression = query12_chartC_qE;
68
68
  }
69
- else if (q1Value && q2Value && q3Value) {
69
+ else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
70
70
  expression = query123_chartC_qE;
71
71
  }
72
72
  }
73
73
  }
74
74
  else if (!chartCategoryField) {
75
75
  if (statusField) {
76
- if (!q1Value && !q2Value && !q3Value) {
76
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
77
77
  expression = q_status_qE;
78
78
  }
79
- else if (q1Value && !q2Value && !q3Value) {
79
+ else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
80
80
  expression = query1_status_qE;
81
81
  }
82
- else if (q1Value && q2Value && !q3Value) {
82
+ else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
83
83
  expression = query12_status_qE;
84
84
  }
85
- else if (q1Value && q2Value && q3Value) {
85
+ else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
86
86
  expression = query123_status_qE;
87
87
  }
88
88
  }
89
89
  else if (!statusField) {
90
- if (!q1Value && !q2Value && !q3Value) {
90
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
91
91
  expression = qExpression;
92
92
  }
93
- else if (q1Value && !q2Value && !q3Value) {
93
+ else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
94
94
  expression = query1_qE;
95
95
  }
96
- else if (q1Value && q2Value && !q3Value) {
96
+ else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
97
97
  expression = query12_qE;
98
98
  }
99
- else if (q1Value && q2Value && q3Value) {
99
+ else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
100
100
  expression = query123_qE;
101
101
  }
102
102
  }
@@ -105,60 +105,60 @@ class QueryExpressionLayers {
105
105
  else if (!qExpression) {
106
106
  if (chartCategoryField) {
107
107
  if (statusField) {
108
- if (!q1Value && !q2Value && !q3Value) {
108
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
109
109
  expression = q_status_chartC;
110
110
  }
111
- else if (q1Value && !q2Value && !q3Value) {
111
+ else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
112
112
  expression = query1_status_chartC;
113
113
  }
114
- else if (q1Value && q2Value && !q3Value) {
114
+ else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
115
115
  expression = query12_status_chartC;
116
116
  }
117
- else if (q1Value && q2Value && q3Value) {
117
+ else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
118
118
  expression = query123_status_chartC;
119
119
  }
120
120
  }
121
121
  else if (!statusField) {
122
- if (!q1Value && !q2Value && !q3Value) {
122
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
123
123
  expression = q_chartC;
124
124
  }
125
- else if (q1Value && !q2Value && !q3Value) {
125
+ else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
126
126
  expression = query1_chartC;
127
127
  }
128
- else if (q1Value && q2Value && !q3Value) {
128
+ else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
129
129
  expression = query12_chartC;
130
130
  }
131
- else if (q1Value && q2Value && q3Value) {
131
+ else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
132
132
  expression = query123_chartC;
133
133
  }
134
134
  }
135
135
  }
136
136
  else if (!chartCategoryField) {
137
137
  if (statusField) {
138
- if (!q1Value && !q2Value && !q3Value) {
138
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
139
139
  expression = q_status;
140
140
  }
141
- else if (q1Value && !q2Value && !q3Value) {
141
+ else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
142
142
  expression = query1_status;
143
143
  }
144
- else if (q1Value && q2Value && !q3Value) {
144
+ else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
145
145
  expression = query12_status;
146
146
  }
147
- else if (q1Value && q2Value && q3Value) {
147
+ else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
148
148
  expression = query123_status;
149
149
  }
150
150
  }
151
151
  else if (!statusField) {
152
- if (!q1Value && !q2Value && !q3Value) {
152
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
153
153
  expression = "1=1";
154
154
  }
155
- else if (q1Value && !q2Value && !q3Value) {
155
+ else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
156
156
  expression = query1;
157
157
  }
158
- else if (q1Value && q2Value && !q3Value) {
158
+ else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
159
159
  expression = query12;
160
160
  }
161
- else if (q1Value && q2Value && q3Value) {
161
+ else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
162
162
  expression = query123;
163
163
  }
164
164
  }
@@ -166,31 +166,8 @@ class QueryExpressionLayers {
166
166
  }
167
167
  return expression;
168
168
  };
169
- this.queryDefinitionExpression = ({ queryExpression, featureLayer, }) => {
170
- if (queryExpression) {
171
- if (featureLayer) {
172
- if (Array.isArray(featureLayer)) {
173
- featureLayer.forEach((layer) => {
174
- if (layer) {
175
- layer.definitionExpression = queryExpression;
176
- layer.visible = true;
177
- }
178
- });
179
- }
180
- else {
181
- featureLayer.definitionExpression = queryExpression;
182
- featureLayer.visible = true;
183
- }
184
- }
185
- }
186
- };
187
- this.featureLayers = featureLayers;
188
- this.q1Value = q1Value;
189
- this.q1Field = q1Field;
190
- this.q2Value = q2Value;
191
- this.q2Field = q2Field;
192
- this.q3Value = q3Value;
193
- this.q3Field = q3Field;
169
+ this.qValues = qValues;
170
+ this.qFields = qFields;
194
171
  this.chartCategory = chartCategory;
195
172
  this.chartCategoryField = chartCategoryField;
196
173
  this.status = status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "query-layers-expression",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Eiji Matsuzaki",
package/src/index.ts CHANGED
@@ -1,12 +1,8 @@
1
1
  import FeatureLayer from "@arcgis/core/layers/FeatureLayer";
2
2
 
3
3
  interface queryExpressionType {
4
- q1Value?: any;
5
- q1Field?: any;
6
- q2Value?: any;
7
- q2Field?: any;
8
- q3Value?: any;
9
- q3Field?: any;
4
+ qValues?: [any?, any?, any?];
5
+ qFields?: [any?, any?, any?];
10
6
  chartCategory?: any;
11
7
  chartCategoryField?: any;
12
8
  status?: number;
@@ -15,22 +11,8 @@ interface queryExpressionType {
15
11
  }
16
12
 
17
13
  class QueryExpressionLayers implements queryExpressionType {
18
- featureLayers:
19
- | [
20
- FeatureLayer,
21
- FeatureLayer?,
22
- FeatureLayer?,
23
- FeatureLayer?,
24
- FeatureLayer?,
25
- FeatureLayer?,
26
- ]
27
- | any;
28
- q1Value?: any;
29
- q1Field?: any;
30
- q2Value?: any;
31
- q2Field?: any;
32
- q3Value?: any;
33
- q3Field?: any;
14
+ qValues?: [any?, any?, any?] | any;
15
+ qFields?: [any?, any?, any?] | any;
34
16
  chartCategory?: any;
35
17
  chartCategoryField?: any;
36
18
  status?: number;
@@ -38,26 +20,16 @@ class QueryExpressionLayers implements queryExpressionType {
38
20
  qExpression?: any;
39
21
 
40
22
  constructor(
41
- featureLayers: any,
42
- q1Value: any,
43
- q1Field: any,
44
- q2Value: any,
45
- q2Field: any,
46
- q3Value: any,
47
- q3Field: any,
23
+ qValues: any,
24
+ qFields: any,
48
25
  chartCategory: any,
49
26
  chartCategoryField: any,
50
27
  status: number,
51
28
  statusField: any,
52
29
  qExpression: any,
53
30
  ) {
54
- this.featureLayers = featureLayers;
55
- this.q1Value = q1Value;
56
- this.q1Field = q1Field;
57
- this.q2Value = q2Value;
58
- this.q2Field = q2Field;
59
- this.q3Value = q3Value;
60
- this.q3Field = q3Field;
31
+ this.qValues = qValues;
32
+ this.qFields = qFields;
61
33
  this.chartCategory = chartCategory;
62
34
  this.chartCategoryField = chartCategoryField;
63
35
  this.status = status;
@@ -68,12 +40,8 @@ class QueryExpressionLayers implements queryExpressionType {
68
40
  //--- Method ---//
69
41
  //--- Query Expression
70
42
  queryExpression = ({
71
- q1Value,
72
- q1Field,
73
- q2Value,
74
- q2Field,
75
- q3Value,
76
- q3Field,
43
+ qValues,
44
+ qFields,
77
45
  chartCategory,
78
46
  chartCategoryField,
79
47
  status,
@@ -81,9 +49,9 @@ class QueryExpressionLayers implements queryExpressionType {
81
49
  qExpression,
82
50
  }: queryExpressionType) => {
83
51
  //--- Basic query expression
84
- const query1 = `${q1Field} = '${q1Value}'`;
85
- const query2 = `${q2Field} = '${q2Value}'`;
86
- const query3 = `${q3Field} = '${q3Value}'`;
52
+ const query1 = `${qFields?.[0]} = '${qValues?.[0]}'`;
53
+ const query2 = `${qFields?.[1]} = '${qValues?.[1]}'`;
54
+ const query3 = `${qFields?.[2]} = '${qValues?.[2]}'`;
87
55
  const query12 = `${query1} AND ${query2}`;
88
56
  const query123 = `${query1} AND ${query2} AND ${query3}`;
89
57
  const q_status = `${statusField} = ${status}`;
@@ -120,45 +88,45 @@ class QueryExpressionLayers implements queryExpressionType {
120
88
  if (qExpression) {
121
89
  if (chartCategoryField) {
122
90
  if (statusField) {
123
- if (!q1Value && !q2Value && !q3Value) {
91
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
124
92
  expression = q_status_chartC_qE;
125
- } else if (q1Value && !q2Value && !q3Value) {
93
+ } else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
126
94
  expression = query1_status_chartC_qE;
127
- } else if (q1Value && q2Value && !q3Value) {
95
+ } else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
128
96
  expression = query12_status_chartC_qE;
129
- } else if (q1Value && q2Value && q3Value) {
97
+ } else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
130
98
  expression = query123_status_chartC_qE;
131
99
  }
132
100
  } else if (!statusField) {
133
- if (!q1Value && !q2Value && !q3Value) {
101
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
134
102
  expression = q_chartC_qE;
135
- } else if (q1Value && !q2Value && !q3Value) {
103
+ } else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
136
104
  expression = query1_chartC_qE;
137
- } else if (q1Value && q2Value && !q3Value) {
105
+ } else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
138
106
  expression = query12_chartC_qE;
139
- } else if (q1Value && q2Value && q3Value) {
107
+ } else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
140
108
  expression = query123_chartC_qE;
141
109
  }
142
110
  }
143
111
  } else if (!chartCategoryField) {
144
112
  if (statusField) {
145
- if (!q1Value && !q2Value && !q3Value) {
113
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
146
114
  expression = q_status_qE;
147
- } else if (q1Value && !q2Value && !q3Value) {
115
+ } else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
148
116
  expression = query1_status_qE;
149
- } else if (q1Value && q2Value && !q3Value) {
117
+ } else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
150
118
  expression = query12_status_qE;
151
- } else if (q1Value && q2Value && q3Value) {
119
+ } else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
152
120
  expression = query123_status_qE;
153
121
  }
154
122
  } else if (!statusField) {
155
- if (!q1Value && !q2Value && !q3Value) {
123
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
156
124
  expression = qExpression;
157
- } else if (q1Value && !q2Value && !q3Value) {
125
+ } else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
158
126
  expression = query1_qE;
159
- } else if (q1Value && q2Value && !q3Value) {
127
+ } else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
160
128
  expression = query12_qE;
161
- } else if (q1Value && q2Value && q3Value) {
129
+ } else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
162
130
  expression = query123_qE;
163
131
  }
164
132
  }
@@ -166,45 +134,45 @@ class QueryExpressionLayers implements queryExpressionType {
166
134
  } else if (!qExpression) {
167
135
  if (chartCategoryField) {
168
136
  if (statusField) {
169
- if (!q1Value && !q2Value && !q3Value) {
137
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
170
138
  expression = q_status_chartC;
171
- } else if (q1Value && !q2Value && !q3Value) {
139
+ } else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
172
140
  expression = query1_status_chartC;
173
- } else if (q1Value && q2Value && !q3Value) {
141
+ } else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
174
142
  expression = query12_status_chartC;
175
- } else if (q1Value && q2Value && q3Value) {
143
+ } else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
176
144
  expression = query123_status_chartC;
177
145
  }
178
146
  } else if (!statusField) {
179
- if (!q1Value && !q2Value && !q3Value) {
147
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
180
148
  expression = q_chartC;
181
- } else if (q1Value && !q2Value && !q3Value) {
149
+ } else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
182
150
  expression = query1_chartC;
183
- } else if (q1Value && q2Value && !q3Value) {
151
+ } else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
184
152
  expression = query12_chartC;
185
- } else if (q1Value && q2Value && q3Value) {
153
+ } else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
186
154
  expression = query123_chartC;
187
155
  }
188
156
  }
189
157
  } else if (!chartCategoryField) {
190
158
  if (statusField) {
191
- if (!q1Value && !q2Value && !q3Value) {
159
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
192
160
  expression = q_status;
193
- } else if (q1Value && !q2Value && !q3Value) {
161
+ } else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
194
162
  expression = query1_status;
195
- } else if (q1Value && q2Value && !q3Value) {
163
+ } else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
196
164
  expression = query12_status;
197
- } else if (q1Value && q2Value && q3Value) {
165
+ } else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
198
166
  expression = query123_status;
199
167
  }
200
168
  } else if (!statusField) {
201
- if (!q1Value && !q2Value && !q3Value) {
169
+ if (!qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
202
170
  expression = "1=1";
203
- } else if (q1Value && !q2Value && !q3Value) {
171
+ } else if (qValues?.[0] && !qValues?.[1] && !qValues?.[2]) {
204
172
  expression = query1;
205
- } else if (q1Value && q2Value && !q3Value) {
173
+ } else if (qValues?.[0] && qValues?.[1] && !qValues?.[2]) {
206
174
  expression = query12;
207
- } else if (q1Value && q2Value && q3Value) {
175
+ } else if (qValues?.[0] && qValues?.[1] && qValues?.[2]) {
208
176
  expression = query123;
209
177
  }
210
178
  }