@@ -73,7 +73,7 @@ function createPersonaCharacteristicsTable(){
7373      debugLogger ( String ( this . url ) ) ; 
7474      debugLogger ( "error: "  +  xhr . responseText  +   ", textstatus: "  +  textStatus  +  ", thrown: "  +  errorThrown ) ; 
7575    } 
76-   } ) 
76+   } ) ; 
7777} 
7878
7979$ ( document ) . on ( 'click' ,  "td.personacharacteristic-rows" ,  function  ( )  { 
@@ -90,30 +90,51 @@ $(document).on('click', "td.personacharacteristic-rows", function () {
9090    url : serverIP  +  "/api/persona_characteristics/name/"  +  encodeURIComponent ( name ) , 
9191    success : function  ( data )  { 
9292      fillOptionMenu ( "fastTemplates/editPersonaCharacteristicOptions.html" ,  "#objectViewer" ,  null ,  true ,  true ,  function  ( )  { 
93-         $ ( "#editPersonaCharacteristicOptionsForm" ) . validator ( ) ; 
94-         $ ( "#UpdatePersonaCharacteristic" ) . text ( "Update" ) ; 
95-         $ . session . set ( "PersonaCharacteristic" ,  JSON . stringify ( data ) ) ; 
96- 
97-         $ ( "#theModQual" ) . val ( data . theModQual ) ; 
98-         $ ( "#theCharacteristic" ) . val ( data . theCharacteristic ) ; 
93+         $ . ajax ( { 
94+           type : "GET" , 
95+           dataType : "json" , 
96+           accept : "application/json" , 
97+           data : { 
98+             session_id : String ( $ . session . get ( 'sessionID' ) ) 
99+           } , 
100+           crossDomain : true , 
101+           url : serverIP  +  "/api/dimensions/table/persona" , 
102+           success : function  ( pNames )  { 
103+             var  personaSelect  =  $ ( '#thePersonaName' ) ; 
104+             $ . each ( pNames ,  function  ( index , pName )  { 
105+               personaSelect . append ( $ ( "<option></option>" ) . attr ( "value" , pName ) . text ( pName ) ) ; 
106+             } ) ; 
107+             $ ( "#editPersonaCharacteristicOptionsForm" ) . validator ( ) ; 
108+             $ ( "#UpdatePersonaCharacteristic" ) . text ( "Update" ) ; 
109+             $ . session . set ( "PersonaCharacteristic" ,  JSON . stringify ( data ) ) ; 
110+             personaSelect . val ( data . thePersonaName ) ; 
111+             $ ( "#theVariable" ) . val ( data . theVariable ) ; 
112+             $ ( "#theModQual" ) . val ( data . theModQual ) ; 
113+             $ ( "#theCharacteristic" ) . val ( data . theCharacteristic ) ; 
99114
100-         $ ( "#theGrounds" ) . find ( "tbody" ) . empty ( ) ; 
101-         $ . each ( data . theGrounds , function ( idx , item )  { 
102-           appendGWR ( "#theGrounds" , 'ground' , item ) ;  
103-         } ) ;  
104- 
105-         $ ( "#theWarrant" ) . find ( "tbody" ) . empty ( ) ; 
106-         $ . each ( data . theWarrant , function ( idx , item )  { 
107-           appendGWR ( "#theWarrant" , 'warrant' , item ) ;  
108-         } ) ; 
109-         $ ( "#theRebuttal" ) . find ( "tbody" ) . empty ( ) ; 
110-         $ . each ( data . theRebuttal , function ( idx , item )  { 
111-           appendGWR ( "#theRebuttal" , 'rebuttal' , item ) ;  
115+             $ ( "#theGrounds" ) . find ( "tbody" ) . empty ( ) ; 
116+             $ . each ( data . theGrounds , function ( idx , item )  { 
117+               appendGWR ( "#theGrounds" , 'ground' , item ) ;  
118+             } ) ;  
119+ 
120+             $ ( "#theWarrant" ) . find ( "tbody" ) . empty ( ) ; 
121+             $ . each ( data . theWarrant , function ( idx , item )  { 
122+               appendGWR ( "#theWarrant" , 'warrant' , item ) ;  
123+             } ) ; 
124+             $ ( "#theRebuttal" ) . find ( "tbody" ) . empty ( ) ; 
125+             $ . each ( data . theRebuttal , function ( idx , item )  { 
126+               appendGWR ( "#theRebuttal" , 'rebuttal' , item ) ;  
127+             } ) ; 
128+             $ ( "#theBacking" ) . find ( "tbody" ) . empty ( ) ; 
129+             $ . each ( data . theBacking , function ( idx , item )  { 
130+               appendBacking ( item ) ;  
131+             } ) ;  
132+           } , 
133+           error : function  ( xhr ,  textStatus ,  errorThrown )  { 
134+             debugLogger ( String ( this . url ) ) ; 
135+             debugLogger ( "error: "  +  xhr . responseText  +   ", textstatus: "  +  textStatus  +  ", thrown: "  +  errorThrown ) ; 
136+           } 
112137        } ) ; 
113-         $ ( "#theBacking" ) . find ( "tbody" ) . empty ( ) ; 
114-         $ . each ( data . theBacking , function ( idx , item )  { 
115-           appendBacking ( item ) ;  
116-         } ) ;  
117138      } ) ; 
118139    } , 
119140    error : function  ( xhr ,  textStatus ,  errorThrown )  { 
@@ -128,6 +149,10 @@ mainContent.on('click', '#UpdatePersonaCharacteristic', function (e) {
128149  e . preventDefault ( ) ; 
129150  var  pc  =  JSON . parse ( $ . session . get ( "PersonaCharacteristic" ) ) ; 
130151  var  oldName  =  pc . theCharacteristic ; 
152+   pc . thePersonaName  =  $ ( "#thePersonaName" ) . val ( ) ; 
153+   pc . theVariable  =  $ ( "#theVariable" ) . val ( ) ; 
154+   pc . theModQual  =  $ ( "#theModQual" ) . val ( ) ; 
155+   pc . theCharacteristic  =  $ ( "#theCharacteristic" ) . val ( ) ; 
131156
132157  if ( $ ( "#editPersonaCharacteristicOptionsForm" ) . hasClass ( "new" ) ) { 
133158    postPersonaCharacteristic ( pc ,  function  ( )  { 
@@ -142,25 +167,46 @@ mainContent.on('click', '#UpdatePersonaCharacteristic', function (e) {
142167  } 
143168} ) ; 
144169
145- $ ( document ) . on ( 'click' ,  'td.deletePersonaCharacteristicsButton ' ,  function  ( e )  { 
170+ $ ( document ) . on ( 'click' ,  'td.deletePersonaCharacteristicButton ' ,  function  ( e )  { 
146171  e . preventDefault ( ) ; 
147-   deletePersonaCharacteristic ( $ ( this ) . find ( 'i' ) . attr ( "value" ) ,  function  ( )  { 
172+   var  pName  =  $ ( this ) . closest ( 'tr' ) . find ( 'td:eq(3)' ) . text ( ) ; 
173+   deletePersonaCharacteristic ( pName ,  function  ( )  { 
148174    createPersonaCharacteristicsTable ( ) ; 
149175  } ) ; 
150176} ) ; 
151177
152178$ ( document ) . on ( "click" ,  "#addNewPersonaCharacteristic" ,  function  ( )  { 
153179  activeElement ( "objectViewer" ) ; 
154180  fillOptionMenu ( "fastTemplates/editPersonaCharacteristicOptions.html" ,  "#objectViewer" ,  null ,  true ,  true ,  function  ( )  { 
155-     $ ( "#editPersonaCharacteristicOptionsForm" ) . validator ( ) ; 
156-     $ ( "#UpdatePersonaCharacteristic" ) . text ( "Create" ) ; 
157-     $ ( "#editPersonaCharacteristicOptionsForm" ) . addClass ( "new" ) ; 
158-     $ . session . set ( "PersonaCharacteristic" ,  JSON . stringify ( jQuery . extend ( true ,  { } , personaCharacteristicDefault  ) ) ) ; 
181+     $ . ajax ( { 
182+       type : "GET" , 
183+       dataType : "json" , 
184+       accept : "application/json" , 
185+       data : { 
186+         session_id : String ( $ . session . get ( 'sessionID' ) ) 
187+       } , 
188+       crossDomain : true , 
189+       url : serverIP  +  "/api/dimensions/table/persona" , 
190+       success : function  ( data )  { 
191+         var  personaSelect  =  $ ( '#thePersonaName' ) ; 
192+         $ . each ( data ,  function  ( index , pName )  { 
193+           personaSelect . append ( $ ( "<option></option>" ) . attr ( "value" , pName ) . text ( pName ) ) ; 
194+         } ) ; 
195+         $ ( "#editPersonaCharacteristicOptionsForm" ) . validator ( ) ; 
196+         $ ( "#UpdatePersonaCharacteristic" ) . text ( "Create" ) ; 
197+         $ ( "#editPersonaCharacteristicOptionsForm" ) . addClass ( "new" ) ; 
198+         $ . session . set ( "PersonaCharacteristic" ,  JSON . stringify ( jQuery . extend ( true ,  { } , personaCharacteristicDefault  ) ) ) ; 
199+       } , 
200+       error : function  ( xhr ,  textStatus ,  errorThrown )  { 
201+         debugLogger ( String ( this . url ) ) ; 
202+         debugLogger ( "error: "  +  xhr . responseText  +  ", textstatus: "  +  textStatus  +  ", thrown: "  +  errorThrown ) ; 
203+       } 
204+     } ) ; 
159205  } ) ; 
160206} ) ; 
161207
162208
163- function  putPersonaCharacteristic ( pc ,  oldName ,  usePopup ,   callback ) { 
209+ function  putPersonaCharacteristic ( pc ,  oldName ,  callback ) { 
164210  var  output  =  { } ; 
165211  output . object  =  pc ; 
166212  output . session_id  =  $ . session . get ( 'sessionID' ) ; 
@@ -178,18 +224,14 @@ function putPersonaCharacteristic(pc, oldName, usePopup, callback){
178224    data : output , 
179225    url : serverIP  +  "/api/persona_characteristics/name/"  +  encodeURIComponent ( oldName )  +  "?session_id="  +  $ . session . get ( 'sessionID' ) , 
180226    success : function  ( data )  { 
181-       if ( usePopup )  { 
182-         showPopup ( true ) ; 
183-       } 
227+       showPopup ( true ) ; 
184228      if ( jQuery . isFunction ( callback ) ) { 
185229        callback ( ) ; 
186230      } 
187231    } , 
188232    error : function  ( xhr ,  textStatus ,  errorThrown )  { 
189-       if ( usePopup )  { 
190-         var  error  =  JSON . parse ( xhr . responseText ) ; 
191-         showPopup ( false ,  String ( error . message ) ) ; 
192-       } 
233+       var  error  =  JSON . parse ( xhr . responseText ) ; 
234+       showPopup ( false ,  String ( error . message ) ) ; 
193235      debugLogger ( String ( this . url ) ) ; 
194236      debugLogger ( "error: "  +  xhr . responseText  +   ", textstatus: "  +  textStatus  +  ", thrown: "  +  errorThrown ) ; 
195237    } 
@@ -281,6 +323,9 @@ function loadCharacteristicReference() {
281323      $ . each ( data ,  function ( key ,  item )  { 
282324        $ ( "#theReferenceName" ) . append ( "<option>"  +  item  +  "</option>" ) ; 
283325      } ) ;  
326+       var  cr  =  JSON . parse ( $ ( "#editCharacteristicReference" ) . data ( "currentcr" ) ) ; 
327+       $ ( "#theReferenceName" ) . val ( cr . name ) ; 
328+       $ ( "#theDescription" ) . val ( cr . description ) ; 
284329    } , 
285330    error : function  ( xhr ,  textStatus ,  errorThrown )  { 
286331      debugLogger ( String ( this . url ) ) ; 
@@ -290,23 +335,95 @@ function loadCharacteristicReference() {
290335} ; 
291336
292337function  addCharacteristicReference ( )  { 
338+   var  cr  =  JSON . parse ( $ ( "#editCharacteristicReference" ) . data ( "crtype" ) ) ; 
293339  var  item  =  { } ; 
294340  item . theReferenceName  =  $ ( "#theReferenceName" ) . val ( ) ; 
295341  item . theReferenceDescription  =  $ ( "#theDescription" ) . val ( ) ; 
296-   appendGWR ( "#theGrounds" , 'ground' , item ) ;  
342+   appendGWR ( cr . tableId , cr . classId , item ) ;  
343+   item . theDimensionName  =  'document' ; 
344+   var  pc  =  JSON . parse ( $ . session . get ( "PersonaCharacteristic" ) ) ; 
345+   if  ( cr . tableId  ==  '#theGrounds' )  { 
346+     item . theCharacteristicType  =  'grounds' ; 
347+     pc . theGrounds . push ( item ) ; 
348+   } 
349+   else  if  ( cr . tableId  ==  '#theWarrant' )  { 
350+     item . theCharacteristicType  =  'warrant' ; 
351+     pc . theWarrant . push ( item ) ; 
352+   } 
353+   else  { 
354+     item . theCharacteristicType  =  'rebuttal' ; 
355+     pc . theRebuttal . push ( item ) ; 
356+   } 
357+   $ . session . set ( "PersonaCharacteristic" ,  JSON . stringify ( pc ) ) ; 
297358  $ ( "#editCharacteristicReference" ) . modal ( 'hide' ) ; 
298359} 
299360
300- function  loadCharacteristicReference ( )  { 
301-   var  currentCr  =  $ ( "#editCharacteristicReference" ) . data ( 'currentcr' ) ; 
302-   $ ( "#theReferenceName" ) . val ( currentCr . theReferenceName ) ; 
303-   $ ( "#theDescription" ) . val ( currentCr . theReferenceDescription ) ; 
361+ function  updateReferenceList ( )  { 
362+   var  cr  =  JSON . parse ( $ ( "#editCharacteristicReference" ) . data ( "currentcr" ) ) ; 
363+   var  item  =  { } ; 
364+   item . theReferenceName  =  $ ( "#theReferenceName" ) . val ( ) ; 
365+   item . theReferenceDescription  =  $ ( "#theDescription" ) . val ( ) ; 
366+   $ ( cr . tableId ) . find ( "tbody" ) . find ( 'tr:eq('  +  cr . index  +  ')' ) . find ( 'td:eq(1)' ) . text ( item . theReferenceName ) ; 
367+   $ ( cr . tableId ) . find ( "tbody" ) . find ( 'tr:eq('  +  cr . index  +  ')' ) . find ( 'td:eq(2)' ) . text ( item . theReferenceDescription ) ; 
368+   item . theDimensionName  =  'document' ; 
369+   var  pc  =  JSON . parse ( $ . session . get ( "PersonaCharacteristic" ) ) ; 
370+ 
371+   if  ( cr . tableId  ==  '#theGrounds' )  { 
372+     item . theCharacteristicType  =  'grounds' ; 
373+     $ . each ( pc . theGrounds , function ( idx , g )  { 
374+       if  ( idx  ==  cr . index )  { 
375+         pc . theGrounds [ idx ]  =  item ; 
376+       } 
377+     } ) ; 
378+   } 
379+   else  if  ( cr . tableId  ==  '#theWarrant' )  { 
380+     item . theCharacteristicType  =  'warrant' ; 
381+     $ . each ( pc . theWarrant , function ( idx , w )  { 
382+       if  ( idx  ==  cr . index )  { 
383+         pc . theWarrant [ idx ]  =  item ; 
384+       } 
385+     } ) ; 
386+   } 
387+   else  { 
388+     item . theCharacteristicType  =  'rebuttal' ; 
389+     $ . each ( pc . theRebuttal , function ( idx , r )  { 
390+       if  ( idx  ==  cr . index )  { 
391+         pc . theRebuttal [ idx ]  =  item ; 
392+       } 
393+     } ) ; 
394+   } 
395+   $ . session . set ( "PersonaCharacteristic" ,  JSON . stringify ( pc ) ) ; 
396+   $ ( "#editCharacteristicReference" ) . modal ( 'hide' ) ; 
304397} 
305398
306399
307400mainContent . on ( "click" ,  "#addGrounds" ,  function ( ) { 
401+   var  crt  =  { } ; 
402+   crt . tableId  =  "#theGrounds" ; 
403+   crt . classId  =  'ground' ;  
308404  $ ( "#editCharacteristicReference" ) . data ( 'loadcr' , loadCharacteristicReference ) ; 
309405  $ ( "#editCharacteristicReference" ) . data ( "savecr" , addCharacteristicReference ) ; 
406+   $ ( "#editCharacteristicReference" ) . data ( "crtype" , JSON . stringify ( crt ) ) ; 
407+   $ ( "#editCharacteristicReference" ) . modal ( 'show' ) ; 
408+ } ) ; 
409+ 
410+ mainContent . on ( "click" ,  "#addWarrant" ,  function ( ) { 
411+   var  crt  =  { } ; 
412+   crt . tableId  =  "#theWarrant" ; 
413+   crt . classId  =  'warrant' ;  
414+   $ ( "#editCharacteristicReference" ) . data ( 'loadcr' , loadCharacteristicReference ) ; 
415+   $ ( "#editCharacteristicReference" ) . data ( "savecr" , addCharacteristicReference ) ; 
416+   $ ( "#editCharacteristicReference" ) . data ( "crtype" , JSON . stringify ( crt ) ) ; 
417+   $ ( "#editCharacteristicReference" ) . modal ( 'show' ) ; 
418+ } ) ; 
419+ 
420+ mainContent . on ( "click" ,  "#addRebuttal" ,  function ( ) { 
421+   var  crt  =  { } ; 
422+   crt . tableId  =  "#theRebuttal" ; 
423+   crt . classId  =  'rebuttal' ;  
424+   $ ( "#editCharacteristicReference" ) . data ( 'loadcr' , loadCharacteristicReference ) ; 
425+   $ ( "#editCharacteristicReference" ) . data ( "savecr" , addCharacteristicReference ) ; 
426+   $ ( "#editCharacteristicReference" ) . data ( "crtype" , JSON . stringify ( crt ) ) ; 
310427  $ ( "#editCharacteristicReference" ) . modal ( 'show' ) ; 
311428} ) ; 
312429
@@ -322,12 +439,37 @@ $("#editCharacteristicReference").on('click', '#saveCharacteristicReference',fun
322439
323440mainContent . on ( "click" , ".ground" ,  function  ( )  { 
324441  var  propRow  =  $ ( this ) . closest ( "tr" ) ; 
325-   var  selectedCr  =  { } ; 
326-   selectedCr . reference  =  propRow . find ( "td:eq(1)" ) . text ( ) ; 
327-   selectedCr . description  =  propRow . find ( "td:eq(2)" ) . text ( ) ; 
328- 
442+   var  cr  =  { } ; 
443+   cr . name  =  propRow . find ( "td:eq(1)" ) . text ( ) ; 
444+   cr . description  =  propRow . find ( "td:eq(2)" ) . text ( ) ; 
445+   cr . index  =  propRow . index ( ) ; 
446+   cr . tableId  =  "#theGrounds" ; 
447+   $ ( "#editCharacteristicReference" ) . data ( "currentcr" , JSON . stringify ( cr ) ) ; 
448+   $ ( "#editCharacteristicReference" ) . data ( 'loadcr' , loadCharacteristicReference ) ; 
449+   $ ( "#editCharacteristicReference" ) . data ( "savecr" , updateReferenceList ) ; 
450+   $ ( "#editCharacteristicReference" ) . modal ( 'show' ) ; 
451+ } ) ; 
452+ mainContent . on ( "click" , ".warrant" ,  function  ( )  { 
453+   var  propRow  =  $ ( this ) . closest ( "tr" ) ; 
454+   var  cr  =  { } ; 
455+   cr . name  =  propRow . find ( "td:eq(1)" ) . text ( ) ; 
456+   cr . description  =  propRow . find ( "td:eq(2)" ) . text ( ) ; 
457+   cr . index  =  propRow . index ( ) ; 
458+   cr . tableId  =  "#theWarrant" ; 
459+   $ ( "#editCharacteristicReference" ) . data ( "currentcr" , JSON . stringify ( cr ) ) ; 
460+   $ ( "#editCharacteristicReference" ) . data ( 'loadcr' , loadCharacteristicReference ) ; 
461+   $ ( "#editCharacteristicReference" ) . data ( "savecr" , updateReferenceList ) ; 
462+   $ ( "#editCharacteristicReference" ) . modal ( 'show' ) ; 
463+ } ) ; 
464+ mainContent . on ( "click" , ".rebuttal" ,  function  ( )  { 
465+   var  propRow  =  $ ( this ) . closest ( "tr" ) ; 
466+   var  cr  =  { } ; 
467+   cr . name  =  propRow . find ( "td:eq(1)" ) . text ( ) ; 
468+   cr . description  =  propRow . find ( "td:eq(2)" ) . text ( ) ; 
469+   cr . index  =  propRow . index ( ) ; 
470+   cr . tableId  =  "#theRebuttal" ; 
471+   $ ( "#editCharacteristicReference" ) . data ( "currentcr" , JSON . stringify ( cr ) ) ; 
329472  $ ( "#editCharacteristicReference" ) . data ( 'loadcr' , loadCharacteristicReference ) ; 
330-   $ ( "#editCharacteristicReference" ) . data ( "savecr" , updateCharacteristicReference ) ; 
331-   $ ( "#editCharacteristicReference" ) . data ( "currentcr" , JSON . stringify ( selectedCr ) ) ; 
473+   $ ( "#editCharacteristicReference" ) . data ( "savecr" , updateReferenceList ) ; 
332474  $ ( "#editCharacteristicReference" ) . modal ( 'show' ) ; 
333475} ) ; 
0 commit comments