Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save markmansour-zz/150327 to your computer and use it in GitHub Desktop.
Save markmansour-zz/150327 to your computer and use it in GitHub Desktop.
YAHOO.AgileBench.StoryDataSource = function() {
this.todoDataSource = null;
this.inprogressDataSource = null;
this.completeDataSource = null;
this.incompleteDataSource = null;
this.dataSourceReady = new YAHOO.util.CustomEvent("dataSourceReady", this);
this.init = function() {
url = "http://server/stories.json"
var request = YAHOO.util.Connect.asyncRequest('GET', url, jsonRequestCallback);
};
// get the data from the server
var jsonRequestCallback =
{
success: function(o) {
json_response = YAHOO.lang.JSON.parse(o.responseText);
fields = ["position", "label", "title", "details", "assigned", "story_type", "workflow_state", "estimate", "url", "move_url", "destory_url", "next_events"];
todoDataSource = new YAHOO.util.LocalDataSource(json_response.todo);
todoDataSource.responseSchema = {
fields: fields
};
inprogressDataSource = new YAHOO.util.LocalDataSource(json_response.in_progress);
inprogressDataSource.responseSchema = {
fields: fields
};
completeDataSource = new YAHOO.util.LocalDataSource(json_response.complete);
completeDataSource.responseSchema = {
fields: fields
};
incompleteDataSource = new YAHOO.util.LocalDataSource(json_response.incomplete);
incompleteDataSource.responseSchema = {
fields: fields
};
callingObject = this.argument.storyDataSource;
callingObject.todoDataSource = todoDataSource
callingObject.inprogressDataSource = inprogressDataSource
callingObject.completeDataSource = completeDataSource
callingObject.incompleteDataSource = incompleteDataSource
callingObject.dataSourceReady.fire(callingObject);
},
failure: function(o) {
console.log("successfully loaded json request");
},
argument: { storyDataSource: this }
}
};
initTable = function() {
myLogReader = new YAHOO.widget.LogReader();
console.log("loaded...");
var myColumnDefs = [
...
];
this.onDataSourceReady = function() {
drawTable(this.todoDataSource, "todo", "todo_stories");
drawTable(this.inprogressDataSource, "in progress", "in_progress_stories");
}
this.drawTable = function(dataSource, caption, dom_node) {
dataTable = new YAHOO.AgileBench.DataTable(dom_node, myColumnDefs, dataSource,
{caption: caption},
{width:"950px"}
);
dataTable.subscribe("rowMouseoverEvent", dataTable.onEventHighlightRow);
dataTable.subscribe("rowMouseoutEvent", dataTable.onEventUnhighlightRow);
dataTable.subscribe("rowDragDropEvent", dataTable.onEventRowDragDrop);
}
// this part of the code just seems wrong and out of character. Is that right?
sdt = new YAHOO.AgileBench.StoryDataSource();
sdt.dataSourceReady.subscribe(this.onDataSourceReady, this);
sdt.init();
};
YAHOO.util.Event.addListener(window, "load", function() {
initTable();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment