Apply pickDate-config setting to hide calendar in datepicker (#11632)

* Apply pickDate-config setting to hide calendar in datepicker 

A time-only picker is only possible if the format is configured like "hh:mm:ss". By using the pickDate config it is possible to determine whether the calendar should be shown or not, instead of depending on a certain time format.

* Changed timeformat to accept both hh:mm:ss and hh:mm

Edited the regex to math times with and without seconds. The calendar should not be shown anymore if the timeformat is (H)H:mm:ss or (H)H:mm.

* Removed unused config property pickDate

config.pickDate is never used and can be removed.

* remove pickDate config from datepickers config
This commit is contained in:
inetzo
2021-11-24 02:07:35 +01:00
committed by GitHub
parent f7be5a5dec
commit 7538f0c4ad
2 changed files with 1 additions and 4 deletions

View File

@@ -124,7 +124,6 @@
vm.logOptions.orderDirection = 'Descending';
vm.fromDatePickerConfig = {
pickDate: true,
pickTime: true,
useSeconds: false,
useCurrent: false,
@@ -138,7 +137,6 @@
};
vm.toDatePickerConfig = {
pickDate: true,
pickTime: true,
useSeconds: false,
format: "YYYY-MM-DD HH:mm",

View File

@@ -11,7 +11,6 @@ function dateTimePickerController($scope, angularHelper, dateHelper, validationM
// setup the default config
var config = {
pickDate: true,
pickTime: true,
useSeconds: true,
format: "YYYY-MM-DD HH:mm:ss",
@@ -56,7 +55,7 @@ function dateTimePickerController($scope, angularHelper, dateHelper, validationM
// Don't show calendar if date format has been set to only time
const timeFormat = $scope.model.config.format.toLowerCase();
const timeFormatPattern = /^h{1,2}:m{1,2}:s{1,2}\s?a?$/gmi;
const timeFormatPattern = /^h{1,2}:m{1,2}(:s{1,2})?\s?a?$/gmi;
if (timeFormat.match(timeFormatPattern)) {
$scope.datePickerConfig.enableTime = true;
$scope.datePickerConfig.noCalendar = true;