FSN#35817 Autorisaties via API2/Scaffolding
svn path=/Website/trunk/; revision=28565
This commit is contained in:
@@ -22,6 +22,14 @@ function model_fac_functie (functie_key, params)
|
||||
this.primary = "fac_functie_key";
|
||||
this.records_name = "fac_functies";
|
||||
this.record_name = "fac_functie";
|
||||
var module = null;
|
||||
if (params.disc_key > 0)
|
||||
{
|
||||
var sql = "SELECT ins_discipline_module FROM ins_tab_discipline WHERE ins_discipline_key = " + params.disc_key;
|
||||
var oRs = Oracle.Execute(sql);
|
||||
var module = oRs("ins_discipline_module").Value;
|
||||
oRs.Close();
|
||||
}
|
||||
this.fields = {
|
||||
"id": {
|
||||
"dbs": "fac_functie_key",
|
||||
@@ -36,6 +44,7 @@ function model_fac_functie (functie_key, params)
|
||||
"label": L("fac_functie_module"),
|
||||
"readonly": true,
|
||||
"typ": "varchar",
|
||||
"filterdefault": module?":!"+module:null,
|
||||
"foreign": {
|
||||
"tbl": "fac_module",
|
||||
"key": "fac_module_name",
|
||||
@@ -77,7 +86,7 @@ function model_fac_functie (functie_key, params)
|
||||
}
|
||||
};
|
||||
|
||||
if (params.groep_key > 0)
|
||||
if (params.groep_key > 0 || params.disc_key > 0)
|
||||
{
|
||||
this.includes = {"authorization":
|
||||
{ "model": new model_fac_groeprechten(params),
|
||||
@@ -93,7 +102,13 @@ function model_fac_functie (functie_key, params)
|
||||
"modal": true
|
||||
}
|
||||
|
||||
this.REST_GET = generic_REST_GET(this);
|
||||
var xparams = null;
|
||||
if (module)
|
||||
xparams = { GET: { wheres: ["fac_functie_module = " + safe.quoted_sql(module),
|
||||
"fac_functie_discipline = 1" // dan ook alleen de discipline gebonden functies
|
||||
] } }
|
||||
|
||||
this.REST_GET = generic_REST_GET(this, xparams);
|
||||
this.REST_POST = generic_REST_POST(this);
|
||||
this.REST_PUT = generic_REST_PUT(this);
|
||||
this.REST_DELETE = generic_REST_DELETE(this);
|
||||
|
||||
@@ -15,7 +15,18 @@
|
||||
|
||||
*/
|
||||
|
||||
// params kan bevatten een group_key, een disc_key en een functie_key
|
||||
/* params kan bevatten een groep_key, een disc_key en een functie_key
|
||||
We ondersteunen de volgende combinatiees:
|
||||
groep_key functie_key disc_key
|
||||
- - - Niet ondersteund, te complex
|
||||
- - X Ja
|
||||
- X - Ja
|
||||
- X X Ja
|
||||
X - - Ja
|
||||
X - X Niet ondersteund. Als je een groep of disc hebt moet je eerst functie kiezen
|
||||
X X - Ja
|
||||
X X X Niet ondersteund (dan krijg je een detail popupje)
|
||||
*/
|
||||
function model_fac_groeprechten (params)
|
||||
{
|
||||
if (params && (params.groep_key > 0 || params.disc_key > 0 || params.functie_key > 0))
|
||||
@@ -109,6 +120,13 @@ function model_fac_groeprechten (params)
|
||||
return nn_disc;
|
||||
return "";
|
||||
};
|
||||
function fnGroep(oRs, field, model)
|
||||
{
|
||||
var nn_grp = oRs(api2.sqlfield_alias(model, "fac_groep")).Value;
|
||||
if (nn_grp > 0)
|
||||
return nn_grp;
|
||||
return "";
|
||||
};
|
||||
|
||||
if (params.functie_key > 0 && params.groep_key > 0)
|
||||
{
|
||||
@@ -172,6 +190,29 @@ function model_fac_groeprechten (params)
|
||||
"hidden_fld": true
|
||||
};
|
||||
}
|
||||
else // moet disc_key wel gevuld zijn
|
||||
{
|
||||
this.tablesql = "(SELECT MIN(fac_groeprechten_key) fac_groeprechten_key,"
|
||||
+ " COUNT(fac_groep_key) nn_groep,"
|
||||
+ " fac_functie_key,"
|
||||
+ " ins_discipline_key,"
|
||||
+ " MIN(fac_gebruiker_prs_level_read) fac_gebruiker_prs_level_read,"
|
||||
+ " MIN(fac_gebruiker_prs_level_write) fac_gebruiker_prs_level_write,"
|
||||
+ " MIN(fac_gebruiker_alg_level_read) fac_gebruiker_alg_level_read,"
|
||||
+ " MIN(fac_gebruiker_alg_level_write) fac_gebruiker_alg_level_write"
|
||||
+ " FROM fac_groeprechten"
|
||||
+ " WHERE ins_discipline_key = " + params.disc_key
|
||||
+ " GROUP BY ins_discipline_key, fac_functie_key) fac_groeprechten";
|
||||
this.record_title += " TODO Disc: " + params.groep_key;
|
||||
this.fields["fac_groep"] =
|
||||
{
|
||||
"dbs": "nn_groep",
|
||||
"label": L("fac_groep_key"),
|
||||
"typ": "number",
|
||||
val: fnGroep,
|
||||
"hidden_fld": true
|
||||
};
|
||||
}
|
||||
|
||||
this.list = {
|
||||
"columns": [
|
||||
|
||||
@@ -31,13 +31,17 @@ function model_ins_tab_discipline(disc_key, params)
|
||||
"filter": "exact",
|
||||
"seq": "ins_s_ins_discipline_key"
|
||||
},
|
||||
"ins_discipline_module": {
|
||||
"module": {
|
||||
"dbs": "ins_discipline_module",
|
||||
"label": L("ins_discipline_module"),
|
||||
"typ": "varchar",
|
||||
"required": true,
|
||||
"defaultvalue": "RES",
|
||||
"hidden_fld": true
|
||||
"hidden_fld": true,
|
||||
"foreign": {
|
||||
"tbl": "fac_module",
|
||||
"key": "fac_module_name",
|
||||
"desc": "fac_module_name || ' - ' || fac_module_remark"
|
||||
}
|
||||
},
|
||||
"ins_discipline_min_level": {
|
||||
"dbs": "ins_discipline_min_level",
|
||||
@@ -123,6 +127,7 @@ function model_ins_tab_discipline(disc_key, params)
|
||||
var xparams = null;
|
||||
if (params.functie_key > 0)
|
||||
xparams = { GET: { wheres: ["ins_discipline_module IN (SELECT fac_functie_module FROM fac_functie WHERE fac_functie_key = " + params.functie_key + ")"] } }
|
||||
|
||||
this.REST_GET = generic_REST_GET(this, xparams);
|
||||
this.REST_POST = generic_REST_POST(this);
|
||||
this.REST_PUT = generic_REST_PUT(this);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
function fnrowData(oRs)
|
||||
{
|
||||
var funcdisc = oRs.Fields("discipline").Value;
|
||||
var data = {funcdisc: funcdisc, groep_key: groep_key};
|
||||
var data = {funcdisc: funcdisc, groep_key: groep_key, disc_key: disc_key};
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
{
|
||||
"search": {
|
||||
"autosearch": true,
|
||||
"labels" : [],
|
||||
"filters": [
|
||||
"module"
|
||||
]
|
||||
@@ -43,12 +44,13 @@
|
||||
}
|
||||
},
|
||||
"transit": {
|
||||
"name": "fac_groep",
|
||||
"val": groep_key
|
||||
"name": groep_key>0?"fac_groep":"disc",
|
||||
"val": groep_key>0?groep_key:disc_key
|
||||
}
|
||||
};
|
||||
if (groep_key > 0)
|
||||
{
|
||||
scf_params.search.labels.push({ "lbl": "GROEP", "txt" : groep_key });
|
||||
scf_params.list.columns =
|
||||
scf_params.list.columns.concat([
|
||||
"authorization.ins_discipline",
|
||||
@@ -58,5 +60,17 @@
|
||||
"authorization.alg_level_write"
|
||||
]);
|
||||
}
|
||||
if (disc_key > 0)
|
||||
{
|
||||
scf_params.search.labels.push({ "lbl": "DISC", "txt" : disc_key });
|
||||
scf_params.list.columns =
|
||||
scf_params.list.columns.concat([
|
||||
"authorization.fac_groep",
|
||||
"authorization.prs_level_read",
|
||||
"authorization.prs_level_write",
|
||||
"authorization.alg_level_read",
|
||||
"authorization.alg_level_write"
|
||||
]);
|
||||
}
|
||||
scaffolding(model, scf_params);
|
||||
%>
|
||||
|
||||
@@ -19,7 +19,7 @@ function edit_rechten(row)
|
||||
}
|
||||
else // eerst nog een groep erbij kiezen
|
||||
{
|
||||
var url = "appl/mgt/fac_groep.asp?fac_functie=" + functie_key;
|
||||
var url = "appl/mgt/fac_groep.asp?fac_functie=" + functie_key + "&disc=" + funData.disc_key;
|
||||
FcltMgr.openDetail(url, { reuse: true });
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
{
|
||||
"search": {
|
||||
"autosearch": true,
|
||||
"labels" : [],
|
||||
"filters": [
|
||||
"name",
|
||||
"remark"
|
||||
@@ -31,6 +32,7 @@
|
||||
"id",
|
||||
"name",
|
||||
"remark",
|
||||
// Leuk maar veel te veel "users.user",
|
||||
"substitutes"],
|
||||
"requires": {
|
||||
js: ["./fac_groep.js"]
|
||||
@@ -50,6 +52,7 @@
|
||||
|
||||
if (functie_key > 0)
|
||||
{
|
||||
scf_params.search.labels.push({ "lbl": "FUNCTIE", "txt" : functie_key });
|
||||
scf_params.list.columns =
|
||||
scf_params.list.columns.concat([
|
||||
"authorization.ins_discipline",
|
||||
|
||||
@@ -25,7 +25,10 @@
|
||||
|
||||
function fnrowData(oRs)
|
||||
{
|
||||
var data = {functie_key: functie_key, groep_key: groep_key};
|
||||
var data = { functie_key: functie_key,
|
||||
groep_key: groep_key,
|
||||
module: oRs.Fields("module").Value
|
||||
};
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
|
||||
@@ -34,7 +37,8 @@
|
||||
"search": {
|
||||
"autosearch": true,
|
||||
"filters": [
|
||||
"name"
|
||||
"name",
|
||||
"module"
|
||||
]
|
||||
},
|
||||
"list": {
|
||||
|
||||
@@ -19,7 +19,7 @@ function edit_rechten(row)
|
||||
}
|
||||
else // eerst nog een functie erbij kiezen
|
||||
{
|
||||
var url = "appl/mgt/fac_functie.asp?fac_groep=" + grpData.groep_key;
|
||||
var url = "appl/mgt/fac_functie.asp?disc=" + disc_key;
|
||||
FcltMgr.openDetail(url, { reuse: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,8 +339,12 @@ function scf_RWFIELDTR(model, fld, val, key, params)
|
||||
if (val && val.id && params.required)
|
||||
emptyOption = null;
|
||||
}
|
||||
if (val && typeof val == "object" && "id" in val)
|
||||
{ // dereference
|
||||
val = val.id;
|
||||
}
|
||||
FCLTselector(fld, sql, { label: field.label,
|
||||
initKey: params.search?null:(val?val.id:null),
|
||||
initKey: val||null,
|
||||
emptyOption: emptyOption,
|
||||
emptyKey: (field.typ=="key"?-1:""),
|
||||
readonly: (foreign.readonly?foreign.readonly:false),
|
||||
|
||||
@@ -18,7 +18,7 @@ function scaffolding_search(model, scf_params)
|
||||
|
||||
if ("search" in model)
|
||||
{
|
||||
scf_params.search.title = scf_params.search.title || model.search.title;
|
||||
scf_params.search.title = scf_params.search.title || model.search.title || model.records_title;
|
||||
scf_params.search.filters = scf_params.search.filters || model.search.filters || [];
|
||||
}
|
||||
FCLTHeader.Requires({plugins:[],
|
||||
@@ -167,6 +167,14 @@ function scaffolding_search(model, scf_params)
|
||||
|
||||
BLOCK_START("searchtable", L("lcl_filterblok") + est_title);
|
||||
|
||||
if (scf_params.search.labels)
|
||||
{
|
||||
for (var i=0; i < scf_params.search.labels.length; i++)
|
||||
{
|
||||
ROFIELDTR("fldtxt", scf_params.search.labels[i].lbl, scf_params.search.labels[i].txt);
|
||||
}
|
||||
}
|
||||
|
||||
var includefilters = [];
|
||||
for (var i=0; i < scf_params.search.filters.length; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user