Make media annotation (fade/cue/etc) values clearable.

This commit is contained in:
Buster Neece 2023-12-16 12:19:27 -06:00
parent 14a1513003
commit afc1f2fde9
No known key found for this signature in database
3 changed files with 50 additions and 16 deletions

View File

@ -57,9 +57,22 @@
</template>
<template
v-if="description || slots.description"
v-if="description || slots.description || clearable"
#description="slotProps"
>
<div
v-if="clearable"
class="buttons"
>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
@click.prevent="clear"
>
{{ $gettext('Clear Field') }}
</button>
</div>
<slot
v-bind="slotProps"
name="description"
@ -121,6 +134,10 @@ const props = defineProps({
type: Boolean,
default: false
},
clearable: {
type: Boolean,
default: false
},
advanced: {
type: Boolean,
default: false
@ -143,18 +160,18 @@ const filteredModel = computed({
},
set(newValue) {
if ((isNumeric.value || props.inputEmptyIsNull) && '' === newValue) {
newValue = null;
}
model.value = null;
} else {
if (props.inputTrim && null !== newValue) {
newValue = newValue.replace(/^\s+|\s+$/gm, '');
}
if (props.inputTrim && null !== newValue) {
newValue = newValue.replace(/^\s+|\s+$/gm, '');
}
if (isNumeric.value) {
newValue = Number(newValue);
}
if (isNumeric.value) {
newValue = Number(newValue);
model.value = newValue;
}
model.value = newValue;
}
});
@ -164,6 +181,10 @@ const focus = () => {
$input.value?.focus();
};
const clear = () => {
filteredModel.value = '';
}
onMounted(() => {
if (props.autofocus) {
nextTick(() => {

View File

@ -15,6 +15,7 @@
:input-attrs="{ step: '0.1' }"
:label="$gettext('Amplify: Amplification (dB)')"
:description="$gettext('The volume in decibels to amplify the track with. Leave blank to use the system default.')"
clearable
/>
<form-group-field
@ -25,6 +26,7 @@
:input-attrs="{ step: '0.1' }"
:label="$gettext('Custom Fading: Overlap Time (seconds)')"
:description="$gettext('The time that this song should overlap its surrounding songs when fading. Leave blank to use the system default.')"
clearable
/>
<form-group-field
@ -35,6 +37,7 @@
:input-attrs="{ step: '0.1' }"
:label="$gettext('Custom Fading: Fade-In Time (seconds)')"
:description="$gettext('The time period that the song should fade in. Leave blank to use the system default.')"
clearable
/>
<form-group-field
@ -45,6 +48,7 @@
:input-attrs="{ step: '0.1' }"
:label="$gettext('Custom Fading: Fade-Out Time (seconds)')"
:description="$gettext('The time period that the song should fade out. Leave blank to use the system default.')"
clearable
/>
<form-group-field
@ -55,6 +59,7 @@
:input-attrs="{ step: '0.1' }"
:label="$gettext('Custom Cues: Cue-In Point (seconds)')"
:description="$gettext('Seconds from the start of the song that the AutoDJ should start playing.')"
clearable
/>
<form-group-field
@ -65,6 +70,7 @@
:input-attrs="{ step: '0.1' }"
:label="$gettext('Custom Cues: Cue-Out Point (seconds)')"
:description="$gettext('Seconds from the start of the song that the AutoDJ should stop playing.')"
clearable
/>
</div>
</template>

View File

@ -344,7 +344,7 @@ class StationMedia implements
public function setAmplify(?float $amplify = null): void
{
$this->amplify = Types::stringOrNull($amplify, true);
$this->amplify = $this->annotationToString($amplify);
}
public function getFadeOverlap(): ?float
@ -354,7 +354,7 @@ class StationMedia implements
public function setFadeOverlap(?float $fadeOverlap = null): void
{
$this->fade_overlap = Types::stringOrNull($fadeOverlap, true);
$this->fade_overlap = $this->annotationToString($fadeOverlap);
}
public function getFadeIn(): ?float
@ -364,7 +364,7 @@ class StationMedia implements
public function setFadeIn(string|int|float $fadeIn = null): void
{
$this->fade_in = Types::stringOrNull(Time::displayTimeToSeconds($fadeIn), true);
$this->fade_in = $this->annotationToString($fadeIn);
}
public function getFadeOut(): ?float
@ -374,7 +374,7 @@ class StationMedia implements
public function setFadeOut(string|int|float $fadeOut = null): void
{
$this->fade_out = Types::stringOrNull(Time::displayTimeToSeconds($fadeOut), true);
$this->fade_out = $this->annotationToString($fadeOut);
}
public function getCueIn(): ?float
@ -384,7 +384,7 @@ class StationMedia implements
public function setCueIn(string|int|float $cueIn = null): void
{
$this->cue_in = Types::stringOrNull(Time::displayTimeToSeconds($cueIn), true);
$this->cue_in = $this->annotationToString($cueIn);
}
public function getCueOut(): ?float
@ -394,7 +394,7 @@ class StationMedia implements
public function setCueOut(string|int|float $cueOut = null): void
{
$this->cue_out = Types::stringOrNull(Time::displayTimeToSeconds($cueOut), true);
$this->cue_out = $this->annotationToString($cueOut);
}
/**
@ -473,6 +473,13 @@ class StationMedia implements
return $this->playlists;
}
private function annotationToString(string|float|int $annotation = null): ?string
{
return Types::stringOrNull(
Time::displayTimeToSeconds($annotation)
);
}
public function fromMetadata(MetadataInterface $metadata): void
{
$this->setLength($metadata->getDuration());