Commit f357317f by Jonathan Reinink

Automatically convert routes to strings

1 parent 87b77f79
...@@ -54,7 +54,7 @@ export default { ...@@ -54,7 +54,7 @@ export default {
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true
Inertia.post(this.route('login.attempt').url(), { Inertia.post(this.route('login.attempt'), {
email: this.form.email, email: this.form.email,
password: this.form.password, password: this.form.password,
remember: this.form.remember, remember: this.form.remember,
......
...@@ -71,7 +71,7 @@ export default { ...@@ -71,7 +71,7 @@ export default {
methods: { methods: {
submit() { submit() {
this.form.post({ this.form.post({
url: this.route('contacts.store').url(), url: this.route('contacts.store'),
then: data => Inertia.visit(this.route('contacts.edit', data.id)), then: data => Inertia.visit(this.route('contacts.edit', data.id)),
}) })
}, },
......
...@@ -79,23 +79,23 @@ export default { ...@@ -79,23 +79,23 @@ export default {
methods: { methods: {
submit() { submit() {
this.form.put({ this.form.put({
url: this.route('contacts.update', this.contact.id).url(), url: this.route('contacts.update', this.contact.id),
then: () => Inertia.visit(this.route('contacts')), then: () => Inertia.visit(this.route('contacts')),
}) })
}, },
destroy() { destroy() {
if (confirm('Are you sure you want to delete this contact?')) { if (confirm('Are you sure you want to delete this contact?')) {
this.form.delete({ this.form.delete({
url: this.route('contacts.destroy', this.contact.id).url(), url: this.route('contacts.destroy', this.contact.id),
then: () => Inertia.replace(this.route('contacts.edit', this.contact.id).url()), then: () => Inertia.replace(this.route('contacts.edit', this.contact.id)),
}) })
} }
}, },
restore() { restore() {
if (confirm('Are you sure you want to restore this contact?')) { if (confirm('Are you sure you want to restore this contact?')) {
this.form.put({ this.form.put({
url: this.route('contacts.restore', this.contact.id).url(), url: this.route('contacts.restore', this.contact.id),
then: () => Inertia.replace(this.route('contacts.edit', this.contact.id).url()), then: () => Inertia.replace(this.route('contacts.edit', this.contact.id)),
}) })
} }
}, },
......
...@@ -94,7 +94,7 @@ export default { ...@@ -94,7 +94,7 @@ export default {
form: { form: {
handler: _.throttle(function() { handler: _.throttle(function() {
let query = _.pickBy(this.form) let query = _.pickBy(this.form)
Inertia.replace(this.route('contacts', Object.keys(query).length ? query : { remember: 'forget' }).url()) Inertia.replace(this.route('contacts', Object.keys(query).length ? query : { remember: 'forget' }))
}, 150), }, 150),
deep: true, deep: true,
}, },
......
...@@ -77,7 +77,7 @@ export default { ...@@ -77,7 +77,7 @@ export default {
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true
Inertia.post(this.route('organizations.store').url(), this.form).then(() => this.sending = false) Inertia.post(this.route('organizations.store'), this.form).then(() => this.sending = false)
}, },
}, },
} }
......
...@@ -111,16 +111,16 @@ export default { ...@@ -111,16 +111,16 @@ export default {
}, },
methods: { methods: {
submit() { submit() {
Inertia.put(this.route('organizations.update', this.organization.id).url(), this.form) Inertia.put(this.route('organizations.update', this.organization.id), this.form)
}, },
destroy() { destroy() {
if (confirm('Are you sure you want to delete this organization?')) { if (confirm('Are you sure you want to delete this organization?')) {
Inertia.delete(this.route('organizations.destroy', this.organization.id).url()) Inertia.delete(this.route('organizations.destroy', this.organization.id))
} }
}, },
restore() { restore() {
if (confirm('Are you sure you want to restore this organization?')) { if (confirm('Are you sure you want to restore this organization?')) {
Inertia.put(this.route('organizations.restore', this.organization.id).url()) Inertia.put(this.route('organizations.restore', this.organization.id))
} }
}, },
}, },
......
...@@ -86,7 +86,7 @@ export default { ...@@ -86,7 +86,7 @@ export default {
form: { form: {
handler: _.throttle(function() { handler: _.throttle(function() {
let query = _.pickBy(this.form) let query = _.pickBy(this.form)
Inertia.replace(this.route('organizations', Object.keys(query).length ? query : { remember: 'forget' }).url()) Inertia.replace(this.route('organizations', Object.keys(query).length ? query : { remember: 'forget' }))
}, 150), }, 150),
deep: true, deep: true,
}, },
......
...@@ -57,7 +57,7 @@ export default { ...@@ -57,7 +57,7 @@ export default {
methods: { methods: {
submit() { submit() {
this.form.post({ this.form.post({
url: this.route('users.store').url(), url: this.route('users.store'),
then: data => Inertia.visit(this.route('users.edit', data.id)), then: data => Inertia.visit(this.route('users.edit', data.id)),
}) })
}, },
......
...@@ -65,23 +65,23 @@ export default { ...@@ -65,23 +65,23 @@ export default {
methods: { methods: {
submit() { submit() {
this.form.put({ this.form.put({
url: this.route('users.update', this.user.id).url(), url: this.route('users.update', this.user.id),
then: () => Inertia.visit(this.route('users')), then: () => Inertia.visit(this.route('users')),
}) })
}, },
destroy() { destroy() {
if (confirm('Are you sure you want to delete this user?')) { if (confirm('Are you sure you want to delete this user?')) {
this.form.delete({ this.form.delete({
url: this.route('users.destroy', this.user.id).url(), url: this.route('users.destroy', this.user.id),
then: () => Inertia.replace(this.route('users.edit', this.user.id).url()), then: () => Inertia.replace(this.route('users.edit', this.user.id)),
}) })
} }
}, },
restore() { restore() {
if (confirm('Are you sure you want to restore this user?')) { if (confirm('Are you sure you want to restore this user?')) {
this.form.put({ this.form.put({
url: this.route('users.restore', this.user.id).url(), url: this.route('users.restore', this.user.id),
then: () => Inertia.replace(this.route('users.edit', this.user.id).url()), then: () => Inertia.replace(this.route('users.edit', this.user.id)),
}) })
} }
}, },
......
...@@ -90,7 +90,7 @@ export default { ...@@ -90,7 +90,7 @@ export default {
form: { form: {
handler: _.throttle(function() { handler: _.throttle(function() {
let query = _.pickBy(this.form) let query = _.pickBy(this.form)
Inertia.replace(this.route('users', Object.keys(query).length ? query : { remember: 'forget' }).url()) Inertia.replace(this.route('users', Object.keys(query).length ? query : { remember: 'forget' }))
}, 150), }, 150),
deep: true, deep: true,
}, },
......
...@@ -3,7 +3,7 @@ import PortalVue from 'portal-vue' ...@@ -3,7 +3,7 @@ import PortalVue from 'portal-vue'
import Vue from 'vue' import Vue from 'vue'
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.mixin({ methods: { route: window.route } }) Vue.mixin({ methods: { route: (...args) => window.route(...args).url() } })
Vue.use(PortalVue) Vue.use(PortalVue)
let app = document.getElementById('app') let app = document.getElementById('app')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!