Bugfix in JS for project/activity selection in timesheet edit dialog (#1894)

This commit is contained in:
Kevin Papst
2020-08-16 16:20:24 +02:00
committed by GitHub
parent 2d4cfbe821
commit 4200208c7b
4 changed files with 18 additions and 7 deletions

View File

@@ -51,7 +51,9 @@ export default class KimaiSelectDataAPI extends KimaiPlugin {
const selectValue = jQuery(this).val();
if (selectValue === '' || (Array.isArray(selectValue) && selectValue.length === 0)) {
// Problem: select a project with activities and then select a customer that has no project
// results in a wrong URL, it triggers "activities?project=" instead of using the "emptyUrl"
if (selectValue === undefined || selectValue === null || selectValue === '' || (Array.isArray(selectValue) && selectValue.length === 0)) {
if (this.dataset['emptyUrl'] === undefined) {
self._updateSelect(targetSelect, {});
jQuery(targetSelect).attr('disabled', 'disabled');
@@ -79,8 +81,9 @@ export default class KimaiSelectDataAPI extends KimaiPlugin {
let targetField = jQuery('#' + formPrefix + test[1]);
let newValue = '';
if (targetField.length === 0) {
// debug: this case for example happens in duration only mode, when the end field is not found
//console.log('ERROR: Cannot find field with name "' + test[1] + '" by selector: #' + formPrefix + test[1]);
// happens for example:
// - in duration only mode, when the end field is not found
// console.log('ERROR: Cannot find field with name "' + test[1] + '" by selector: #' + formPrefix + test[1]);
} else {
if (targetField.val() !== null) {
newValue = targetField.val();
@@ -98,7 +101,15 @@ export default class KimaiSelectDataAPI extends KimaiPlugin {
newValue = moment(newValue, targetField.data('format')).format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
}
}
} else {
// happens for example:
// - when the end date is not set on a timesheet record and the project list is loaded (as the URL contains the %end% replacer)
// console.log('Empty value found for field with name "' + test[1] + '" by selector: #' + formPrefix + test[1]);
}
} else {
// happens for example:
// - when a customer without projects is selected
// console.log('ERROR: Empty field with name "' + test[1] + '" by selector: #' + formPrefix + test[1]);
}
}

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,7 @@
"build/runtime.098eaae1.js",
"build/0.79dbdbb9.js",
"build/1.512c747c.js",
"build/app.bbc43299.js"
"build/app.cafc411b.js"
],
"css": [
"build/app.554717a4.css"
@@ -53,7 +53,7 @@
"build/runtime.098eaae1.js": "sha384-xNNrNinl64G3nCUrIskgSjU0mUXXCB9lj6XCSInBTwxSKXk8uTMafnLHtdWdIGtd",
"build/0.79dbdbb9.js": "sha384-U2Ao0ORAZ8PCeDmyRsqQFET3hc7pfUBimq0PrqFdG4/s0Bdi+qBj4TJK3o70bCd5",
"build/1.512c747c.js": "sha384-SneGUmydV7WMkwkQp+4ql0TCXq1Or/1kQeIObbiMjx9QFM0DruGsytf77g4OxrGI",
"build/app.bbc43299.js": "sha384-WlGU/poBy3KLHz5/X5H3idDqTGW8yTk4Dqoy7GRM+chHibdncGJx6E9lEnkwX/kC",
"build/app.cafc411b.js": "sha384-sc27ZMn3ySrIZOjZ6G5bkSbG5yptYP4Cck2n5p2fOid056W/QaQZN2U4vDt0EipW",
"build/app.554717a4.css": "sha384-dITltEp59C3NH6o/8ZcpZJgHPLx+/I5t9xDQVsbQn7YoJ0GEV82gDDqe64ebjU29",
"build/invoice.74279541.js": "sha384-2BXic5Sgorf2tXai6zSAN4wLY2dbg06L03/xMKW6itMcszvtnRArKzfBh6DNcF3f",
"build/invoice.13d8ef4e.css": "sha384-B6RN/wZJToSBCZk2JeLokIqWEhbh+Eb9arYbt9dM+YoC2Z6PnCeTwTqSGyexWWJh",

View File

@@ -3,7 +3,7 @@
"build/1.512c747c.js": "build/1.512c747c.js",
"build/2.7ab75d0a.js": "build/2.7ab75d0a.js",
"build/app.css": "build/app.554717a4.css",
"build/app.js": "build/app.bbc43299.js",
"build/app.js": "build/app.cafc411b.js",
"build/calendar.css": "build/calendar.1408f57e.css",
"build/calendar.js": "build/calendar.0e49d4da.js",
"build/chart.js": "build/chart.34d60a88.js",