FSN#39212 Api voor settings

svn path=/Website/branches/v2016.3/; revision=32603
This commit is contained in:
Erik Groener
2017-01-30 11:16:50 +00:00
parent ceb1720c29
commit 11ba127842

View File

@@ -12,23 +12,33 @@
*/
%>
<%
// TODO: labels toevoegen
//FAC_LCL('lcl_fac_name', 'Naam', 'Name', 'Name', 'Nom')
//FAC_LCL('lcl_fac_comment', 'Opmerking', 'Remark', 'Anmerkung', 'Remarque')
//FAC_LCL('lcl_fac_flags', 'Flags', 'Flags', 'Flags', 'Flags')
//FAC_LCL('lcl_fac_setting', 'Setting', 'Setting', 'Einstellung', 'Param<61>tres')
//FAC_LCL('lcl_fac_setting_m', 'Settings', 'Settings', 'Einstellungen', 'Param<61>tres')
function model_fac_setting()
function model_fac_setting(setting_key, params)
{
this.table = "fac_setting";
this.primary = "fac_setting_key";
this.records_name = "fac_settings";
this.record_name = "fac_setting";
this.REST_GET = generic_REST_GET(_model_fac_setting,
{ "GET": {
wheres: [ "BITAND(fac_setting_flags,1)=1"
]
}
}
)
// this.REST_POST = generic_REST_POST(_model_mld_discipline);
// this.REST_PUT = generic_REST_PUT(_model_mld_discipline);
// this.REST_DELETE = generic_REST_DELETE(this);
}
_model_fac_setting = // Internal only
{
"table": "fac_setting",
"primary": "fac_setting_key",
"records_name": "fac_settings",
"record_name": "fac_setting",
"autfunction": "WEB_PROFIL",
"record_title": L("lcl_fac_setting"),
"records_title": L("lcl_fac_setting_m"),
this.fields = {
"fields": {
"id": {
"dbs": "fac_setting_key",
"label": "Key",
@@ -39,51 +49,57 @@ function model_fac_setting()
},
"module": {
"dbs": "fac_setting_module",
"label": L("lcl_fac_module"),
// "label": L("lcl_fac_module"),
"typ": "varchar",
"required": true
},
"name": {
"dbs": "fac_setting_name",
"label": L("lcl_fac_name"),
// "label": L("lcl_fac_name"),
"typ": "varchar",
"required": true
},
"description": {
"dbs": "fac_setting_description",
"label": L("lcl_fac_descr"),
// "label": L("lcl_fac_descr"),
"typ": "varchar",
"required": true
},
"comment": {
"dbs": "fac_setting_comment",
"label": L("lcl_fac_comment"),
// "label": L("lcl_fac_comment"),
"typ": "varchar"
},
"flags": {
"dbs": "fac_setting_flags",
"label": L("lcl_fac_flags"),
// "label": L("lcl_fac_flags"),
"typ": "number"
},
"type": {
"dbs": "fac_setting_type",
"label": L("lcl_fac_settingtype"),
// "label": L("lcl_fac_settingtype"),
"typ": "varchar",
"required": true
},
"default": {
"dbs": "fac_setting_default",
"label": L("lcl_fac_default"),
// "label": L("lcl_fac_default"),
"typ": "varchar"
},
"overrule": {
"dbs": "fac_setting_pvalue",
// "label": L("lcl_fac_overrule"),
"typ": "varchar"
},
"value": {
"dbs": "fac_setting_pvalue",
"label": L("lcl_fac_value"),
"dbs": "value",
"sql": "COALESCE(fac_setting_pvalue, fac_setting_default)",
// "label": L("lcl_fac_value"),
"typ": "varchar"
},
"date": {
"dbs": "fac_setting_datum",
"label": L("lcl_fac_time"),
// "label": L("lcl_fac_time"),
"typ": "datetime"
},
"changed_by": {
@@ -98,53 +114,6 @@ function model_fac_setting()
"typ": "key",
"foreign": "fac_functie"
}
};
this.list = {
"columns": [
"id",
"name",
"value"
]
};
this.search = {
"autosearch": true
};
this.autfunction = "WEB_FACFAC";
this.record_title = L("lcl_fac_setting");
this.records_title = L("lcl_fac_setting_m");
this._check_authorization = function(params, method)
{
var autfunction = this.autfunction;
params.authparams = user.checkAutorisation(autfunction, null, null, true); // pessimistisch
};
this.REST_GET = function _GET(params)
{
this._check_authorization(params, "GET");
//
var query = api2.sqlfields(params, this );
// In pvalue ( =veld[8] ) moet de effectieve waarde worden getoond.
// Dus dit veld vervangen door een coalesce().
query.selects[8] = "COALESCE(fac_setting.fac_setting_pvalue, fac_setting.fac_setting_default) fac_setting_pvalue"
var wheres = api2.sqlfilter(params, this);
wheres.push("BITAND(fac_setting_flags,1)=1");
query.wheres = query.wheres.concat(wheres);
var sql = "SELECT " + query.selects.join(", ")
+ " FROM " + query.tables.join(", ");
if (query.wheres.length)
sql += " WHERE " + query.wheres.join(" AND " );
var json = api2.sql2json (params, sql, this );
return json;
};
//this.REST_POST = generic_REST_POST(this);
//this.REST_PUT = generic_REST_PUT(this);
//this.REST_DELETE = generic_REST_DELETE(this, {});
}
}
%>