chore: 2-way binding for address forms, like this?
follow up to 1f0c9e2
This commit is contained in:
parent
b4524fdd77
commit
9d806e6ede
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from "vue";
|
import { ref, watch, watchEffect } from "vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
|
@ -22,6 +22,11 @@ watch(
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Synchronize external changes to the internal state
|
||||||
|
watchEffect(() => {
|
||||||
|
Object.assign(orgAddress.value, props.modelValue);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from "vue";
|
import { ref, watch, watchEffect } from "vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
|
@ -24,6 +24,11 @@ watch(
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Synchronize external changes to the internal state
|
||||||
|
watchEffect(() => {
|
||||||
|
Object.assign(address.value, props.modelValue);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,6 @@ const billingAddressData: Ref<BillingAddressType | null> = fetchBillingAddress.d
|
||||||
|
|
||||||
watch(billingAddressData, (newVal) => {
|
watch(billingAddressData, (newVal) => {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
console.log("New billing address data: ", newVal);
|
|
||||||
// TODO: we get the billing address from the shop api but updating the form does not work
|
|
||||||
// TODO: I don't understand how this was supposed to work in the first place -> how do we do this? :)
|
|
||||||
address.value = {
|
address.value = {
|
||||||
firstName: newVal.first_name,
|
firstName: newVal.first_name,
|
||||||
lastName: newVal.last_name,
|
lastName: newVal.last_name,
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,6 @@ from django.views import defaults as default_views
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django_ratelimit.exceptions import Ratelimited
|
from django_ratelimit.exceptions import Ratelimited
|
||||||
from graphene_django.views import GraphQLView
|
from graphene_django.views import GraphQLView
|
||||||
from wagtail import urls as wagtail_urls
|
|
||||||
from wagtail.admin import urls as wagtailadmin_urls
|
|
||||||
from wagtail.documents import urls as wagtaildocs_urls
|
|
||||||
|
|
||||||
from vbv_lernwelt.api.user import list_organisations, me_user_view
|
from vbv_lernwelt.api.user import list_organisations, me_user_view
|
||||||
from vbv_lernwelt.assignment.views import request_assignment_completion_status
|
from vbv_lernwelt.assignment.views import request_assignment_completion_status
|
||||||
|
|
@ -58,6 +55,9 @@ from vbv_lernwelt.importer.views import (
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.notify.views import email_notification_settings
|
from vbv_lernwelt.notify.views import email_notification_settings
|
||||||
from vbv_lernwelt.shop.views import get_billing_address, update_billing_address
|
from vbv_lernwelt.shop.views import get_billing_address, update_billing_address
|
||||||
|
from wagtail import urls as wagtail_urls
|
||||||
|
from wagtail.admin import urls as wagtailadmin_urls
|
||||||
|
from wagtail.documents import urls as wagtaildocs_urls
|
||||||
|
|
||||||
|
|
||||||
class SignedIntConverter(IntConverter):
|
class SignedIntConverter(IntConverter):
|
||||||
|
|
|
||||||
|
|
@ -4,30 +4,29 @@ from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('shop', '0001_initial'),
|
("shop", "0001_initial"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RenameField(
|
migrations.RenameField(
|
||||||
model_name='billingaddress',
|
model_name="billingaddress",
|
||||||
old_name='company_street_address',
|
old_name="company_street_address",
|
||||||
new_name='company_street',
|
new_name="company_street",
|
||||||
),
|
),
|
||||||
migrations.RenameField(
|
migrations.RenameField(
|
||||||
model_name='billingaddress',
|
model_name="billingaddress",
|
||||||
old_name='company_street_number_address',
|
old_name="company_street_number_address",
|
||||||
new_name='company_street_number',
|
new_name="company_street_number",
|
||||||
),
|
),
|
||||||
migrations.RenameField(
|
migrations.RenameField(
|
||||||
model_name='billingaddress',
|
model_name="billingaddress",
|
||||||
old_name='street_address',
|
old_name="street_address",
|
||||||
new_name='street',
|
new_name="street",
|
||||||
),
|
),
|
||||||
migrations.RenameField(
|
migrations.RenameField(
|
||||||
model_name='billingaddress',
|
model_name="billingaddress",
|
||||||
old_name='street_number_address',
|
old_name="street_number_address",
|
||||||
new_name='street_number',
|
new_name="street_number",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue