FSN#35817 Autorisaties via API2/Scaffolding

svn path=/Website/trunk/; revision=28548
This commit is contained in:
Jos Groot Lipman
2016-03-21 09:02:54 +00:00
parent fad75dd909
commit e0545a6ca4
12 changed files with 400 additions and 63 deletions

View File

@@ -16,7 +16,7 @@
<!-- #include file="../api2/model_fac_groeprechten.inc" --> <!-- #include file="../api2/model_fac_groeprechten.inc" -->
<% <%
function model_fac_functie (params) function model_fac_functie (functie_key, params)
{ {
this.table = "fac_functie"; this.table = "fac_functie";
this.primary = "fac_functie_key"; this.primary = "fac_functie_key";
@@ -77,21 +77,18 @@ function model_fac_functie (params)
} }
}; };
this.includes = { if (params.groep_key > 0)
"authorization": { {
"model": new model_fac_groeprechten(params), this.includes = {"authorization":
"joinfield": "fac_functie" { "model": new model_fac_groeprechten(params),
} "joinfield": "fac_functie"
}; }};
}
this.autfunction = "WEB_PRSMSU"; this.autfunction = "WEB_PRSMSU";
this.record_title = L("fac_functie"); this.record_title = L("fac_functie");
this.records_title = L("fac_functie_m"); this.records_title = L("fac_functie_m");
this.search = {
title : L("lcl_rechten")
};
this.edit = { this.edit = {
"modal": true "modal": true
} }
@@ -101,13 +98,4 @@ function model_fac_functie (params)
this.REST_PUT = generic_REST_PUT(this); this.REST_PUT = generic_REST_PUT(this);
this.REST_DELETE = generic_REST_DELETE(this); this.REST_DELETE = generic_REST_DELETE(this);
} }
/*
FACXSL_LCL('fac_functie_code', 'Code', 'Code', 'Kode', 'Code')
FACXSL_LCL('fac_functie_omschrijving', 'Omschrijving', 'Description', 'Umschreibung', 'Description')
FACXSL_LCL('fac_functie_module', 'Module', 'Module', 'Modul', 'Module')
FACXSL_LCL('fac_functie_info', 'Info', 'Info', 'Info', 'Info')
FACXSL_LCL('fac_functie', 'Facilitor functie', '@@', '@@', '@@')
FACXSL_LCL('fac_functie_m', 'FACILITOR functies', '@@', '@@', '@@')
*/
%> %>

View File

@@ -4,7 +4,7 @@
File: model_fac_groep.inc File: model_fac_groep.inc
Description: Vanuit CodeCharge gegenereerd model voor fac_groep Description: Model voor fac_groep
Context: Context:
@@ -15,7 +15,7 @@
<!-- #include file="model_fac_groeprechten.inc" --> <!-- #include file="model_fac_groeprechten.inc" -->
<% <%
function model_fac_groep(params) function model_fac_groep(groep_key, params)
{ {
this.table = "fac_groep"; this.table = "fac_groep";
this.primary = "fac_groep_key"; this.primary = "fac_groep_key";
@@ -56,7 +56,8 @@ function model_fac_groep(params)
"joinfield": "fac_groep" "joinfield": "fac_groep"
} }
}; };
if (params.groep_key > 0)
if (params.functie_key > 0)
{ {
this.includes["authorization"] this.includes["authorization"]
= { = {

View File

@@ -8,13 +8,14 @@
Context: Context:
Notes: Notes: fac-groeprechten heeft drie 1-op-n relaties: fac_groep,
fac_functie en ins_discipline
We *eisen* dat je altijd minstens 1 van de drie bij een
instantiatie van het model moet meegeven
*/ */
%>
<%
// fac-groeprechten heeft drie 1-op-n relaties
// params kan bevatten een group_key, een disc_key en een functie_key // params kan bevatten een group_key, een disc_key en een functie_key
//
function model_fac_groeprechten (params) function model_fac_groeprechten (params)
{ {
if (params && (params.groep_key > 0 || params.disc_key > 0 || params.functie_key > 0)) if (params && (params.groep_key > 0 || params.disc_key > 0 || params.functie_key > 0))
@@ -24,8 +25,13 @@ function model_fac_groeprechten (params)
this.table = "fac_groeprechten"; this.table = "fac_groeprechten";
this.primary = "fac_groeprechten_key"; this.primary = "fac_groeprechten_key";
this.records_name = "fac_groeprechtens"; this.records_name = "fac_groeprecht";
this.record_name = "fac_groeprechten"; this.record_name = "fac_groeprechten";
this.autfunction = "WEB_PRSSYS";
this.record_title = L("fac_groeprechten");
this.records_title = L("fac_groeprechten_m");
this.fields = { this.fields = {
"id": { "id": {
"dbs": "fac_groeprechten_key", "dbs": "fac_groeprechten_key",
@@ -40,7 +46,12 @@ function model_fac_groeprechten (params)
"dbs": "fac_groep_key", "dbs": "fac_groep_key",
"label": L("fac_groep_key"), "label": L("fac_groep_key"),
"typ": "key", "typ": "key",
"hidden_fld": true "hidden_fld": true,
"foreign": {
"tbl": "fac_groep",
"key": "fac_groep_KEY",
"desc": "fac_groep_omschrijving"
}
}, },
"fac_functie": { "fac_functie": {
"dbs": "fac_functie_key", "dbs": "fac_functie_key",
@@ -107,6 +118,14 @@ function model_fac_groeprechten (params)
+ " AND fac_groep_key = " + params.groep_key + " AND fac_groep_key = " + params.groep_key
+ ") fac_groeprechten"; + ") fac_groeprechten";
} }
if (params.functie_key > 0 && params.disc_key > 0)
{
this.tablesql = "(SELECT *"
+ " FROM fac_groeprechten"
+ " WHERE fac_functie_key = " + params.functie_key
+ " AND ins_discipline_key = " + params.disc_key
+ ") fac_groeprechten";
}
else if (params.functie_key > 0) else if (params.functie_key > 0)
{ {
this.tablesql = "(SELECT MIN(fac_groeprechten_key) fac_groeprechten_key," this.tablesql = "(SELECT MIN(fac_groeprechten_key) fac_groeprechten_key,"
@@ -120,6 +139,7 @@ function model_fac_groeprechten (params)
+ " FROM fac_groeprechten" + " FROM fac_groeprechten"
+ " WHERE fac_functie_key = " + params.functie_key + " WHERE fac_functie_key = " + params.functie_key
+ " GROUP BY fac_groep_key, fac_functie_key) fac_groeprechten"; + " GROUP BY fac_groep_key, fac_functie_key) fac_groeprechten";
this.record_title += " TODO Functie: " + params.functie_key;
this.fields["ins_discipline"] = this.fields["ins_discipline"] =
{ {
"dbs": "nn_disc", "dbs": "nn_disc",
@@ -142,6 +162,7 @@ function model_fac_groeprechten (params)
+ " FROM fac_groeprechten" + " FROM fac_groeprechten"
+ " WHERE fac_groep_key = " + params.groep_key + " WHERE fac_groep_key = " + params.groep_key
+ " GROUP BY fac_groep_key, fac_functie_key) fac_groeprechten"; + " GROUP BY fac_groep_key, fac_functie_key) fac_groeprechten";
this.record_title += " TODO Groep: " + params.groep_key;
this.fields["ins_discipline"] = this.fields["ins_discipline"] =
{ {
"dbs": "nn_disc", "dbs": "nn_disc",
@@ -156,6 +177,7 @@ function model_fac_groeprechten (params)
"columns": [ "columns": [
"id", "id",
"fac_functie", "fac_functie",
"fac_groep",
"ins_discipline", "ins_discipline",
"prs_level_read", "prs_level_read",
"prs_level_write", "prs_level_write",
@@ -163,9 +185,6 @@ function model_fac_groeprechten (params)
"alg_level_write" "alg_level_write"
] ]
}; };
this.autfunction = "WEB_PRSSYS";
this.record_title = L("fac_groeprechten");
this.records_title = L("fac_groeprechten_m");
this.REST_GET = generic_REST_GET(this); this.REST_GET = generic_REST_GET(this);
this.REST_POST = generic_REST_POST(this); this.REST_POST = generic_REST_POST(this);

View File

@@ -0,0 +1,131 @@
<% /*
$Revision$
$Id$
File: model_ins_tab_discipline.inc
Description: Model voor ins_tab_catalogus
Context:
Notes: Vooralsnog alleen gebruikt voor autorisie bewerkingen
Zou waarschijnlijk als basis kunnen dienen voor de diverse
'discipline' van modules
*/
%>
<!-- #include file="model_fac_groeprechten.inc" -->
<%
// Krijgt in params altijd een functie_key en groep_key
function model_ins_tab_discipline(disc_key, params)
{
this.table = "ins_tab_discipline";
this.primary = "ins_discipline_key";
this.records_name = "reservationcatalogs";
this.record_name = "reservationcatalog";
this.fields = {
"id": {
"dbs": "ins_discipline_key",
"label": "Key",
"typ": "key",
"required": true,
"filter": "exact",
"seq": "ins_s_ins_discipline_key"
},
"ins_discipline_module": {
"dbs": "ins_discipline_module",
"label": L("ins_discipline_module"),
"typ": "varchar",
"required": true,
"defaultvalue": "RES",
"hidden_fld": true
},
"ins_discipline_min_level": {
"dbs": "ins_discipline_min_level",
"label": L("ins_discipline_min_level"),
"typ": "key",
"required": true,
"insertonly": true,
"LOV": L("ins_discipline_min_levelLOV"),
"LOVinit": ""
},
"name": {
"dbs": "ins_discipline_omschrijving",
"label": L("ins_discipline_omschrijving"),
"typ": "varchar",
"filter": "like",
"translate": true,
"required": true
},
"sequence": {
"dbs": "ins_discipline_volgnr",
"label": L("ins_discipline_volgnr"),
"typ": "number"
},
"costtype": {
"dbs": "prs_kostensoort_key",
"label": L("prs_kostensoort_key"),
"typ": "key",
"foreign": "prs_kostensoort",
"LOVinit": ""
},
"ins_discipline_kpnverplicht": {
"dbs": "ins_discipline_kpnverplicht",
"label": L("ins_discipline_kpnverplicht"),
"typ": "check"
},
"ins_discipline_email": {
"dbs": "ins_discipline_email",
"label": L("ins_discipline_email"),
"typ": "varchar"
},
"ins_discipline_ktopercentage": {
"dbs": "ins_discipline_ktopercentage",
"label": L("ins_discipline_ktopercentage"),
"typ": "number"
},
"ins_discipline_ktodrempel": {
"dbs": "ins_discipline_ktodrempel",
"label": L("ins_discipline_ktodrempel"),
"typ": "number"
}
}
this.soft_delete = "ins_discipline_verwijder";
this.list = {
"columns": [
"id",
"ins_discipline_min_level",
"name",
"costtype",
"sequence"
]
};
this.search = {
"autosearch": true,
"filters": [
"ins_discipline_min_level",
"costtype",
"name"
]
};
if (params.groep_key > 0 && params.functie_key > 0)
{
this.includes = {"authorization":
{ "model": new model_fac_groeprechten(params),
"joinfield": "ins_discipline"
}};
}
this.autfunction = "WEB_PRSSYS";
this.record_title = L("res_v_res_catalogus"); // TODO: De generieke termen
this.records_title = L("res_v_res_catalogus_m");
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);
this.REST_DELETE = generic_REST_DELETE(this);
}
%>

View File

@@ -5,16 +5,14 @@
<!-- #include file="../api2/model_fac_functie.inc" --> <!-- #include file="../api2/model_fac_functie.inc" -->
<% <%
var fac_groep_key = getQParamInt("fac_groep", -1); var groep_key = getQParamInt("fac_groep", -1);
var disc_key = getQParamInt("disc", -1); var disc_key = getQParamInt("disc", -1);
var functie_key = getQParamInt("id", getQParamInt("fac_functie", -1)); var model = new model_fac_functie(null, { groep_key: groep_key, disc_key: disc_key });
var model = new model_fac_functie({ groep_key: fac_groep_key, disc_key: disc_key, functie_key: functie_key });
function fnrowData(oRs) function fnrowData(oRs)
{ {
var funcdisc = oRs.Fields("discipline").Value; var funcdisc = oRs.Fields("discipline").Value;
var data = {funcdisc: funcdisc, groep_key: fac_groep_key}; var data = {funcdisc: funcdisc, groep_key: groep_key};
return JSON.stringify(data); return JSON.stringify(data);
} }
@@ -29,14 +27,15 @@
"list": { "list": {
"columns": [ "columns": [
"id", "id",
"description", //"module",
"name", "name",
"authorization.ins_discipline", "description"
"authorization.prs_level_read",
"authorization.prs_level_write",
"authorization.alg_level_read",
"authorization.alg_level_write"
], ],
"orderby": [
"module",
"name",
"description"
],
"default_action": "edit_rechten", "default_action": "edit_rechten",
"fnRowData": fnrowData, "fnRowData": fnrowData,
"requires": { "requires": {
@@ -45,8 +44,19 @@
}, },
"transit": { "transit": {
"name": "fac_groep", "name": "fac_groep",
"val": fac_groep_key "val": groep_key
} }
}; };
if (groep_key > 0)
{
scf_params.list.columns =
scf_params.list.columns.concat([
"authorization.ins_discipline",
"authorization.prs_level_read",
"authorization.prs_level_write",
"authorization.alg_level_read",
"authorization.alg_level_write"
]);
}
scaffolding(model, scf_params); scaffolding(model, scf_params);
%> %>

View File

@@ -8,16 +8,19 @@ function edit_rechten(row)
var functie_key = row.getAttribute("ROWKEY"); var functie_key = row.getAttribute("ROWKEY");
var funData = eval("(" + row.getAttribute("ROWDATA") + ")"); var funData = eval("(" + row.getAttribute("ROWDATA") + ")");
if (funData.funcdisc) if (funData.groep_key > 0 && funData.funcdisc) // naar het overzicht per discipline
{ {
var url = "appl/mgt/fac_functie.asp?id=" + functie_key + "&fac_groep=" + funData.groep_key; var url = "appl/mgt/ins_tab_discipline.asp?mode=list&fac_groep=" + funData.groep_key + "&fac_functie=" + functie_key;
FcltMgr.openDetail(url, { reuse: true }); FcltMgr.openDetail(url, { reuse: true });
} }
else else if (funData.groep_key > 0)
{ {
var url = "appl/mgt/fac_functie.asp?fac_groep=" + funData.groep_key;
alert("Todo: rechten popupje groep {0} functie {1}".format(funData.groep_key, functie_key)); alert("Todo: rechten popupje groep {0} functie {1}".format(funData.groep_key, functie_key));
//FcltMgr.openDetail(url, { reuse: true }); }
else // eerst nog een groep erbij kiezen
{
var url = "appl/mgt/fac_groep.asp?fac_functie=" + functie_key;
FcltMgr.openDetail(url, { reuse: true });
} }
} }

View File

@@ -5,11 +5,17 @@
<!-- #include file="../api2/model_fac_groep.inc" --> <!-- #include file="../api2/model_fac_groep.inc" -->
<% <%
var fac_groep_key = getQParamInt("id", getQParamInt("fac_groep", -1)); var functie_key = getQParamInt("fac_functie", -1);
var disc_key = getQParamInt("disc", -1); var disc_key = getQParamInt("disc", -1);
var functie_key = getQParamInt("functie_key", -1);
var model = new model_fac_groep({ groep_key: fac_groep_key, disc_key: disc_key, functie_key: functie_key }); var model = new model_fac_groep(null, { disc_key: disc_key, functie_key: functie_key });
function fnrowData(oRs)
{
var funcdisc = oRs.Fields("discipline").Value;
var data = {funcdisc: funcdisc, functie_key: functie_key};
return JSON.stringify(data);
}
scf_params = scf_params =
{ {
@@ -29,18 +35,23 @@
"requires": { "requires": {
js: ["./fac_groep.js"] js: ["./fac_groep.js"]
}, },
"actions": [ "fnRowData": fnrowData,
{ action: "edit_rechten", caption: L("lcl_rechten") } "default_action": "edit_rechten"
] // TODO: Maar via de knop de originele mode=wrap ondersteunen
//"actions": [
// { action: "edit_rechten", caption: L("lcl_rechten") }
//]
}, },
"transit": { "transit": {
"name": "fac_functie", "name": "fac_functie",
"val": functie_key "val": functie_key
} }
}; };
if (fac_groep_key)
if (functie_key > 0)
{ {
scf_params.list.columns.concat([ scf_params.list.columns =
scf_params.list.columns.concat([
"authorization.ins_discipline", "authorization.ins_discipline",
"authorization.prs_level_read", "authorization.prs_level_read",
"authorization.prs_level_write", "authorization.prs_level_write",
@@ -48,5 +59,6 @@
"authorization.alg_level_write" "authorization.alg_level_write"
]); ]);
} }
scaffolding(model, scf_params); scaffolding(model, scf_params);
%> %>

View File

@@ -6,6 +6,20 @@
function edit_rechten(row) function edit_rechten(row)
{ {
var groep_key = row.getAttribute("ROWKEY"); var groep_key = row.getAttribute("ROWKEY");
var url = "appl/mgt/fac_functie.asp?fac_groep=" + groep_key; var grpData = eval("(" + row.getAttribute("ROWDATA") + ")");
FcltMgr.openDetail(url, { reuse: true });
if (grpData.functie_key > 0 && grpData.funcdisc) // naar het overzicht per discipline
{
var url = "appl/mgt/ins_tab_discipline.asp?mode=list&fac_groep=" + groep_key + "&fac_functie=" + grpData.functie_key;
FcltMgr.openDetail(url, { reuse: true });
}
else if (grpData.functie_key > 0)
{
alert("Todo: rechten popupje groep {0} functie {1}".format(groep_key, grpData.functie_key));
}
else // eerst nog een functie erbij kiezen
{
var url = "appl/mgt/fac_functie.asp?fac_groep=" + groep_key;
FcltMgr.openDetail(url, { reuse: true });
}
} }

View File

@@ -0,0 +1,60 @@
<%@language = "javascript" %>
<% /*
$Revision$
$Id$
File: model_fac_groeprechten.inc
Description: Dit is het model om de *rechten* van een groep voor diverse
functies te beheren.
Veronderstelt dat groep en functie al bekend zijn
Context:
Notes:
*/
%>
<!-- #include file="../scf/scaffolding.inc" -->
<!-- #include file="../mgt/mgt_tools.inc" -->
<!-- #include file="../api2/model_fac_groeprechten.inc" -->
<%
var groep_key = getQParamInt("fac_groep");
var functie_key = getQParamInt("fac_functie");
var model = new model_fac_groeprechten({ groep_key: groep_key, functie_key: functie_key });
var scf_params =
{
"search": {
"autosearch": true,
"filters": [
"module"
]
},
"list": {
"columns": [
"id",
"ins_discipline",
"prs_level_read",
"prs_level_write",
"alg_level_read",
"alg_level_write"
],
"xxxorderby": [
"module",
"name",
"description"
],
"default_action": "edit_rechten",
"requires": {
js: ["./fac_functie.js"]
}
},
"transit": {
"name": "fac_groep",
"val": groep_key
}
};
scaffolding(model, scf_params);
%>

View File

@@ -0,0 +1,74 @@
<%@language = "javascript" %>
<% /*
$Revision$
$Id$
File: ins_tab_discipline.inc
Description: Dit is het model om de *rechten* van een discipline voor diverse
functies te beheren.
Veronderstelt vooralsnog dat groep en functie al bekend zijn
Context:
Notes:
*/
%>
<!-- #include file="../scf/scaffolding.inc" -->
<!-- #include file="../mgt/mgt_tools.inc" -->
<!-- #include file="../api2/model_ins_tab_discipline.inc" -->
<%
var groep_key = getQParamInt("fac_groep", -1);
var functie_key = getQParamInt("fac_functie", -1);
var model = new model_ins_tab_discipline(null, { groep_key: groep_key, functie_key: functie_key });
function fnrowData(oRs)
{
var data = {functie_key: functie_key, groep_key: groep_key};
return JSON.stringify(data);
}
var scf_params =
{
"search": {
"autosearch": true,
"filters": [
"name"
]
},
"list": {
"columns": [
"id",
"name"
],
"xxxorderby": [
"module",
"name",
"description"
],
"default_action": "edit_rechten",
"fnRowData": fnrowData,
"requires": {
js: ["./ins_tab_discipline.js"]
}
},
"transit": {
"name": "fac_groep",
"val": groep_key
}
};
if (groep_key > 0 && functie_key > 0)
{
scf_params.list.columns =
scf_params.list.columns.concat([
//"authorization.ins_discipline",
"authorization.prs_level_read",
"authorization.prs_level_write",
"authorization.alg_level_read",
"authorization.alg_level_write"
]);
}
scaffolding(model, scf_params);
%>

View File

@@ -0,0 +1,25 @@
/*
$Revision$
$Id$
*/
function edit_rechten(row)
{
var disc_key = row.getAttribute("ROWKEY");
var grpData = eval("(" + row.getAttribute("ROWDATA") + ")");
if (grpData.functie_key > 0 && grpData.groep_key)
{
alert("Todo: rechten popupje groep {0} functie {1}".format(grpData.groep_key, grpData.functie_key));
}
else if (grpData.functie_key > 0)
{
var url = "appl/mgt/ins_tab_discipline.asp?mode=list&fac_groep=" + grpData.groep_key + "&fac_functie=" + grpData.functie_key;
FcltMgr.openDetail(url, { reuse: true });
}
else // eerst nog een functie erbij kiezen
{
var url = "appl/mgt/fac_functie.asp?fac_groep=" + grpData.groep_key;
FcltMgr.openDetail(url, { reuse: true });
}
}

View File

@@ -308,7 +308,7 @@ function buildAlgLevelLOV()
+ ";3;" + L("lcl_building") + ";3;" + L("lcl_building")
+ ";4;" + L("lcl_building") + ";4;" + L("lcl_building")
+ ";5;" + L("lcl_room") + ";5;" + L("lcl_room")
+ ";9;" + L("Geen"); + ";9;" + L("fac_functie_auth_none");
return AlgLevelLOV; return AlgLevelLOV;
} }
@@ -321,7 +321,7 @@ function buildPrsLevelLOV()
+ ";3;" + L("lcl_dep_name_level3") + ";3;" + L("lcl_dep_name_level3")
+ ";4;" + L("lcl_dep_name_level4") + ";4;" + L("lcl_dep_name_level4")
+ ";5;" + L("lcl_dep_name_level5") + ";5;" + L("lcl_dep_name_level5")
+ ";9;" + L("Geen"); + ";9;" + L("fac_functie_auth_none");
return PrsLevelLOV; return PrsLevelLOV;
} }
%> %>