Commit e7267ea7674ed0c5887cea021eec80922ec08019

Authored by nbm
1 parent 1d3294e7

Make it possible to load initialiseConditionalFieldsets multiple times.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3862 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/js/conditional_usage.js
@@ -71,6 +71,19 @@ The system works based on 3 concepts: @@ -71,6 +71,19 @@ The system works based on 3 concepts:
71 var conditional_usage_undostack = new Array(); 71 var conditional_usage_undostack = new Array();
72 var conditional_usage_keys = new Array(); 72 var conditional_usage_keys = new Array();
73 73
  74 +
  75 +// sorry mom.
  76 +function checkStackForFieldset(fieldset) {
  77 + for (var i=0; i<conditional_usage_keys.length; i++) {
  78 + if (conditional_usage_keys[i] == fieldset) {
  79 + simpleLog('DEBUG','found undostack at keyindex '+i);
  80 + return true;
  81 + }
  82 + }
  83 + return false;
  84 +}
  85 +
  86 +
74 // grow and go. 87 // grow and go.
75 function getStackForFieldset(fieldset) { 88 function getStackForFieldset(fieldset) {
76 for (var i=0; i<conditional_usage_keys.length; i++) { 89 for (var i=0; i<conditional_usage_keys.length; i++) {
@@ -323,12 +336,14 @@ function initialiseConditionalFieldsets() { @@ -323,12 +336,14 @@ function initialiseConditionalFieldsets() {
323 // triggers initial update - since this contains no "fixed" vars, it'll remove "unfixed" widgets 336 // triggers initial update - since this contains no "fixed" vars, it'll remove "unfixed" widgets
324 // and insert the initial (master) field. 337 // and insert the initial (master) field.
325 for (var i=0; i<fieldsets.length; i++) { 338 for (var i=0; i<fieldsets.length; i++) {
  339 + if (!checkStackForFieldset(fieldsets[i])) {
326 var undo_button = INPUT({'type':'button','value':'undo'},null); 340 var undo_button = INPUT({'type':'button','value':'undo'},null);
327 attachToElementEvent(undo_button,'click',partial(popStack, fieldsets[i])); 341 attachToElementEvent(undo_button,'click',partial(popStack, fieldsets[i]));
328 fieldsets[i].appendChild(undo_button); 342 fieldsets[i].appendChild(undo_button);
329 // initialise the stack. 343 // initialise the stack.
330 getStackForFieldset(fieldsets[i]); 344 getStackForFieldset(fieldsets[i]);
331 updateFieldset(fieldsets[i]); 345 updateFieldset(fieldsets[i]);
  346 + }
332 } 347 }
333 } 348 }
334 349