API2: model.search.filters ipv. kijken naar field.filter. Die laatst is voortaan alleen nog optioneel voor overrule filtertype

svn path=/Website/trunk/; revision=24483
This commit is contained in:
Jos Groot Lipman
2015-03-17 13:53:48 +00:00
parent 0af5c1f8cc
commit ac15342eb5
9 changed files with 33 additions and 14 deletions

View File

@@ -288,6 +288,7 @@ api2 = {
case "datetime":
val = getFParamDate(formfields[i].frm, null);
break;
case "memo":
case "varchar":
val = getFParam(formfields[i].frm, null);
break;
@@ -1379,7 +1380,7 @@ function generic_REST_GET(model)
+ (query.wheres.length ? " WHERE " + query.wheres.join(" AND " ) : "")
+ " ORDER BY " + (model.fields.name?model.fields.name.dbs:model.fields.id.dbs);
var maxcnt = getQParamInt("showall", 0) == 1?S("qp_maxrows2"):S("qp_maxrows");
var maxcnt = params.filter.showall==1?S("qp_maxrows2"):S("qp_maxrows");
var sql = "SELECT * FROM (" + sql + ") WHERE ROWNUM <= " + (maxcnt + 1); // Eentje extra om overflow-melding te triggeren in resultsettable
var json = api2.sql2json (params, sql, model);
@@ -1422,6 +1423,7 @@ function generic_REST_PUT(model)
return function _generic_REST_PUT(params, jsondata, the_key)
{
var result = {};
var fields = api2.update_fields(params, model, jsondata);
var wheres = [model.fields.id.dbs + " = " + the_key];
var xxxUpd = buildTrackingUpdate(model.table, wheres.join(" AND " ), fields, { noValidateToken: true });

View File

@@ -19,6 +19,7 @@ function model_generic_template()
this.record_name = "<unkown>";
this.fields = {};
this.list = { columns: [] };
this.search = { filters: [] };
this.soft_delete = null;
this.autfunction = "WEB_PRSSYS";
}
@@ -170,6 +171,8 @@ function model_generic(table, autfunction)
{
field.filter = "like";
}
if (field.filter)
model.search.filters.push(fld);
model.fields[fld] = field;
if (fld == "id" || fld == "name" || fld == "description" || field.filter)

View File

@@ -212,7 +212,8 @@ function model_reports_template()
this.REST_POST = false;
this.REST_DELETE = false;
this.search = { title: L("lcl_usrrap_report") }
this.search = { title: L("lcl_usrrap_report"),
filters: [] }
}
// Voltooi model_reports_template voor een bepaald rapport
@@ -287,6 +288,9 @@ function model_reports(fac_usrrap_key)
model.fields[fld] = field;
if (usrrap.columns[i].visible.id == 'V')
model.list.columns.push(fld);
if (usrrap.columns[i].filter)
model.search.filters.push(fld);
}
__Log(model);
return model;

View File

@@ -38,7 +38,9 @@ function model_reportsx(usrrap_key, params)
"autorefresh" : { dbs: "fac_usrrap_autorefresh", typ: "check", label: L("lcl_usrrap_autorefresh")}
};
this.list = { columns: ["id", "name", "description"] };
this.search = { autosearch: true };
this.search = { autosearch: true,
filters: ["id", "name", "description"]
};
this.includes = {"columns": { model: model_reportcolumns,
joinfield: "fac_usrrap_key"
@@ -94,7 +96,7 @@ function model_reportsx(usrrap_key, params)
var sql = "SELECT " + query.selects.join(", ")
+ " FROM " + query.tables.join(", ")
+ (query.wheres.length ? " WHERE " + query.wheres.join(" AND " ) : "")
+ " ORDER BY fac_usrrap_key";
+ " ORDER BY 2";
if (params.include && params.include.length)
sql += ", fac_usrrap_cols_volgnr";

View File

@@ -25,6 +25,8 @@ JSON_Result = true;
var columns = [getQParam("distinct")];
var xxx_params = { filter : api2.qs2json(), columns: columns, groupby: ["U"] }; // U=distinct
xxx_params.filter.showall = 1;
xxx_params.filter.limit = 9999;
var result = { distinct: columns[0], values: rapport.REST_GET(xxx_params) };
Response.Write(JSON.stringify(result));

View File

@@ -123,7 +123,9 @@ function CONTENT_END()
function CONTROLGROUP_START(params)
{
%><div data-role="controlgroup" data-mini="true" style="text-align:center"><%
params = params || {};
%><div data-role="controlgroup" data-mini="true" <%= params.id?" id='" + params.id + "'":"" %>
<%= params.horizontal?" data-type='horizontal'":"" %> style="text-align:center"><%
}
function CONTROLGROUP_END()
{
@@ -205,6 +207,7 @@ function RWFIELD(pId, plabel, pvalue, params)
{
params = params||{};
var vcontain = (params.contain?" class='ui-field-contain'":"");
var vdatarole = (params.datarole?" data-role='"+params.datarole+"'":"");
var vlabel = plabel ? "<label"+(pId ? " for='"+pId+"'" : "")
+((!params.readonly&&!params.disabled) ? " class='ed'": "")+">" + plabel + ":</label>" : "";
@@ -222,7 +225,7 @@ function RWFIELD(pId, plabel, pvalue, params)
? "<textarea " + (plabel ? "placeholder='"+plabel+"'" : "") + vinputattr + ">" + safe.textarea(pvalue) + "</textarea>"
: "<input " + (plabel ? "placeholder='"+plabel+"'" : "") + vinputattr + " value='" + safe.htmlattr(pvalue) + "' />"
);
%><div<%=vdatarole%>><%=vlabel%><%=vinput%></div><%
%><div<%=vdatarole%><%=vcontain%>><%=vlabel%><%=vinput%></div><%
}
function BTN_BACK(plabel)

View File

@@ -77,9 +77,9 @@ function scaffolding_edit(model, scf_params)
{
var field = model.fields[fld];
if (field.readonly || fld == "id")
scf_ROFIELDTR(field, fld, xxx_data[fld]);
scf_ROFIELDTR(model, fld, xxx_data[fld]);
else if (field.insertonly && key > 0)
scf_ROFIELDTR(field, fld, xxx_data[fld]);
scf_ROFIELDTR(model, fld, xxx_data[fld]);
else
scf_RWFIELDTR(field, fld, xxx_data[fld], key);
}

View File

@@ -16,9 +16,11 @@ function scaffolding_search(model, scf_params)
scf_params.search = scf_params.search || model.search;
scf_params.list = scf_params.list || model.list || {};
if (!scf_params.search.title && "search" in model)
scf_params.search.title = model.search.title;
if ("search" in model)
{
scf_params.search.title = scf_params.search.title || model.search.title;
scf_params.search.filters = scf_params.search.filters || model.search.filters || [];
}
FCLTHeader.Requires({plugins:[],
js: ["jquery-ui.js", "jquery.timepicker-table.js"],
css: ["timePicker-table.css"]});
@@ -103,14 +105,15 @@ function scaffolding_search(model, scf_params)
BLOCK_START("searchtable", L("lcl_filterblok") + " " + (model.records_title||"") + est_title);
for (var fld in model.fields)
for (var i=0; i < scf_params.search.filters.length; i++)
{
var fld = scf_params.search.filters[i];
var field = model.fields[fld];
var def = field.filterdefault || defaults[fld];
if (field.hidden)
continue;
if (field.filter == 'like' || field.filter == 'exact')
if (field.filter == 'like' || field.filter == 'exact' || !("filter" in field))
scf_RWFIELDTR(field, fld, def);
else if (field.filter == "range")
{

View File

@@ -94,7 +94,7 @@ function scaffolding_show(model, scf_params)
<%
BLOCK_START("facInfo", model.record_name);
for (var fld in model.fields)
scf_ROFIELDTR(model.fields[fld], fld, xxx_data[fld], key);
scf_ROFIELDTR(model, fld, xxx_data[fld], key);
BLOCK_END();
%>
</form>