Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75eeef0
commit d3755ed
Showing
83 changed files
with
36,294 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
//defer classes/ajax/AJAXReferenceControls.js | ||
var AJAXReferenceControls = Class.create({ | ||
initialize: function(tableElement, id, parentElement, refSysId, rowSysId, refQualTag) { | ||
this.refName = id; | ||
this.id = "LIST_EDIT_" + id; | ||
this.tableElement = tableElement; | ||
this.dependent = null; | ||
this.refImageFocused = false; | ||
this.refSysId = refSysId; | ||
this.rowSysId = rowSysId; | ||
this.createAdditionalValues(refQualTag); | ||
this.createInput(parentElement); | ||
this.createLookup(parentElement); | ||
this.createDependent(parentElement); | ||
}, | ||
clearDropDown: function() { | ||
if (this.ac) | ||
this.ac.clearDropDown(); | ||
}, | ||
createAdditionalValues: function(refQualTag) { | ||
this.additionalValues = {}; | ||
this.additionalValues.sys_uniqueValue = this.rowSysId; | ||
this.additionalValues.sys_target = this.tableElement.getTable().getName(); | ||
this.additionalValues.sysparm_list_edit_ref_qual_tag = refQualTag; | ||
}, | ||
createInput: function(parentElement) { | ||
this._createHidden(parentElement, this.id, ''); | ||
this.input = cel("input", parentElement); | ||
input = this.input; | ||
input.id = "sys_display." + this.id; | ||
input.onfocus = this._onFocus.bind(this); | ||
input.onkeydown = this._onKeyDown.bindAsEventListener(this); | ||
input.onkeypress = this._onKeyPress.bindAsEventListener(this); | ||
input.onkeyup = this._onKeyUp.bindAsEventListener(this); | ||
input.autocomplete = "off"; | ||
input.ac_columns = ""; | ||
input.ac_order_by = ""; | ||
}, | ||
resolveReference: function() { | ||
if (this.ac) | ||
this.ac.onBlur(); | ||
}, | ||
setDisplayValue: function(value) { | ||
this.input.value = value; | ||
}, | ||
getInput: function() { | ||
return this.input; | ||
}, | ||
getValue: function() { | ||
return gel(this.id).value; | ||
}, | ||
getDisplayValue: function() { | ||
return this.input.value; | ||
}, | ||
isResolving: function() { | ||
return (this.ac && this.ac.isResolving()); | ||
}, | ||
setResolveCallback: function(f) { | ||
if (!this.ac) | ||
return; | ||
this.ac.setResolveCallback(f); | ||
}, | ||
createLookup: function(parent) { | ||
var image = createImage("images/reference_list.gifx", "Lookup using list"); | ||
image.id = "ref_list." + this.id; | ||
image.onclick = this._refListOpen.bindAsEventListener(this); | ||
image.onfocus = this._onRefImageFocus.bindAsEventListener(this); | ||
image.onblur = this._onRefImageBlur.bindAsEventListener(this); | ||
image.style.marginLeft = "5px"; | ||
parent.appendChild(image); | ||
}, | ||
createDependent: function(parent) { | ||
if (!this.tableElement.isDependent()) | ||
return; | ||
var input = cel("input"); | ||
input.type = "hidden"; | ||
this.dependent = "sys_dependent"; | ||
input.id = this.tableElement.getTable().getName() + "." + this.dependent; | ||
input.name = input.id; | ||
parent.appendChild(input); | ||
this.dependentInput = input; | ||
}, | ||
setRecord: function(record) { | ||
this.record = record; | ||
}, | ||
_createHidden: function(parent, id, value) { | ||
var input = cel("input"); | ||
input.type = "hidden"; | ||
input.id = id; | ||
input.value = value; | ||
parent.appendChild(input); | ||
return input; | ||
}, | ||
_setDependent: function() { | ||
if (this.dependent == null) | ||
return; | ||
this.dependentInput.value = this.record.getValue(this.tableElement.getDependent()); | ||
}, | ||
_onFocus: function(evt) { | ||
if (this.ac) | ||
return; | ||
this._setDependent(); | ||
var dep = ''; | ||
if (this.dependentInput) | ||
dep = "sys_dependent"; | ||
this.ac = new AJAXReferenceCompleter(this.input, this.id, dep); | ||
this.ac.elementName = this.refName; | ||
this.ac.referenceSelect(this.refSysId, this.input.value); | ||
this.ac.clearDerivedFields = false; | ||
for (var n in this.additionalValues) | ||
this.ac.setAdditionalValue(n, this.additionalValues[n]); | ||
}, | ||
_onKeyDown: function(evt) { | ||
acReferenceKeyDown(this.input, evt); | ||
}, | ||
_onKeyPress: function(evt) { | ||
acReferenceKeyPress(this.input, evt); | ||
}, | ||
_onKeyUp: function(evt) { | ||
acReferenceKeyUp(this.input, evt); | ||
}, | ||
_refListOpen: function(evt) { | ||
if (!this.refImageFocused) | ||
return false; | ||
var te = this.tableElement; | ||
this._setDependent(); | ||
var url = reflistOpenUrl(this.refName, this.id, te.getName(), te.getReference()); | ||
for (var n in this.additionalValues) | ||
url += "&" + n + "=" + encodeText(this.additionalValues[n]); | ||
if (this.dependentInput) | ||
url += "&sysparm_dependent=" + escape(this.dependentInput.value); | ||
popupOpenStandard(url, "lookup"); | ||
return false; | ||
}, | ||
_onRefImageFocus: function(e) { | ||
this.refImageFocused = true; | ||
}, | ||
_onRefImageBlur: function(e) { | ||
this.refImageFocused = false; | ||
}, | ||
type: function() { | ||
return "AJAXReferenceControls"; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
//defer classes/ActionSecurity.js | ||
var ActionSecurity = Class.create({ | ||
initialize: function() { | ||
}, | ||
execute: function(form) { | ||
var ids = form.sysparm_checked_items.value; | ||
var table = form.sys_target.value; | ||
var action = form.sys_action.value; | ||
var map = this._canExecute(ids, table, action); | ||
map = map[action]; | ||
var yes = 0; | ||
var no = 0; | ||
for (key in map) { | ||
if (map[key] == 'true') | ||
yes++; | ||
else | ||
no++; | ||
} | ||
if (no == 0) | ||
return true; | ||
if (yes == 0) { | ||
this._alertNone(no); | ||
return false; | ||
} | ||
var answer = this._alertPartial(yes, no); | ||
if (answer) { | ||
var al = new Array(); | ||
for (key in map) | ||
if (map[key] == 'true') | ||
al.push(key); | ||
form.sysparm_checked_items.value = al.join(','); | ||
} | ||
return answer; | ||
}, | ||
pruneSelect: function(select, form) { | ||
var ids = getChecked(form); | ||
if (ids == '') { | ||
this._disableAll(select); | ||
select.focus(); // IE6 closes the dropdown after we've changed it so we'll help it open it | ||
return; | ||
} | ||
this._enableAll(select); | ||
var options = select.options; | ||
var actionList = new Array(); | ||
for (var i = 0; i < options.length; i++) { | ||
var cond = options[i].getAttribute('gsft_condition'); | ||
if (cond != 'true') | ||
continue; | ||
actionList.push(options[i].getAttribute('gsft_id')); | ||
} | ||
if (actionList.length == 0) | ||
return; | ||
var table = form.sys_target.value; | ||
var map = this._canExecute(ids, table, actionList.join(',')); | ||
for (var i = 0; i < options.length; i++) { | ||
var cond = options[i].getAttribute('gsft_condition'); | ||
if (cond != 'true') | ||
continue; | ||
var submap = map[options[i].getAttribute('gsft_id')]; | ||
this._checkMap(submap, options[i]); | ||
} | ||
select.focus(); // IE6 closes the dropdown after we've changed it so we'll help it open it | ||
}, | ||
_disableAll: function(select) { | ||
var options = select.options; | ||
for (var i =0; i < options.length; i++) { | ||
var row = options[i].getAttribute('gsft_row'); | ||
if (row != 'true') | ||
continue; | ||
this._disableOption(options[i]); | ||
} | ||
}, | ||
_disableOption: function(option) { | ||
option.disabled = true; | ||
option.style.color = '#777'; | ||
option.innerHTML = ' ' + option.getAttribute('gsft_base_label'); | ||
}, | ||
_enableAll: function(select) { | ||
var options = select.options; | ||
for (var i =0; i < options.length; i++) { | ||
var row = options[i].getAttribute('gsft_row'); | ||
if (row != 'true') | ||
continue; | ||
this._enableOption(options[i]); | ||
} | ||
}, | ||
_enableOption : function(option) { | ||
option.disabled = false; | ||
option.style.color = ''; | ||
}, | ||
_checkMap: function(map, option) { | ||
var yes = 0; | ||
var no = 0; | ||
var legit = new Array(); | ||
for (key in map) | ||
if (map[key] == 'true') { | ||
yes++; | ||
legit.push(key); | ||
} else | ||
no++; | ||
if (yes == 0) { | ||
this._disableOption(option); | ||
return; | ||
} | ||
this._enableOption(option); | ||
if (no == 0) { | ||
option.innerHTML = ' ' + option.getAttribute('gsft_base_label'); | ||
option.setAttribute('gsft_allow', legit.join(',')); | ||
return; | ||
} | ||
option.innerHTML = ' ' + option.getAttribute('gsft_base_label') + ' (' + yes + ' of ' + (yes + no) + ')'; | ||
option.setAttribute('gsft_allow', legit.join(',')); | ||
}, | ||
_alertNone: function(no) { | ||
var m = 'Security does not allow the execution of that action against the specified record'; | ||
if (no > 1) | ||
m = m + 's'; | ||
alert(m); | ||
}, | ||
_alertPartial: function(yes, no) { | ||
var total = yes + no; | ||
var m = 'Security allows the execution of that action against ' + yes + ' of ' + total + ' records. Proceed?'; | ||
return confirm(m); | ||
}, | ||
_canExecute: function(ids, table, action_list) { | ||
var ajax = new GlideAjax("AJAXActionSecurity"); | ||
ajax.addParam("sysparm_checked_items", ids); | ||
ajax.addParam("sys_target", table); | ||
ajax.addParam("sys_action", action_list); | ||
var xml = ajax.getXMLWait(); | ||
var answer = new Object(); | ||
var al = action_list.split(','); | ||
for (var n =0; n < al.length; n++) { | ||
var work = new Object(); | ||
var root = xml.getElementsByTagName("action_"+ al[n])[0]; | ||
var keys = root.childNodes; | ||
for (var i =0; i < keys.length; i++) { | ||
var key = keys[i].getAttribute('sys_id'); | ||
work[key] = keys[i].getAttribute('can_execute'); | ||
} | ||
answer[al[n]] = work; | ||
} | ||
return answer; | ||
} | ||
}); |
Oops, something went wrong.