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

68
package-lock.json generated
View File

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

View File

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

View File

@ -66,7 +66,7 @@ export default {
data() {
return {
sending: false,
form: {
form: Inertia.remember({
first_name: this.contact.first_name,
last_name: this.contact.last_name,
organization_id: this.contact.organization_id,
@ -77,7 +77,7 @@ export default {
region: this.contact.region,
country: this.contact.country,
postal_code: this.contact.postal_code,
},
}),
}
},
methods: {

View File

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

View File

@ -98,7 +98,7 @@ export default {
data() {
return {
sending: false,
form: {
form: Inertia.remember({
name: this.organization.name,
email: this.organization.email,
phone: this.organization.phone,
@ -107,7 +107,7 @@ export default {
region: this.organization.region,
country: this.organization.country,
postal_code: this.organization.postal_code,
},
}),
}
},
methods: {

View File

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

View File

@ -56,13 +56,13 @@ export default {
data() {
return {
sending: false,
form: {
form: Inertia.remember({
first_name: this.user.first_name,
last_name: this.user.last_name,
email: this.user.email,
password: this.user.password,
owner: this.user.owner,
},
}),
}
},
methods: {