Implement new "Inertia remember" functionality

This commit is contained in:
Jonathan Reinink 2019-04-22 11:07:35 -04:00
parent 0b6114dd88
commit ae568c2b47
8 changed files with 82 additions and 104 deletions

38
composer.lock generated
View File

@ -427,12 +427,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/inertiajs/inertia-laravel.git", "url": "https://github.com/inertiajs/inertia-laravel.git",
"reference": "307747e352eefb48a84e7e17b63ea7738606f2a1" "reference": "d22b42840936f377ba77cef563332f7e544b91ef"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/inertiajs/inertia-laravel/zipball/307747e352eefb48a84e7e17b63ea7738606f2a1", "url": "https://api.github.com/repos/inertiajs/inertia-laravel/zipball/d22b42840936f377ba77cef563332f7e544b91ef",
"reference": "307747e352eefb48a84e7e17b63ea7738606f2a1", "reference": "d22b42840936f377ba77cef563332f7e544b91ef",
"shasum": "" "shasum": ""
}, },
"require-dev": { "require-dev": {
@ -467,7 +467,7 @@
"inertia", "inertia",
"laravel" "laravel"
], ],
"time": "2019-04-17T18:00:32+00:00" "time": "2019-04-22T14:39:16+00:00"
}, },
{ {
"name": "jakub-onderka/php-console-color", "name": "jakub-onderka/php-console-color",
@ -559,16 +559,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v5.8.12", "version": "v5.8.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "6dd75b67811a265c57144ab15f25a8061ed4721f" "reference": "837e3823e2274d22b8e281d093391b5d9c23029a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/6dd75b67811a265c57144ab15f25a8061ed4721f", "url": "https://api.github.com/repos/laravel/framework/zipball/837e3823e2274d22b8e281d093391b5d9c23029a",
"reference": "6dd75b67811a265c57144ab15f25a8061ed4721f", "reference": "837e3823e2274d22b8e281d093391b5d9c23029a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -702,7 +702,7 @@
"framework", "framework",
"laravel" "laravel"
], ],
"time": "2019-04-16T13:47:32+00:00" "time": "2019-04-18T15:28:45+00:00"
}, },
{ {
"name": "laravel/tinker", "name": "laravel/tinker",
@ -1580,16 +1580,16 @@
}, },
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v6.2.0", "version": "v6.2.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/swiftmailer/swiftmailer.git", "url": "https://github.com/swiftmailer/swiftmailer.git",
"reference": "6fa3232ff9d3f8237c0fae4b7ff05e1baa4cd707" "reference": "5397cd05b0a0f7937c47b0adcb4c60e5ab936b6a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/6fa3232ff9d3f8237c0fae4b7ff05e1baa4cd707", "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/5397cd05b0a0f7937c47b0adcb4c60e5ab936b6a",
"reference": "6fa3232ff9d3f8237c0fae4b7ff05e1baa4cd707", "reference": "5397cd05b0a0f7937c47b0adcb4c60e5ab936b6a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1638,7 +1638,7 @@
"mail", "mail",
"mailer" "mailer"
], ],
"time": "2019-03-10T07:52:41+00:00" "time": "2019-04-21T09:21:45+00:00"
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
@ -4102,16 +4102,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "7.5.8", "version": "7.5.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "c29c0525cf4572c11efe1db49a8b8aee9dfac58a" "reference": "134669cf0eeac3f79bc7f0c793efbc158bffc160"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c29c0525cf4572c11efe1db49a8b8aee9dfac58a", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/134669cf0eeac3f79bc7f0c793efbc158bffc160",
"reference": "c29c0525cf4572c11efe1db49a8b8aee9dfac58a", "reference": "134669cf0eeac3f79bc7f0c793efbc158bffc160",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4182,7 +4182,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2019-03-26T13:23:54+00:00" "time": "2019-04-19T15:50:46+00:00"
}, },
{ {
"name": "sebastian/code-unit-reverse-lookup", "name": "sebastian/code-unit-reverse-lookup",

68
package-lock.json generated
View File

@ -1971,9 +1971,9 @@
} }
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30000960", "version": "1.0.30000962",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000960.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000962.tgz",
"integrity": "sha512-7nK5qs17icQaX6V3/RYrJkOsZyRNnroA4+ZwxaKJzIKy+crIy0Mz5CBlLySd2SNV+4nbUZeqeNfiaEieUBu3aA==", "integrity": "sha512-WXYsW38HK+6eaj5IZR16Rn91TGhU3OhbwjKZvJ4HN/XBIABLKfbij9Mnd3pM0VEwZSlltWjoWg3I8FQ0DGgNOA==",
"dev": true "dev": true
}, },
"chalk": { "chalk": {
@ -3097,9 +3097,9 @@
"dev": true "dev": true
}, },
"electron-to-chromium": { "electron-to-chromium": {
"version": "1.3.124", "version": "1.3.125",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.124.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.125.tgz",
"integrity": "sha512-glecGr/kFdfeXUHOHAWvGcXrxNU+1wSO/t5B23tT1dtlvYB26GY8aHzZSWD7HqhqC800Lr+w/hQul6C5AF542w==", "integrity": "sha512-XxowpqQxJ4nDwUXHtVtmEhRqBpm2OnjBomZmZtHD0d2Eo0244+Ojezhk3sD/MBSSe2nxCdGQFRXHIsf/LUTL9A==",
"dev": true "dev": true
}, },
"elliptic": { "elliptic": {
@ -5123,20 +5123,22 @@
"dev": true "dev": true
}, },
"inertia": { "inertia": {
"version": "github:inertiajs/inertia#ad5585bb4c983499b9d5c6d389395aa72617bf52", "version": "github:inertiajs/inertia#280a85a07dcb7ac02fb236fdbb68810a4be1e128",
"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#3652c3eed8a236f730ab170dc7fbb408342812f1", "version": "github:inertiajs/inertia-vue#7e6cff62e2ebdc0f432ec146a293cfd1fc88f329",
"from": "github:inertiajs/inertia-vue", "from": "github:inertiajs/inertia-vue",
"dev": true, "dev": true,
"requires": { "requires": {
"inertia": "github:inertiajs/inertia#ad5585bb4c983499b9d5c6d389395aa72617bf52" "inertia": "github:inertiajs/inertia#280a85a07dcb7ac02fb236fdbb68810a4be1e128"
} }
}, },
"inflight": { "inflight": {
@ -5423,27 +5425,27 @@
"dev": true "dev": true
}, },
"is-path-cwd": { "is-path-cwd": {
"version": "2.0.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.0.0.tgz", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.1.0.tgz",
"integrity": "sha512-m5dHHzpOXEiv18JEORttBO64UgTEypx99vCxQLjbBvGhOJxnTNglYoFXxwo6AbsQb79sqqycQEHv2hWkHZAijA==", "integrity": "sha512-Sc5j3/YnM8tDeyCsVeKlm/0p95075DyLmDEIkSgQ7mXkrOX+uTCtmQFm0CYzVyJwcCCmO3k8qfJt17SxQwB5Zw==",
"dev": true "dev": true
}, },
"is-path-in-cwd": { "is-path-in-cwd": {
"version": "2.0.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-2.0.0.tgz", "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-2.1.0.tgz",
"integrity": "sha512-6Vz5Gc9s/sDA3JBVu0FzWufm8xaBsqy1zn8Q6gmvGP6nSDMw78aS4poBNeatWjaRpTpxxLn1WOndAiOlk+qY8A==", "integrity": "sha512-rNocXHgipO+rvnP6dk3zI20RpOtrAM/kzbB258Uw5BWr3TpXi861yzjo16Dn4hUox07iw5AyeMLHWsujkjzvRQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"is-path-inside": "^1.0.0" "is-path-inside": "^2.1.0"
} }
}, },
"is-path-inside": { "is-path-inside": {
"version": "1.0.1", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-2.1.0.tgz",
"integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "integrity": "sha512-wiyhTzfDWsvwAW53OBWF5zuvaOGlZ6PwYxAbPVDhpm+gM09xKQGjBq/8uYN12aDvMxnAnq3dxTyoSoRNmg5YFg==",
"dev": true, "dev": true,
"requires": { "requires": {
"path-is-inside": "^1.0.1" "path-is-inside": "^1.0.2"
} }
}, },
"is-plain-object": { "is-plain-object": {
@ -5957,6 +5959,12 @@
"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",
@ -6059,18 +6067,18 @@
"dev": true "dev": true
}, },
"mime-db": { "mime-db": {
"version": "1.39.0", "version": "1.40.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.39.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz",
"integrity": "sha512-DTsrw/iWVvwHH+9Otxccdyy0Tgiil6TWK/xhfARJZF/QFhwOgZgOIvA2/VIGpM8U7Q8z5nDmdDWC6tuVMJNibw==", "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==",
"dev": true "dev": true
}, },
"mime-types": { "mime-types": {
"version": "2.1.23", "version": "2.1.24",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.23.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz",
"integrity": "sha512-ROk/m+gMVSrRxTkMlaQOvFmFmYDc7sZgrjjM76abqmd2Cc5fCV7jAMA5XUccEtJ3cYiYdgixUVI+fApc2LkXlw==", "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"mime-db": "~1.39.0" "mime-db": "1.40.0"
} }
}, },
"mimic-fn": { "mimic-fn": {
@ -9774,9 +9782,9 @@
} }
}, },
"webpack-cli": { "webpack-cli": {
"version": "3.3.0", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.0.tgz", "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.1.tgz",
"integrity": "sha512-t1M7G4z5FhHKJ92WRKwZ1rtvi7rHc0NZoZRbSkol0YKl4HvcC8+DsmGDmK7MmZxHSAetHagiOsjOB6MmzC2TUw==", "integrity": "sha512-c2inFU7SM0IttEgF7fK6AaUsbBnORRzminvbyRKS+NlbQHVZdCtzKBlavRL5359bFsywXGRAItA5di/IruC8mg==",
"dev": true, "dev": true,
"requires": { "requires": {
"chalk": "^2.4.1", "chalk": "^2.4.1",

View File

@ -49,10 +49,6 @@ export default {
TextInput, TextInput,
}, },
props: { props: {
contact: {
type: Object,
default: () => ({}),
},
organizations: Array, organizations: Array,
errors: { errors: {
type: Object, type: Object,
@ -62,7 +58,7 @@ export default {
data() { data() {
return { return {
sending: false, sending: false,
form: { form: Inertia.remember({
first_name: null, first_name: null,
last_name: null, last_name: null,
organization_id: null, organization_id: null,
@ -73,15 +69,9 @@ export default {
region: null, region: null,
country: null, country: null,
postal_code: null, postal_code: null,
}, }),
} }
}, },
watch: {
form: {
handler: form => Inertia.cache('contact', form),
deep: true,
},
},
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true

View File

@ -66,7 +66,7 @@ export default {
data() { data() {
return { return {
sending: false, sending: false,
form: { form: Inertia.remember({
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,7 +77,7 @@ 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: {

View File

@ -44,10 +44,6 @@ export default {
TextInput, TextInput,
}, },
props: { props: {
organization: {
type: Object,
default: () => ({}),
},
errors: { errors: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
@ -56,24 +52,18 @@ export default {
data() { data() {
return { return {
sending: false, sending: false,
form: { form: Inertia.remember({
name: this.organization.name, name: null,
email: this.organization.email, email: null,
phone: this.organization.phone, phone: null,
address: this.organization.address, address: null,
city: this.organization.city, city: null,
region: this.organization.region, region: null,
country: this.organization.country, country: null,
postal_code: this.organization.postal_code, postal_code: null,
}, }),
} }
}, },
watch: {
form: {
handler: form => Inertia.cache('organization', form),
deep: true,
},
},
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true

View File

@ -98,7 +98,7 @@ export default {
data() { data() {
return { return {
sending: false, sending: false,
form: { form: Inertia.remember({
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,7 +107,7 @@ 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: {

View File

@ -40,10 +40,6 @@ export default {
TextInput, TextInput,
}, },
props: { props: {
user: {
type: Object,
default: () => ({ owner: false }),
},
errors: { errors: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
@ -52,21 +48,15 @@ export default {
data() { data() {
return { return {
sending: false, sending: false,
form: { form: Inertia.remember({
first_name: this.user.first_name, first_name: null,
last_name: this.user.last_name, last_name: null,
email: this.user.email, email: null,
password: this.user.password, password: null,
owner: this.user.owner, owner: false,
}, }),
} }
}, },
watch: {
form: {
handler: form => Inertia.cache('user', form),
deep: true,
},
},
methods: { methods: {
submit() { submit() {
this.sending = true this.sending = true

View File

@ -56,13 +56,13 @@ export default {
data() { data() {
return { return {
sending: false, sending: false,
form: { form: Inertia.remember({
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: {