FSN#38299 Flexkenmerken via de API kunnen bewerken

svn path=/Website/trunk/; revision=33406
This commit is contained in:
Jos Groot Lipman
2017-04-04 14:06:34 +00:00
parent a719867d84
commit b16684eecb
27 changed files with 76 additions and 60 deletions

View File

@@ -718,6 +718,8 @@ api2 = {
continue;
if (field.readonly)
continue;
if (field.insertonly && !params.isNew)
continue;
if (field.fnval)
var newval = field.fnval(jsondata);
@@ -1188,7 +1190,7 @@ api2 = {
},
error: function (code, msg)
{
abort_with_warning(msg, code)
abort_with_warning(msg, code);
},
find_fieldindex_by_dbsname: function(array, value)
{
@@ -1493,7 +1495,7 @@ function generic_REST_POST(model, gparams)
var jsondata_dp = { };
for (var fld in jsondata)
{
if (fld in this.disc_params.model.fields && !(fld in model.fields))
if (fld in model.disc_params.model.fields && !(fld in model.fields))
{
jsondata_dp[fld] = jsondata[fld];
delete jsondata[fld];
@@ -1517,7 +1519,7 @@ function generic_REST_POST(model, gparams)
if (err.friendlyMsg)
abort_with_warning(err.friendlyMsg);
var inctrack = api2.process_includes(params, this, jsondata, the_key);
var inctrack = api2.process_includes(params, model, jsondata, the_key);
if ("disc_params" in model)
{
@@ -1529,7 +1531,7 @@ function generic_REST_POST(model, gparams)
var err = Oracle.Execute(xxxIns.sql, true);
if (err.friendlyMsg)
{
var sql = "DELETE FROM " + this.table + " WHERE " + this.fields.id.dbs + " = " + the_key;
var sql = "DELETE FROM " + model.table + " WHERE " + model.fields.id.dbs + " = " + the_key;
Oracle.Execute(sql);
abort_with_warning(err.friendlyMsg);
}
@@ -1557,13 +1559,13 @@ function generic_REST_PUT(model, gparams)
var jsondata_dp = { };
for (var fld in jsondata)
{
if (fld in this.disc_params.model.fields && !(fld in model.fields))
if (fld in model.disc_params.model.fields && !(fld in model.fields))
{
jsondata_dp[fld] = jsondata[fld];
delete jsondata[fld];
}
}
jsondata_dp[this.disc_params.joinfield] = the_key;
jsondata_dp[model.disc_params.joinfield] = the_key;
}
var dbfields = api2.update_fields(params, model, jsondata);
@@ -1577,12 +1579,12 @@ function generic_REST_PUT(model, gparams)
if (err.friendlyMsg)
abort_with_warning(err.friendlyMsg);
}
var inctrack = api2.process_includes(params, this, jsondata, the_key);
var inctrack = api2.process_includes(params, model, jsondata, the_key);
if ("disc_params" in model)
{
// Nu de one-on-one tabel
var dbfields = api2.update_fields(params, this.disc_params.model, jsondata_dp);
var dbfields = api2.update_fields(params, model.disc_params.model, jsondata_dp);
var wheres = [model.disc_params.model.fields[model.disc_params.joinfield].dbs + " = " + the_key];
var xxxUpd = buildTrackingUpdate(model.disc_params.model.table, wheres.join(" AND " ), dbfields, { noValidateToken: true });
if (xxxUpd) // Misschien geen velden opgegeven.

View File

@@ -12,14 +12,15 @@
*/
%>
<%
function model_alg_kenmerk(niveau)
function model_alg_kenmerk(niveau, params)
{
params = params || {};
this.records_name = "realestateproperties";
this.record_name = "realestateproperty";
this.table = "alg_kenmerk";
this.primary = "alg_kenmerk_key";
this.soft_delete = "alg_kenmerk_verwijder";
this.autfunction = "WEB_PRSSYS";
this.autfunction = params.internal?false:"WEB_PRSSYS";
this.record_title = L("alg_kenmerk");
this.records_title = L("alg_kenmerk_m");
this.module = "ALG";

View File

@@ -13,14 +13,15 @@
%>
<%
function model_bes_kenmerk()
function model_bes_kenmerk(params)
{
params = params || {};
this.records_name = "orderlineproperties";
this.record_name = "orderlineproperty";
this.table = "bes_kenmerk";
this.primary = "bes_kenmerk_key";
this.soft_delete = "bes_kenmerk_verwijder";
this.autfunction = "WEB_BESMGT";
this.autfunction = params.internal?false:"WEB_BESMGT";
this.record_title = L("bes_kenmerk");
this.records_title = L("bes_kenmerk_m");
this.module = "BES";
@@ -235,6 +236,6 @@ function model_bes_kenmerk()
this.REST_POST = generic_REST_POST(this);
this.REST_PUT = generic_REST_PUT(this);
this.REST_DELETE = generic_REST_DELETE(this, {});
this.REST_DELETE = generic_REST_DELETE(this);
}
%>

View File

@@ -93,7 +93,7 @@ function model_bes_srtkenmerk()
%>
<script type="text/javascript">
var module = "BES";
var property_type = "<%=kenmerktype%>";
var property_type = "<%=safe.jsstring(kenmerktype)%>";
</script>
<%
}
@@ -102,6 +102,6 @@ function model_bes_srtkenmerk()
this.REST_GET = generic_REST_GET(this);
this.REST_POST = generic_REST_POST(this);
this.REST_PUT = generic_REST_PUT(this);
this.REST_DELETE = generic_REST_DELETE(this, {});
this.REST_DELETE = generic_REST_DELETE(this);
}
%>

View File

@@ -13,14 +13,15 @@
%>
<%
function model_bez_kenmerk()
function model_bez_kenmerk(params)
{
params = params || {};
this.records_name = "visitorproperties";
this.record_name = "visitorproperty";
this.table = "bez_kenmerk";
this.primary = "bez_kenmerk_key";
this.soft_delete = "bez_kenmerk_verwijder";
this.autfunction = "WEB_PRSSYS";
this.autfunction = params.internal?false:"WEB_PRSSYS";
this.record_title = L("bez_kenmerk");
this.records_title = L("bez_kenmerk_m");
this.module = "BEZ";
@@ -141,7 +142,7 @@ function model_bez_kenmerk()
%>
<script type="text/javascript">
var module = "BEZ";
var property_type = "<%=kenmerktype%>";
var property_type = "<%=safe.jsstring(kenmerktype)%>";
</script>
<%
}
@@ -150,6 +151,6 @@ function model_bez_kenmerk()
this.REST_GET = generic_REST_GET(this);
this.REST_POST = generic_REST_POST(this);
this.REST_PUT = generic_REST_PUT(this);
this.REST_DELETE = generic_REST_DELETE(this, {});
this.REST_DELETE = generic_REST_DELETE(this);
}
%>

View File

@@ -13,14 +13,15 @@
%>
<%
function model_cnt_kenmerk()
function model_cnt_kenmerk(params)
{
params = params || {};
this.records_name = "contractproperties";
this.record_name = "contractproperty";
this.table = "cnt_kenmerk";
this.primary = "cnt_kenmerk_key";
this.soft_delete = "cnt_kenmerk_verwijder";
this.autfunction = "WEB_CNTMGT";
this.autfunction = params.internal?false:"WEB_CNTMGT";
this.record_title = L("cnt_kenmerk");
this.records_title = L("cnt_kenmerk_m");
this.module = "CNT";

View File

@@ -99,7 +99,7 @@ function model_cnt_srtkenmerk()
%>
<script type="text/javascript">
var module = "CNT";
var property_type = "<%=kenmerktype%>";
var property_type = "<%=safe.jsstring(kenmerktype)%>";
</script>
<%
}

View File

@@ -59,7 +59,7 @@ function model_companies()
this.includes = {
"custom_fields" : {
"model": new model_custom_fields(this, new model_prs_kenmerk("B"), { readman: true, readuse: true, pNiveau: "B" }),
"model": new model_custom_fields(this, new model_prs_kenmerk("B", { internal: true }), { readman: true, readuse: true, pNiveau: "B" }),
"joinfield": "flexparentkey"
}
};

View File

@@ -13,14 +13,15 @@
%>
<%
function model_faq_kenmerk()
function model_faq_kenmerk(params)
{
params = params || {};
this.records_name = "knowledgeproperties";
this.record_name = "knowledgeproperty";
this.table = "faq_kenmerk";
this.primary = "faq_kenmerk_key";
this.soft_delete = "faq_kenmerk_verwijder";
this.autfunction = "WEB_FAQMGT";
this.autfunction = params.internal?false:"WEB_FAQMGT";
this.record_title = L("faq_kenmerk");
this.records_title = L("faq_kenmerk_m");
this.module = "FAQ";
@@ -139,7 +140,7 @@ function model_faq_kenmerk()
%>
<script type="text/javascript">
var module = "FAQ";
var property_type = "<%=kenmerktype%>";
var property_type = "<%=safe.jsstring(kenmerktype)%>";
</script>
<%
}

View File

@@ -13,14 +13,15 @@
%>
<%
function model_fin_kenmerk()
function model_fin_kenmerk(params)
{
params = params || {};
this.records_name = "invoiceproperties";
this.record_name = "invoiceproperty";
this.table = "fin_kenmerk";
this.primary = "fin_kenmerk_key";
this.soft_delete = "fin_kenmerk_verwijder";
this.autfunction = "WEB_PRSSYS";
this.autfunction = params.internal?false:"WEB_PRSSYS";
this.record_title = L("fin_kenmerk");
this.records_title = L("fin_kenmerk_m");
this.module = "FIN";
@@ -147,7 +148,7 @@ function model_fin_kenmerk()
%>
<script type="text/javascript">
var module = "FIN";
var property_type = "<%=kenmerktype%>";
var property_type = "<%=safe.jsstring(kenmerktype)%>";
</script>
<%
}

View File

@@ -14,14 +14,15 @@
%>
<%
function model_ins_kenmerk(fnparams)
function model_ins_kenmerk(niveau, params)
{
params = params || {};
this.records_name = "objectproperties";
this.record_name = "objectproperty";
this.table = "ins_kenmerk";
this.primary = "ins_kenmerk_key";
this.soft_delete = "ins_kenmerk_verwijder";
this.autfunction = "WEB_INSMGT";
this.autfunction = params.internal?false:"WEB_INSMGT";
this.record_title = L("ins_kenmerk");
this.records_title = L("ins_kenmerk_m");
this.module = "INS";
@@ -217,7 +218,6 @@ function model_ins_kenmerk(fnparams)
// Server side code!
//
// Afhankelijk van niveau:
var niveau = fnparams.niveau;
var gparams = { GET: { } };
if (niveau == "C")
@@ -275,7 +275,7 @@ function model_ins_kenmerk(fnparams)
this.REST_GET = generic_REST_GET(this, gparams);
this.REST_POST = generic_REST_POST(this);
this.REST_PUT = generic_REST_PUT(this);
this.REST_DELETE = generic_REST_DELETE(this, {});
this.REST_DELETE = generic_REST_DELETE(this);
function fill_ins_niveau_LOV()

View File

@@ -257,7 +257,7 @@ function model_ins_srtcontrole()
this.includes = {
"kenmerken": {
"model": new model_ins_kenmerk( {niveau:"C"} ),
"model": new model_ins_kenmerk("C", { internal: true }),
"joinfield": "objectkey",
"enable_update": true
}

View File

@@ -105,7 +105,7 @@ function model_ins_srtkenmerk()
%>
<script type="text/javascript">
var module = "INS";
var property_type = "<%=kenmerktype%>";
var property_type = "<%=safe.jsstring(kenmerktype)%>";
</script>
<%
}

View File

@@ -65,7 +65,7 @@ function model_invoices(fin_key, params)
joinfield: "fin_factuur_key",
enable_update: true
},
"custom_fields" : { model: new model_custom_fields(this, new model_fin_kenmerk(), { readman: true, readuse: true }),
"custom_fields" : { model: new model_custom_fields(this, new model_fin_kenmerk({ internal: true }), { readman: true, readuse: true }),
joinfield: "flexparentkey"
},
"tracking": {

View File

@@ -56,7 +56,7 @@ function model_alg_locatie()
this.includes =
{
"custom_fields" : {
"model": new model_custom_fields(this, new model_alg_kenmerk("L"), { readman: true, readuse: true }),
"model": new model_custom_fields(this, new model_alg_kenmerk("L", { internal: true }), { readman: true, readuse: true }),
"joinfield": "flexparentkey"
}
};

View File

@@ -16,14 +16,15 @@
%>
<%
function model_mld_kenmerk()
function model_mld_kenmerk(params)
{
params = params || {};
this.records_name = "issueproperties";
this.record_name = "issueproperty";
this.table = "mld_kenmerk";
this.primary = "mld_kenmerk_key";
this.soft_delete = "mld_kenmerk_verwijder";
this.autfunction = "WEB_MLDMGT";
this.autfunction = params.internal?false:"WEB_MLDMGT";
this.record_title = L("mld_kenmerk");
this.records_title = L("mld_kenmerk_m");
this.module = "MLD";

View File

@@ -99,7 +99,7 @@ function model_mld_srtkenmerk()
%>
<script type="text/javascript">
var module = "MLD";
var property_type = "<%=kenmerktype%>";
var property_type = "<%=safe.jsstring(kenmerktype)%>";
</script>
<%
}

View File

@@ -87,7 +87,7 @@ function model_orders(opdr_key, params)
model: new model_notes("MLD"),
joinfield: "mld_opdr_key"
},
"customfields" : { model: new model_custom_fields(this, new model_mld_kenmerk(), { pNiveau: "O", readman: true, readuse: true }),
"customfields" : { model: new model_custom_fields(this, new model_mld_kenmerk({ internal: true }), { pNiveau: "O", readman: true, readuse: true }),
joinfield: "flexparentkey"
},
"trackings": {

View File

@@ -12,14 +12,15 @@
*/
%>
<%
function model_prs_kenmerk(niveau)
function model_prs_kenmerk(niveau, params)
{
params = params || {};
this.records_name = "basisproperties";
this.record_name = "basisproperty";
this.table = "prs_kenmerk";
this.primary = "prs_kenmerk_key";
this.soft_delete = "prs_kenmerk_verwijder";
this.autfunction = "WEB_PRSSYS";
this.autfunction = params.internal?false:"WEB_PRSSYS";
this.record_title = L("mgt_kenmerk") + " " + get_prs_naam(niveau);
this.records_title = L("mgt_kenmerk_m") + " " + get_prs_naam(niveau);
this.module = "PRS";
@@ -169,7 +170,7 @@ function model_prs_kenmerk(niveau)
%>
<script type="text/javascript">
var module = "PRS";
var property_type = "<%=kenmerktype%>";
var property_type = "<%=safe.jsstring(kenmerktype)%>";
</script>
<%
}
@@ -185,7 +186,7 @@ function model_prs_kenmerk(niveau)
this.REST_GET = generic_REST_GET(this, gparams);
this.REST_POST = generic_REST_POST(this);
this.REST_PUT = generic_REST_PUT(this);
this.REST_DELETE = generic_REST_DELETE(this, {});
this.REST_DELETE = generic_REST_DELETE(this);
function get_prs_naam(niveau)

View File

@@ -208,7 +208,7 @@ function model_prs_perslid(params)
"multiadd": "authorizationgroup"
},
"customfields" : {
"model": new model_custom_fields(this, new model_prs_kenmerk("P"), { readman: true, readuse: true, pNiveau: "P" }),
"model": new model_custom_fields(this, new model_prs_kenmerk("P", { internal: true }), { readman: true, readuse: true, pNiveau: "P" }),
"joinfield": "flexparentkey"
},
"trackings": {

View File

@@ -12,14 +12,15 @@
*/
%>
<%
function model_res_kenmerk()
function model_res_kenmerk(params)
{
params = params || {};
this.records_name = "bookingproperties";
this.record_name = "bookingproperty";
this.table = "res_kenmerk";
this.primary = "res_kenmerk_key";
this.soft_delete = "res_kenmerk_verwijder";
this.autfunction = "WEB_RESMGT";
this.autfunction = params.internal?false:"WEB_RESMGT";
this.record_title = L("res_kenmerk");
this.records_title = L("res_kenmerk_m");
this.module = "RES";
@@ -143,9 +144,9 @@ function model_res_kenmerk()
}
this.REST_GET = generic_REST_GET(this, this.gparams);
this.REST_GET = generic_REST_GET(this);
this.REST_POST = generic_REST_POST(this);
this.REST_PUT = generic_REST_PUT(this);
this.REST_DELETE = generic_REST_DELETE(this, {});
this.REST_DELETE = generic_REST_DELETE(this);
}
%>

View File

@@ -97,7 +97,7 @@ function model_res_srtkenmerk()
%>
<script type="text/javascript">
var module = "RES";
var property_type = "<%=kenmerktype%>";
var property_type = "<%=safe.jsstring(kenmerktype)%>";
</script>
<%
}

View File

@@ -96,7 +96,7 @@ function model_reservations(rsv_key, params)
model: new model_tracking(['reservering', 'xreservering']),
joinfield: "trackingrefkey"
},
"custom_fields" : { model: new model_custom_fields(this, new model_res_kenmerk(), { readman: true, readuse: true }),
"custom_fields" : { model: new model_custom_fields(this, new model_res_kenmerk({ internal: true }), { readman: true, readuse: true }),
joinfield: "flexparentkey"
}
};

View File

@@ -80,7 +80,7 @@ function model_rooms(room_key, params)
}
},
"custom_fields" : {
"model": new model_custom_fields(this, new model_alg_kenmerk("L"), { readman: true, readuse: true }),
"model": new model_custom_fields(this, new model_alg_kenmerk("L", { internal: true }), { readman: true, readuse: true }),
"joinfield": "flexparentkey"
},
"tracking": {

View File

@@ -4,10 +4,9 @@
<!-- #include file="../api2/model_ins_kenmerk.inc" -->
<%
var kenmerk_params = {};
kenmerk_params.niveau = getQParam("inspectie", "");
var niveau = getQParam("inspectie", "");
var this_model = new model_ins_kenmerk(kenmerk_params);
var this_model = new model_ins_kenmerk(niveau);
scaffolding(this_model,
{
@@ -23,7 +22,7 @@ scaffolding(this_model,
}
},
"transit": {
"inspectie": kenmerk_params.niveau
"inspectie": niveau
}
});
%>

View File

@@ -1117,6 +1117,13 @@ function abort_with_warning(warning, code)
Response.ContentType = "application/json";
Response.Write(JSON.stringify(data, null, 2));
}
var codestr = String(code);
if (typeof code == "number")
{
var codestr = { 400: "Bad request", 403: "Forbidden", 404: "Forbidden" }[code];
if (codestr)
code = code + " " + codestr;
}
Response.Status = code;
Response.End;
}

View File

@@ -934,8 +934,7 @@ Perslid.prototype.checkAutorisation_readit = function _checkAutorisation_readit(
}
else
{
Response.Status = '403 Forbidden';
// Response.Write(L("lcl_no_auth")); ?
abort_with_warning(L("lcl_no_auth"), 403);
Response.End();
}
}
@@ -1136,7 +1135,7 @@ Perslid.prototype.func_enabled2 = function _func_enabled2(module, params)
var ALGLevel = -2; // Nog onbepaald
var PRSLevel = -2; // Nog onbepaald
var func_enabled = { _funcodes: [],
var func_enabled = { _funcodes: {},
canWrite : function (funcode)
{
if (this._funcodes[funcode]) // Rechten op te vragen via canWrite