Skip to content

Commit fba860b

Browse files
committed
fix(webapps): add translation handler
- Fix translation loading problem on the batch operation page. - Execute new handler on all translation keys. - Add search pill comparison operators as proper translate strings. - Add null-conditional operator to avoid errors related to #4351
1 parent 7b61042 commit fba860b

File tree

14 files changed

+143
-120
lines changed

14 files changed

+143
-120
lines changed

webapps/frontend/camunda-commons-ui/lib/widgets/search/cam-widget-search.js

+22-28
Original file line numberDiff line numberDiff line change
@@ -141,31 +141,27 @@ module.exports = [
141141
$scope.translations[key] = $translate.instant(value);
142142
});
143143

144-
const initTypes = () => {
145-
$scope.types.map(function(el) {
146-
el.id.value = $translate.instant(el.id.value);
147-
if (el.operators) {
148-
el.operators = el.operators.map(function(op) {
149-
op.value = $translate.instant(op.value);
150-
return op;
151-
});
152-
}
153-
154-
if (el.options && typeof el.options[0] === 'object') {
155-
el.mappedOptions = el.options.map(({key, value}) => {
156-
return {
157-
key: key,
158-
value: $translate.instant(value)
159-
};
160-
});
144+
$scope.types.map(function(el) {
145+
el.id.value = $translate.instant(el.id.value);
146+
if (el.operators) {
147+
el.operators = el.operators.map(function(op) {
148+
op.value = $translate.instant(op.value);
149+
return op;
150+
});
151+
}
161152

162-
el.options = el.mappedOptions.map(({value}) => value);
163-
}
164-
return el;
165-
});
166-
};
153+
if (el.options && typeof el.options[0] === 'object') {
154+
el.mappedOptions = el.options.map(({key, value}) => {
155+
return {
156+
key: key,
157+
value: $translate.instant(value)
158+
};
159+
});
167160

168-
if ($scope.types) initTypes();
161+
el.options = el.mappedOptions.map(({value}) => value);
162+
}
163+
return el;
164+
});
169165

170166
angular.forEach($scope.operators, function(operatorGroupedByType) {
171167
angular.forEach(operatorGroupedByType, function(operator) {
@@ -735,7 +731,7 @@ module.exports = [
735731

736732
if (
737733
$scope.matchAny &&
738-
!$location.search().hasOwnProperty(searchId + 'OrQuery')// eslint-disable-line
734+
!$location.search().hasOwnProperty(searchId + 'OrQuery') // eslint-disable-line
739735
) {
740736
newLocation = $location.url() + '&' + searchId + 'OrQuery';
741737
} else if (!$scope.matchAny) {
@@ -775,11 +771,11 @@ module.exports = [
775771
$scope.$on('$locationChangeSuccess', function() {
776772
$scope.matchAny = $location
777773
.search()
778-
.hasOwnProperty(searchId + 'OrQuery');// eslint-disable-line
774+
.hasOwnProperty(searchId + 'OrQuery'); // eslint-disable-line
779775

780776
if (
781777
!IGNORE_URL_UPDATE &&
782-
$location.search().hasOwnProperty(searchId + 'Query')// eslint-disable-line
778+
$location.search().hasOwnProperty(searchId + 'Query') // eslint-disable-line
783779
) {
784780
// make new array of searches from the url
785781
var searches = getSearchesFromURL();
@@ -825,11 +821,9 @@ module.exports = [
825821
$scope.searches[i].type.values = types;
826822
}
827823
};
828-
829824
$scope.$watch(
830825
'types',
831826
function() {
832-
initTypes();
833827
//in case if array of types changed - update dropdown values
834828
$scope.searchTypes = $scope.types.map(function(el) {
835829
return el.id;

webapps/frontend/public/app/admin/locales/en.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,10 @@
676676
"USER_MEMBERSHIP_TENANT_SELECT_TENANTS": "Select Tenants",
677677
"USER_MEMBERSHIP_TENANT_TENANT_ID": "Tenant ID",
678678
"USER_MEMBERSHIP_TENANT_TENANT_NAME": "Tenant Name",
679-
"VALUE": "Value"
679+
"VALUE": "Value",
680+
"SEARCH_LESS_THAN": "<",
681+
"SEARCH_LESS_THAN_EQUALS": "<=",
682+
"SEARCH_GREATER_THAN": ">",
683+
"SEARCH_GREATER_THAN_EQUALS": ">="
680684
}
681685
}

webapps/frontend/public/app/cockpit/locales/en.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -2554,6 +2554,10 @@
25542554
"VARIABLE_UPLOAD_PROGRESS": "Upload progress: {{progress}}%",
25552555
"VARIABLE_UPLOAD_SELECT_FILE": "Select a file containing the binary content for the variable",
25562556
"VARIABLE_UPLOAD_UPLOAD": "Upload",
2557-
"WITHOUT_DUE_DATE": "Without Due Date"
2557+
"WITHOUT_DUE_DATE": "Without Due Date",
2558+
"SEARCH_LESS_THAN": "<",
2559+
"SEARCH_LESS_THAN_EQUALS": "<=",
2560+
"SEARCH_GREATER_THAN": ">",
2561+
"SEARCH_GREATER_THAN_EQUALS": ">="
25582562
}
25592563
}

webapps/frontend/public/app/tasklist/locales/en.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@
513513
"name": "Name",
514514
"owner": "Owner",
515515
"parentTask": "Parent task",
516-
"priority": "Priority"
516+
"priority": "Priority",
517+
"SEARCH_LESS_THAN": "<",
518+
"SEARCH_LESS_THAN_EQUALS": "<=",
519+
"SEARCH_GREATER_THAN": ">",
520+
"SEARCH_GREATER_THAN_EQUALS": ">="
517521
}
518522
}

webapps/frontend/public/app/welcome/locales/en.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@
182182
"TOGGLE_NAVIGATION": "Toggle navigation",
183183
"UPDATE": "Update",
184184
"USERNAME": "Username",
185-
"USERNAME_FOR_AUTHENTICATION": "Username for authentication: {{username}}"
185+
"USERNAME_FOR_AUTHENTICATION": "Username for authentication: {{username}}",
186+
"SEARCH_LESS_THAN": "<",
187+
"SEARCH_LESS_THAN_EQUALS": "<=",
188+
"SEARCH_GREATER_THAN": ">",
189+
"SEARCH_GREATER_THAN_EQUALS": ">="
186190
}
187191
}

webapps/frontend/ui/cockpit/client/scripts/batches/config/batch-search-config.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@
5959
},
6060
{
6161
"key": "gt",
62-
"value": ">"
62+
"value": "SEARCH_GREATER_THAN"
6363
},
6464
{
6565
"key": "gteq",
66-
"value": ">="
66+
"value": "SEARCH_GREATER_THAN_EQUALS"
6767
},
6868
{
6969
"key": "lt",
70-
"value": "<"
70+
"value": "SEARCH_LESS_THAN"
7171
},
7272
{
7373
"key": "lteq",
74-
"value": "<="
74+
"value": "SEARCH_LESS_THAN_EQUALS"
7575
},
7676
{
7777
"key": "like",
@@ -89,19 +89,19 @@
8989
},
9090
{
9191
"key": "gt",
92-
"value": ">"
92+
"value": "SEARCH_GREATER_THAN"
9393
},
9494
{
9595
"key": "gteq",
96-
"value": ">="
96+
"value": "SEARCH_GREATER_THAN_EQUALS"
9797
},
9898
{
9999
"key": "lt",
100-
"value": "<"
100+
"value": "SEARCH_LESS_THAN"
101101
},
102102
{
103103
"key": "lteq",
104-
"value": "<="
104+
"value": "SEARCH_LESS_THAN_EQUALS"
105105
},
106106
{
107107
"key": "like",
@@ -119,19 +119,19 @@
119119
},
120120
{
121121
"key": "gt",
122-
"value": ">"
122+
"value": "SEARCH_GREATER_THAN"
123123
},
124124
{
125125
"key": "gteq",
126-
"value": ">="
126+
"value": "SEARCH_GREATER_THAN_EQUALS"
127127
},
128128
{
129129
"key": "lt",
130-
"value": "<"
130+
"value": "SEARCH_LESS_THAN"
131131
},
132132
{
133133
"key": "lteq",
134-
"value": "<="
134+
"value": "SEARCH_LESS_THAN_EQUALS"
135135
}
136136
],
137137
"boolean": [

webapps/frontend/ui/cockpit/plugins/base/app/views/processDefinition/process-instance-search-config.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@
6060
},
6161
{
6262
"key": "gt",
63-
"value": ">"
63+
"value": "SEARCH_GREATER_THAN"
6464
},
6565
{
6666
"key": "gteq",
67-
"value": ">="
67+
"value": "SEARCH_GREATER_THAN_EQUALS"
6868
},
6969
{
7070
"key": "lt",
71-
"value": "<"
71+
"value": "SEARCH_LESS_THAN"
7272
},
7373
{
7474
"key": "lteq",
75-
"value": "<="
75+
"value": "SEARCH_LESS_THAN_EQUALS"
7676
},
7777
{
7878
"key": "like",
@@ -100,19 +100,19 @@
100100
},
101101
{
102102
"key": "gt",
103-
"value": ">"
103+
"value": "SEARCH_GREATER_THAN"
104104
},
105105
{
106106
"key": "gteq",
107-
"value": ">="
107+
"value": "SEARCH_GREATER_THAN_EQUALS"
108108
},
109109
{
110110
"key": "lt",
111-
"value": "<"
111+
"value": "SEARCH_LESS_THAN"
112112
},
113113
{
114114
"key": "lteq",
115-
"value": "<="
115+
"value": "SEARCH_LESS_THAN_EQUALS"
116116
},
117117
{
118118
"key": "like",
@@ -130,19 +130,19 @@
130130
},
131131
{
132132
"key": "gt",
133-
"value": ">"
133+
"value": "SEARCH_GREATER_THAN"
134134
},
135135
{
136136
"key": "gteq",
137-
"value": ">="
137+
"value": "SEARCH_GREATER_THAN_EQUALS"
138138
},
139139
{
140140
"key": "lt",
141-
"value": "<"
141+
"value": "SEARCH_LESS_THAN"
142142
},
143143
{
144144
"key": "lteq",
145-
"value": "<="
145+
"value": "SEARCH_LESS_THAN_EQUALS"
146146
},
147147
{
148148
"key": "like",
@@ -160,19 +160,19 @@
160160
},
161161
{
162162
"key": "gt",
163-
"value": ">"
163+
"value": "SEARCH_GREATER_THAN"
164164
},
165165
{
166166
"key": "gteq",
167-
"value": ">="
167+
"value": "SEARCH_GREATER_THAN_EQUALS"
168168
},
169169
{
170170
"key": "lt",
171-
"value": "<"
171+
"value": "SEARCH_LESS_THAN"
172172
},
173173
{
174174
"key": "lteq",
175-
"value": "<="
175+
"value": "SEARCH_LESS_THAN_EQUALS"
176176
}
177177
],
178178
"boolean": [

webapps/frontend/ui/cockpit/plugins/base/app/views/processInstance/variable-instances-tab-search-config.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@
4646
},
4747
{
4848
"key": "gt",
49-
"value": ">"
49+
"value": "SEARCH_GREATER_THAN"
5050
},
5151
{
5252
"key": "gteq",
53-
"value": ">="
53+
"value": "SEARCH_GREATER_THAN_EQUALS"
5454
},
5555
{
5656
"key": "lt",
57-
"value": "<"
57+
"value": "SEARCH_LESS_THAN"
5858
},
5959
{
6060
"key": "lteq",
61-
"value": "<="
61+
"value": "SEARCH_LESS_THAN_EQUALS"
6262
},
6363
{
6464
"key": "like",
@@ -79,19 +79,19 @@
7979
},
8080
{
8181
"key": "gt",
82-
"value": ">"
82+
"value": "SEARCH_GREATER_THAN"
8383
},
8484
{
8585
"key": "gteq",
86-
"value": ">="
86+
"value": "SEARCH_GREATER_THAN_EQUALS"
8787
},
8888
{
8989
"key": "lt",
90-
"value": "<"
90+
"value": "SEARCH_LESS_THAN"
9191
},
9292
{
9393
"key": "lteq",
94-
"value": "<="
94+
"value": "SEARCH_LESS_THAN_EQUALS"
9595
},
9696
{
9797
"key": "like",
@@ -109,19 +109,19 @@
109109
},
110110
{
111111
"key": "gt",
112-
"value": ">"
112+
"value": "SEARCH_GREATER_THAN"
113113
},
114114
{
115115
"key": "gteq",
116-
"value": ">="
116+
"value": "SEARCH_GREATER_THAN_EQUALS"
117117
},
118118
{
119119
"key": "lt",
120-
"value": "<"
120+
"value": "SEARCH_LESS_THAN"
121121
},
122122
{
123123
"key": "lteq",
124-
"value": "<="
124+
"value": "SEARCH_LESS_THAN_EQUALS"
125125
},
126126
{
127127
"key": "like",
@@ -139,19 +139,19 @@
139139
},
140140
{
141141
"key": "gt",
142-
"value": ">"
142+
"value": "SEARCH_GREATER_THAN"
143143
},
144144
{
145145
"key": "gteq",
146-
"value": ">="
146+
"value": "SEARCH_GREATER_THAN_EQUALS"
147147
},
148148
{
149149
"key": "lt",
150-
"value": "<"
150+
"value": "SEARCH_LESS_THAN"
151151
},
152152
{
153153
"key": "lteq",
154-
"value": "<="
154+
"value": "SEARCH_LESS_THAN_EQUALS"
155155
}
156156
],
157157
"boolean": [

0 commit comments

Comments
 (0)