FSN#35498 UDR: kolom-expressies mogelijk maken
svn path=/Website/trunk/; revision=29386
This commit is contained in:
@@ -29,8 +29,12 @@ function model_reportcolumns(usrrap_key, params)
|
||||
this.edit = { modal: true };
|
||||
|
||||
this.fields =
|
||||
{ "id" : { dbs: "fac_usrrap_cols_key", typ: "key", filter: "exact", seq: "fac_s_fac_usrrap_cols_key" },
|
||||
"name" : { dbs: "fac_usrrap_cols_column_name", typ: "varchar", label: L("lcl_rap_column"), insertonly: true },
|
||||
{ "id" : { dbs: "fac_usrrap_cols_key", typ: "key", label: "Key",
|
||||
filter: "exact",
|
||||
seq: "fac_s_fac_usrrap_cols_key" },
|
||||
"name" : { dbs: "fac_usrrap_cols_column_name", typ: "varchar", label: L("lcl_rap_column"),
|
||||
required: true,
|
||||
readonly: true },
|
||||
"datatype" : { dbs: "fac_usrrap_cols_datatype", typ: "varchar", label: L("lcl_rap_datatype"),
|
||||
required: true,
|
||||
LOV: L("lcl_rap_datatypeLOV")}, // "varchar;Tekst;date;Datum;datetime;Datumtijd;float;Float;currency;Bedrag;number;Getal"
|
||||
@@ -45,7 +49,9 @@ function model_reportcolumns(usrrap_key, params)
|
||||
"group" : { dbs: "fac_usrrap_cols_group", typ: "varchar", label: L("lcl_rap_groupby"),
|
||||
required: true,
|
||||
LOV: L("lcl_rap_groupbyLOV") },
|
||||
"fac_usrrap_key" : { dbs: "fac_usrrap_key", typ: "key" }
|
||||
"fac_usrrap_key" : { dbs: "fac_usrrap_key", typ: "key", hidden_fld: true },
|
||||
"expression": { dbs: "fac_usrrap_cols_expression", typ: "memo", label: "sql-expressie",
|
||||
readonly: true}
|
||||
|
||||
};
|
||||
|
||||
@@ -59,7 +65,7 @@ function model_reportcolumns(usrrap_key, params)
|
||||
this.hook_pre_edit = function (obj)
|
||||
{
|
||||
this.fields.filter.LOV = api2.filterLOV(L("lcl_rap_filterLOV"), "A,E,R"); // De meesten mogen L(ike) niet
|
||||
if (obj.datatype)
|
||||
if (obj.datatype && !obj.expression)
|
||||
{
|
||||
switch (obj.datatype.id)
|
||||
{
|
||||
@@ -92,6 +98,14 @@ function model_reportcolumns(usrrap_key, params)
|
||||
this.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G");
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.expression || !obj.id)
|
||||
{
|
||||
this.fields.expression.readonly = false;
|
||||
this.fields.expression.required = true;
|
||||
this.fields.name.readonly = false;
|
||||
this.fields.name.required = true;
|
||||
}
|
||||
};
|
||||
|
||||
// Maakt de default fac_usrrap_cols records aan aan de hand van de view of werk ze bij
|
||||
@@ -236,7 +250,8 @@ function model_reportcolumns(usrrap_key, params)
|
||||
__Log("Dropping column {0}".format(oldcols[o].name));
|
||||
// We kennen geen REST_DELETE
|
||||
var sql = "DELETE fac_usrrap_cols"
|
||||
+ " WHERE fac_usrrap_cols_key = " + oldcols[o].id;
|
||||
+ " WHERE fac_usrrap_cols_expression IS NULL"
|
||||
+ " AND fac_usrrap_cols_key = " + oldcols[o].id;
|
||||
Oracle.Execute(sql);
|
||||
}
|
||||
}
|
||||
@@ -320,7 +335,9 @@ function model_reportcolumns(usrrap_key, params)
|
||||
var dbfields = api2.update_fields(params, this, jsondata); // Build updater
|
||||
|
||||
dbfields["id"] = this.fields["id"];
|
||||
dbfields["xxx"] = { dbs: "fac_usrrap_key", typ: "key", val: parent_key };
|
||||
if (parent_key && !jsondata.fac_usrrap_key)
|
||||
dbfields["xxx"] = { dbs: "fac_usrrap_key", typ: "key", val: parent_key };
|
||||
|
||||
var rapIns = buildInsert("fac_usrrap_cols", dbfields, { noValidateToken: true });
|
||||
var col_key = rapIns.sequences["fac_usrrap_col_key"];
|
||||
|
||||
@@ -345,7 +362,7 @@ function model_reportcolumns(usrrap_key, params)
|
||||
this.REST_PUT = false;
|
||||
}
|
||||
|
||||
if (params.internal)
|
||||
if (params.internal || user.has("WEB_FACTAB"))
|
||||
{
|
||||
this.REST_POST = this._REST_POST; // Voor de clone-report
|
||||
}
|
||||
|
||||
@@ -213,6 +213,7 @@ function model_reports(fac_usrrap_key)
|
||||
label: label,
|
||||
orglabel: label,
|
||||
fixedlabel: fixedlabel,
|
||||
sql: usrrap.columns[i].expression,
|
||||
typ: usrrap.columns[i].datatype.id,
|
||||
orgtyp: usrrap.columns[i].datatype.id,
|
||||
group: usrrap.columns[i].group,
|
||||
|
||||
@@ -173,6 +173,13 @@ function model_reportsx(usrrap_key, rapparams)
|
||||
{
|
||||
this._check_authorization(params, "PUT");
|
||||
|
||||
var sql = "SELECT fac_usrrap_view_name"
|
||||
+ " FROM fac_usrrap"
|
||||
+ " WHERE fac_usrrap_key = " + the_key;
|
||||
var oRs = Oracle.Execute(sql);
|
||||
var old_view = oRs("fac_usrrap_view_name").Value;
|
||||
oRs.Close();
|
||||
|
||||
var dbfields = api2.update_fields(params, this, jsondata); // Build updater
|
||||
this._analyze_fields(dbfields, params, jsondata);
|
||||
|
||||
@@ -185,6 +192,18 @@ function model_reportsx(usrrap_key, rapparams)
|
||||
|
||||
var beztrack = api2.process_includes(params, this, jsondata, the_key);
|
||||
|
||||
if (old_view != jsondata.viewname)
|
||||
{ // Verwijder alle kolommen als er een nieuwe view is ingevuld, maar laat de expressies staan.
|
||||
var sql = "DELETE fac_usrrap_cols"
|
||||
+ " WHERE fac_usrrap_cols_expression IS NULL"
|
||||
+ " AND fac_usrrap_key = " + the_key;
|
||||
var err = Oracle.Execute(sql, true);
|
||||
if (err.friendlyMsg)
|
||||
abort_with_warning(err.friendlyMsg);
|
||||
// Voeg de kolommen van de nieuwe view weer toe.
|
||||
this.includes["columns"].model._view2columns(the_key, null, []);
|
||||
}
|
||||
|
||||
return { key: the_key, warning: "" };
|
||||
};
|
||||
|
||||
|
||||
@@ -490,7 +490,10 @@ function scf_RWFIELDTR(model, fld, val, key, params)
|
||||
|
||||
params.maxlength = field.len;
|
||||
if (field.typ == "memo")
|
||||
RWTEXTAREATR(fld, "fld", field.label, val, params);
|
||||
{
|
||||
var pclass = "fld" + (params.required ? " required" : "");
|
||||
RWTEXTAREATR(fld, pclass, field.label, val, params);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (field.typ)
|
||||
|
||||
Reference in New Issue
Block a user