Created
April 1, 2015 18:53
-
-
Save anonymous/5d1c788db2c4e780d880 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| onLoadData: function(){ | |
| this.errors = ""; | |
| SuperAgent | |
| .get("http://127.0.0.1:8000/buildings/") | |
| .set("Authorization", "") | |
| .set("Accept", "application/json") | |
| .end(function(err, res){ | |
| if(err) | |
| { | |
| this.errors = err; | |
| this.updateError(); | |
| } | |
| else | |
| { | |
| this.objects = res.body; | |
| this.updateObjects(); | |
| } | |
| }.bind(this)); | |
| }, | |
| onAddBuilding: function(item){ | |
| this.errors = ""; | |
| var updatedItem = -1; | |
| SuperAgent | |
| .post("http://127.0.0.1:8000/buildings/") | |
| .send(item) | |
| .set("Authorization", "") | |
| .set("Accept", "application/json") | |
| .end(function(err, res){ | |
| if (err) { | |
| this.errors = err; | |
| this.trigger(item); | |
| } | |
| else if(res.status !== 201) | |
| { | |
| this.errors = res.body; | |
| this.trigger(item); | |
| } | |
| else | |
| { | |
| updatedItem = res.body; | |
| if (!updatedItem.hasOwnProperty("id")) { | |
| this.errors = res.body; | |
| this.trigger(item); | |
| } | |
| this.objects.push(updatedItem); | |
| this.trigger(updatedItem); | |
| } | |
| }.bind(this)); | |
| }, |
This file contains hidden or 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
| 'use strict'; | |
| var Reflux = require('reflux'); | |
| var BuildingActions = Reflux.createActions([ | |
| "loadData", | |
| "addBuilding", | |
| "deleteBuilding", | |
| "patchBuilding", | |
| "addWatcher", | |
| "deleteWatcher" | |
| ]); | |
| module.exports = BuildingActions; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment