@@ -78,13 +78,36 @@ const metadata = {
78
78
maxValue : {
79
79
type : String ,
80
80
} ,
81
+
81
82
/**
82
- * Defines whether a slider for secconds will be available. By default there are sliders for hours and minutes only .
83
+ * Defines whether a slider for seconds will be available. By default there are sliders for hours, minutes and seconds .
83
84
* @type {boolean }
84
85
* @defaultvalue false
85
86
* @public
86
87
*/
87
- showSeconds : {
88
+ hideSeconds : {
89
+ type : Boolean ,
90
+ } ,
91
+
92
+ /**
93
+ * Defines whether the slider for minutes will be available. By default there are sliders for hours, minutes and seconds.
94
+ * @type {boolean }
95
+ * @defaultvalue false
96
+ * @public
97
+ * @since 1.0.0-rc.8
98
+ */
99
+ hideMinutes : {
100
+ type : Boolean ,
101
+ } ,
102
+
103
+ /**
104
+ * Defines whether the slider for hours will be available. By default there are sliders for hours, minutes and seconds.
105
+ * @type {boolean }
106
+ * @defaultvalue false
107
+ * @public
108
+ * @since 1.0.0-rc.8
109
+ */
110
+ hideHours : {
88
111
type : Boolean ,
89
112
} ,
90
113
@@ -248,7 +271,7 @@ class DurationPicker extends UI5Element {
248
271
}
249
272
250
273
normalizaValue ( ) {
251
- this . value = `${ this . selectedHours || "00" } : ${ this . selectedMinutes || "00" } ${ this . showSeconds ? `:${ this . selectedSeconds || "00" } ` : "" } ` ;
274
+ this . value = `${ ! this . hideHours ? this . selectedHours || "00" : "" } ${ ! this . hideHours && ! this . hideMinutes ? ":" : "" } ${ ! this . hideMinutes ? this . selectedMinutes || "00" : "" } ${ ! this . hideSeconds ? `:${ this . selectedSeconds || "00" } ` : "" } ` ;
252
275
}
253
276
254
277
/**
@@ -260,11 +283,39 @@ class DurationPicker extends UI5Element {
260
283
return value . split ( ":" ) ;
261
284
}
262
285
286
+ getSecondsFromFormattedValue ( destructuredValues ) {
287
+ if ( this . hideSeconds ) {
288
+ return "" ;
289
+ }
290
+
291
+ if ( this . hideHours && this . hideMinutes ) {
292
+ return destructuredValues [ 0 ] ;
293
+ }
294
+
295
+ if ( this . hideHours || this . hideMinutes ) {
296
+ return destructuredValues [ 1 ] ;
297
+ }
298
+
299
+ return destructuredValues [ 2 ] ;
300
+ }
301
+
302
+ getMinutesFromFormattedValue ( destructuredValues ) {
303
+ if ( this . hideMinutes ) {
304
+ return "" ;
305
+ }
306
+
307
+ if ( this . hideHours ) {
308
+ return destructuredValues [ 0 ] ;
309
+ }
310
+
311
+ return destructuredValues [ 1 ] ;
312
+ }
313
+
263
314
setSelectedValues ( ) {
264
315
const destructuredValues = this . readFormattedValue ( this . value || "" ) ;
265
- let currentHours = destructuredValues [ 0 ] ,
266
- currentMinutes = destructuredValues [ 1 ] ,
267
- currentSeconds = destructuredValues [ 2 ] ;
316
+ let currentHours = this . hideHours ? "" : destructuredValues [ 0 ] ,
317
+ currentMinutes = this . getMinutesFromFormattedValue ( destructuredValues ) , // this.hideHours && !this.hideMinutes ? destructuredValues[0] : "" ,
318
+ currentSeconds = this . getSecondsFromFormattedValue ( destructuredValues ) ; // this.hideHours && this.hideHours ? destructuredValues[0] : {} ;
268
319
269
320
if ( currentHours > - 1 ) {
270
321
if ( currentHours > this . _maxValue [ 0 ] ) {
@@ -275,7 +326,7 @@ class DurationPicker extends UI5Element {
275
326
}
276
327
277
328
if ( currentMinutes > - 1 ) {
278
- if ( parseInt ( currentMinutes ) % this . minutesStep !== 0 ) {
329
+ if ( currentMinutes && parseInt ( currentMinutes ) % this . minutesStep !== 0 ) {
279
330
currentMinutes = this . findNearestStep ( currentMinutes , this . minutesStep ) ;
280
331
}
281
332
if ( this . _maxValue [ 0 ] && this . selectedHours === this . _maxValue [ 0 ] ) {
@@ -288,7 +339,7 @@ class DurationPicker extends UI5Element {
288
339
}
289
340
290
341
if ( currentSeconds > - 1 ) {
291
- if ( parseInt ( currentSeconds ) % this . secondsStep !== 0 ) {
342
+ if ( currentSeconds && parseInt ( currentSeconds ) % this . secondsStep !== 0 ) {
292
343
currentSeconds = this . findNearestStep ( currentSeconds , this . secondsStep ) ;
293
344
}
294
345
if ( this . _maxValue [ 0 ] && this . _maxValue [ 1 ] && this . selectedHours >= this . _maxValue [ 0 ] && this . selectedSeconds >= this . _maxValue [ 1 ] ) {
@@ -375,7 +426,7 @@ class DurationPicker extends UI5Element {
375
426
376
427
submitPickers ( ) {
377
428
const prevValue = this . value ;
378
- this . value = `${ this . hoursSlider . value } : ${ this . minutesSlider . value } ${ this . showSeconds ? `:${ this . secondsSlider . value } ` : "" } ` ;
429
+ this . value = `${ ! this . hideHours ? this . hoursSlider . value : "" } ${ ! this . hideHours && ! this . hideMinutes ? ":" : "" } ${ ! this . hideMinutes ? this . minutesSlider . value : "" } ${ ! this . hideSeconds ? `:${ this . secondsSlider . value } ` : "" } ` ;
379
430
this . togglePicker ( ) ;
380
431
if ( prevValue !== this . value ) {
381
432
this . fireEvent ( "change" , { value : this . value } ) ;
0 commit comments