Commit ec127d43 authored by Adam Procter's avatar Adam Procter 💩

saves from pouch to couch

save from pouch to couch via store (not sure store is storing state changes however)
parent 779843c5
Pipeline #204 failed with stages
in 1 minute and 24 seconds
This diff is collapsed.
<template>
<section class="register">
<h1>Register</h1>
<form @submit="registeraccount()">
<form @submit.prevent="registeraccount()">
<!-- <form @submit.prevent="registeraccount()"> -->
<input type="text" name="name" v-model="name" placeholder="Name" />
<input type="text" name="email" v-model="email" placeholder="Email" />
......@@ -21,13 +21,11 @@ export default {
name: 'register-account',
data() {
return {
input :{
name:'',
email:'',
domain:'',
permissions:1,
verified:false
}
}
},
mounted() {
......@@ -35,8 +33,9 @@ export default {
},
methods: {
registeraccount() {
//console.log(this.name)
this.$store.dispatch('registerAccount', this.input)
//console.log(this.input)
this.$store.dispatch('registerAccount', this)
}
}
// var uniqueid = Math.random().toString(36).substring(2, 15)
......
......@@ -25,7 +25,7 @@ export default new Vuex.Store({
mutations: {
DB_INIT(state, data) {
state.database = data.database;
state.database = data.database;
},
LOGIN (state) {
......@@ -43,7 +43,7 @@ export default new Vuex.Store({
var uniqueid = Math.random().toString(36).substring(2, 15)
+ Math.random().toString(36).substring(2, 15);
//console.log(payload)
// before : is the couch name to the right is data from component
accounts_db.put
({
......@@ -59,12 +59,28 @@ export default new Vuex.Store({
},
SHOW_KNOWLEDGE_OBJECTS (state, payload) {
SHOW_KNOWLEDGE_OBJECTS (data, payload) {
var ids = [];
state.allobjects.forEach(item => {ids.push(item.id)})
accounts_db.allDocs({
include_docs: true,
attachments: true
})
state.allobjects.forEach(item => {ids.push(item.id)})
if (!ids.includes(payload.id)){
state.allobjects.push(payload);
}
//accounts_db.allDocs({
// include_docs: true,
// attachments: true
// }).then(result => {
// Array.from(result.rows.values()).forEach((element) => {
// this.$store.dispatch('showKnowledgeObjects', element)
// })
},
ADD_KNOWLEDGE_OBJECT(data, payload){
......@@ -91,12 +107,12 @@ export default new Vuex.Store({
},
registerAccount({ commit }, payload) {
commit('REGISTER_ACCOUNT', payload)
//console.log(payload.name)
commit('REGISTER_ACCOUNT', payload)
},
showKnowledgeObjects({ commit }, payload) {
commit('SHOW_KNOWLEDGE_OBJECTS', payload)
showKnowledgeObjects({ commit }) {
commit('SHOW_KNOWLEDGE_OBJECTS')
},
addKnowledgeObject({ commit }, payload) {
......
<template>
<div class="markdown">
<logo></logo>
<form @submit="addKnowledgeObject()">
<form @submit.prevent="addKnowledgeObject()">
<label>Type: </label>
<select name="type" v-model="type" placeholder="choose">
......@@ -37,13 +37,11 @@ name: 'editor',
},
data() {
return {
// input :{
type:'',
author:'',
title:'',
connections:[],
metadata:{}
// }
}
},
......@@ -55,7 +53,7 @@ name: 'editor',
addKnowledgeObject() {
this.$store.dispatch('addKnowledgeObject', this.input)
this.$store.dispatch('addKnowledgeObject', this)
// var uniqueid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
......
......@@ -31,9 +31,10 @@ export default {
created() {
// what should the store do here
this.$store.subscribe('showKnowledgeObjects')
// this.$store.state.count
this.$store.dispatch('showKnowledgeObjects')
//return this.$store.getters.allObjects
// if (db){
// localdb.sync(db)
// }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment