Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
[#1965](https://github.com/nextcloud/cookbook/pull/1965) @seyfeb
- Replace eye icon with close icon for cancelling recipe edit
[#1971](https://github.com/nextcloud/cookbook/pull/1971) @seyfeb
- Fill prep, cook, and total time in `RecipeEdit` after loading
[#1973](https://github.com/nextcloud/cookbook/pull/1973) @seyfeb

### Maintenance
- Add PHP lint checker to ensure valid (legacy) PHP syntax
Expand Down
25 changes: 18 additions & 7 deletions src/components/FormComponents/EditTimeField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</template>

<script setup>
import { ref, watch } from 'vue';
import { ref, onMounted, watch } from 'vue';

const emit = defineEmits(['input']);

Expand Down Expand Up @@ -49,12 +49,7 @@ const hours = ref(null);
*/
const minutes = ref(null);

watch(
() => props.value,
() => {
[hours.value, minutes.value] = props.value.time;
},
);
// Methods

const handleInput = () => {
minutes.value = minutes.value ? minutes.value : 0;
Expand All @@ -69,6 +64,22 @@ const handleInput = () => {
paddedTime: `PT${hoursPadded}H${minutesPadded}M`,
});
};

const setLocalValueFromProps = () => {
if (props.value?.time) {
[hours.value, minutes.value] = props.value.time;
}
};

// Watchers

watch(() => props.value, setLocalValueFromProps);

// Vue lifecycle

onMounted(() => {
setLocalValueFromProps();
});
</script>

<script>
Expand Down