@@ -95,7 +95,6 @@ module.exports = baseVw.extend({
9595
9696 this . purchasesCol . fetch ( {
9797 success : function ( models ) {
98- //self.renderPurchases();
9998 self . renderTab ( "purchases" , self . purchasesCol , self . purchasesWrapper ) ;
10099 models . length && self . setSearchList ( 'transactionsPurchases' ) ;
101100 self . salesCol . fetch ( {
@@ -106,7 +105,6 @@ module.exports = baseVw.extend({
106105 }
107106 self . casesCol . fetch ( {
108107 success : function ( models ) {
109- //self.renderCases();
110108 self . renderTab ( "cases" , self . casesCol , self . casesWrapper ) ;
111109 models . length && self . setSearchList ( 'transactionsCases' ) ;
112110 } ,
@@ -165,38 +163,12 @@ module.exports = baseVw.extend({
165163 } ) ;
166164 } ,
167165
168- findOrderByID : function ( orderID ) {
169- var orderModelP = this . purchasesCol . findWhere ( { order_id : this . orderID } ) ,
170- orderModelS = this . salesCol . findWhere ( { order_id : this . orderID } ) ,
171- orderModelC = this . casesCol . findWhere ( { order_id : this . orderID } ) ,
172- orderModel = orderModelP || orderModelS || orderModelC ;
173-
174- if ( orderModelP ) {
175- tType = "purchases" ;
176- self . setState ( 'purchases' , self . orderID )
177- } else if ( orderModelS ) {
178- tType = "sales" ;
179- self . setState ( 'sales' , self . orderID )
180- } else if ( orderModelC ) {
181- tType = "cases" ;
182- self . setState ( 'cases' , self . orderID )
183- }
184-
185- //don't forget to make this part work to get the model when the socket message comes in
186- return orderModel ;
187- } ,
188-
189166 handleSocketMessage : function ( response ) {
190167 var data = JSON . parse ( response . data ) ;
191168 if ( data . notification && data . notification . order_id ) {
192169 this . getData ( ) ;
193170 } else if ( data . message && data . message . subject ) {
194- //increment the unread count of the order with the message
195- var orderShortDiscBtn = this . $ ( '.js-orderShortDiscusson[data-order="' + data . message . subject + '"]' ) ;
196- var orderShortDiscBtnBadge = orderShortDiscBtn . find ( '.js-unreadBadge' ) ;
197- orderShortDiscBtn . removeClass ( 'hide' ) ;
198- var newCount = Number ( orderShortDiscBtnBadge . attr ( 'data-count' ) ) + 1 ;
199- orderShortDiscBtnBadge . attr ( 'data-count' , newCount ) ;
171+ this . getData ( ) ;
200172 }
201173 } ,
202174
@@ -280,7 +252,14 @@ module.exports = baseVw.extend({
280252 var self = this ;
281253 filterBy = filterBy || this . filterBy ;
282254 tabWrapper . html ( '' ) ;
283- if ( ! filterBy || filterBy == "all" || filterBy == "dateNewest" ) {
255+ if ( ! filterBy || filterBy == "all" ) {
256+ tabCollection . comparator = function ( model ) {
257+ //add 1 so unread:zero doesn't get dropped from the front of the string when it's changed to a number by the -
258+ return - ( String ( model . get ( "unread" ) + 1 ) + String ( model . get ( "timestamp" ) ) ) ;
259+ } ;
260+ tabCollection . sort ( ) ;
261+ }
262+ if ( filterBy == "dateNewest" ) {
284263 tabCollection . comparator = function ( model ) {
285264 return - model . get ( "timestamp" ) ;
286265 } ;
0 commit comments