feature: document handlers
This commit is contained in:
@@ -5,54 +5,28 @@
|
||||
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">
|
||||
<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)
|
||||
<div id="Document_Generation_Dialog" class="dialog" title="Generate Document">
|
||||
</div>
|
||||
@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>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var generatePdfUrl = '@Url.Action(MVC.API.DocumentTemplate.Generate())/';
|
||||
var generatePackageUrl = '@Url.Action(MVC.API.DocumentTemplatePackage.Generate())/';
|
||||
var generateTargetId = '@HttpUtility.UrlEncode(Model.Target.AttachmentReferenceId)';
|
||||
var $control = $('#Document_Generate');
|
||||
var $generationHost;
|
||||
|
||||
var downloadDocument = function (templateId) {
|
||||
|
||||
var url;
|
||||
if (templateId.lastIndexOf('Package:', 0) === 0)
|
||||
url = generatePackageUrl + templateId.substring(8);
|
||||
else
|
||||
url = generatePdfUrl + templateId;
|
||||
url = url + '?TargetId=' + generateTargetId;
|
||||
|
||||
if ($.connection && $.connection.hub && $.connection.hub.transport &&
|
||||
$.connection.hub.transport.name == 'foreverFrame') {
|
||||
// SignalR active with foreverFrame transport - use popup window
|
||||
window.open(url, '_blank', 'height=150,width=250,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
|
||||
} else {
|
||||
// use iFrame
|
||||
if (!$generationHost) {
|
||||
$generationHost = $('<iframe>')
|
||||
.attr({ 'src': url, 'title': 'Document Generation Host' })
|
||||
.addClass('hidden')
|
||||
.appendTo('body')
|
||||
.contents();
|
||||
} else {
|
||||
$generationHost[0].location.href = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$control.change(function () {
|
||||
var templateId = $control.val();
|
||||
if (templateId) {
|
||||
downloadDocument(templateId);
|
||||
|
||||
$control.val('').blur();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/Disco-DocumentGenerator");
|
||||
}
|
||||
@@ -59,6 +59,72 @@ WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" id=\"Document_Generation_Container\"");
|
||||
|
||||
WriteLiteral(" data-targetid=\"");
|
||||
|
||||
|
||||
#line 8 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
Write(HttpUtility.UrlEncode(Model.Target.AttachmentReferenceId));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(" data-targettype=\"");
|
||||
|
||||
|
||||
#line 8 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
Write(Model.Target.HasAttachmentType);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(" data-generatepdfurl=\"");
|
||||
|
||||
|
||||
#line 8 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
Write(Url.Action(MVC.API.DocumentTemplate.Generate()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("/\"");
|
||||
|
||||
WriteLiteral(" data-generatepackageurl=\"");
|
||||
|
||||
|
||||
#line 8 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
Write(Url.Action(MVC.API.DocumentTemplatePackage.Generate()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("/\"");
|
||||
|
||||
WriteLiteral(" data-handlerspresent=\"");
|
||||
|
||||
|
||||
#line 8 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
Write(Model.HandlersPresent ? "true" : "false");
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(" data-handlersurl=\"");
|
||||
|
||||
|
||||
#line 8 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
Write(Url.Action(MVC.API.DocumentTemplate.DocumentHandlers()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
@@ -70,7 +136,23 @@ WriteLiteral(" ");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div");
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 10 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 10 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
if (Model.HandlersPresent)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" id=\"Document_Generation_Dialog\"");
|
||||
|
||||
@@ -78,64 +160,64 @@ WriteLiteral(" class=\"dialog\"");
|
||||
|
||||
WriteLiteral(" title=\"Generate Document\"");
|
||||
|
||||
WriteLiteral(">\r\n </div>\r\n </div>\r\n");
|
||||
WriteLiteral(">\r\n <div");
|
||||
|
||||
WriteLiteral(" <script");
|
||||
WriteLiteral(" class=\"handlerPicker\"");
|
||||
|
||||
WriteLiteral(" type=\"text/javascript\"");
|
||||
WriteLiteral(">\r\n <div");
|
||||
|
||||
WriteLiteral(">\r\n $(function () {\r\n var generatePdfUrl = \'");
|
||||
WriteLiteral(" data-id=\"download\"");
|
||||
|
||||
WriteLiteral(" class=\"selected\"");
|
||||
|
||||
WriteLiteral(">\r\n <i");
|
||||
|
||||
WriteLiteral(" class=\"fa fa-download fa-fw fa-lg\"");
|
||||
|
||||
WriteLiteral("></i>Download\r\n </div>\r\n <div");
|
||||
|
||||
WriteLiteral(" id=\"Document_Generation_Dialog_Handlers_Loading\"");
|
||||
|
||||
WriteLiteral(">\r\n <i");
|
||||
|
||||
WriteLiteral(" class=\"ajaxLoading\"");
|
||||
|
||||
WriteLiteral(" title=\"Loading\"");
|
||||
|
||||
WriteLiteral("></i>\r\n </div>\r\n </div>\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"details\"");
|
||||
|
||||
WriteLiteral(">\r\n <div");
|
||||
|
||||
WriteLiteral(" id=\"Document_Generation_Dialog_Download_Container\"");
|
||||
|
||||
WriteLiteral(">\r\n <a");
|
||||
|
||||
WriteLiteral(" id=\"Document_Generation_Dialog_Download\"");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral(" class=\"button\"");
|
||||
|
||||
WriteLiteral(">Download Document</a>\r\n </div>\r\n <div");
|
||||
|
||||
WriteLiteral(" id=\"Document_Generation_Dialog_HandlerUI\"");
|
||||
|
||||
WriteLiteral(">\r\n </div>\r\n </div>\r\n </div>\r\n");
|
||||
|
||||
|
||||
#line 15 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
Write(Url.Action(MVC.API.DocumentTemplate.Generate()));
|
||||
#line 29 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("/\';\r\n var generatePackageUrl = \'");
|
||||
WriteLiteral(" </div>\r\n");
|
||||
|
||||
|
||||
#line 16 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
Write(Url.Action(MVC.API.DocumentTemplatePackage.Generate()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("/\';\r\n var generateTargetId = \'");
|
||||
|
||||
|
||||
#line 17 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
Write(HttpUtility.UrlEncode(Model.Target.AttachmentReferenceId));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\';\r\n var $control = $(\'#Document_Generate\');\r\n var $generat" +
|
||||
"ionHost;\r\n\r\n var downloadDocument = function (templateId) {\r\n\r\n " +
|
||||
" var url;\r\n if (templateId.lastIndexOf(\'Package:\', 0) ==" +
|
||||
"= 0)\r\n url = generatePackageUrl + templateId.substring(8);\r\n " +
|
||||
" else\r\n url = generatePdfUrl + templateId;\r\n " +
|
||||
" url = url + \'?TargetId=\' + generateTargetId;\r\n\r\n if " +
|
||||
"($.connection && $.connection.hub && $.connection.hub.transport &&\r\n " +
|
||||
" $.connection.hub.transport.name == \'foreverFrame\') {\r\n " +
|
||||
" // SignalR active with foreverFrame transport - use popup window\r\n " +
|
||||
" window.open(url, \'_blank\', \'height=150,width=250,location=no,menubar=no," +
|
||||
"resizable=no,scrollbars=no,status=no,toolbar=no\');\r\n } else {\r\n " +
|
||||
" // use iFrame\r\n if (!$generationHost) {\r\n " +
|
||||
" $generationHost = $(\'<iframe>\')\r\n " +
|
||||
" .attr({ \'src\': url, \'title\': \'Document Generation Host\' })\r\n " +
|
||||
" .addClass(\'hidden\')\r\n .appendTo(\'body\')\r\n " +
|
||||
" .contents();\r\n } else {\r\n " +
|
||||
" $generationHost[0].location.href = url;\r\n }\r\n " +
|
||||
" }\r\n }\r\n\r\n $control.change(function () {\r\n " +
|
||||
" var templateId = $control.val();\r\n if (templateId) " +
|
||||
"{\r\n downloadDocument(templateId);\r\n\r\n $con" +
|
||||
"trol.val(\'\').blur();\r\n }\r\n });\r\n });\r\n </scr" +
|
||||
"ipt>\r\n");
|
||||
|
||||
|
||||
#line 58 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
#line 31 "..\..\Views\Shared\_GenerateDocumentControl.cshtml"
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/Disco-DocumentGenerator");
|
||||
}
|
||||
|
||||
#line default
|
||||
|
||||
Reference in New Issue
Block a user