<%@language = "javascript" %>

<!-- #include file="../scf/scaffolding.inc" -->
<!-- #include file="../api2/model_alg_kenmerk.inc" -->
<%
var niveau = getQParam("level"); // [ E | D | L | T | G | V | R ]

var this_model = new model_alg_kenmerk(niveau);

this_model.hook_pre_edit = function (obj, fld)
{
    var kenmerktype = (obj.attributetype ? obj.attributetype.id : "");
    fld.attributetype.LOV = buildKenmerktypeLOV(kenmerktype);
    fld.propertydefault.label = ((obj.id > 0 && obj.attributetype.id == "l") || obj.attributetype == "l" ? L("mgt_kenmerk_icon"): L("mgt_kenmerk_default"));
    fld.readonly.label = ((obj.id > 0 && obj.attributetype.id == "l") || obj.attributetype == "l" ? L("mgt_kenmerk_collapsed"): L("mgt_kenmerk_toonbaar"));
%>
<script type="text/javascript">
  var module = "ALG";
  var property_type = "<%=kenmerktype%>";
</script>
<%
}

this_model.hook_pre_show = function (obj, fld)
{
    fld.propertydefault.label = (obj.attributetype.id == "l" ? L("mgt_kenmerk_icon"): L("mgt_kenmerk_default"));
    fld.readonly.label = (obj.attributetype.id == "l" ? L("mgt_kenmerk_collapsed"): L("mgt_kenmerk_toonbaar"));
}


scaffolding(this_model,
    {
        "search": {
            "autosearch": true,
            "filters": [
                "name",
                "attributetype"
            ],
            "transit": [
                "attributetype"
            ]
        },
        "list": {
            "columns": [
                "sequence",
                "name",
                "rolecode",
                "attributetype",
                "authorization",
                "code",
                "id"
            ],
            "orderby": [
                "sequence",
                "name"
            ]
        },
        "edit": {
            "requires": { js: ["./mgt_srtkenmerk.js"] }
        },
        "layout": {
            "block": [
                {
                    "blockid": "algKenmerkAlgemeen",
                    "label": L("mgt_kenmerk"),
                    "icon": "fa-table-tree",
                    "ishtmlsafe": true,
                    "hidden": false,
                    "buttons": [],
                    "fields": [
                        "id",
                        "name",
                        "level", //??
                        "rolecode",
                        "group",
                        "sequence",
                        "propertydefault",
                        "hint",
                        "regexp",
                        "code"
                    ]
                },
                {
                    "blockid": "algKenmerkType",
                    "label": L("mgt_srtkenmerk_kenmerktype"),
                    "icon": "fa-asterisk",
                    "ishtmlsafe": true,
                    "hidden": false,
                    "buttons": [],
                    "fields": [
                        "attributetype",
                        "domain",
                        "length",
                        "decimals",
                        "minimum",
                        "maximum",
                        "unit"
                    ]
                },
                {
                    "blockid": "algKenmerkFormat",
                    "label": L("mgt_kenmerk_displayprops"),
                    "icon": "fa-face-viewfinder",
                    "ishtmlsafe": true,
                    "hidden": false,
                    "buttons": [],
                    "fields": [
                        "required",
                        "authorization",
                        "showexpression",
                        "readonly",
                        "inlist",
                        "position",
                        "system"
                    ]
                }
            ]
        },
        "print": {},
        "transit": { "level": niveau }
    });
%>
<% ASPPAGE_END(); %>
