@@ -12,6 +12,7 @@ define(['marionette',
1212
1313 'modules/imaging/models/plan' ,
1414 'modules/imaging/collections/plans' ,
15+ 'modules/shipment/views/plate' ,
1516
1617 'collections/beamlinesetups' ,
1718
@@ -27,6 +28,7 @@ define(['marionette',
2728 SubSamples ,
2829 TableView , table , FilterView , utils ,
2930 DiffractionPlan , DiffractionPlans ,
31+ PlateView ,
3032 BeamlineSetups ,
3133 template , pointemplate , gridtemplate , xfetemplate ,
3234 VMXiPoint , VMXiGrid , VMXiXFE ,
@@ -360,53 +362,6 @@ define(['marionette',
360362 { id : 'manual' , name : 'Manual' } ,
361363 ] ,
362364
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- }
410365 } )
411366
412367
@@ -517,6 +472,7 @@ define(['marionette',
517472 qfilt : '.qfilt' ,
518473 afilt : '.afilt' ,
519474 rimg : '.image' ,
475+ plate : '.plate' ,
520476 } ,
521477
522478 events : {
@@ -773,11 +729,20 @@ define(['marionette',
773729 return this . ui . notcompleted . is ( ':checked' ) ? 1 : null
774730 } ,
775731
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+
776740 refreshSubSamples : function ( ) {
777741 this . subsamples . fetch ( ) . done ( this . onSubsamplesReady . bind ( this ) )
778742 } ,
779743
780- initialize : function ( ) {
744+ initialize : function ( options ) {
745+ this . params = options . params
781746 this . _lastSample = null
782747 this . _subsamples_ready = [ ]
783748
@@ -787,8 +752,9 @@ define(['marionette',
787752 this . unfilteredSubsamples = null
788753 this . subsamples = new SubSamples ( )
789754 this . subsamples . queryParams . cid = this . model . get ( 'CONTAINERID' )
790- this . subsamples . state . pageSize = 10
755+ if ( this . params . s ) this . subsamples . queryParams . s = this . params . s
791756
757+ this . subsamples . state . pageSize = 10
792758 this . _subsamples_ready . push ( this . subsamples . fetch ( ) )
793759
794760 this . inspections = new ContainerInspections ( )
@@ -842,6 +808,12 @@ define(['marionette',
842808 }
843809 } ,
844810
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+ } ,
845817
846818 populatePresets : function ( ) {
847819 this . ui . preset . html ( this . plans . opts ( ) )
@@ -878,7 +850,7 @@ define(['marionette',
878850 } ,
879851
880852 selectSample : function ( ) {
881- this . subsamples . at ( 0 ) . set ( { isSelected : true } )
853+ if ( this . subsamples . at ( 0 ) ) this . subsamples . at ( 0 ) . set ( { isSelected : true } )
882854 } ,
883855
884856 refreshQSubSamples : function ( ) {
@@ -902,6 +874,8 @@ define(['marionette',
902874 this . ui . unqueuebutton . hide ( )
903875 this . subsamples . queryParams . nodata = this . getNoData . bind ( this )
904876 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 )
905879 this . _ready . done ( this . doOnRender . bind ( this ) )
906880 } ,
907881
@@ -927,6 +901,8 @@ define(['marionette',
927901 collection : this . subsamples ,
928902 columns : subSamplesColumns ,
929903 tableClass : 'subsamples' ,
904+ filter : 's' ,
905+ search : this . params . s ,
930906 loading : true ,
931907 backgrid : { row : ClickableRow , emptyText : 'No sub samples found' } ,
932908 noPageUrl : true ,
@@ -992,11 +968,29 @@ define(['marionette',
992968 } )
993969
994970 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 )
995975 } ,
996976
997977 onShow : function ( ) {
998978 this . rimg . show ( this . image )
999979 } ,
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+ } ,
1000994
1001995 } )
1002996
0 commit comments