FSN#35498 UDR: kolom-expressies mogelijk maken

svn path=/Website/trunk/; revision=30038
This commit is contained in:
Erik Groener
2016-07-13 13:08:57 +00:00
parent 2d0c0befcf
commit e9d9fbc2e9
2 changed files with 15 additions and 8 deletions

View File

@@ -159,7 +159,6 @@ function model_reportcolumns(usrrap_key, params)
if (user.has("WEB_FACTAB") && (obj.expression || !obj.id))
{
this.fields.expression.readonly = false;
this.fields.expression.required = true;
}
};
@@ -167,7 +166,6 @@ function model_reportcolumns(usrrap_key, params)
{
if (obj.id == -1)
this.fields.expression.readonly = false;
this.fields.expression.required = true;
}
// Maakt de default fac_usrrap_cols records aan aan de hand van de view of werk ze bij
@@ -380,6 +378,10 @@ function model_reportcolumns(usrrap_key, params)
};
this.REST_PUT = function (params, jsondata, the_key) /* update columns */
{
var valid_char = /^[_0-9a-zA-Z]+$/; // Alleen deze tekens zijn geldig!
if (!valid_char.test(jsondata.name))
abort_with_warning(L("lcl_rap_column_invalid"));
var dbfields = api2.update_fields(params, this, jsondata); // Build updater
var sql = buildUpdate("fac_usrrap_cols", dbfields, { noValidateToken: true }) + " fac_usrrap_cols_key = " + the_key;
@@ -394,6 +396,10 @@ function model_reportcolumns(usrrap_key, params)
// Only internally used by report_clone and _view2columns
this._REST_POST = function (params, jsondata, parent_key) /* insert columns */
{
var valid_char = /^[_0-9a-zA-Z]+$/;
if (!valid_char.test(jsondata.name))
abort_with_warning(L("lcl_rap_column_invalid"));
var dbfields = api2.update_fields(params, this, jsondata); // Build updater
dbfields["id"] = this.fields["id"];

View File

@@ -359,6 +359,7 @@ function report_GET(params)
continue;
var field = this.fields[fld];
var field_expression = (field.sql ? field.sql : field.dbs);
var field_group = (field.sql && field.sql.toUpperCase().indexOf("SELECT") > 0 ? i+1 : field_expression); // Voorkom dat er een subselect in de group_by komt te staan.
if (!field)
shared.internal_error("Column {0} not found in report".format(fld));
field.keepdbsforfilter = true;
@@ -367,7 +368,7 @@ function report_GET(params)
switch (params.groupby[i] || "G")
{
case "G":
groupbys.push(field_expression);
groupbys.push(field_group);
break;
case "U":
field.sql = "DISTINCT(" + field_expression + ")";
@@ -398,28 +399,28 @@ function report_GET(params)
else
field.sql = "TO_CHAR(" + field_expression + ", 'HH24')||':00'";
field.newtyp = "varchar";
groupbys.push(field.sql);
groupbys.push(field_group);
if (!field.fixedlabel)
field.label = L("lcl_usrrap_label_HOUR").format(field.label);
break;
case "D":
field.sql = "TRUNC(" + field_expression + ", 'DD')";
field.newtyp = "date";
groupbys.push(field.sql);
groupbys.push(field_group);
if (!field.fixedlabel)
field.label = L("lcl_usrrap_label_DAY").format(field.label);
break;
case "W":
field.sql = "TO_CHAR(" + field_expression + ", 'YYYY-IW')";
field.newtyp = "varchar";
groupbys.push(field.sql);
groupbys.push(field_group);
if (!field.fixedlabel)
field.label = L("lcl_usrrap_label_WEEK").format(field.label);
break;
case "M":
field.sql = "TO_CHAR(" + field_expression + ", 'YYYY-MM')";
field.newtyp = "varchar";
groupbys.push(field.sql);
groupbys.push(field_group);
if (!field.fixedlabel)
field.label = L("lcl_usrrap_label_MONTH").format(field.label);
break;
@@ -433,7 +434,7 @@ function report_GET(params)
case "Y":
field.sql = "TO_CHAR(" + field_expression + ", 'YYYY')";
field.newtyp = "varchar";
groupbys.push(field.sql);
groupbys.push(field_group);
if (!field.fixedlabel)
field.label = L("lcl_usrrap_label_YEAR").format(field.label);
break;