1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-15 18:56:22 +00:00

add planet create modal & switching func

This commit is contained in:
Rokt33r
2015-07-21 12:02:40 +09:00
parent 864001bdff
commit 72a08e8fec
9 changed files with 217 additions and 138 deletions

View File

@@ -8,6 +8,7 @@ var apiUrl = 'http://localhost:8000/'
var PlanetStore = Reflux.createStore({
init: function () {
this.listenTo(PlanetActions.createPlanet, this.createPlanet)
this.listenTo(PlanetActions.fetchPlanet, this.fetchPlanet)
this.listenTo(PlanetActions.createSnippet, this.createSnippet)
this.listenTo(PlanetActions.updateSnippet, this.updateSnippet)
@@ -16,6 +17,31 @@ var PlanetStore = Reflux.createStore({
this.listenTo(PlanetActions.updateBlueprint, this.updateBlueprint)
this.listenTo(PlanetActions.deleteBlueprint, this.deleteBlueprint)
},
createPlanet: function (input) {
request
.post(apiUrl + 'planets/create')
.set({
Authorization: 'Bearer ' + localStorage.getItem('token')
})
.send(input)
.end(function (err, res) {
if (err) {
console.error(err)
this.trigger(null)
return
}
var planet = res.body
planet.Snippets = []
planet.Blueprints = []
planet.Articles = []
this.trigger({
status: 'planetCreated',
data: planet
})
}.bind(this))
},
fetchPlanet: function (planetName) {
request
.get(apiUrl + planetName)