Skip to content
Browse files

modifying background/tickets to work with new custom_field defintion …

…in tickets
  • Loading branch information...
1 parent 93f2785 commit 3853f31a50b43cd35305a43e4629ffddd2dbaea1 @kotfic kotfic committed Apr 6, 2012
Showing with 18 additions and 7 deletions.
  1. +16 −6 background.html
  2. +2 −1 js/assembla_spaces.js
View
22 background.html
@@ -108,16 +108,16 @@
_sortTicketsByDateAsc : function (ticket1, ticket2 ){
- if(ticket1.get("due_date") === undefined && ticket2.get("due_date") == undefined){
+ if(ticket1.getDueDate() === undefined && ticket2.getDueDate() == undefined){
return 1;
- } else if(ticket1.get("due_date") === undefined){
+ } else if(ticket1.getDueDate() === undefined){
return 1;
- } else if(ticket2.get("due_date") === undefined){
+ } else if(ticket2.getDueDate() === undefined){
return -1;
} else {
- var date1 = new Date(ticket1.get("due_date"));
- var date2 = new Date(ticket2.get("due_date"));
+ var date1 = new Date(ticket1.getDueDate());
+ var date2 = new Date(ticket2.getDueDate());
if( date1 == date2 ){
return 0;
} else if( date1 > date2 ) {
@@ -209,7 +209,17 @@
-AssemblaApp.Models.Ticket = Backbone.Model.extend({ });
+AssemblaApp.Models.Ticket = Backbone.Model.extend({
+
+ getDueDate : function() {
+ if( this.get("custom_fields") ){
+ var custom_field = _.find( this.get("custom_fields"), function( item ){ return item.attr.name == "Due Date"; } );
+ if( custom_field && custom_field.value ){
+ return custom_field.value
+ }
+ }
+ }
+});
AssemblaApp.Collections.Ticket = Backbone.Collection.extend({ model: AssemblaApp.Models.Ticket });
View
3 js/assembla_spaces.js
@@ -65,7 +65,7 @@ AssemblaApp.Views.Ticket_Tab_Accordion = Backbone.View.extend({
initialize : function(){
this._ticketViews = [];
- AssemblaApp.dispatcher.on("bootstrapActiveSpaces:loaded", function () {
+ AssemblaApp.getActiveSpaces().on("change", function () {
this.collection = AssemblaApp.getActiveTickets();
this.render();
}, this);
@@ -108,6 +108,7 @@ AssemblaApp.Views.Ticket_Accordion_Element = Backbone.View.extend({
t.date_class = (d < current_date) ? "past_due" : '';
}
+
t.space_name = AssemblaApp.getActiveSpaces().get(t.space_id).get('name');
t.space_wiki_name = AssemblaApp.getSpaceBaseUrl( AssemblaApp.getActiveSpaces().get(t.space_id).get("wiki_name") );

0 comments on commit 3853f31

Please sign in to comment.
Something went wrong with that request. Please try again.