Update to new Inertia plugin format

This commit is contained in:
Jonathan Reinink 2019-04-24 14:45:13 -04:00
parent b83fda83a5
commit 6e757083e3
16 changed files with 53 additions and 84 deletions

44
package-lock.json generated
View File

@ -1971,9 +1971,9 @@
} }
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30000962", "version": "1.0.30000963",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000962.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000963.tgz",
"integrity": "sha512-WXYsW38HK+6eaj5IZR16Rn91TGhU3OhbwjKZvJ4HN/XBIABLKfbij9Mnd3pM0VEwZSlltWjoWg3I8FQ0DGgNOA==", "integrity": "sha512-n4HUiullc7Lw0LyzpeLa2ffP8KxFBGdxqD/8G3bSL6oB758hZ2UE2CVK+tQN958tJIi0/tfpjAc67aAtoHgnrQ==",
"dev": true "dev": true
}, },
"chalk": { "chalk": {
@ -2138,9 +2138,9 @@
} }
}, },
"color": { "color": {
"version": "3.1.0", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/color/-/color-3.1.0.tgz", "resolved": "https://registry.npmjs.org/color/-/color-3.1.1.tgz",
"integrity": "sha512-CwyopLkuRYO5ei2EpzpIh6LqJMt6Mt+jZhO5VI5f/wJLZriXQE32/SSqzmrh+QB+AZT81Cj8yv+7zwToW8ahZg==", "integrity": "sha512-PvUltIXRjehRKPSy89VnDWFKY58xyhTLyxIg21vwQBI6qLwZNPmC8k3C1uytIgFKEpOIzN4y32iPm8231zFHIg==",
"dev": true, "dev": true,
"requires": { "requires": {
"color-convert": "^1.9.1", "color-convert": "^1.9.1",
@ -5123,22 +5123,20 @@
"dev": true "dev": true
}, },
"inertia": { "inertia": {
"version": "github:inertiajs/inertia#280a85a07dcb7ac02fb236fdbb68810a4be1e128", "version": "github:inertiajs/inertia#52829f02f5db25b033d3ea925cae4836cd11bfa6",
"from": "github:inertiajs/inertia", "from": "github:inertiajs/inertia",
"dev": true, "dev": true,
"requires": { "requires": {
"axios": "^0.18.0", "axios": "^0.18.0",
"lodash": "^4.17.5",
"melanke-watchjs": "^1.5.0",
"nprogress": "^0.2.0" "nprogress": "^0.2.0"
} }
}, },
"inertia-vue": { "inertia-vue": {
"version": "github:inertiajs/inertia-vue#7e6cff62e2ebdc0f432ec146a293cfd1fc88f329", "version": "github:inertiajs/inertia-vue#de7306319de89777c82d51c48d63df59453ee0c9",
"from": "github:inertiajs/inertia-vue", "from": "github:inertiajs/inertia-vue",
"dev": true, "dev": true,
"requires": { "requires": {
"inertia": "github:inertiajs/inertia#280a85a07dcb7ac02fb236fdbb68810a4be1e128" "inertia": "github:inertiajs/inertia#52829f02f5db25b033d3ea925cae4836cd11bfa6"
} }
}, },
"inflight": { "inflight": {
@ -5959,12 +5957,6 @@
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=",
"dev": true "dev": true
}, },
"melanke-watchjs": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/melanke-watchjs/-/melanke-watchjs-1.5.0.tgz",
"integrity": "sha512-YUQzBucdH5p3s/UPQ0fvYyzqRfyLKTS35Qj5iaVBQ6XYGvvpEX7afR1xi8uUGsTEfFNqDFRrADz9TkVu4/TeXQ==",
"dev": true
},
"mem": { "mem": {
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz",
@ -6320,9 +6312,9 @@
} }
}, },
"node-releases": { "node-releases": {
"version": "1.1.15", "version": "1.1.17",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.15.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.17.tgz",
"integrity": "sha512-cKV097BQaZr8LTSRUa2+oc/aX5L8UkZtPQrMSTgiJEeaW7ymTDCoRaGCoaTqk0lqnalcoSHu4wjSl0Cmj2+bMw==", "integrity": "sha512-/SCjetyta1m7YXLgtACZGDYJdCSIBAWorDWkGCGZlydP2Ll7J48l7j/JxNYZ+xsgSPbWfdulVS/aY+GdjUsQ7Q==",
"dev": true, "dev": true,
"requires": { "requires": {
"semver": "^5.3.0" "semver": "^5.3.0"
@ -8090,9 +8082,9 @@
"dev": true "dev": true
}, },
"resolve": { "resolve": {
"version": "1.10.0", "version": "1.10.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.1.tgz",
"integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", "integrity": "sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==",
"dev": true, "dev": true,
"requires": { "requires": {
"path-parse": "^1.0.6" "path-parse": "^1.0.6"
@ -8252,9 +8244,9 @@
} }
}, },
"rxjs": { "rxjs": {
"version": "6.4.0", "version": "6.5.1",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.1.tgz",
"integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==", "integrity": "sha512-y0j31WJc83wPu31vS1VlAFW5JGrnGC+j+TtGAa1fRQphy48+fDYiDmX8tjGloToEsMkxnouOg/1IzXGKkJnZMg==",
"dev": true, "dev": true,
"requires": { "requires": {
"tslib": "^1.9.0" "tslib": "^1.9.0"

View File

@ -23,7 +23,6 @@
</template> </template>
<script> <script>
import { Inertia } from 'inertia-vue'
import LoadingButton from '@/Shared/LoadingButton' import LoadingButton from '@/Shared/LoadingButton'
import Logo from '@/Shared/Logo' import Logo from '@/Shared/Logo'
import TextInput from '@/Shared/TextInput' import TextInput from '@/Shared/TextInput'
@ -54,7 +53,7 @@ export default {
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true
Inertia.post(this.route('login.attempt'), { this.$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,

View File

@ -34,7 +34,6 @@
</template> </template>
<script> <script>
import { Inertia, InertiaLink } from 'inertia-vue'
import Layout from '@/Shared/Layout' import Layout from '@/Shared/Layout'
import LoadingButton from '@/Shared/LoadingButton' import LoadingButton from '@/Shared/LoadingButton'
import SelectInput from '@/Shared/SelectInput' import SelectInput from '@/Shared/SelectInput'
@ -42,7 +41,6 @@ import TextInput from '@/Shared/TextInput'
export default { export default {
components: { components: {
InertiaLink,
Layout, Layout,
LoadingButton, LoadingButton,
SelectInput, SelectInput,
@ -55,10 +53,11 @@ export default {
default: () => ({}), default: () => ({}),
}, },
}, },
remember: 'form',
data() { data() {
return { return {
sending: false, sending: false,
form: Inertia.remember({ form: {
first_name: null, first_name: null,
last_name: null, last_name: null,
organization_id: null, organization_id: null,
@ -69,13 +68,13 @@ export default {
region: null, region: null,
country: null, country: null,
postal_code: null, postal_code: null,
}), },
} }
}, },
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true
Inertia.post(this.route('contacts.store'), this.form) this.$inertia.post(this.route('contacts.store'), this.form)
.then(() => this.sending = false) .then(() => this.sending = false)
}, },
}, },

View File

@ -39,7 +39,6 @@
</template> </template>
<script> <script>
import { Inertia, InertiaLink } from 'inertia-vue'
import Layout from '@/Shared/Layout' import Layout from '@/Shared/Layout'
import LoadingButton from '@/Shared/LoadingButton' import LoadingButton from '@/Shared/LoadingButton'
import SelectInput from '@/Shared/SelectInput' import SelectInput from '@/Shared/SelectInput'
@ -48,7 +47,6 @@ import TrashedMessage from '@/Shared/TrashedMessage'
export default { export default {
components: { components: {
InertiaLink,
Layout, Layout,
LoadingButton, LoadingButton,
SelectInput, SelectInput,
@ -63,10 +61,11 @@ export default {
default: () => ({}), default: () => ({}),
}, },
}, },
remember: 'form',
data() { data() {
return { return {
sending: false, sending: false,
form: Inertia.remember({ form: {
first_name: this.contact.first_name, first_name: this.contact.first_name,
last_name: this.contact.last_name, last_name: this.contact.last_name,
organization_id: this.contact.organization_id, organization_id: this.contact.organization_id,
@ -77,23 +76,23 @@ export default {
region: this.contact.region, region: this.contact.region,
country: this.contact.country, country: this.contact.country,
postal_code: this.contact.postal_code, postal_code: this.contact.postal_code,
}), },
} }
}, },
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true
Inertia.put(this.route('contacts.update', this.contact.id), this.form) this.$inertia.put(this.route('contacts.update', this.contact.id), this.form)
.then(() => this.sending = false) .then(() => this.sending = false)
}, },
destroy() { destroy() {
if (confirm('Are you sure you want to delete this contact?')) { if (confirm('Are you sure you want to delete this contact?')) {
Inertia.delete(this.route('contacts.destroy', this.contact.id)) this.$inertia.delete(this.route('contacts.destroy', 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?')) {
Inertia.put(this.route('contacts.restore', this.contact.id)) this.$inertia.put(this.route('contacts.restore', this.contact.id))
} }
}, },
}, },

View File

@ -64,7 +64,6 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { Inertia, InertiaLink } from 'inertia-vue'
import Icon from '@/Shared/Icon' import Icon from '@/Shared/Icon'
import Layout from '@/Shared/Layout' import Layout from '@/Shared/Layout'
import Pagination from '@/Shared/Pagination' import Pagination from '@/Shared/Pagination'
@ -72,7 +71,6 @@ import SearchFilter from '@/Shared/SearchFilter'
export default { export default {
components: { components: {
InertiaLink,
Icon, Icon,
Layout, Layout,
Pagination, Pagination,
@ -94,7 +92,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' })) this.$inertia.replace(this.route('contacts', Object.keys(query).length ? query : { remember: 'forget' }))
}, 150), }, 150),
deep: true, deep: true,
}, },

View File

@ -10,13 +10,11 @@
</template> </template>
<script> <script>
import { InertiaLink } from 'inertia-vue'
import Layout from '@/Shared/Layout' import Layout from '@/Shared/Layout'
export default { export default {
components: { components: {
Layout, Layout,
InertiaLink,
}, },
} }
</script> </script>

View File

@ -29,7 +29,6 @@
</template> </template>
<script> <script>
import { Inertia, InertiaLink } from 'inertia-vue'
import Layout from '@/Shared/Layout' import Layout from '@/Shared/Layout'
import LoadingButton from '@/Shared/LoadingButton' import LoadingButton from '@/Shared/LoadingButton'
import SelectInput from '@/Shared/SelectInput' import SelectInput from '@/Shared/SelectInput'
@ -37,7 +36,6 @@ import TextInput from '@/Shared/TextInput'
export default { export default {
components: { components: {
InertiaLink,
Layout, Layout,
LoadingButton, LoadingButton,
SelectInput, SelectInput,
@ -49,10 +47,11 @@ export default {
default: () => ({}), default: () => ({}),
}, },
}, },
remember: ['form'],
data() { data() {
return { return {
sending: false, sending: false,
form: Inertia.remember({ form: {
name: null, name: null,
email: null, email: null,
phone: null, phone: null,
@ -61,13 +60,13 @@ export default {
region: null, region: null,
country: null, country: null,
postal_code: null, postal_code: null,
}), },
} }
}, },
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true
Inertia.post(this.route('organizations.store'), this.form) this.$inertia.post(this.route('organizations.store'), this.form)
.then(() => this.sending = false) .then(() => this.sending = false)
}, },
}, },

View File

@ -70,7 +70,6 @@
</template> </template>
<script> <script>
import { Inertia, InertiaLink } from 'inertia-vue'
import Icon from '@/Shared/Icon' import Icon from '@/Shared/Icon'
import Layout from '@/Shared/Layout' import Layout from '@/Shared/Layout'
import LoadingButton from '@/Shared/LoadingButton' import LoadingButton from '@/Shared/LoadingButton'
@ -80,7 +79,6 @@ import TrashedMessage from '@/Shared/TrashedMessage'
export default { export default {
components: { components: {
InertiaLink,
Icon, Icon,
Layout, Layout,
LoadingButton, LoadingButton,
@ -95,10 +93,11 @@ export default {
default: () => ({}), default: () => ({}),
}, },
}, },
remember: ['form'],
data() { data() {
return { return {
sending: false, sending: false,
form: Inertia.remember({ form: {
name: this.organization.name, name: this.organization.name,
email: this.organization.email, email: this.organization.email,
phone: this.organization.phone, phone: this.organization.phone,
@ -107,23 +106,23 @@ export default {
region: this.organization.region, region: this.organization.region,
country: this.organization.country, country: this.organization.country,
postal_code: this.organization.postal_code, postal_code: this.organization.postal_code,
}), },
} }
}, },
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true
Inertia.put(this.route('organizations.update', this.organization.id), this.form) this.$inertia.put(this.route('organizations.update', this.organization.id), this.form)
.then(() => this.sending = false) .then(() => this.sending = false)
}, },
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)) this.$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)) this.$inertia.put(this.route('organizations.restore', this.organization.id))
} }
}, },
}, },

View File

@ -56,7 +56,6 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { Inertia, InertiaLink } from 'inertia-vue'
import Icon from '@/Shared/Icon' import Icon from '@/Shared/Icon'
import Layout from '@/Shared/Layout' import Layout from '@/Shared/Layout'
import Pagination from '@/Shared/Pagination' import Pagination from '@/Shared/Pagination'
@ -64,7 +63,6 @@ import SearchFilter from '@/Shared/SearchFilter'
export default { export default {
components: { components: {
InertiaLink,
Icon, Icon,
Layout, Layout,
Pagination, Pagination,
@ -86,7 +84,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' })) this.$inertia.replace(this.route('organizations', Object.keys(query).length ? query : { remember: 'forget' }))
}, 150), }, 150),
deep: true, deep: true,
}, },

View File

@ -25,7 +25,6 @@
</template> </template>
<script> <script>
import { Inertia, InertiaLink } from 'inertia-vue'
import Layout from '@/Shared/Layout' import Layout from '@/Shared/Layout'
import LoadingButton from '@/Shared/LoadingButton' import LoadingButton from '@/Shared/LoadingButton'
import SelectInput from '@/Shared/SelectInput' import SelectInput from '@/Shared/SelectInput'
@ -33,7 +32,6 @@ import TextInput from '@/Shared/TextInput'
export default { export default {
components: { components: {
InertiaLink,
Layout, Layout,
LoadingButton, LoadingButton,
SelectInput, SelectInput,
@ -45,22 +43,23 @@ export default {
default: () => ({}), default: () => ({}),
}, },
}, },
remember: 'form',
data() { data() {
return { return {
sending: false, sending: false,
form: Inertia.remember({ form: {
first_name: null, first_name: null,
last_name: null, last_name: null,
email: null, email: null,
password: null, password: null,
owner: false, owner: false,
}), },
} }
}, },
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true
Inertia.post(this.route('users.store'), this.form) this.$inertia.post(this.route('users.store'), this.form)
.then(() => this.sending = false) .then(() => this.sending = false)
}, },
}, },

View File

@ -30,7 +30,6 @@
</template> </template>
<script> <script>
import { Inertia, InertiaLink } from 'inertia-vue'
import Layout from '@/Shared/Layout' import Layout from '@/Shared/Layout'
import LoadingButton from '@/Shared/LoadingButton' import LoadingButton from '@/Shared/LoadingButton'
import SelectInput from '@/Shared/SelectInput' import SelectInput from '@/Shared/SelectInput'
@ -39,7 +38,6 @@ import TrashedMessage from '@/Shared/TrashedMessage'
export default { export default {
components: { components: {
InertiaLink,
Layout, Layout,
LoadingButton, LoadingButton,
SelectInput, SelectInput,
@ -53,32 +51,33 @@ export default {
default: () => ({}), default: () => ({}),
}, },
}, },
remember: 'form',
data() { data() {
return { return {
sending: false, sending: false,
form: Inertia.remember({ form: {
first_name: this.user.first_name, first_name: this.user.first_name,
last_name: this.user.last_name, last_name: this.user.last_name,
email: this.user.email, email: this.user.email,
password: this.user.password, password: this.user.password,
owner: this.user.owner, owner: this.user.owner,
}), },
} }
}, },
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true
Inertia.put(this.route('users.update', this.user.id), this.form) this.$inertia.put(this.route('users.update', this.user.id), this.form)
.then(() => this.sending = false) .then(() => this.sending = false)
}, },
destroy() { destroy() {
if (confirm('Are you sure you want to delete this user?')) { if (confirm('Are you sure you want to delete this user?')) {
Inertia.delete(this.route('users.destroy', this.user.id)) this.$inertia.delete(this.route('users.destroy', 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?')) {
Inertia.put(this.route('users.restore', this.user.id)) this.$inertia.put(this.route('users.restore', this.user.id))
} }
}, },
}, },

View File

@ -61,14 +61,12 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { Inertia, InertiaLink } from 'inertia-vue'
import Icon from '@/Shared/Icon' import Icon from '@/Shared/Icon'
import Layout from '@/Shared/Layout' import Layout from '@/Shared/Layout'
import SearchFilter from '@/Shared/SearchFilter' import SearchFilter from '@/Shared/SearchFilter'
export default { export default {
components: { components: {
InertiaLink,
Icon, Icon,
Layout, Layout,
SearchFilter, SearchFilter,
@ -90,7 +88,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' })) this.$inertia.replace(this.route('users', Object.keys(query).length ? query : { remember: 'forget' }))
}, 150), }, 150),
deep: true, deep: true,
}, },

View File

@ -47,7 +47,6 @@
</template> </template>
<script> <script>
import { InertiaLink } from 'inertia-vue'
import Dropdown from '@/Shared/Dropdown' import Dropdown from '@/Shared/Dropdown'
import Icon from '@/Shared/Icon' import Icon from '@/Shared/Icon'
import Logo from '@/Shared/Logo' import Logo from '@/Shared/Logo'
@ -55,7 +54,6 @@ import MainMenu from '@/Shared/MainMenu'
export default { export default {
components: { components: {
InertiaLink,
Dropdown, Dropdown,
Icon, Icon,
Logo, Logo,

View File

@ -28,12 +28,10 @@
</template> </template>
<script> <script>
import { InertiaLink } from 'inertia-vue'
import Icon from '@/Shared/Icon' import Icon from '@/Shared/Icon'
export default { export default {
components: { components: {
InertiaLink,
Icon, Icon,
}, },
methods: { methods: {

View File

@ -8,12 +8,7 @@
</template> </template>
<script> <script>
import { InertiaLink } from 'inertia-vue'
export default { export default {
components: {
InertiaLink,
},
props: { props: {
links: Array, links: Array,
}, },

1
resources/js/app.js vendored
View File

@ -4,6 +4,7 @@ import Vue from 'vue'
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.mixin({ methods: { route: (...args) => window.route(...args).url() } }) Vue.mixin({ methods: { route: (...args) => window.route(...args).url() } })
Vue.use(Inertia)
Vue.use(PortalVue) Vue.use(PortalVue)
let app = document.getElementById('app') let app = document.getElementById('app')