@model Disco.Web.Models.Shared.GenerateDocumentControlModel
@if (Model.Templates.Count > 0 || Model.TemplatePackages.Count > 0)
{
    var selectListItems = new List<SelectListItem>();
    selectListItems.Add(new SelectListItem() { Selected = true, Value = string.Empty, Text = "Generate Document" });
    selectListItems.AddRange(Model.Templates.ToSelectListItems());
    selectListItems.AddRange(Model.TemplatePackages.ToSelectListItems());
    <div id="Document_Generation_Container" data-targetid="@HttpUtility.UrlEncode(Model.Target.AttachmentReferenceId)" data-targettype="@Model.Target.HasAttachmentType" data-generatepdfurl="@Url.Action(MVC.API.DocumentTemplate.Generate())/" data-generatepackageurl="@Url.Action(MVC.API.DocumentTemplatePackage.Generate())/" data-handlerspresent="@(Model.HandlersPresent ? "true" : "false")" data-handlersurl="@Url.Action(MVC.API.DocumentTemplate.DocumentHandlers())">
        @Html.DropDownList("Document_Generate", selectListItems)
        @if (Model.HandlersPresent)
        {
            <div id="Document_Generation_Dialog" class="dialog" title="Generate Document">
                <div class="handlerPicker">
                    <div data-id="download" class="selected">
                        <i class="fa fa-download fa-fw fa-lg"></i>Download
                    </div>
                    <div id="Document_Generation_Dialog_Handlers_Loading">
                        <i class="ajaxLoading" title="Loading"></i>
                    </div>
                </div>
                <div class="details">
                    <div id="Document_Generation_Dialog_Download_Container">
                        <a id="Document_Generation_Dialog_Download" href="#" class="button">Download Document</a>
                    </div>
                    <div id="Document_Generation_Dialog_HandlerUI">
                    </div>
                </div>
            </div>
        }
    </div>
    Html.BundleDeferred("~/ClientScripts/Modules/Disco-DocumentGenerator");
}