//~OPTIONS
{
  clientRendering: true,
  lockTemplate: false,
  autoUpdate: true,
}

//~ARGUMENTS
{
  value:                  undefined,
  file:                   fcf.argRef("value.file"),
  fileAlias:              fcf.argRef("value.alias"),
  downloadCounter:        fcf.argRef("value.downloadCounter"),
  enableAlias:            true,
  enableLink:             true,
  enableDownloadCounter:  false,
}

//~TEMPLATE
%{{
  var filePath = args.file && typeof args.file === "object" && args.file.name ? args.file.name :
                 args.file && typeof args.file === "object" && args.file.path ? args.file.path :
                 typeof args.file === "string"                                ? args.file :
                                                                                null;
  var fileName = filePath ? fcf.getFileName(filePath) : fcf.t("Not set");
  var directory = args.directory ? args.directory+"/" : "@path:files/";
  var fileLink = filePath ? fcf.getPath(filePath.indexOf("/")!=-1 ? filePath : directory + filePath, false) : null;
}}%
<div class="fcf-par" id="file">
  <div style="min-width:150px;  display: inline-block">!{{File}}!: </div>
  <div style="display:inline-block; padding-right:1.5em">@{{ fileName }}@</div>
  @{{ render.template("@controls:button", {title: fcf.t("Select a file"), fcfEventClick: "parent.onFileSelect()"}); }}@
  @{{ render.template("@controls:button", {title: fcf.t("Clear"), fcfEventClick: "parent.onFileClear()"}); }}@
</div>
%{{ if (args.enableAlias) { }}%
<div class="fcf-par">
  <div style="min-width:150px; display: inline-block">!{{File alias}}!:</div> @{{ render.template("@controls:text-edit", {value: fcf.argRef("fileAlias") }); }}@
</div>
%{{ } }}%
%{{ if (args.enableDownloadCounter) { }}%
<div class="fcf-par">
  <div style="min-width:150px; display: inline-block">!{{Download counter}}!:</div> @{{ render.template("@controls:int-edit", {value: fcf.argRef("downloadCounter") }); }}@
</div>
%{{ } }}%
%{{ if (args.enableLink) { }}%
<div class="fcf-par">
  <div style="min-width:150px; display: inline-block">!{{Link}}!:</div> @{{ fileLink ? "<a href='" + fileLink + "' target='_blank'>" + fileLink + "</a>" : ""}}@
</div>
%{{ } }}%
