-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82c7e68
commit 01bae0d
Showing
29 changed files
with
1,586 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ Style/Documentation: | |
Metrics/BlockLength: | ||
Exclude: | ||
- '**/*_spec.rb' | ||
|
||
Metrics/MethodLength: | ||
Max: 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
vite: bin/vite dev | ||
web: bin/rails s -p 3000 -b 0.0.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<template> | ||
<!-- <h1>Hello App!</h1> | ||
<p> | ||
<strong>Current route path:</strong> {{ $route.fullPath }} | ||
</p> | ||
<nav> | ||
<RouterLink to="/">Go to Home</RouterLink> | ||
<RouterLink to="/about">Go to About</RouterLink> | ||
</nav> --> | ||
<main> | ||
<RouterView /> | ||
</main> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<script setup> | ||
import router from '../entrypoints/router'; | ||
import ErrorMessage from './ErrorMessage.vue' | ||
defineProps({ | ||
id: String | ||
}) | ||
</script> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
app: { | ||
id: 0, | ||
name: '', | ||
description: '', | ||
}, | ||
error: {}, | ||
} | ||
}, | ||
created() { | ||
this.fetchApp() | ||
}, | ||
methods: { | ||
async fetchApp() { | ||
const response = await fetch(`/applications/${this.id}.json`) | ||
this.app = await response.json() | ||
}, | ||
async onSubmit() { | ||
this.error = {} | ||
const response = await fetch(`/applications/${this.id}.json`, { | ||
method: 'PATCH', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').getAttribute('content'), | ||
}, | ||
body: JSON.stringify(this.app), | ||
}) | ||
if (response.ok) { | ||
router.push({ name: 'Application', params: { id: this.id } }) | ||
return | ||
} | ||
this.error = await response.json() | ||
} | ||
}, | ||
} | ||
</script> | ||
|
||
<template> | ||
<form @submit.prevent="onSubmit"> | ||
<div> | ||
<label for="name">Name</label> | ||
<input type="text" id="name" v-model="app.name" /> | ||
</div> | ||
<div> | ||
<label for="description">Description</label> | ||
<textarea id="description" v-model="app.description"></textarea> | ||
</div> | ||
<button type="submit">Save</button> | ||
<p><router-link :to="{ name: 'Application', params: { id: app.id } }">Cancel</router-link></p> | ||
</form> | ||
<ErrorMessage :error="error"></ErrorMessage> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<script setup> | ||
defineProps({ | ||
id: String | ||
}) | ||
</script> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
app: { | ||
name: '', | ||
description: '', | ||
}, | ||
error: {}, | ||
} | ||
}, | ||
created() { | ||
this.fetchApp() | ||
}, | ||
methods: { | ||
async fetchApp() { | ||
const response = await fetch(`/applications/${this.id}.json`) | ||
this.app = await response.json() | ||
}, | ||
async onDestroy() { | ||
this.error = {} | ||
if (!confirm('Are you sure?')) { | ||
return | ||
} | ||
const response = await fetch(`/applications/${this.id}.json`, { | ||
method: 'DELETE', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').getAttribute('content'), | ||
}, | ||
}) | ||
if (response.ok) { | ||
this.$router.push('/') | ||
return | ||
} | ||
this.error = await response.json() | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<template> | ||
<h2>{{ app.name }}</h2> | ||
<p>{{ app.description }}</p> | ||
<p><router-link :to="{ name: 'ApplicationEdit', params: { id: app.id } }">Edit</router-link></p> | ||
<p><button @click="onDestroy">Destroy</button></p> | ||
<ErrorMessage :error="error"></ErrorMessage> | ||
<p><router-link to="/">back</router-link></p> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script setup> | ||
defineProps({ | ||
error: Object | ||
}) | ||
</script> | ||
|
||
<template> | ||
<ul v-if="error.errors"> | ||
<li v-for="(errors, attributeName) in error.errors"> | ||
{{ attributeName }}: {{ errors.join(",") }} | ||
</li> | ||
</ul> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<script setup> | ||
import ErrorMessage from './ErrorMessage.vue' | ||
</script> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
apps: [], | ||
newApp: { | ||
name: '', | ||
description: '', | ||
}, | ||
error: {}, | ||
} | ||
}, | ||
created() { | ||
this.fetchApps() | ||
}, | ||
methods: { | ||
async fetchApps() { | ||
const response = await fetch('/applications.json') | ||
this.apps = await response.json() | ||
}, | ||
async onSubmitNewApp() { | ||
this.error = {} | ||
const response = await fetch(`/applications.json`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').getAttribute('content'), | ||
}, | ||
body: JSON.stringify(this.newApp), | ||
}) | ||
if (response.ok) { | ||
this.apps.push(await response.json()) | ||
this.newApp = { name: '', description: '' } | ||
return | ||
} | ||
this.error = await response.json() | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<template> | ||
<h2>Applications</h2> | ||
<ul> | ||
<li v-for="app in apps" :key="app.id"> | ||
<router-link :to="{ name: 'Application', params: { id: app.id } }"> | ||
{{ app.name }} | ||
</router-link> | ||
</li> | ||
</ul> | ||
<h3>New application</h3> | ||
<form @submit.prevent="onSubmitNewApp"> | ||
<div> | ||
<label for="name">Name</label> | ||
<input type="text" id="name" v-model="newApp.name" /> | ||
</div> | ||
<div> | ||
<label for="description">Description</label> | ||
<textarea id="description" v-model="newApp.description"></textarea> | ||
</div> | ||
<button type="submit">Save</button> | ||
</form> | ||
<ErrorMessage :error="error"></ErrorMessage> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createApp } from 'vue/dist/vue.esm-bundler'; | ||
import router from './router' | ||
import App from '../components/App.vue'; | ||
|
||
const app = createApp(App) | ||
.use(router) | ||
.mount('#app'); | ||
|
||
console.log("app", app); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { createWebHistory, createRouter } from 'vue-router' | ||
|
||
import HomeView from '../components/HomeView.vue' | ||
import ApplicationView from '../components/ApplicationView.vue' | ||
import ApplicationEditView from '../components/ApplicationEditView.vue' | ||
|
||
const routes = [ | ||
{ path: '/', component: HomeView }, | ||
{ path: '/applications/:id', name: 'Application', component: ApplicationView, props: true }, | ||
{ path: '/applications/:id/edit', name: 'ApplicationEdit', component: ApplicationEditView, props: true }, | ||
] | ||
|
||
const router = createRouter({ | ||
history: createWebHistory(), | ||
routes, | ||
}) | ||
|
||
export default router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +0,0 @@ | ||
<%= form_with model: @application do |form| %> | ||
<div> | ||
<%= form.label :name %><br> | ||
<%= form.text_field :name %> | ||
<% @application.errors.full_messages_for(:name).each do |message| %> | ||
<div><%= message %></div> | ||
<% end %> | ||
</div> | ||
|
||
<div> | ||
<%= form.label :description %><br> | ||
<%= form.text_area :description %> | ||
<% @application.errors.full_messages_for(:description).each do |message| %> | ||
<div><%= message %></div> | ||
<% end %> | ||
</div> | ||
|
||
<div> | ||
<%= form.submit %> | ||
</div> | ||
<% end %> | ||
Oops, something went wrong.