//~OPTIONS
{
  extends: "fcfManagement:templates/pages/base.tmpl",
  access:  ["root"],
}

//~ARGUMENTS
{
  title: fcf.t("Data editor."),
}

//~ARGUMENTS body
{
  mode: "read.min",
}

//~TEMPLATE body
<p>
<fieldset>
<legend>!{{Output mode}}!</legend>
@{{render.template("@controls:checkbox", {
    outputMode: fcf.argRef(args.fcfId, "mode"),
    value: fcf.argVal("@{{args.outputMode == 'read.min'}}@", {important: true}),
    title: fcf.argVal("!{{Minimal}}!"),
    fcfEventClick: "parent.setArg('mode', 'read.min')"
    })
}}@
@{{render.template("@controls:checkbox", {
    outputMode: fcf.argRef(args.fcfId, "mode"),
    value: fcf.argVal("@{{args.outputMode == 'read.full'}}@", {important: true}),
    title: fcf.argVal("!{{Full}}!"),
    fcfEventClick: "parent.setArg('mode', 'read.full')"
    }),
}}@
</fieldset>
</p>
@{{
  render.template({
    template: "@dbcontrols:table",
    args: {
      fcfAlias:       "table",
      mode:           fcf.argRef("mode"),
      page:           fcf.argUrl("page", {default: 1}),
      enableToolbar:  true,
      enableSearch:   true,
      enableClear:    true,
      projection:     route.args.projection,
      toolbarLeftItems: fcf.argVal([fcf.argTmpl("@controls:button",
                                     {  title: "!{{New Record}}!",
                                        fcfEventClick: "parent.getParent().onNewRecord()"}
                                    )
                        ]),
      viewButtonEdit: fcf.argVal(
                          [{
                            alias:        "@action",
                            title:        "!{Actions}!",
                            type:         "string",
                            template:     "fcfManagement:templates/pages/data/records/buttons.tmpl",
                            args: {
                              fcfEventView:     "parent.getParent().onView(\"@{record['@key']}@\")",
                              fcfEventEdit:     "parent.getParent().onEdit(\"@{record['@key']}@\")",
                              fcfEventDelete:   "parent.getParent().onDelete(\"@{record['@key']}@\")",
                            }
                          }],
                          { attach: { arg: "columns", type: "append" } },
                        ),
    }
  })
}}@
