Commit d8f976150a155d588b1a7b825de98cf8ee6aabc2
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
Showing
2 changed files
with
23 additions
and
16 deletions
resources/js/jsonlookup.js
| @@ -44,7 +44,7 @@ JSONLookupWidget.prototype = { | @@ -44,7 +44,7 @@ JSONLookupWidget.prototype = { | ||
| 44 | this.triggers['add'] = null; | 44 | this.triggers['add'] = null; |
| 45 | this.triggers['remove'] = null; | 45 | this.triggers['remove'] = null; |
| 46 | 46 | ||
| 47 | - this.initialValuesLoaded = false | 47 | + this.initialValuesLoaded = false; |
| 48 | this.getValues(); | 48 | this.getValues(); |
| 49 | }, | 49 | }, |
| 50 | 50 | ||
| @@ -74,7 +74,7 @@ JSONLookupWidget.prototype = { | @@ -74,7 +74,7 @@ JSONLookupWidget.prototype = { | ||
| 74 | 74 | ||
| 75 | 'errGetValues' : function(res) { | 75 | 'errGetValues' : function(res) { |
| 76 | alert('There was an error retrieving data. Please check connectivity and try again.'); | 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 | this.renderValues(); | 78 | this.renderValues(); |
| 79 | }, | 79 | }, |
| 80 | 80 | ||
| @@ -94,7 +94,7 @@ JSONLookupWidget.prototype = { | @@ -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 | var aParam = {'value':k}; | 100 | var aParam = {'value':k}; |
| @@ -103,22 +103,21 @@ JSONLookupWidget.prototype = { | @@ -103,22 +103,21 @@ JSONLookupWidget.prototype = { | ||
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | var val = this.oValues[k]; | 105 | var val = this.oValues[k]; |
| 106 | + var sDisp = val; | ||
| 106 | if(!isUndefinedOrNull(val['display'])) { | 107 | if(!isUndefinedOrNull(val['display'])) { |
| 107 | var sDisp = val['display']; | 108 | var sDisp = val['display']; |
| 108 | - if(!isUndefinedOrNull(val['selected']) && val['selected'] == true) { | 109 | + if(!isUndefinedOrNull(val['selected']) && val['selected'] === true) { |
| 109 | val['selected'] = undefined; | 110 | val['selected'] = undefined; |
| 110 | - aParam['selected'] = 'selected'; | 111 | + aParam['selected'] = true; |
| 111 | bSelFound = true; | 112 | bSelFound = true; |
| 112 | } | 113 | } |
| 113 | - } else { | ||
| 114 | - var sDisp = val; | ||
| 115 | } | 114 | } |
| 116 | var oO = OPTION(aParam, sDisp); | 115 | var oO = OPTION(aParam, sDisp); |
| 117 | aOptions.push(oO); | 116 | aOptions.push(oO); |
| 118 | } | 117 | } |
| 119 | 118 | ||
| 120 | replaceChildNodes(this.oSelectAvail, aOptions); | 119 | replaceChildNodes(this.oSelectAvail, aOptions); |
| 121 | - if(bSelFound) this.onclickAdd(); | 120 | + if(bSelFound) { this.onclickAdd(); } |
| 122 | }, | 121 | }, |
| 123 | 122 | ||
| 124 | 'modItems' : function(type, value) { | 123 | 'modItems' : function(type, value) { |
| @@ -128,7 +127,8 @@ JSONLookupWidget.prototype = { | @@ -128,7 +127,8 @@ JSONLookupWidget.prototype = { | ||
| 128 | // check against other - if other has value, remove it from other, skip next bit | 127 | // check against other - if other has value, remove it from other, skip next bit |
| 129 | var aNewOther = []; | 128 | var aNewOther = []; |
| 130 | var exists = false; | 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 | if(this[aOtherTarget][i]!=value) { | 132 | if(this[aOtherTarget][i]!=value) { |
| 133 | aNewOther.push(this[aOtherTarget][i]); | 133 | aNewOther.push(this[aOtherTarget][i]); |
| 134 | } else { | 134 | } else { |
| @@ -143,7 +143,7 @@ JSONLookupWidget.prototype = { | @@ -143,7 +143,7 @@ JSONLookupWidget.prototype = { | ||
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | exists = false; | 145 | exists = false; |
| 146 | - for(var i=0; i<this[aTarget].length; i++) { | 146 | + for(i=0; i<this[aTarget].length; i++) { |
| 147 | if(this[aTarget][i] == value) { | 147 | if(this[aTarget][i] == value) { |
| 148 | exists = true; | 148 | exists = true; |
| 149 | break; | 149 | break; |
| @@ -194,16 +194,23 @@ JSONLookupWidget.prototype = { | @@ -194,16 +194,23 @@ JSONLookupWidget.prototype = { | ||
| 194 | 194 | ||
| 195 | 'onclickAdd' : function(e) { | 195 | 'onclickAdd' : function(e) { |
| 196 | var aCurOptions = extend([], this.oSelectAssigned.options); | 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 | this.modItems('add', o.value); | 202 | this.modItems('add', o.value); |
| 200 | - o.selected = false; | 203 | + o.setAttribute('selected', false); |
| 201 | aCurOptions.push(o); | 204 | aCurOptions.push(o); |
| 202 | 205 | ||
| 203 | if(!isUndefinedOrNull(this.triggers['add'])) { | 206 | if(!isUndefinedOrNull(this.triggers['add'])) { |
| 204 | this.triggers['add'](this.oValues[o.value]); | 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 | }, this)); | 214 | }, this)); |
| 208 | 215 | ||
| 209 | aCurOptions.sort(keyComparator('innerHTML')); | 216 | aCurOptions.sort(keyComparator('innerHTML')); |
| @@ -214,7 +221,7 @@ JSONLookupWidget.prototype = { | @@ -214,7 +221,7 @@ JSONLookupWidget.prototype = { | ||
| 214 | 'onclickRemove' : function(e) { | 221 | 'onclickRemove' : function(e) { |
| 215 | var aOptions = []; | 222 | var aOptions = []; |
| 216 | forEach(this.oSelectAssigned.options, bind(function(o) { | 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 | this.modItems('remove', o.value); | 225 | this.modItems('remove', o.value); |
| 219 | if(!isUndefinedOrNull(this.triggers['remove'])) { | 226 | if(!isUndefinedOrNull(this.triggers['remove'])) { |
| 220 | this.triggers['remove'](this.oValues[o.value]); | 227 | this.triggers['remove'](this.oValues[o.value]); |
| @@ -237,7 +244,7 @@ JSONLookupWidget.prototype = { | @@ -237,7 +244,7 @@ JSONLookupWidget.prototype = { | ||
| 237 | 244 | ||
| 238 | function initJSONLookup(name, action) { | 245 | function initJSONLookup(name, action) { |
| 239 | return function() { | 246 | return function() { |
| 240 | - _aLookupWidgets[name] = new JSONLookupWidget; | 247 | + _aLookupWidgets[name] = new JSONLookupWidget(); |
| 241 | _aLookupWidgets[name].initialize(name, action); | 248 | _aLookupWidgets[name].initialize(name, action); |
| 242 | } | 249 | } |
| 243 | } | 250 | } |
resources/js/permissions.js
| @@ -58,7 +58,7 @@ PermissionsTable.prototype = { | @@ -58,7 +58,7 @@ PermissionsTable.prototype = { | ||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | var dRow = TR(null, | 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 | map(function(aPerm) { | 62 | map(function(aPerm) { |
| 63 | var aProps = { 'type':'checkbox', | 63 | var aProps = { 'type':'checkbox', |
| 64 | 'name':'foo['+aPerm['id']+']['+oRow['type']+'][]', | 64 | 'name':'foo['+aPerm['id']+']['+oRow['type']+'][]', |