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]);
}
}