Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

online house #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions client/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": [
["latest", {
"es2015": { "modules": false }
}]
],
"plugins": ["transform-object-rest-spread"]
}
5 changes: 5 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
node_modules/
dist/
npm-debug.log
yarn-error.log
18 changes: 18 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# client

> A Vue.js project

## Build Setup

``` bash
# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build
```

For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader).
11 changes: 11 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>client</title>
</head>
<body>
<div id="app"></div>
<script src="/dist/build.js"></script>
</body>
</html>
30 changes: 30 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "client",
"description": "A Vue.js project",
"version": "1.0.0",
"author": "zidane9 <[email protected]>",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"axios": "^0.16.1",
"vue": "^2.2.1",
"vue-router": "^2.4.0",
"vuex": "^2.3.1"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-latest": "^6.0.0",
"cross-env": "^3.0.0",
"css-loader": "^0.25.0",
"file-loader": "^0.9.0",
"vue-loader": "^11.1.4",
"vue-template-compiler": "^2.2.1",
"webpack": "^2.2.0",
"webpack-dev-server": "^2.2.0"
}
}
49 changes: 49 additions & 0 deletions client/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<template>
<div id="app">
<div class="layout-logo">Finding you the right home</div>
<div >
<img src="http://daftarperumahanmurah.com/assets/9aae334/Rumah-Dijual.jpg" >

</div>

<div>
<button>
<router-link to="/houses/new">Add House for Sell</router-link>
</button>

<button @click="initHouses">
<router-link to="/houses">List House for Sell</router-link>
</button>
</div>

<router-view></router-view>

<!-- <div class="">
{{$store.state}}
</div> -->
</div>
</template>

<script>
import { mapActions } from 'vuex'
import ListHouse from './components/ListHouse.vue'

export default{
name: 'app',
data(){
return {
// types: ['general', 'knock-knock', 'programming'],
// checkedTypes: ['general', 'knock-knock', 'programming']
}
},
methods: mapActions([
'initHouses'
]),
components:{
ListHouse
}
// created() {
// this.$store.dispatch('initHouses')
// }
}
</script>
Binary file added client/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions client/src/components/AddHouse.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<template lang="html">
<div class="">
<div >
<h5>Add House For Sell</h5>
<form>
<table>
<tr>
<td>Title</td>
<td><input type="text" name="title" v-model="newHouse.title" ></td>
</tr>
<tr>
<td>Description</td>
<td><input type="text" name="description" v-model="newHouse.description" ></td>
</tr>
<tr>
<td>Price</td>
<td><input type="text" name="price" v-model="newHouse.price" ></td>
</tr>
<tr>
<td>Image</td>
<td><input type="text" name="image" v-model="newHouse.image" ></td>
</tr>
<tr>
<td>Owner</td>
<td><input type="text" name="owner" v-model="newHouse.owner" ></td>
</tr>
<tr>
<td>Phone</td>
<td><input type="text" name="phone" v-model="newHouse.phone" ></td>
</tr>
<tr>
<td>Address</td>
<td><input type="text" name="address" v-model="newHouse.address" ></td>
</tr>
</table>
</form>
<button @click="addHouse(newHouse)" >Submit</button>

</div>

</div>
</template>

<script>
import { mapActions } from 'vuex'

export default {
data(){
return {
newHouse: {
title: '',
description: '',
price: '',
image: '',
owner: '',
phone: '',
address: ''
}
}
},
methods: mapActions ([
'addHouse'
])
// getHouse(e) {
// this.$store.dispatch('getHouse', e.target.value)
// },
// addHouse(){
// this.$store.dispatch('addHouse')
// this.$store.dispatch('clearHouse')
// }

}
</script>

<style lang="css">

</style>
79 changes: 79 additions & 0 deletions client/src/components/DetailHouse.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<template lang="html">
<div class="">
<div >
<h5>Detail</h5>
<form>

<table>
<tr>
<td>Title</td>
<td><input type="text" name="title" v-model="house.title" ></td>
</tr>
<tr>
<td>Description</td>
<td><input type="text" name="description" v-model="house.description" ></td>
</tr>
<tr>
<td>Price</td>
<td><input type="text" name="price" v-model="house.price" ></td>
</tr>
<tr>
<td>Image</td>
<td><input type="text" name="image" v-model="house.image" ></td>
</tr>
<tr>
<td>Owner</td>
<td><input type="text" name="owner" v-model="house.owner" ></td>
</tr>
<tr>
<td>Phone</td>
<td><input type="text" name="phone" v-model="house.phone" ></td>
</tr>
<tr>
<td>Address</td>
<td><input type="text" name="address" v-model="house.address" ></td>
</tr>
</table>
</form>
<button @click="updateHouse(house)" >Update</button>

</div>

</div>
</template>

<script>
import { mapActions } from 'vuex'

export default {
props:['house'],
// data(){
// return {
// house: {
// title: '',
// description: '',
// price: '',
// image: '',
// owner: '',
// phone: '',
// address: ''
// }
// }
// },
methods: mapActions ([
'updateHouse'
])
// getHouse(e) {
// this.$store.dispatch('getHouse', e.target.value)
// },
// addHouse(){
// this.$store.dispatch('addHouse')
// this.$store.dispatch('clearHouse')
// }

}
</script>

<style lang="css">

</style>
55 changes: 55 additions & 0 deletions client/src/components/House.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template lang="html">
<div class="">
<div style="border:1px solid black" >
<table>
<tr>
<td><img width="200px" height="150px" :src="house.image"></td>
<td>{{house.title}}</td>
<tr>
<td><button @click="show">show</button></td>
<td><button @click="removeHouse(house._id)" >remove</button></td>
</tr>

</table>
<detail-house v-if="isShow" :house="house"></detail-house>

</div>

</div>
</template>

<script>
import { mapActions } from 'vuex'
import DetailHouse from './DetailHouse.vue'

export default {
props: ['house'],
data(){
return {
isShow: false
// newHouse: {
// title: '',
// description: '',
// price: '',
// image: '',
// owner: '',
// phone: '',
// address: ''
// }
}
},
methods: {
...mapActions ([
'removeHouse'
]),
show(){
if(this.isShow) this.isShow=false;
else this.isShow=true;
}
},
components:{
DetailHouse
}

}
</script>
24 changes: 24 additions & 0 deletions client/src/components/ListHouse.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template lang="html">
<div class="">
<h5 v-if="$store.state.houses.length > 0">List House for Sell</h5>
<House v-for="(house, index) in $store.state.houses" :house="house" key="index"></House>
</div>
</template>

<script>
// import { mapActions } from 'vuex'
import House from './House.vue'

export default {

data(){
return {

}
},
components:{
House
}

}
</script>
3 changes: 3 additions & 0 deletions client/src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const serverUrl = 'http://localhost:3000';

module.exports = serverUrl
Loading