Implemented new timeline functionality client-side.

* Fixed returned information in ts_api:put_timeline/3
* Added UI for new timeline button.
* Added client-side implementation of new timeline creation. There is a problem
  on the server-side, PUT should support creating new items and updating
  existing items.
This commit is contained in:
Jonathan Bernard
2011-06-07 08:34:20 -05:00
parent 76083b5972
commit 89336e844f
7 changed files with 41 additions and 12 deletions

View File

@ -356,7 +356,8 @@ $(document).ready(function(){
"dblclick .timeline-id" : "editId",
"dblclick .timeline-desc" : "editDesc",
"keypress .timeline-id-input" : "updateOnEnter",
"keypress .timeline-desc-input" : "updateOnEnter"
"keypress .timeline-desc-input" : "updateOnEnter",
"click .new-timeline-link" : "showNewTimelineDialog"
},
initialize: function(options) {
@ -406,6 +407,10 @@ $(document).ready(function(){
this.render();
},
showNewTimelineDialog: function() {
TS.app.newTimelineDialog.show();
},
updateOnEnter: function(e) {
if (e.keyCode == 13) { this.close(); this.save() }
}
@ -468,9 +473,6 @@ $(document).ready(function(){
// create the login dialog
this.loginDialog = new TS.LoginView
// create the new timeline dialog
this.newTimelineDialog = new TS.NewTimelineView
// initialize data, either from boostrapped data, or via user login
if (window.bootstrap) { this.initializeData(window.bootstrap()) }
else {
@ -500,6 +502,10 @@ $(document).ready(function(){
{collection: this.timelines.collection,
initialTimelineId: data.initialTimelineId});
// create the new timeline dialog
this.newTimelineDialog = new TS.NewTimelineView(
{timelineCollection: this.timelines.collection});
// create entry models from the bootstrapped data
var entryModels = _.map(data.entries, function(entry) {
return new TS.EntryModel(entry);
@ -614,8 +620,7 @@ $(document).ready(function(){
if (options.timelineCollection == undefined) {
throw "Can not create the NewTimelineView without the timeline collection."
} else {
this.timelineCollection = this.collection.get(
options.timelineCollection);
this.timelineCollection = options.timelineCollection;
}
},
@ -624,14 +629,16 @@ $(document).ready(function(){
var timelineId = this.$("#new-timeline-id").val();
var timelineDesc = this.$("#new-timeline-desc").val();
this.timelineCollection.create(
{id: timelineId, description: timelineDesc});
{id: timelineId, description: timelineDesc,
created: getUTCTimestamp()});
this.hide();
},
hide: function() { $(this.el).addClass('hidden'); },
show: function() {
this.$("#new-timeline-id".val('');
this.$("#new-timeline-desc".val('');
this.$("#new-timeline-id").val("");
this.$("#new-timeline-desc").val("");
$(this.el).removeClass('hidden');
this.$("#new-timeline-id").focus();
}