Feature #67: Advanced document template events

OnGenerated and OnImportAttachment allow advanced users to enter
expressions which will be evaluated whenever these document
template/importing events are triggered. This enables greater
automation.
This commit is contained in:
Gary Sharp
2014-07-26 20:02:59 +10:00
parent c528a2be26
commit 1cc7e94646
32 changed files with 2179 additions and 1474 deletions
@@ -21,6 +21,8 @@ namespace Disco.Web.Areas.API.Controllers
const string pDescription = "description";
const string pScope = "scope";
const string pFilterExpression = "filterexpression";
const string pOnGenerateExpression = "ongenerateexpression";
const string pOnImportAttachmentExpression = "onimportattachmentexpression";
const string pFlattenForm = "flattenform";
[DiscoAuthorize(Claims.Config.DocumentTemplate.Configure)]
@@ -50,6 +52,12 @@ namespace Disco.Web.Areas.API.Controllers
Authorization.Require(Claims.Config.DocumentTemplate.ConfigureFilterExpression);
UpdateFilterExpression(documentTemplate, value);
break;
case pOnGenerateExpression:
UpdateOnGenerateExpression(documentTemplate, value);
break;
case pOnImportAttachmentExpression:
UpdateOnImportAttachmentExpression(documentTemplate, value);
break;
case pFlattenForm:
UpdateFlattenForm(documentTemplate, value);
break;
@@ -141,6 +149,16 @@ namespace Disco.Web.Areas.API.Controllers
{
return Update(id, pFilterExpression, FilterExpression, redirect);
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.Configure, Claims.Config.DocumentTemplate.ConfigureFilterExpression)]
public virtual ActionResult UpdateOnGenerateExpression(string id, string OnGenerateExpression = null, bool redirect = false)
{
return Update(id, pOnGenerateExpression, OnGenerateExpression, redirect);
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.Configure, Claims.Config.DocumentTemplate.ConfigureFilterExpression)]
public virtual ActionResult UpdateOnImportAttachmentExpression(string id, string OnImportAttachmentExpression = null, bool redirect = false)
{
return Update(id, pOnImportAttachmentExpression, OnImportAttachmentExpression, redirect);
}
[DiscoAuthorize(Claims.Config.DocumentTemplate.Configure)]
public virtual ActionResult UpdateFlattenForm(string id, string FlattenForm = null, bool redirect = false)
{
@@ -303,6 +321,36 @@ namespace Disco.Web.Areas.API.Controllers
Database.SaveChanges();
}
private void UpdateOnGenerateExpression(Disco.Models.Repository.DocumentTemplate documentTemplate, string OnGenerateExpression)
{
if (string.IsNullOrWhiteSpace(OnGenerateExpression))
{
documentTemplate.OnGenerateExpression = null;
}
else
{
documentTemplate.OnGenerateExpression = OnGenerateExpression.Trim();
}
// Invalidate Cache
documentTemplate.OnGenerateExpressionInvalidateCache();
Database.SaveChanges();
}
private void UpdateOnImportAttachmentExpression(Disco.Models.Repository.DocumentTemplate documentTemplate, string OnImportAttachmentExpression)
{
if (string.IsNullOrWhiteSpace(OnImportAttachmentExpression))
{
documentTemplate.OnImportAttachmentExpression = null;
}
else
{
documentTemplate.OnImportAttachmentExpression = OnImportAttachmentExpression.Trim();
}
// Invalidate Cache
documentTemplate.OnImportAttachmentExpressionInvalidateCache();
Database.SaveChanges();
}
private void UpdateFlattenForm(Disco.Models.Repository.DocumentTemplate documentTemplate, string FlattenForm)
{
if (string.IsNullOrWhiteSpace(FlattenForm))
@@ -9,6 +9,7 @@
var canConfig = Authorization.Has(Claims.Config.DeviceProfile.Configure);
var canConfigExpression = Authorization.Has(Claims.Config.DeviceProfile.ConfigureComputerNameTemplate);
var canDelete = (Authorization.Has(Claims.Config.DeviceProfile.Delete) && Model.CanDelete);
var canViewPlugins = Authorization.Has(Claims.Config.Plugin.Install);
var hideAdvanced =
Model.DeviceProfile.AssignedUsersLinkedGroup == null &&
@@ -18,6 +19,7 @@
{
Html.BundleDeferred("~/Style/Fancytree");
Html.BundleDeferred("~/ClientScripts/Modules/jQuery-Fancytree");
Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers");
}
}
<div id="configurationDeviceProfileShow" class="form@(hideAdvanced ? " Config_HideAdvanced" : null)" style="width: 640px">
@@ -39,41 +41,12 @@
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var $Name = $('#DeviceProfile_Name');
var $NameAjaxSave = $Name.next('.ajaxSave');
$Name
.watermark('Profile Short Name')
.focus(function () { $Name.select() })
.keydown(function (e) {
$NameAjaxSave.show();
if (e.which == 13) {
$(this).blur();
}
}).blur(function () {
$NameAjaxSave.hide();
})
.change(function () {
$NameAjaxSave.hide();
var $ajaxLoading = $NameAjaxSave.next('.ajaxLoading').show();
var data = { ProfileName: $Name.val() };
$.ajax({
url: '@Url.Action(MVC.API.DeviceProfile.UpdateName(Model.DeviceProfile.Id))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update name: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update name: ' + textStatus);
$ajaxLoading.hide();
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_Name'),
'Name',
'@Url.Action(MVC.API.DeviceProfile.UpdateName(Model.DeviceProfile.Id))',
'ProfileName'
);
});
</script>
}
@@ -93,41 +66,12 @@
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var $ShortName = $('#DeviceProfile_ShortName');
var $ShortNameAjaxSave = $ShortName.next('.ajaxSave');
$ShortName
.watermark('Profile Short Name')
.focus(function () { $ShortName.select() })
.keydown(function (e) {
$ShortNameAjaxSave.show();
if (e.which == 13) {
$(this).blur();
}
}).blur(function () {
$ShortNameAjaxSave.hide();
})
.change(function () {
$ShortNameAjaxSave.hide();
var $ajaxLoading = $ShortNameAjaxSave.next('.ajaxLoading').show();
var data = { ShortName: $ShortName.val() };
$.ajax({
url: '@Url.Action(MVC.API.DeviceProfile.UpdateShortName(Model.DeviceProfile.Id))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update short name: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update short name: ' + textStatus);
$ajaxLoading.hide();
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_ShortName'),
'Short Name',
'@Url.Action(MVC.API.DeviceProfile.UpdateShortName(Model.DeviceProfile.Id))',
'ShortName'
);
});
</script>
}
@@ -142,46 +86,17 @@
</th>
<td>@if (canConfig)
{
@Html.TextBoxFor(model => model.DeviceProfile.Description)
@Html.EditorFor(model => model.DeviceProfile.Description)
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var $Description = $('#DeviceProfile_Description');
var $DescriptionAjaxSave = $Description.next('.ajaxSave');
$Description
.watermark('Profile Description')
.focus(function () { $Description.select() })
.keydown(function (e) {
$DescriptionAjaxSave.show();
if (e.which == 13) {
$(this).blur();
}
}).blur(function () {
$DescriptionAjaxSave.hide();
})
.change(function () {
$DescriptionAjaxSave.hide();
var $ajaxLoading = $DescriptionAjaxSave.next('.ajaxLoading').show();
var data = { Description: $Description.val() };
$.ajax({
url: '@Url.Action(MVC.API.DeviceProfile.UpdateDescription(Model.DeviceProfile.Id))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update description: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update description: ' + textStatus);
$ajaxLoading.hide();
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_Description'),
'Description',
'@Url.Action(MVC.API.DeviceProfile.UpdateDescription(Model.DeviceProfile.Id))',
'Description'
);
});
</script>
}
@@ -210,19 +125,12 @@
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
$('#DeviceProfile_DistributionType').change(function () {
var $this = $(this);
var $ajaxLoading = $this.next('.ajaxLoading').show();
var data = { DistributionType: $this.val() };
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateDistributionType(Model.DeviceProfile.Id))', data, function (response, result) {
if (result != 'success' || response != 'OK') {
alert('Unable to change Distribution Type:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_DistributionType'),
null,
'@Url.Action(MVC.API.DeviceProfile.UpdateDistributionType(Model.DeviceProfile.Id))',
'DistributionType'
);
});
</script>
}
@@ -241,19 +149,12 @@
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
$('#DeviceProfile_DefaultOrganisationAddress').change(function () {
var $this = $(this);
var $ajaxLoading = $this.next('.ajaxLoading').show();
var data = { DefaultOrganisationAddress: $this.val() };
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateDefaultOrganisationAddress(Model.DeviceProfile.Id))', data, function (response, result) {
if (result != 'success' || response != 'OK') {
alert('Unable to change Address:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_DefaultOrganisationAddress'),
null,
'@Url.Action(MVC.API.DeviceProfile.UpdateDefaultOrganisationAddress(Model.DeviceProfile.Id))',
'DefaultOrganisationAddress'
);
});
</script>
}
@@ -273,36 +174,18 @@
<tr>
<th>Allocate Certificates:
</th>
<td>@if (canConfig)
<td>@if (canConfig && Model.CertificateProviders.Count > 0)
{
@Html.DropDownListFor(model => model.DeviceProfile.CertificateProviderId, Model.CertificateProviders.ToSelectListItems(null, true, "Not Allocated"))
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var $field = $('#DeviceProfile_CertificateProviderId');
var $ajaxLoading = $field.next('.ajaxLoading');
$field
.change(function () {
$ajaxLoading.show();
var data = { CertificateProviderId: $field.val() };
$.ajax({
url: '@Url.Action(MVC.API.DeviceProfile.UpdateCertificateProviderId(Model.DeviceProfile.Id))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update Certificate Provider Id: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update Certificate Provider Id: ' + textStatus);
$ajaxLoading.hide();
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_CertificateProviderId'),
null,
'@Url.Action(MVC.API.DeviceProfile.UpdateCertificateProviderId(Model.DeviceProfile.Id))',
'CertificateProviderId'
);
});
</script>
}
@@ -325,6 +208,14 @@
}
}
}
@if (canViewPlugins)
{
<div class="info-box">
<p class="fa-p">
<i class="fa fa-info-circle"></i>View the <a href="@(Url.Action(MVC.Config.Plugins.Install()))">Plugin Catalogue</a> to discover and install certificate provider plugins.
</p>
</div>
}
</td>
</tr>
<tr>
@@ -333,46 +224,29 @@
</th>
<td>@if (canConfig && canConfigExpression)
{
@Html.TextBoxFor(model => model.DeviceProfile.ComputerNameTemplate)
@Html.EditorFor(model => model.DeviceProfile.ComputerNameTemplate)
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<a id="expressionBrowserAnchor" href="@(Url.Action(MVC.Config.DocumentTemplate.ExpressionBrowser()))">&nbsp;</a>
<script type="text/javascript">
$(function () {
var $ComputerNameTemplate = $('#DeviceProfile_ComputerNameTemplate');
var $ajaxSave = $ComputerNameTemplate.next('.ajaxSave');
$ComputerNameTemplate
.focus(function () { $ComputerNameTemplate.select() })
.keydown(function (e) {
$ajaxSave.show();
if (e.which == 13) {
$(this).blur();
}
}).blur(function () {
$ajaxSave.hide();
})
.change(function () {
$ajaxSave.hide();
var $ajaxLoading = $ajaxSave.next('.ajaxLoading').show();
var data = { ComputerNameTemplate: $ComputerNameTemplate.val() };
$.ajax({
url: '@(Url.Action(MVC.API.DeviceProfile.UpdateComputerNameTemplate(Model.DeviceProfile.Id)))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update computer name template: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update computer name template: ' + textStatus);
$ajaxLoading.hide();
}
});
});
var field = $('#DeviceProfile_ComputerNameTemplate');
var fieldOriginalWidth, fieldOriginalHeight;
document.DiscoFunctions.PropertyChangeHelper(
field,
'None',
'@Url.Action(MVC.API.DeviceProfile.UpdateComputerNameTemplate(Model.DeviceProfile.Id))',
'ComputerNameTemplate'
);
field.focus(function () {
fieldOriginalWidth = field.width();
fieldOriginalHeight = field.height();
field.css('overflow', 'visible').animate({ width: field.parent().width() - 52, height: 75 }, 200);
}).blur(function () {
field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
}).attr('placeholder', 'None').attr('spellcheck', 'false');
});
</script>
}
@@ -395,19 +269,12 @@
<input id="DeviceProfile_EnforceComputerNameConvention" type="checkbox" @(Model.DeviceProfile.EnforceComputerNameConvention ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/>
<script type="text/javascript">
$(function () {
$('#DeviceProfile_EnforceComputerNameConvention').click(function () {
var $this = $(this);
var $ajaxLoading = $this.nextAll('.ajaxLoading').show();
var data = { EnforceComputerNameConvention: $this.is(':checked') };
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateEnforceComputerNameConvention(Model.DeviceProfile.Id))', data, function (response, result) {
if (result != 'success' || response != 'OK') {
alert('Unable to change Enforce Computer Name Convention:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_EnforceComputerNameConvention'),
null,
'@Url.Action(MVC.API.DeviceProfile.UpdateEnforceComputerNameConvention(Model.DeviceProfile.Id))',
'EnforceComputerNameConvention'
);
});
</script>
}
@@ -434,19 +301,12 @@
<input id="DeviceProfile_ProvisionADAccount" type="checkbox" @(Model.DeviceProfile.ProvisionADAccount ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/>
<script type="text/javascript">
$(function () {
$('#DeviceProfile_ProvisionADAccount').click(function () {
var $this = $(this);
var $ajaxLoading = $this.nextAll('.ajaxLoading').show();
var data = { ProvisionADAccount: $this.is(':checked') };
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateProvisionADAccount(Model.DeviceProfile.Id))', data, function (response, result) {
if (result != 'success' || response != 'OK') {
alert('Unable to change Provision AD Account:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_ProvisionADAccount'),
null,
'@Url.Action(MVC.API.DeviceProfile.UpdateProvisionADAccount(Model.DeviceProfile.Id))',
'ProvisionADAccount'
);
});
</script>
}
@@ -465,19 +325,12 @@
<input id="DeviceProfile_AssignedUserLocalAdmin" type="checkbox" @(Model.DeviceProfile.AssignedUserLocalAdmin ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/>
<script type="text/javascript">
$(function () {
$('#DeviceProfile_AssignedUserLocalAdmin').click(function () {
var $this = $(this);
var $ajaxLoading = $this.nextAll('.ajaxLoading').show();
var data = { AssignedUserLocalAdmin: $this.is(':checked') };
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateAssignedUserLocalAdmin(Model.DeviceProfile.Id))', data, function (response, result) {
if (result != 'success' || response != 'OK') {
alert('Unable to change Assigned User Is Local Administrator:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_AssignedUserLocalAdmin'),
null,
'@Url.Action(MVC.API.DeviceProfile.UpdateAssignedUserLocalAdmin(Model.DeviceProfile.Id))',
'AssignedUserLocalAdmin'
);
});
</script>
}
@@ -496,19 +349,12 @@
<input id="DeviceProfile_AllowUntrustedReimageJobEnrolment" type="checkbox" @(Model.DeviceProfile.AllowUntrustedReimageJobEnrolment ? new MvcHtmlString("checked=\"checked\" ") : null)/>
<script type="text/javascript">
$(function () {
$('#DeviceProfile_AllowUntrustedReimageJobEnrolment').click(function () {
var $this = $(this);
var $ajaxLoading = $this.nextAll('.ajaxLoading').show();
var data = { AllowUntrustedReimageJobEnrolment: $this.is(':checked') };
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateAllowUntrustedReimageJobEnrolment(Model.DeviceProfile.Id))', data, function (response, result) {
if (result != 'success' || response != 'OK') {
alert('Unable to change Allow Untrusted Reimage Job Enrolment:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_AllowUntrustedReimageJobEnrolment'),
null,
'@Url.Action(MVC.API.DeviceProfile.UpdateAllowUntrustedReimageJobEnrolment(Model.DeviceProfile.Id))',
'AllowUntrustedReimageJobEnrolment'
);
});
</script>
}
@@ -668,19 +514,12 @@
<input id="DeviceProfile_EnforceOrganisationalUnit" type="checkbox" @(Model.DeviceProfile.EnforceOrganisationalUnit ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/>
<script type="text/javascript">
$(function () {
$('#DeviceProfile_EnforceOrganisationalUnit').click(function () {
var $this = $(this);
var $ajaxLoading = $this.nextAll('.ajaxLoading').show();
var data = { EnforceOrganisationalUnit: $this.is(':checked') };
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateEnforceOrganisationalUnit(Model.DeviceProfile.Id))', data, function (response, result) {
if (result != 'success' || response != 'OK') {
alert('Unable to change Enforce Organisation Unit:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_EnforceOrganisationalUnit'),
null,
'@Url.Action(MVC.API.DeviceProfile.UpdateEnforceOrganisationalUnit(Model.DeviceProfile.Id))',
'EnforceOrganisationalUnit'
);
});
</script>
}
File diff suppressed because it is too large Load Diff
@@ -35,12 +35,12 @@
<h3 data-bind="text: title"></h3>
<div data-bind="visible: undetected">
Disco QR-Code not found<br />
<a target="_blank" data-bind="attr: { href: manuallyAssignUrl }, visible: $parent.sessionEnded">Manually Assign Page</a>
<a target="_blank" href="#" data-bind="attr: { href: manuallyAssignUrl }, visible: $parent.sessionEnded">Manually Assign Page</a>
</div>
<div data-bind="visible: detected">
Document: <a target="_blank" data-bind="text: documentTemplate, attr: { href: documentTemplateUrl }"></a>
Document: <a target="_blank" href="#" data-bind="text: documentTemplate, attr: { href: documentTemplateUrl }"></a>
<br />
Target: <a target="_blank" data-bind="text: assignedData, attr: { href: assignedDataUrl }"></a>
Target: <a target="_blank" href="#" data-bind="text: assignedData, attr: { href: assignedDataUrl }"></a>
</div>
<div data-bind="visible: !(detected() || undetected())">
<p class="sessionStatus" data-bind="text: progressStatus">
@@ -306,7 +306,7 @@
logHub = $.connection.logNotifications;
logHub.client.receiveLog = parseLog
$.connection.hub.qs = { LogModules: '@(Disco.BI.DocumentTemplateBI.Importer.DocumentImporterLog.Current.LiveLogGroupName)' };
$.connection.hub.qs = { LogModules: '@(Disco.BI.DocumentTemplateBI.DocumentsLog.Current.LiveLogGroupName)' };
$.connection.hub.error(function (error) {
alert('Live-Log Error: ' + error);
});
@@ -144,6 +144,8 @@ WriteLiteral(">\r\n Disco QR-Code not found<br />\r\n
WriteLiteral(" target=\"_blank\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(" data-bind=\"attr: { href: manuallyAssignUrl }, visible: $parent.sessionEnded\"");
WriteLiteral(">Manually Assign Page</a>\r\n </div>\r\n " +
@@ -155,6 +157,8 @@ WriteLiteral(">\r\n Document: <a");
WriteLiteral(" target=\"_blank\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(" data-bind=\"text: documentTemplate, attr: { href: documentTemplateUrl }\"");
WriteLiteral("></a>\r\n <br />\r\n Target: <a" +
@@ -162,6 +166,8 @@ WriteLiteral("></a>\r\n <br />\r\n
WriteLiteral(" target=\"_blank\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(" data-bind=\"text: assignedData, attr: { href: assignedDataUrl }\"");
WriteLiteral("></a>\r\n </div>\r\n <div");
@@ -460,7 +466,7 @@ WriteLiteral(@"',
#line 309 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Disco.BI.DocumentTemplateBI.Importer.DocumentImporterLog.Current.LiveLogGroupName);
Write(Disco.BI.DocumentTemplateBI.DocumentsLog.Current.LiveLogGroupName);
#line default
@@ -11,6 +11,8 @@
Model.DocumentTemplate.UsersLinkedGroup == null &&
Model.DocumentTemplate.DevicesLinkedGroup == null &&
Model.DocumentTemplate.FilterExpression == null &&
Model.DocumentTemplate.OnGenerateExpression == null &&
Model.DocumentTemplate.OnImportAttachmentExpression == null &&
Model.TemplateExpressions.All(e => e.All(p => !p.ParseError));
#region Can Bulk Generate
@@ -35,6 +37,11 @@
#endregion
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(null), Model.DocumentTemplate.Description);
if (canConfig)
{
Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers");
}
}
<div id="Config_DocumentTemplates_Show" class="@(hideAdvanced ? "Config_HideAdvanced" : null)">
<div class="form" style="width: 650px; margin: 10px auto 20px;">
@@ -63,41 +70,12 @@
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var $Description = $('#DocumentTemplate_Description');
var $DescriptionAjaxSave = $Description.next('.ajaxSave');
$Description
.watermark('Description')
.focus(function () { $Description.select() })
.keydown(function (e) {
$DescriptionAjaxSave.show();
if (e.which == 13) {
$(this).blur();
}
}).blur(function () {
$DescriptionAjaxSave.hide();
})
.change(function () {
$DescriptionAjaxSave.hide();
var $ajaxLoading = $DescriptionAjaxSave.next('.ajaxLoading').show();
var data = { Description: $Description.val() };
$.ajax({
url: '@Url.Action(MVC.API.DocumentTemplate.UpdateDescription(Model.DocumentTemplate.Id))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update description: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update description: ' + textStatus);
$ajaxLoading.hide();
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DocumentTemplate_Description'),
'Description',
'@Url.Action(MVC.API.DocumentTemplate.UpdateDescription(Model.DocumentTemplate.Id))',
'Description'
);
});
</script>
}
@@ -123,19 +101,12 @@
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
$('#DocumentTemplate_FlattenForm').click(function () {
var $this = $(this);
var $ajaxLoading = $this.next('.ajaxLoading').show();
var data = { FlattenForm: $this.is(':checked') };
$.getJSON('@(Url.Action(MVC.API.DocumentTemplate.UpdateFlattenForm(Model.DocumentTemplate.Id)))', data, function (response, result) {
if (result != 'success' || response != 'OK') {
alert('Unable to change Flatten Form:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
document.DiscoFunctions.PropertyChangeHelper(
$('#DocumentTemplate_FlattenForm'),
null,
'@Url.Action(MVC.API.DocumentTemplate.UpdateFlattenForm(Model.DocumentTemplate.Id))',
'FlattenForm'
);
});
</script>
}
@@ -429,54 +400,46 @@
</th>
<td>@if (canConfig && Authorization.Has(Claims.Config.DocumentTemplate.ConfigureFilterExpression))
{
@Html.TextBoxFor(model => model.DocumentTemplate.FilterExpression)
@Html.EditorFor(model => model.DocumentTemplate.FilterExpression)
@AjaxHelpers.AjaxRemove()
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var $FilterExpression = $('#DocumentTemplate_FilterExpression');
var $ajaxLoading = $FilterExpression.nextAll('.ajaxLoading').first();
var $ajaxRemove = $FilterExpression.nextAll('.ajaxRemove').first();
$FilterExpression
.watermark('Filter Expression')
.focus(function () { $FilterExpression.select() })
.keydown(function (e) {
if (e.which == 13) {
$(this).blur();
}
}).change(function () {
updateFilterExpression($FilterExpression.val());
});
if ($FilterExpression.val() != '')
$ajaxRemove.show();
$ajaxRemove.click(function () {
updateFilterExpression('');
$FilterExpression.val('');
var field = $('#DocumentTemplate_FilterExpression');
var fieldRemove = field.next('.ajaxRemove');
var fieldOriginalWidth, fieldOriginalHeight;
document.DiscoFunctions.PropertyChangeHelper(
field,
'None',
'@Url.Action(MVC.API.DocumentTemplate.UpdateFilterExpression(Model.DocumentTemplate.Id))',
'FilterExpression'
);
field.focus(function () {
fieldOriginalWidth = field.width();
fieldOriginalHeight = field.height();
field.css('overflow', 'visible').animate({ width: field.parent().width() - 42, height: 75 }, 200);
}).blur(function () {
field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
}).change(function () {
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
}).attr('placeholder', 'None').attr('spellcheck', 'false');
fieldRemove.click(function () {
field.val('').change();
});
var updateFilterExpression = function (filterExpression) {
$ajaxLoading.show();
$ajaxRemove.hide();
var data = { FilterExpression: filterExpression };
$.ajax({
url: '@Url.Action(MVC.API.DocumentTemplate.UpdateFilterExpression(Model.DocumentTemplate.Id))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
if (data.FilterExpression != '')
$ajaxRemove.fadeIn('fast');
} else {
$ajaxLoading.hide();
alert('Unable to update filter expression: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update filter expression: ' + textStatus);
$ajaxLoading.hide();
}
});
};
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
});
</script>
}
@@ -493,6 +456,147 @@
</div>
}
}
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i>This expression will be evaluated to determine if this template is shown in the <em>Generate Document</em> drop-down list.
</p>
</div>
</td>
</tr>
<tr>
<th>On Generated Expression:
</th>
<td>@if (canConfig && Authorization.Has(Claims.Config.DocumentTemplate.ConfigureFilterExpression))
{
@Html.EditorFor(model => model.DocumentTemplate.OnGenerateExpression)
@AjaxHelpers.AjaxRemove()
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var field = $('#DocumentTemplate_OnGenerateExpression');
var fieldRemove = field.next('.ajaxRemove');
var fieldOriginalWidth, fieldOriginalHeight;
document.DiscoFunctions.PropertyChangeHelper(
field,
'None',
'@Url.Action(MVC.API.DocumentTemplate.UpdateOnGenerateExpression(Model.DocumentTemplate.Id))',
'OnGenerateExpression'
);
field.focus(function () {
fieldOriginalWidth = field.width();
fieldOriginalHeight = field.height();
field.css('overflow', 'visible').animate({ width: field.parent().width() - 42, height: 75 }, 200);
}).blur(function () {
field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
}).change(function () {
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
}).attr('placeholder', 'None').attr('spellcheck', 'false');
fieldRemove.click(function () {
field.val('').change();
});
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
});
</script>
}
else
{
if (string.IsNullOrWhiteSpace(Model.DocumentTemplate.OnGenerateExpression))
{
<span class="smallMessage">&lt;None Specified&gt;</span>
}
else
{
<div class="code">
@Model.DocumentTemplate.OnGenerateExpression
</div>
}
}
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i>This expression will be evaluated each time a document is generated from this template.
</p>
</div>
</td>
</tr>
<tr>
<th>On Import Expression:
</th>
<td>@if (canConfig && Authorization.Has(Claims.Config.DocumentTemplate.ConfigureFilterExpression))
{
@Html.EditorFor(model => model.DocumentTemplate.OnImportAttachmentExpression)
@AjaxHelpers.AjaxRemove()
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var field = $('#DocumentTemplate_OnImportAttachmentExpression');
var fieldRemove = field.next('.ajaxRemove');
var fieldOriginalWidth, fieldOriginalHeight;
document.DiscoFunctions.PropertyChangeHelper(
field,
'None',
'@Url.Action(MVC.API.DocumentTemplate.UpdateOnImportAttachmentExpression(Model.DocumentTemplate.Id))',
'OnImportAttachmentExpression'
);
field.focus(function () {
fieldOriginalWidth = field.width();
fieldOriginalHeight = field.height();
field.css('overflow', 'visible').animate({ width: field.parent().width() - 42, height: 75 }, 200);
}).blur(function () {
field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
}).change(function () {
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
}).attr('placeholder', 'None').attr('spellcheck', 'false');
fieldRemove.click(function () {
field.val('').change();
});
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
});
</script>
}
else
{
if (string.IsNullOrWhiteSpace(Model.DocumentTemplate.OnImportAttachmentExpression))
{
<span class="smallMessage">&lt;None Specified&gt;</span>
}
else
{
<div class="code">
@Model.DocumentTemplate.OnImportAttachmentExpression
</div>
}
}
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i>This expression will be evaluated each time a document is imported (as an attachment) where it is determined the document was based on this template.
</p>
</div>
</td>
</tr>
<tr>
File diff suppressed because it is too large Load Diff
@@ -61,7 +61,9 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
if (PropertyField[0].nodeName.toLowerCase() == 'textarea') {
PropertyField.keydown(function () {
$ajaxSave.show();
})
}).blur(function () {
$ajaxSave.hide();
});
}
}
};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -60,7 +60,9 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
if (PropertyField[0].nodeName.toLowerCase() == 'textarea') {
PropertyField.keydown(function () {
$ajaxSave.show();
})
}).blur(function () {
$ajaxSave.hide();
});
}
}
};
+14 -2
View File
@@ -287,8 +287,12 @@ table.deviceProfileTable th.type {
table.deviceProfileTable th.deviceCount {
width: 120px;
}
#configurationDeviceProfileShow #ComputerNameTemplate {
width: 300px;
#configurationDeviceProfileShow #DeviceProfile_ComputerNameTemplate {
height: 16px;
min-height: 16px;
width: calc(100% - 32px);
overflow: hidden;
font-family: Consolas, "Courier New", monospace;
}
#configurationDeviceProfileShow #expressionBrowserAnchor {
display: inline-block;
@@ -622,6 +626,14 @@ div.logEventsViewport table.logEventsViewport > tbody > tr > td.eventType {
#Config_DocumentTemplates_Show > div.form > table > tbody > tr > th {
width: 140px;
}
#Config_DocumentTemplates_Show #DocumentTemplate_FilterExpression,
#Config_DocumentTemplates_Show #DocumentTemplate_OnGenerateExpression,
#Config_DocumentTemplates_Show #DocumentTemplate_OnImportAttachmentExpression {
height: 16px;
min-height: 16px;
overflow: hidden;
font-family: Consolas, "Courier New", monospace;
}
#Config_DocumentTemplates_Show #Config_DocumentTemplates_Scope_Button {
margin-top: 4px;
}
+13 -2
View File
@@ -228,8 +228,12 @@ table.deviceProfileTable {
}
#configurationDeviceProfileShow {
#ComputerNameTemplate {
width: 300px;
#DeviceProfile_ComputerNameTemplate {
height: 16px;
min-height: 16px;
width: calc(~"100% - 32px");
overflow: hidden;
font-family: @FontFamilyMono;
}
#expressionBrowserAnchor {
@@ -656,6 +660,13 @@ div.logEventsViewport {
width: 140px;
}
#DocumentTemplate_FilterExpression, #DocumentTemplate_OnGenerateExpression, #DocumentTemplate_OnImportAttachmentExpression {
height: 16px;
min-height: 16px;
overflow: hidden;
font-family: @FontFamilyMono;
}
#Config_DocumentTemplates_Scope_Button {
margin-top: 4px;
}
File diff suppressed because one or more lines are too long
@@ -83,6 +83,18 @@ namespace Disco.Web.Areas.API.Controllers
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult UpdateOnGenerateExpression()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnGenerateExpression);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult UpdateOnImportAttachmentExpression()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnImportAttachmentExpression);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult UpdateFlattenForm()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateFlattenForm);
@@ -173,6 +185,8 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string Template = "Template";
public readonly string UpdateDescription = "UpdateDescription";
public readonly string UpdateFilterExpression = "UpdateFilterExpression";
public readonly string UpdateOnGenerateExpression = "UpdateOnGenerateExpression";
public readonly string UpdateOnImportAttachmentExpression = "UpdateOnImportAttachmentExpression";
public readonly string UpdateFlattenForm = "UpdateFlattenForm";
public readonly string UpdateScope = "UpdateScope";
public readonly string UpdateJobSubTypes = "UpdateJobSubTypes";
@@ -195,6 +209,8 @@ namespace Disco.Web.Areas.API.Controllers
public const string Template = "Template";
public const string UpdateDescription = "UpdateDescription";
public const string UpdateFilterExpression = "UpdateFilterExpression";
public const string UpdateOnGenerateExpression = "UpdateOnGenerateExpression";
public const string UpdateOnImportAttachmentExpression = "UpdateOnImportAttachmentExpression";
public const string UpdateFlattenForm = "UpdateFlattenForm";
public const string UpdateScope = "UpdateScope";
public const string UpdateJobSubTypes = "UpdateJobSubTypes";
@@ -252,6 +268,26 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string FilterExpression = "FilterExpression";
public readonly string redirect = "redirect";
}
static readonly ActionParamsClass_UpdateOnGenerateExpression s_params_UpdateOnGenerateExpression = new ActionParamsClass_UpdateOnGenerateExpression();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_UpdateOnGenerateExpression UpdateOnGenerateExpressionParams { get { return s_params_UpdateOnGenerateExpression; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_UpdateOnGenerateExpression
{
public readonly string id = "id";
public readonly string OnGenerateExpression = "OnGenerateExpression";
public readonly string redirect = "redirect";
}
static readonly ActionParamsClass_UpdateOnImportAttachmentExpression s_params_UpdateOnImportAttachmentExpression = new ActionParamsClass_UpdateOnImportAttachmentExpression();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_UpdateOnImportAttachmentExpression UpdateOnImportAttachmentExpressionParams { get { return s_params_UpdateOnImportAttachmentExpression; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_UpdateOnImportAttachmentExpression
{
public readonly string id = "id";
public readonly string OnImportAttachmentExpression = "OnImportAttachmentExpression";
public readonly string redirect = "redirect";
}
static readonly ActionParamsClass_UpdateFlattenForm s_params_UpdateFlattenForm = new ActionParamsClass_UpdateFlattenForm();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_UpdateFlattenForm UpdateFlattenFormParams { get { return s_params_UpdateFlattenForm; } }
@@ -457,6 +493,34 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo;
}
[NonAction]
partial void UpdateOnGenerateExpressionOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string OnGenerateExpression, bool redirect);
[NonAction]
public override System.Web.Mvc.ActionResult UpdateOnGenerateExpression(string id, string OnGenerateExpression, bool redirect)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnGenerateExpression);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "OnGenerateExpression", OnGenerateExpression);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect);
UpdateOnGenerateExpressionOverride(callInfo, id, OnGenerateExpression, redirect);
return callInfo;
}
[NonAction]
partial void UpdateOnImportAttachmentExpressionOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string OnImportAttachmentExpression, bool redirect);
[NonAction]
public override System.Web.Mvc.ActionResult UpdateOnImportAttachmentExpression(string id, string OnImportAttachmentExpression, bool redirect)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnImportAttachmentExpression);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "OnImportAttachmentExpression", OnImportAttachmentExpression);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect);
UpdateOnImportAttachmentExpressionOverride(callInfo, id, OnImportAttachmentExpression, redirect);
return callInfo;
}
[NonAction]
partial void UpdateFlattenFormOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string FlattenForm, bool redirect);