Commit d8f976150a155d588b1a7b825de98cf8ee6aabc2

Authored by bryndivey
1 parent 7223d8f5

Fixed the permissions screen


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5768 c91229c3-7414-0410-bfa2-8a42b809f60b
resources/js/jsonlookup.js
... ... @@ -44,7 +44,7 @@ JSONLookupWidget.prototype = {
44 44 this.triggers['add'] = null;
45 45 this.triggers['remove'] = null;
46 46  
47   - this.initialValuesLoaded = false
  47 + this.initialValuesLoaded = false;
48 48 this.getValues();
49 49 },
50 50  
... ... @@ -74,7 +74,7 @@ JSONLookupWidget.prototype = {
74 74  
75 75 'errGetValues' : function(res) {
76 76 alert('There was an error retrieving data. Please check connectivity and try again.');
77   - this.oValues = {'off':'-- Error fetching values --'}
  77 + this.oValues = {'off':'-- Error fetching values --'};
78 78 this.renderValues();
79 79 },
80 80  
... ... @@ -94,7 +94,7 @@ JSONLookupWidget.prototype = {
94 94 }
95 95 }
96 96  
97   - if(found) continue;
  97 + if(found) { continue; }
98 98  
99 99  
100 100 var aParam = {'value':k};
... ... @@ -103,22 +103,21 @@ JSONLookupWidget.prototype = {
103 103 }
104 104  
105 105 var val = this.oValues[k];
  106 + var sDisp = val;
106 107 if(!isUndefinedOrNull(val['display'])) {
107 108 var sDisp = val['display'];
108   - if(!isUndefinedOrNull(val['selected']) && val['selected'] == true) {
  109 + if(!isUndefinedOrNull(val['selected']) && val['selected'] === true) {
109 110 val['selected'] = undefined;
110   - aParam['selected'] = 'selected';
  111 + aParam['selected'] = true;
111 112 bSelFound = true;
112 113 }
113   - } else {
114   - var sDisp = val;
115 114 }
116 115 var oO = OPTION(aParam, sDisp);
117 116 aOptions.push(oO);
118 117 }
119 118  
120 119 replaceChildNodes(this.oSelectAvail, aOptions);
121   - if(bSelFound) this.onclickAdd();
  120 + if(bSelFound) { this.onclickAdd(); }
122 121 },
123 122  
124 123 'modItems' : function(type, value) {
... ... @@ -128,7 +127,8 @@ JSONLookupWidget.prototype = {
128 127 // check against other - if other has value, remove it from other, skip next bit
129 128 var aNewOther = [];
130 129 var exists = false;
131   - for(var i=0; i<this[aOtherTarget].length; i++) {
  130 + var i = 0;
  131 + for(i=0; i<this[aOtherTarget].length; i++) {
132 132 if(this[aOtherTarget][i]!=value) {
133 133 aNewOther.push(this[aOtherTarget][i]);
134 134 } else {
... ... @@ -143,7 +143,7 @@ JSONLookupWidget.prototype = {
143 143 }
144 144  
145 145 exists = false;
146   - for(var i=0; i<this[aTarget].length; i++) {
  146 + for(i=0; i<this[aTarget].length; i++) {
147 147 if(this[aTarget][i] == value) {
148 148 exists = true;
149 149 break;
... ... @@ -194,16 +194,23 @@ JSONLookupWidget.prototype = {
194 194  
195 195 'onclickAdd' : function(e) {
196 196 var aCurOptions = extend([], this.oSelectAssigned.options);
197   - forEach(this.oSelectAvail.options, bind(function(o) {
198   - if(o.selected == 'selected' || o.selected == true) {
  197 + forEach(this.oSelectAvail.options, bind(
  198 + function(o) {
  199 + try {
  200 + var a = o.selected;
  201 + if(a == 'selected' || a === true) {
199 202 this.modItems('add', o.value);
200   - o.selected = false;
  203 + o.setAttribute('selected', false);
201 204 aCurOptions.push(o);
202 205  
203 206 if(!isUndefinedOrNull(this.triggers['add'])) {
204 207 this.triggers['add'](this.oValues[o.value]);
205 208 }
206 209 }
  210 + } catch(e) {
  211 + log(o.value);
  212 + log(e.description);
  213 + }
207 214 }, this));
208 215  
209 216 aCurOptions.sort(keyComparator('innerHTML'));
... ... @@ -214,7 +221,7 @@ JSONLookupWidget.prototype = {
214 221 'onclickRemove' : function(e) {
215 222 var aOptions = [];
216 223 forEach(this.oSelectAssigned.options, bind(function(o) {
217   - if(o.selected == 'selected' || o.selected == true) {
  224 + if(o.selected == 'selected' || o.selected === true) {
218 225 this.modItems('remove', o.value);
219 226 if(!isUndefinedOrNull(this.triggers['remove'])) {
220 227 this.triggers['remove'](this.oValues[o.value]);
... ... @@ -237,7 +244,7 @@ JSONLookupWidget.prototype = {
237 244  
238 245 function initJSONLookup(name, action) {
239 246 return function() {
240   - _aLookupWidgets[name] = new JSONLookupWidget;
  247 + _aLookupWidgets[name] = new JSONLookupWidget();
241 248 _aLookupWidgets[name].initialize(name, action);
242 249 }
243 250 }
... ...
resources/js/permissions.js
... ... @@ -58,7 +58,7 @@ PermissionsTable.prototype = {
58 58 }
59 59  
60 60 var dRow = TR(null,
61   - TD(null, SPAN({'class':'descriptiveText'}, oRow['type'][0].toUpperCase() + oRow['type'].substring(1) + ': '), oRow['name']),
  61 + TD(null, SPAN({'class':'descriptiveText'}, oRow['type'].substring(0,1).toUpperCase() + oRow['type'].substring(1) + ': '), oRow['name']),
62 62 map(function(aPerm) {
63 63 var aProps = { 'type':'checkbox',
64 64 'name':'foo['+aPerm['id']+']['+oRow['type']+'][]',
... ...