Skip to content

Commit 31abed8

Browse files
committed
[FEATURE] Add empty option for states, remove debug code
Resolves: https://projekte.in2code.de/issues/40565
1 parent 4b79787 commit 31abed8

File tree

11 files changed

+22
-711
lines changed

11 files changed

+22
-711
lines changed

Classes/Controller/AbstractController.php

+1
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ public function assignForAll()
372372
{
373373
$jsLabels = [
374374
'loading_states' => LocalizationUtility::translate('js.loading_states'),
375+
'please_choose' => LocalizationUtility::translate('pleaseChoose'),
375376
];
376377
$this->view->assignMultiple(
377378
[

Classes/UserFunc/StaticInfoTables.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use function array_values;
1515
use function count;
16-
use function is_a;
1716
use function is_array;
1817

1918
class StaticInfoTables
@@ -35,15 +34,22 @@ public function getStatesOptions(array $data, TcaSelectItems $tcaSelectItems)
3534
$country = null;
3635
}
3736
}
38-
if (!empty($country)) {
37+
if (empty($country)) {
38+
$data['items'] = [
39+
[
40+
'LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:pleaseChooseCountry',
41+
''
42+
]
43+
];
44+
} else {
3945
$countryZones = $countryZonesDataProvider->getCountryZonesForCountryIso3($country);
4046

4147
foreach ($countryZones as $countryZone) {
4248
$data['items'][] = [$countryZone->getLocalName(), $countryZone->getIsoCode()];
4349
}
4450
}
4551
} else {
46-
$data['items'][] = ['', 'Error: static_info_tables is not installed'];
52+
$data['items'][] = ['Error: static_info_tables is not installed', ''];
4753
}
4854
}
4955

Configuration/TCA/Overrides/fe_users.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@
114114
'config' => [
115115
'type' => 'select',
116116
'renderType' => 'selectSingle',
117+
'items' => [
118+
['LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:pleaseChoose', '']
119+
],
117120
'itemsProcFunc' => 'In2code\\Femanager\\UserFunc\\StaticInfoTables->getStatesOptions',
118121
'maxitems' => 1,
119122
]
@@ -128,7 +131,7 @@
128131
'renderType' => 'selectSingle',
129132
'itemsProcFunc' => 'In2code\\Femanager\\UserFunc\\StaticInfoTables->getCountryOptions',
130133
'items' => [
131-
['', '--- Please Select ---']
134+
['LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:pleaseChoose', '']
132135
],
133136
'maxitems' => 1,
134137
];

Resources/Private/JavaScript/Backend.js

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ define(
7777

7878
// User Logout
7979
$('.logoutUser').click(function (e) {
80-
console.log('#1');
8180
e.preventDefault();
8281
var $this = $(this);
8382
$this

Resources/Private/JavaScript/Femanager.js

+4-30
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ jQuery(document).ready(function($) {
5050
// data fields
5151
document.querySelectorAll('[data-data-endpoint]').forEach(function (nodeElement) {
5252
var triggerCallback = function (event) {
53-
console.log('Triggered event', event);
54-
5553
var endpoint = nodeElement.dataset['dataEndpoint'];
5654

5755
var data = {
@@ -62,65 +60,44 @@ jQuery(document).ready(function($) {
6260
// Convert DOMStringMap to object. https://stackoverflow.com/a/48235245/2025722
6361
// According to Mozilla this should work all the way back to IE 8 without a polyfill.
6462
arguments = JSON.parse(JSON.stringify(nodeElement.dataset));
65-
66-
console.log('Searching for additional arguments', arguments);
67-
6863
for (var argument in arguments) {
6964
if (arguments.hasOwnProperty(argument)) {
70-
console.log(' - Found argument', argument);
7165
if (argument.match('arguments')) {
7266
var sourceField = document.getElementById(arguments[argument]);
73-
console.log(' - argument matched, source field ID, source field', argument, arguments[argument], sourceField);
7467
if (sourceField) {
7568
var argumentName = lcfirst(argument.substr(9));
76-
console.log(' - Adding value', argumentName, sourceField.value);
7769
data['tx_femanager_pi1[' + argumentName + ']'] = sourceField.value;
7870
}
7971
}
8072
}
8173
}
8274

83-
console.log(' - Data', data);
84-
8575
var url = Femanager.getBaseUrl() + 'index.php?id=' + $('#femanagerPid').val() + '&type=1594138042';
8676

87-
console.log(' - URL', url);
88-
8977
$.ajax({
9078
url: url,
9179
data: data,
9280
type: 'POST',
9381
cache: false,
9482
beforeSend: function () {
95-
console.log(' - Disabling element before ajax send', nodeElement);
9683
nodeElement.disabled = 1;
9784
nodeElement.options.length = 0
9885
nodeElement.options[0] = new Option(labels.loading_states);
9986
},
10087
success: function(options) {
101-
console.log('Got response');
102-
if (typeof(options) === 'object') {
103-
if (Object.keys(options).length) {
104-
console.table(options);
105-
} else {
106-
console.log('Response is empty', options);
107-
}
108-
} else {
109-
console.log(options);
110-
}
111-
11288
nodeElement.options.length = 0
89+
for (var option in options) {
90+
nodeElement.options[nodeElement.options.length] = new Option(labels.please_choose);
91+
break;
92+
}
11393
for (var option in options) {
11494
if (options.hasOwnProperty(option)) {
115-
console.log(' - Adding option:', option, options[option]);
11695
nodeElement.options[nodeElement.options.length] = new Option(options[option], option);
11796
}
11897
}
11998
if (nodeElement.options.length === 0) {
120-
console.log(' - Disabling element', nodeElement)
12199
nodeElement.disabled = 1;
122100
} else {
123-
console.log(' - Enabling element', nodeElement)
124101
nodeElement.disabled = 0;
125102
}
126103

@@ -132,12 +109,9 @@ jQuery(document).ready(function($) {
132109
};
133110
var triggerFieldsString = nodeElement.dataset['triggerFields']
134111
if (undefined !== triggerFieldsString) {
135-
console.log('Element has trigger fields', nodeElement, triggerFieldsString);
136112
triggerFieldsString.split(',').forEach(function(element) {
137113
var triggerElement = document.getElementById(element);
138-
console.log(' - trigger field', element, triggerElement);
139114
if (undefined !== triggerElement) {
140-
console.log(' - added event listener', triggerElement);
141115
triggerElement.addEventListener('change', triggerCallback);
142116
}
143117
});

Resources/Private/JavaScript/Validation.js

-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ jQuery.fn.femanagerValidation = function($) {
8484
* @return void
8585
*/
8686
function validateField(element, countForSubmit) {
87-
console.log('Validation:', element, element.prop('disabled'));
8887
if (element.prop('disabled')) {
89-
console.log(' - Skipping validation, element is disabled');
9088
if (countForSubmit) {
9189
requestCallback.addCallbackToQueue(true);
9290
}
@@ -130,7 +128,6 @@ jQuery.fn.femanagerValidation = function($) {
130128
type: 'POST',
131129
cache: false,
132130
success: function(json) { // return values
133-
console.log('Validation response', element, json);
134131
if (countForSubmit) {
135132
requestCallback.addCallbackToQueue(true);
136133
}

Resources/Private/gulpfile.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ var uglify = require('gulp-uglify');
77
var plumber = require('gulp-plumber');
88
var debug = getArg('--debug');
99
var rename = require('gulp-rename');
10-
var stripDebug = require('gulp-strip-debug');
1110

1211
// SCSS zu css
1312
gulp.task('css', function() {
@@ -30,8 +29,7 @@ gulp.task('css', function() {
3029
gulp.task('js', function() {
3130
gulp.src('JavaScript/**/*.js')
3231
.pipe(plumber())
33-
// .pipe(uglify())
34-
// .pipe(stripDebug())
32+
.pipe(uglify())
3533
.pipe(rename({
3634
suffix: '.min'
3735
}))

Resources/Private/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"gulp-plumber": "^1.0.1",
1717
"gulp-rename": "^1.2.2",
1818
"gulp-sass": "^2.1.1",
19-
"gulp-strip-debug": "^3.0.0",
2019
"gulp-uglify": "^1.5.1",
2120
"npm-run-all": "^4.1.5"
2221
}

Resources/Public/JavaScript/Backend.min.js

+1-109
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)