@@ -14,6 +14,9 @@ Ext4.define('Panorama.Window.AddCustomMetricWindow', {
1414 update : 'update' ,
1515 insert : 'insert' ,
1616
17+ SCHEMA_NAME : 'targetedms' ,
18+
19+
1720 initComponent : function ( ) {
1821 var title = this . operation === this . insert ? 'Add New Metric' : 'Edit Metric' ;
1922 this . setTitle ( title ) ;
@@ -28,41 +31,27 @@ Ext4.define('Panorama.Window.AddCustomMetricWindow', {
2831 } ]
2932
3033 this . callParent ( ) ;
31- if ( this . operation === this . update ) {
32- if ( this . metric . Series1SchemaName ) {
33- this . getQueriesForSchema ( this . metric . Series1SchemaName , function ( queries , scope ) {
34- scope . series1queries = queries ;
35- scope . queries1Combo . bindStore ( scope . getQueriesStore ( ) ) ;
3634
37- } ) ;
38- }
39- if ( this . metric . Series2SchemaName ) {
40- this . getQueriesForSchema ( this . metric . Series2SchemaName , function ( queries , scope ) {
41- scope . series2queries = queries ;
42- scope . queries2Combo . bindStore ( scope . getQueriesStore ( ) ) ;
43- } ) ;
44- }
45- if ( this . metric . EnabledSchemaName ) {
46- this . getQueriesForSchema ( this . metric . EnabledSchemaName , function ( queries , scope ) {
47- scope . enabledqueries = queries ;
48- scope . enabledQueriesCombo . bindStore ( scope . getQueriesStore ( ) ) ;
49- } ) ;
35+ LABKEY . Query . getQueries ( {
36+ scope : this ,
37+ schemaName : this . SCHEMA_NAME ,
38+ success : function ( queriesInfo ) {
39+ this . series1queries = queriesInfo . queries ;
40+ this . series2queries = queriesInfo . queries ;
41+ this . enabledqueries = queriesInfo . queries ;
5042 }
51- }
43+ } ) ;
5244
5345 } ,
5446
5547 getItems : function ( ) {
5648 return [
5749 this . getMetricNameField ( ) ,
58- this . getSchema1Combo ( ) ,
5950 this . getQueries1Combo ( ) ,
6051 this . getSeries1AxisLabelField ( ) ,
61- this . getSchema2Combo ( ) ,
6252 this . getQueries2Combo ( ) ,
6353 this . getSeries2AxisLabelField ( ) ,
6454 this . getMetricTypeCombo ( ) ,
65- this . getEnabledSchemaCombo ( ) ,
6655 this . getEnabledQueriesCombo ( ) ,
6756 this . getQueryError ( ) ,
6857 ] ;
@@ -107,47 +96,14 @@ Ext4.define('Panorama.Window.AddCustomMetricWindow', {
10796 } ;
10897 } ,
10998
110- getSchema1Combo : function ( ) {
111- if ( ! this . schema1Combo ) {
112- var config = Ext4 . apply ( this . getSchemaConfig ( 'Series 1' , 'series1' ) , {
113- listeners : {
114- scope : this ,
115- select : function ( combo , recs ) {
116- var rec = recs [ 0 ] ;
117- this . series1schema = rec . data . field1 ;
118- this . queries1Combo . setValue ( null ) ;
119-
120- LABKEY . Query . getQueries ( {
121- scope : this ,
122- schemaName : this . series1schema ,
123- success : function ( queriesInfo ) {
124- this . series1queries = queriesInfo . queries ;
125- }
126- } ) ;
127- }
128- }
129- } ) ;
130-
131- this . schema1Combo = Ext4 . create ( 'Ext.form.field.ComboBox' , config ) ;
132-
133- if ( this . operation === this . update ) {
134- this . schema1Combo . setValue ( this . metric . Series1SchemaName ) ;
135- this . schema1Combo . bindStore ( this . schemas ) ;
136- }
137- }
138-
139- return this . schema1Combo ;
140- } ,
141-
14299 getQueriesConfig : function ( label , name ) {
143100 return {
144101 fieldLabel : label + ' Query' ,
145102 name : name + 'Query' ,
146103 labelWidth : 150 ,
147104 width : 400 ,
148105 displayField : 'title' ,
149- valueField : 'name' ,
150- emptyText : 'Please select ' + label + ' Schema.'
106+ valueField : 'name'
151107 } ;
152108 } ,
153109
@@ -224,37 +180,6 @@ Ext4.define('Panorama.Window.AddCustomMetricWindow', {
224180 return this . series2AxisLabelField ;
225181 } ,
226182
227- getSchema2Combo : function ( ) {
228- if ( ! this . schema2Combo ) {
229- var config = Ext4 . apply ( this . getSchemaConfig ( 'Series 2' , 'series2' ) , {
230- listeners : {
231- scope : this ,
232- select : function ( combo , recs ) {
233- var rec = recs [ 0 ] ;
234- this . series2schema = rec . data . field1 ;
235- this . queries2Combo . setValue ( null ) ;
236-
237- LABKEY . Query . getQueries ( {
238- scope : this ,
239- schemaName : this . series2schema ,
240- success : function ( queriesInfo ) {
241- this . series2queries = queriesInfo . queries ;
242- }
243- } ) ;
244- }
245- }
246- } ) ;
247-
248- this . schema2Combo = Ext4 . create ( 'Ext.form.field.ComboBox' , config ) ;
249-
250- if ( this . operation === this . update ) {
251- this . schema2Combo . setValue ( this . metric . Series2SchemaName ) ;
252- }
253- }
254-
255- return this . schema2Combo ;
256- } ,
257-
258183 getQueries2Combo : function ( ) {
259184 if ( ! this . queries2Combo ) {
260185 var config = Ext4 . apply ( this . getQueriesConfig ( 'Series 2' , 'series2' ) , {
@@ -280,37 +205,6 @@ Ext4.define('Panorama.Window.AddCustomMetricWindow', {
280205 return this . queries2Combo ;
281206 } ,
282207
283- getEnabledSchemaCombo : function ( ) {
284- if ( ! this . enabledSchemaCombo ) {
285- var config = Ext4 . apply ( this . getSchemaConfig ( 'Enabled' , 'enabled' ) , {
286- listeners : {
287- scope : this ,
288- select : function ( combo , recs ) {
289- var rec = recs [ 0 ] ;
290- this . enabledschema = rec . data . field1 ;
291- this . enabledQueriesCombo . setValue ( null ) ;
292-
293- LABKEY . Query . getQueries ( {
294- scope : this ,
295- schemaName : this . enabledschema ,
296- success : function ( queriesInfo ) {
297- this . enabledqueries = queriesInfo . queries ;
298- }
299- } ) ;
300- }
301- }
302- } ) ;
303-
304- this . enabledSchemaCombo = Ext4 . create ( 'Ext.form.field.ComboBox' , config ) ;
305-
306- if ( this . operation === this . update ) {
307- this . enabledSchemaCombo . setValue ( this . metric . EnabledSchemaName ) ;
308- }
309- }
310-
311- return this . enabledSchemaCombo ;
312- } ,
313-
314208 getEnabledQueriesCombo : function ( ) {
315209 if ( ! this . enabledQueriesCombo ) {
316210 var config = Ext4 . apply ( this . getQueriesConfig ( 'Enabled' , 'enabled' ) , {
@@ -426,32 +320,17 @@ Ext4.define('Panorama.Window.AddCustomMetricWindow', {
426320 isValid = false ;
427321 }
428322
429- if ( ! this . schema1Combo . getValue ( ) ) {
430- this . schema1Combo . setActiveError ( errorText ) ;
431- isValid = false ;
432- }
433-
434- if ( this . schema1Combo . getValue ( ) && ! this . queries1Combo . getValue ( ) ) {
323+ if ( ! this . queries1Combo . getValue ( ) ) {
435324 this . queries1Combo . setActiveError ( errorText ) ;
436325 isValid = false ;
437326 }
438327
439- if ( this . schema1Combo . getValue ( ) && ! this . series1AxisLabelField . getValue ( ) . length > 0 ) {
328+ if ( ! this . series1AxisLabelField . getValue ( ) . length > 0 ) {
440329 this . series1AxisLabelField . setActiveError ( errorText ) ;
441330 isValid = false ;
442331 }
443332
444- if ( this . schema2Combo . getValue ( ) && ! this . queries2Combo . getValue ( ) ) {
445- this . queries2Combo . setActiveError ( "Required when series 2 schema is provided." ) ;
446- isValid = false ;
447- }
448-
449- if ( this . schema2Combo . getValue ( ) && ! this . series2AxisLabelField . getValue ( ) . length > 0 ) {
450- this . series2AxisLabelField . setActiveError ( "Required when series 2 schema is provided." ) ;
451- isValid = false ;
452- }
453-
454- if ( this . schema1Combo . getValue ( ) && this . metricTypeCombo . getValue ( ) == null ) {
333+ if ( this . metricTypeCombo . getValue ( ) == null ) {
455334 this . metricTypeCombo . setActiveError ( errorText ) ;
456335 isValid = false ;
457336 }
@@ -510,17 +389,17 @@ Ext4.define('Panorama.Window.AddCustomMetricWindow', {
510389 var records = [ ] ;
511390 var newMetric = { } ;
512391 newMetric . Name = this . metricNameField . getValue ( ) ;
513- newMetric . Series1SchemaName = this . schema1Combo . getValue ( ) ;
392+ newMetric . Series1SchemaName = this . SCHEMA_NAME ;
514393 newMetric . Series1QueryName = this . queries1Combo . getValue ( ) ;
515394 newMetric . Series1Label = this . series1AxisLabelField . getValue ( ) ;
516395 newMetric . PrecursorScoped = this . metricTypeCombo . getValue ( ) ;
517396
518397
519- newMetric . Series2SchemaName = this . schema2Combo . getValue ( ) ;
398+ newMetric . Series2SchemaName = this . SCHEMA_NAME ;
520399 newMetric . Series2QueryName = this . queries2Combo . getValue ( ) ;
521400 newMetric . Series2Label = this . series2AxisLabelField . getValue ( ) ;
522401
523- newMetric . EnabledSchemaName = this . enabledSchemaCombo . getValue ( ) ;
402+ newMetric . EnabledSchemaName = this . SCHEMA_NAME ;
524403 newMetric . EnabledQueryName = this . enabledQueriesCombo . getValue ( ) ;
525404
526405 if ( this . operation === this . update ) {
0 commit comments