@@ -12,7 +12,6 @@ define(['marionette',
1212
1313 'modules/imaging/models/plan' ,
1414 'modules/imaging/collections/plans' ,
15- 'modules/shipment/views/plate' ,
1615
1716 'collections/beamlinesetups' ,
1817
@@ -28,7 +27,6 @@ define(['marionette',
2827 SubSamples ,
2928 TableView , table , FilterView , utils ,
3029 DiffractionPlan , DiffractionPlans ,
31- PlateView ,
3230 BeamlineSetups ,
3331 template , pointemplate , gridtemplate , xfetemplate ,
3432 VMXiPoint , VMXiGrid , VMXiXFE ,
@@ -362,6 +360,53 @@ define(['marionette',
362360 { id : 'manual' , name : 'Manual' } ,
363361 ] ,
364362
363+ initialize : function ( options ) {
364+ ClientFilterView . __super__ . initialize . call ( this , options )
365+
366+ this . filterablecollection = options . collection . fullCollection // || options.collection
367+ this . shadowCollection = this . filterablecollection . clone ( )
368+
369+ this . listenTo ( this . filterablecollection , 'add' , function ( model , collection , options ) {
370+ this . shadowCollection . add ( model , options )
371+ } )
372+ this . listenTo ( this . filterablecollection , 'remove' , function ( model , collection , options ) {
373+ this . shadowCollection . remove ( model , options )
374+ } )
375+ this . listenTo ( this . filterablecollection , 'sort' , function ( col ) {
376+ if ( ! this . query ( ) ) this . shadowCollection . reset ( col . models )
377+ } )
378+ this . listenTo ( this . filterablecollection , 'reset' , function ( col , options ) {
379+ options = _ . extend ( { reindex : true } , options || { } )
380+ if ( options . reindex && options . from == null && options . to == null ) {
381+ this . shadowCollection . reset ( col . models )
382+ if ( this . selected ( ) ) this . _filter ( )
383+ }
384+ } )
385+ } ,
386+
387+ _filter : function ( ) {
388+ var id = this . selected ( )
389+ this . trigger ( 'selected:change' , id , this . selectedName ( ) )
390+ if ( id ) {
391+ this . filterablecollection . reset ( this . shadowCollection . filter ( function ( m ) {
392+ if ( id === 'region' ) {
393+ return m . get ( 'X2' ) && m . get ( 'Y2' )
394+
395+ } else if ( id === 'point' ) {
396+ return m . get ( 'X' ) && m . get ( 'Y' ) && ! m . get ( 'X2' )
397+ }
398+ else if ( id === 'auto' ) {
399+ return m . get ( 'SOURCE' ) == 'auto'
400+
401+ } else if ( id === 'manual' ) {
402+ return m . get ( 'SOURCE' ) == 'manual'
403+ }
404+ } ) , { reindex : false } )
405+ } else {
406+ console . log ( 'reset' , this . shadowCollection )
407+ this . filterablecollection . reset ( this . shadowCollection . models , { reindex : false } )
408+ }
409+ }
365410 } )
366411
367412
@@ -472,7 +517,6 @@ define(['marionette',
472517 qfilt : '.qfilt' ,
473518 afilt : '.afilt' ,
474519 rimg : '.image' ,
475- plate : '.plate' ,
476520 } ,
477521
478522 events : {
@@ -729,20 +773,11 @@ define(['marionette',
729773 return this . ui . notcompleted . is ( ':checked' ) ? 1 : null
730774 } ,
731775
732- getSearch : function ( ) {
733- return this . table . filter . query ( ) || null
734- } ,
735-
736- getFilter : function ( ) {
737- return this . afilt . $el . find ( '.current' ) . attr ( 'id' ) || null
738- } ,
739-
740776 refreshSubSamples : function ( ) {
741777 this . subsamples . fetch ( ) . done ( this . onSubsamplesReady . bind ( this ) )
742778 } ,
743779
744- initialize : function ( options ) {
745- this . params = options . params
780+ initialize : function ( ) {
746781 this . _lastSample = null
747782 this . _subsamples_ready = [ ]
748783
@@ -752,9 +787,8 @@ define(['marionette',
752787 this . unfilteredSubsamples = null
753788 this . subsamples = new SubSamples ( )
754789 this . subsamples . queryParams . cid = this . model . get ( 'CONTAINERID' )
755- if ( this . params . s ) this . subsamples . queryParams . s = this . params . s
756-
757790 this . subsamples . state . pageSize = 10
791+
758792 this . _subsamples_ready . push ( this . subsamples . fetch ( ) )
759793
760794 this . inspections = new ContainerInspections ( )
@@ -808,12 +842,6 @@ define(['marionette',
808842 }
809843 } ,
810844
811- onSubsamplesReady : function ( ) {
812- this . getInspectionImages ( )
813- this . refreshQSubSamples ( )
814- this . listenTo ( this . subsamples , 'change:isSelected' , this . selectSubSample , this )
815- this . listenTo ( this . subsamples , 'sync add remove change:READYFORQUEUE' , this . refreshQSubSamples , this )
816- } ,
817845
818846 populatePresets : function ( ) {
819847 this . ui . preset . html ( this . plans . opts ( ) )
@@ -850,7 +878,7 @@ define(['marionette',
850878 } ,
851879
852880 selectSample : function ( ) {
853- if ( this . subsamples . at ( 0 ) ) this . subsamples . at ( 0 ) . set ( { isSelected : true } )
881+ this . subsamples . at ( 0 ) . set ( { isSelected : true } )
854882 } ,
855883
856884 refreshQSubSamples : function ( ) {
@@ -874,8 +902,6 @@ define(['marionette',
874902 this . ui . unqueuebutton . hide ( )
875903 this . subsamples . queryParams . nodata = this . getNoData . bind ( this )
876904 this . subsamples . queryParams . notcompleted = this . getNotCompleted . bind ( this )
877- this . subsamples . queryParams . s = this . getSearch . bind ( this )
878- this . subsamples . queryParams . filter = this . getFilter . bind ( this )
879905 this . _ready . done ( this . doOnRender . bind ( this ) )
880906 } ,
881907
@@ -901,8 +927,6 @@ define(['marionette',
901927 collection : this . subsamples ,
902928 columns : subSamplesColumns ,
903929 tableClass : 'subsamples' ,
904- filter : 's' ,
905- search : this . params . s ,
906930 loading : true ,
907931 backgrid : { row : ClickableRow , emptyText : 'No sub samples found' } ,
908932 noPageUrl : true ,
@@ -968,29 +992,11 @@ define(['marionette',
968992 } )
969993
970994 this . qsmps . show ( this . table2 )
971-
972- this . plateView = new PlateView ( { collection : this . subsamples . fullCollection , type : this . type , inspectionimages : this . inspectionimages , showMaxScore : true } )
973- this . listenTo ( this . plateView , 'dropClicked' , this . filterByLocation , this )
974- this . plate . show ( this . plateView )
975995 } ,
976996
977997 onShow : function ( ) {
978998 this . rimg . show ( this . image )
979999 } ,
980-
981- filterByLocation : function ( pos ) {
982- if ( ! pos ) return ;
983- var namedrop = this . type . getName ( pos ) + 'd' + this . type . getDrop ( pos )
984- if ( this . table . filter . query ( ) === namedrop ) {
985- this . table . filter . clearSearchBox ( )
986- } else {
987- this . table . filter . searchBox ( ) . val ( namedrop )
988- }
989- this . table . filter . _updateUrl ( )
990- this . subsamples . fetch ( ) . done ( this . selectSample . bind ( this ) )
991- var i = this . inspectionimages . findWhere ( { LOCATION : pos . toString ( ) } )
992- this . image . setModel ( i )
993- } ,
9941000
9951001 } )
9961002
0 commit comments