@@ -8,14 +8,14 @@ define(['marionette', 'backbone', 'backgrid', 'views/table', 'views/filter',
88 'modules/imaging/collections/screencomponents' ,
99 'modules/imaging/views/screencomponentgroup' ,
1010
11- 'modules/shipment/ collections/platetypes ' ,
11+ 'collections/containertypes ' ,
1212 'modules/shipment/views/plate' ,
1313
1414 'templates/imaging/screencomps.html' ,
1515
1616 'backbone-validation' ,
1717 ] , function ( Marionette , Backbone , Backgrid , TableView , FilterView , Editable ,
18- ComponentGroup , ComponentGroups , Component , Components , GroupView , PlateType , PlateView ,
18+ ComponentGroup , ComponentGroups , Component , Components , GroupView , PlateTypes , PlateView ,
1919 template ) {
2020
2121
@@ -29,6 +29,10 @@ define(['marionette', 'backbone', 'backgrid', 'views/table', 'views/filter',
2929 className : 'content' ,
3030 template : template ,
3131
32+ ui : {
33+ containertype : '.containertype' ,
34+ } ,
35+
3236 regions : {
3337 group : '.group' ,
3438 plate : '.plate' ,
@@ -40,6 +44,7 @@ define(['marionette', 'backbone', 'backgrid', 'views/table', 'views/filter',
4044
4145 modelEvents : {
4246 'change:CAPACITY' : 'updatePositions' ,
47+ 'change:CONTAINERTYPEID' : 'updateCapacity' ,
4348 } ,
4449
4550 initialize : function ( options ) {
@@ -58,6 +63,14 @@ define(['marionette', 'backbone', 'backgrid', 'views/table', 'views/filter',
5863 this . updatePositions ( )
5964 } ,
6065
66+ updateCapacity : function ( ) {
67+ var newct = this . ctypes . findWhere ( { CONTAINERTYPEID : this . model . get ( 'CONTAINERTYPEID' ) } )
68+ var newcapacity = newct ? newct . get ( 'CAPACITY' ) : 96
69+ this . model . set ( 'CAPACITY' , newcapacity )
70+ this . $el . find ( '.CAPACITY' ) . html ( newcapacity )
71+ this . onRender ( )
72+ } ,
73+
6174 updatePositions : function ( e ) {
6275 var pos = [ ]
6376 _ . each ( _ . range ( this . model . get ( 'CAPACITY' ) ) , function ( i ) {
@@ -69,6 +82,7 @@ define(['marionette', 'backbone', 'backgrid', 'views/table', 'views/filter',
6982 } ,
7083
7184 setGroup : function ( pos ) {
85+ if ( ! pos ) return
7286 var s = this . collection . findWhere ( { POSITION : pos . toString ( ) } )
7387 if ( s ) this . groupview . setModel ( s )
7488 else {
@@ -87,17 +101,25 @@ define(['marionette', 'backbone', 'backgrid', 'views/table', 'views/filter',
87101 edit . create ( 'NAME' , 'text' )
88102 if ( app . prop == this . model . get ( 'PROP' ) ) {
89103 edit . create ( 'GLOBAL' , 'select' , { data : { 1 : 'Yes' , 0 : 'No' } } )
104+ var self = this
105+ this . ctypes = new PlateTypes ( )
106+ this . ctypes . queryParams = { 'PROPOSALTYPE' : 'mx' , 'ty' : 'plate' }
107+ this . ctypes . fetch ( ) . done ( function ( ) {
108+ edit . create ( 'CONTAINERTYPEID' , 'select' , { data : self . ctypes . kv ( { empty : true } ) } )
109+ } )
110+ } else {
111+ this . ui . containertype . hide ( )
90112 }
91113
92114 this . groupview = new GroupView ( { components : this . components , editable : app . prop == this . model . get ( 'PROP' ) } )
93115 this . group . show ( this . groupview )
94116
95- this . filterview = new FilterView ( { filters : this . positions , url : false , className : 'plate-12-wide' } )
117+ this . filterview = new FilterView ( { filters : this . positions , url : false , className : 'plate-12-wide' , value : 1 } )
96118 this . listenTo ( this . filterview , 'selected:change' , this . setGroup , this )
97119 this . plate . show ( this . filterview )
120+ this . setGroup ( 1 )
98121 } ,
99122
100-
101123 saveGroups : function ( e ) {
102124 e . preventDefault ( )
103125 console . log ( 'save groups' )
0 commit comments