Skip to content
Permalink
Browse files

Working API and Vue.js front

  • Loading branch information...
Depado committed Jan 14, 2016
1 parent c065ce8 commit 75ff64dc34c62c0300557a61770ff7ba909c6d3a
Showing with 210 additions and 9,522 deletions.
  1. +1 −1 .gitattributes
  2. +1 −0 .gitignore
  3. +51 −0 assets/app.js
  4. +0 −9,517 assets/js/vue.js
  5. +10 −3 main.go
  6. +29 −0 models/entry/database.go
  7. +25 −1 models/entry/entry.go
  8. +28 −0 package.json
  9. +65 −0 templates/index.html
@@ -1 +1 @@
assets/* linguist-vendored
node_modules/* linguist-vendored
@@ -25,3 +25,4 @@ _testmain.go

govue
data.db
node_modules
@@ -0,0 +1,51 @@
new Vue({
el: '#entries',
data: {
entry: {
type: 'entry',
attributes: {
title: '',
markdown: '',
}
},
entries: [],
},
ready: function() {
this.entryEndpoint = this.$resource('api/v1/entry/{id}')
this.fetchEntries();
},
methods: {
// We dedicate a method to retrieving and setting some data
fetchEntries: function() {
this.entryEndpoint.get().then(function(response) {
this.$set('entries', response.data.data);
}, function(response) {
console.log(response);
});
},

// Adds an event to the existing events array
postEntry: function() {
var wrapper = {
data: this.entry
}
this.entryEndpoint.save(wrapper).then(function(response) {
this.entries.push(response.data.data);
}, function(response) {
console.log(response);
});
this.entry.type.attributes = {
title: '',
markdown: '',
};
},

deleteEntry: function(index) {
this.entryEndpoint.delete({id: this.entries[index].attributes.id}).then(function(response) {
this.entries.splice(index, 1);
}, function(response) {
console.log(response)
});
}
}
});

0 comments on commit 75ff64d

Please sign in to comment.
You can’t perform that action at this time.