Skip to content

Commit 3f82915

Browse files
committed
this works again
1 parent 10477dd commit 3f82915

File tree

15 files changed

+71
-50
lines changed

15 files changed

+71
-50
lines changed

app/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
'django.contrib.auth.middleware.AuthenticationMiddleware',
5454
'django.contrib.messages.middleware.MessageMiddleware',
5555
'django.middleware.clickjacking.XFrameOptionsMiddleware',
56-
'demo.middleware.DemoMiddleware',
5756
'inertia.middleware.InertiaMiddleware',
57+
'demo.middleware.DemoMiddleware',
5858
]
5959

6060
ROOT_URLCONF = 'app.urls'
@@ -144,3 +144,4 @@
144144
VERSION=2
145145
CSRF_COOKIE_NAME = "XSRF-TOKEN"
146146
CSRF_HEADER_NAME = "HTTP_X_XSRF_TOKEN"
147+
INERTIA_SHARE=False

demo/middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def __init__(self, get_response):
88
# One-time configuration and initialization.
99

1010
def __call__(self, request):
11-
11+
1212
if request.user.is_authenticated:
1313
share(request, 'auth', {
1414
'user':{
@@ -29,7 +29,7 @@ def __call__(self, request):
2929
'id':"request.user.id",
3030
'name':"request.user.username",
3131
},
32-
'id': "request.user.id",
32+
'id': "none",
3333
'firt_name': "request.user.first_name",
3434
'last_name': "request.user.last_name",
3535
'email': "request.user.email",

demo/static/src/Pages/Auth/Login.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ export default {
4949
},
5050
methods: {
5151
submit() {
52-
this.sending = true
53-
this.$inertia.post(this.route('login.attempt'), {
52+
const data = {
5453
email: this.form.email,
5554
password: this.form.password,
5655
remember: this.form.remember,
57-
}).then(() => this.sending = false)
56+
}
57+
58+
this.$inertia.post(this.route('login.attempt'), data, {
59+
onStart: () => this.sending = true,
60+
onFinish: () => this.sending = false,
61+
})
5862
},
5963
},
6064
}

demo/static/src/Pages/Contacts/Create.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ export default {
7171
},
7272
methods: {
7373
submit() {
74-
this.sending = true
75-
this.$inertia.post(this.route('contacts.store'), this.form)
76-
.then(() => this.sending = false)
74+
this.$inertia.post(this.route('contacts.store'), this.form, {
75+
onStart: () => this.sending = true,
76+
onFinish: () => this.sending = false,
77+
})
7778
},
7879
},
7980
}

demo/static/src/Pages/Contacts/Edit.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ export default {
8383
},
8484
methods: {
8585
submit() {
86-
this.sending = true
87-
this.$inertia.put(this.route('contacts.update', this.contact.id), this.form)
88-
.then(() => this.sending = false)
86+
this.$inertia.put(this.route('contacts.update', this.contact.id), this.form, {
87+
onStart: () => this.sending = true,
88+
onFinish: () => this.sending = false,
89+
})
8990
},
9091
destroy() {
9192
if (confirm('Are you sure you want to delete this contact?')) {

demo/static/src/Pages/Organizations/Create.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ export default {
6363
},
6464
methods: {
6565
submit() {
66-
this.sending = true
67-
this.$inertia.post(this.route('organizations.store'), this.form)
68-
.then(() => this.sending = false)
66+
this.$inertia.post(this.route('organizations.store'), this.form, {
67+
onStart: () => this.sending = true,
68+
onFinish: () => this.sending = false,
69+
})
6970
},
7071
},
7172
}

demo/static/src/Pages/Organizations/Edit.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ export default {
111111
},
112112
methods: {
113113
submit() {
114-
this.sending = true
115-
this.$inertia.put(this.route('organizations.update', this.organization.id), this.form)
116-
.then(() => this.sending = false)
114+
this.$inertia.put(this.route('organizations.update', this.organization.id), this.form, {
115+
onStart: () => this.sending = true,
116+
onFinish: () => this.sending = false,
117+
})
117118
},
118119
destroy() {
119120
if (confirm('Are you sure you want to delete this organization?')) {

demo/static/src/Pages/Users/Create.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ export default {
6060
},
6161
methods: {
6262
submit() {
63-
this.sending = true
64-
65-
var data = new FormData()
63+
const data = new FormData()
6664
data.append('first_name', this.form.first_name || '')
6765
data.append('last_name', this.form.last_name || '')
6866
data.append('email', this.form.email || '')
6967
data.append('password', this.form.password || '')
7068
data.append('owner', this.form.owner ? '1' : '0')
7169
data.append('photo', this.form.photo || '')
7270
73-
this.$inertia.post(this.route('users.store'), data)
74-
.then(() => this.sending = false)
71+
this.$inertia.post(this.route('users.store'), data, {
72+
onStart: () => this.sending = true,
73+
onFinish: () => this.sending = false,
74+
})
7575
},
7676
},
7777
}

demo/static/src/Pages/Users/Edit.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ export default {
7575
},
7676
methods: {
7777
submit() {
78-
this.sending = true
79-
8078
var data = new FormData()
8179
data.append('first_name', this.form.first_name || '')
8280
data.append('last_name', this.form.last_name || '')
@@ -86,14 +84,16 @@ export default {
8684
data.append('photo', this.form.photo || '')
8785
data.append('_method', 'put')
8886
89-
this.$inertia.post(this.route('users.update', this.user.id), data)
90-
.then(() => {
91-
this.sending = false
87+
this.$inertia.post(this.route('users.update', this.user.id), data, {
88+
onStart: () => this.sending = true,
89+
onFinish: () => this.sending = false,
90+
onSuccess: () => {
9291
if (Object.keys(this.$page.errors).length === 0) {
9392
this.form.photo = null
9493
this.form.password = null
9594
}
96-
})
95+
},
96+
})
9797
},
9898
destroy() {
9999
if (confirm('Are you sure you want to delete this user?')) {

demo/static/src/Shared/FlashMessages.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<template>
22
<div>
3-
<div v-if="$page.flash.success && show" class="mb-8 flex items-center justify-between bg-green-500 rounded max-w-3xl">
3+
<div v-if="$page.props.flash.success && show" class="mb-8 flex items-center justify-between bg-green-500 rounded max-w-3xl">
44
<div class="flex items-center">
55
<svg class="ml-4 mr-2 flex-shrink-0 w-4 h-4 fill-white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><polygon points="0 11 2 9 7 14 18 3 20 5 7 18" /></svg>
6-
<div class="py-4 text-white text-sm font-medium">{{ $page.flash.success }}</div>
6+
<div class="py-4 text-white text-sm font-medium">{{ $page.props.flash.success }}</div>
77
</div>
88
<button type="button" class="group mr-2 p-2" @click="show = false">
99
<svg class="block w-2 h-2 fill-green-800 group-hover:fill-white" xmlns="http://www.w3.org/2000/svg" width="235.908" height="235.908" viewBox="278.046 126.846 235.908 235.908"><path d="M506.784 134.017c-9.56-9.56-25.06-9.56-34.62 0L396 210.18l-76.164-76.164c-9.56-9.56-25.06-9.56-34.62 0-9.56 9.56-9.56 25.06 0 34.62L361.38 244.8l-76.164 76.165c-9.56 9.56-9.56 25.06 0 34.62 9.56 9.56 25.06 9.56 34.62 0L396 279.42l76.164 76.165c9.56 9.56 25.06 9.56 34.62 0 9.56-9.56 9.56-25.06 0-34.62L430.62 244.8l76.164-76.163c9.56-9.56 9.56-25.06 0-34.62z" /></svg>
1010
</button>
1111
</div>
12-
<div v-if="($page.flash.error || Object.keys($page.errors).length > 0) && show" class="mb-8 flex items-center justify-between bg-red-500 rounded max-w-3xl">
12+
<div v-if="($page.props.flash.error || Object.keys($page.props.errors).length > 0) && show" class="mb-8 flex items-center justify-between bg-red-500 rounded max-w-3xl">
1313
<div class="flex items-center">
1414
<svg class="ml-4 mr-2 flex-shrink-0 w-4 h-4 fill-white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm1.41-1.41A8 8 0 1 0 15.66 4.34 8 8 0 0 0 4.34 15.66zm9.9-8.49L11.41 10l2.83 2.83-1.41 1.41L10 11.41l-2.83 2.83-1.41-1.41L8.59 10 5.76 7.17l1.41-1.41L10 8.59l2.83-2.83 1.41 1.41z" /></svg>
15-
<div v-if="$page.flash.error" class="py-4 text-white text-sm font-medium">{{ $page.flash.error }}</div>
15+
<div v-if="$page.props.flash.error" class="py-4 text-white text-sm font-medium">{{ $page.props.flash.error }}</div>
1616
<div v-else class="py-4 text-white text-sm font-medium">
17-
<span v-if="Object.keys($page.errors).length === 1">There is one form error.</span>
18-
<span v-else>There are {{ Object.keys($page.errors).length }} form errors.</span>
17+
<span v-if="Object.keys($page.props.errors).length === 1">There is one form error.</span>
18+
<span v-else>There are {{ Object.keys($page.props.errors).length }} form.props.errors.</span>
1919
</div>
2020
</div>
2121
<button type="button" class="group mr-2 p-2" @click="show = false">
@@ -33,7 +33,7 @@ export default {
3333
}
3434
},
3535
watch: {
36-
'$page.flash': {
36+
'$page.props.flash': {
3737
handler() {
3838
this.show = true
3939
},

0 commit comments

Comments
 (0)