Skip to content

Commit

Permalink
Merge pull request #1973 from nextcloud/fix/1970-cooking-prep-and-tot…
Browse files Browse the repository at this point in the history
…al-time-are-not-filled-during-edits

Fix/1970 cooking prep and total time are not filled during edits
  • Loading branch information
christianlupus authored Dec 13, 2023
2 parents bc7b7b7 + 1133a4b commit afc74d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
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

0 comments on commit afc74d2

Please sign in to comment.