Files
Facilitor/APPL/Shared/autorisatiegroepselector.inc
Koen Reefman abfe64e292 FCLT#74626 nog wat safe.htmlattr's
svn path=/Website/trunk/; revision=57975
2022-11-14 10:29:33 +00:00

175 lines
7.8 KiB
C++

<% /*
$Revision$
$Id$
File: autorisatiegroepelector.inc
Description: Algemene interface functie om een autorisatiegroep suggestbox te maken
Deze moet je kunnen includen en aanroepen.
Resulteert dan uiteindelijk in een zichtbaar textveld aangemaakt die de autorisatiegroep-omschrijving bevat (autorisatiegroep veld)
en een hidden keyveld die de key van de autorisatiegroep-key bevat (autorisatiekey veld).
Het autorisatiecode veld heeft geen naam en wordt niet meegesubmit.
Het autorisatiekey veld heeft een naam en wordt meegesubmit.
Het resultaat heeft de vorm "[<td>label</td><td>]selectveld[</td>]"
parameters: fieldName: veldnaam van het autorisatiegroepkey veld. Dit veld wordt gesubmit.
objectName: naam van het suggest object dat wordt aangemaakt.
params: object met meegegeven parameters.
autorisatiegroepKey: initiële key waarde van de autorisatiegroep die ingevuld moet worden.
multitoggle: Sta multi-toggle toe
idadd: Identieficatie verschil bij gebruik van meerdere autorisatiegroepselectoren
label: label dat voor het autorisatiegroep veld wordt weergegeven.
filtercode: extra filtercode voor de query die gebruikt wordt voor de suggest.
onChange: onchange op het textveld.
trclass: wordt ook op de <tr> gezet.
isBad: boolean die aangeeft dat het autorisatiegroep veld als ongeldig
en leeg weergegeven moet worden (true|false(default)).
readonly: geeft aan of het autorisatiegroep veld readonly weergegeven moet worden (true|false(default)).
extracode: filtercode van extra filter clausule voor initiële waarde.
suppressEmpty Onderdrukt het veld helemaal indien EN readonly EN leeg.
noBad Als autorisatiegroepKey niet gevonden binnen filter dan veld leeglaten
(in plaats van standaard gedrag: naam wel opzoeken maar 'Bad' maken).
*/ %>
<!-- #include file="./Suggest/autorisatiegroepFilter.inc" -->
<%
FCLTHeader.Requires({ plugins: ["suggest", "jQuery"], js: ["iface.js"] });
function FCLTautorisatiegroepselector(fieldName, objectName, params)
{
params = params || {};
if (!(params.autorisatiegroepKey > 0) && params.readonly && params.suppressEmpty)
return;
var idadd = params.idadd || "";
var lwhenEmpty = (params.whenEmpty != null ? params.whenEmpty : (params.readonly ? L("lcl_select_readonly") : L("lcl_select_auth_group")));
var lautorisatiegroep = "";
var isBad = false;
if (params.autorisatiegroepKey && params.autorisatiegroepKey > 0)
{
var filt_params = params;
if (params.urlAdd)
{
for (i in params.urlAdd)
{
filt_params[params.urlAdd[i].urlParam] = params.urlAdd[i].init;
}
}
var filtClause = getFiltClauseAutorisatiegroep(params.filtercode, filt_params);
var extraInf = getExtraInfAutorisatiegroep(params.extracode);
// Is er een initiele waarde meegegeven? Zoek dan de omschrijving erbij
var sql = "SELECT fg.fac_groep_key, fg.fac_groep_omschrijving autorisatiegroep"
+ extraInf.selectstr
+ " FROM fac_groep fg"
+ extraInf.fromstr
+ " WHERE fg.fac_groep_key = " + params.autorisatiegroepKey
+ filtClause
+ extraInf.wherestr
+ " ORDER BY fg.fac_groep_omschrijving";
var oRs = Oracle.Execute(sql);
if (oRs.Eof) // Misschien (tegenwoordig) uit scope?
{ // Probeer dan maar zonder extra 'where's
oRs.Close(); // close the recordset, oRs will be reused
isBad = true;
sql = "SELECT fg.fac_groep_key, fg.fac_groep_omschrijving autorisatiegroep"
+ extraInf.selectstr
+ " FROM fac_groep fg"
+ extraInf.fromstr
+ " WHERE fg.fac_groep_key = " + params.autorisatiegroepKey
+ extraInf.wherestr
+ " ORDER BY fg.fac_groep_omschrijving";
oRs = Oracle.Execute(sql);
}
if (isBad && params.noBad)
{
isBad = false;
params.autorisatiegroepKey = -1;
}
else
{
lautorisatiegroep = oRs("autorisatiegroep").Value;
}
oRs.Close();
}
// Bouw de url voor de Autorisatiegroepen query op
var autorizationQueryUrl = rooturl + "/appl/shared/suggest/SuggestAutorisatiegroep.asp?1=1"
+ (params.autorisatiegroepKey > 0? "&autorisatiegroepKey=" + params.autorisatiegroepKey : "") // Kan ook met urlAdd meegegeven worden
+ (params.filtercode? "&filtcode=" + params.filtercode : "")
+ (params.extracode? "&extracode=" + params.extracode : "");
if (params.label)
{ %>
<tr <%=params.trclass?"class='" + params.trclass+"'":""%>>
<td class="label">
<label class='selector' for='<%=fieldName%>_show'><%=params.label%></label>
</td>
<td>
<%
}
if (params.readonly) { %>
<span id="<%=fieldName%>_show" class="fld readonly">
<%=safe.html(lautorisatiegroep)%>
</span>
<% } else {
// data-role none because we want to wrap the input field ourselves (because of "suggestKlikker" placement)
if (typeof mobile != "undefined")
{ %>
<div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset">
<% } %>
<input id="<%=fieldName%>_show" class="fld<%=params.required? " required" : ""%>" value="<%=safe.htmlattr(lautorisatiegroep)%>" placeholder="<%=safe.htmlattr(lwhenEmpty)%>"
<%=(typeof mobile != "undefined" ? "data-role=\"none\"" : "")%> <%=params.onChange ? " sgonChange='" + params.onChange + "'" : ""%>>
<% if (typeof mobile != "undefined")
{ %>
</div>
<% }
} %>
<input type="hidden" id="<%=fieldName%>" name="<%=fieldName%>" value="<%=params.autorisatiegroepKey%>">
<%
if (params.label)
{ %>
</td>
</tr>
<%
}
if (!params.readonly)
{
if (params.urlAdd)
{
var urlAddTxt = "[";
for (var i = 0; i < params.urlAdd.length; i++)
{
urlAddTxt += (i > 0? ", " : "") + "{ urlParam: \"" + params.urlAdd[i].urlParam + "\", field: \"" + params.urlAdd[i].field + "\" }";
}
urlAddTxt += "]"
}
%>
<script type="text/javascript">
$(function()
{
<%=objectName%><%=idadd%> = new Suggest(
{ objectName: "<%=objectName%><%=idadd%>",
queryField: $("#<%=fieldName%>_show")[0],
queryUrl: "<%=autorizationQueryUrl%>",
icon: "fa-users",
initKey: <%=params.autorisatiegroepKey? params.autorisatiegroepKey : -1%>,
noJustOne: true, // Controleer niet of er maar één waarde is die geselecteerd moet worden.
keyField: $("#<%=fieldName%>")[0]
<%=params.multitoggle? ", multitoggle: true" : ""%>
<%=params.urlAdd? ", urlAdd: " + urlAddTxt : ""%>
<%=params.isBad? ", isBad: true": ""%>
<%=params.readonly? ", fieldReadonly: true": ""%>
});
<% if (isBad)
{ %>
<%=objectName%><%=idadd%>.isBad();
<% }
if (params.hidden)
{ %>
<%=objectName%><%=idadd%>.makeHidden();
<% } %>
});
</script>
<%
}
}
%>