Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/1970 cooking prep and total time are not filled during edits #1973

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
Loading