Created
June 7, 2016 11:05
-
-
Save pwahlmueller/27673f2dd6899c3d8ca7a062c3673486 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enter file contents here@using Microsoft.EnterpriseManagement.NewSMPortal.SDKTransformer.SMPortalHelper; | |
@{ | |
Dictionary<string, object> requestItem = ViewBag.RequestItem; | |
List<Dictionary<string, object>> formData = ViewBag.FormData; | |
List<Dictionary<string, object>> KAs = ViewBag.KAs; | |
List<System.ComponentModel.DataAnnotations.ValidationResult> ErrorResults = ViewBag.ErrorResults; | |
string relationshipId = ViewBag.RelID; | |
string message = ViewBag.Message; | |
string creationSuccessFlag = ViewBag.CreationSuccessFlag; | |
string BMEId = ViewBag.BMEID; | |
string DisplayName = ViewBag.DisplayName; | |
} | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
.control_label_required:after { | |
content: " *"; | |
color: red; | |
} | |
</style> | |
<link rel="stylesheet" href="@Url.Content("~/Content/css/jquery-ui.css")"> | |
<script src="@Url.Content("~/Content/js/jquery-ui.js")"></script> | |
<script type="text/javascript"> | |
$(document).ready(function () { | |
$('input').each(function () { | |
if ($(this).attr('data-type') == "datepicker") { | |
$(this).datepicker({ | |
changeMonth: true, | |
changeYear: true, | |
dateFormat: 'mm/dd/yy' | |
}); | |
} | |
}); | |
$('span').each(function () { | |
if ($(this).attr('data-required') == "required") { | |
$(this).addClass('control_label_required'); | |
} | |
}); | |
$('label').each(function () { | |
if ($(this).attr('data-required') == "required") { | |
$(this).addClass('control_label_required'); | |
} | |
}); | |
$('input').each(function () { | |
if ($(this).attr('data-required') == "required") { | |
$(this).addClass('control_label_required'); | |
} | |
}); | |
@foreach (var item in formData.FindAll(x => x["Type"].ToString().Equals("select"))) | |
{ | |
@:$('select[name="' + '@item["PathSend"]' + '"] option[value="' + '@item["DefaultEntry"]' + '"]').attr({ 'selected': 'selected' }); | |
} | |
if ('@relationshipId' != '') { | |
$('.fav_this').find('.icon').removeClass('icon-HeartLegacy').addClass('icon-HeartFillLegacy').addClass('icon-fill'); | |
} | |
if ('@Request.Form.AllKeys.Contains("submitButton")' == 'True') { | |
if ('@creationSuccessFlag' == 'true') { | |
pageLoaderAction('hide'); | |
showTossNotification("@Html.Raw(message)", function () { | |
$(location).attr('href', '/Home'); | |
}); | |
} | |
else { | |
pageLoaderAction('hide'); | |
@*showTossNotification("@Html.Raw(message)", function () { });*@ | |
} | |
} | |
//validateOnSubmit(); | |
queryRowClick(); | |
queryDailogClose(); | |
stopCheckBoxClickEvent(); | |
favIconAction(); | |
shareMailAction(); | |
$('.fav_div_container .query_table').DataTable({ | |
"paging": false, | |
searching: false, | |
ordering: false, | |
"language": { | |
"emptyTable": "@Resources.SelfServicePortalResources.EmptyQueryTable", | |
} | |
}); | |
$('.fav_cancel').on('click', function (event) { | |
event.preventDefault(); | |
//event.stopPropagation(); | |
$(location).attr('href', '/Home'); | |
}); | |
$('.queryPickButton').on('click', function (event) { | |
//window.alert('click'); | |
event.stopPropagation(); | |
var clickedElement = $(this).attr("data-idSource"); | |
var docHeight = $(document).height(); | |
var overlayDiv = $("<div id='overlay'></div>").height(docHeight); | |
$("body").append(overlayDiv); | |
$('#page_loader').show(); | |
$.ajax({ | |
url: "/Home/Query", | |
type: 'POST', | |
data: $('form#formLink').serialize() + "&clickedElement=" + clickedElement + "&ROGuid=" + '@requestItem["BMEId"]', | |
success: function (data) { | |
$('#page_loader').hide(); | |
$("body #overlay").remove(); | |
$('div#' + clickedElement).empty(); | |
$('div#' + clickedElement).html(data); | |
var table = $('div#' + clickedElement).find('table').DataTable({ | |
"paging": true, | |
"searching": true, | |
"ordering": true, | |
"scrollY": "35em", | |
"scrollCollapse": true, | |
"autoWidth": true, | |
"language": { | |
"emptyTable": "@Resources.SelfServicePortalResources.NoSearchRecords", | |
"zeroRecords": "@Resources.SelfServicePortalResources.NoSearchRecords", | |
"search": "@Resources.SelfServicePortalResources.Search:", | |
"info": "@Resources.SelfServicePortalResources.Showing _START_ to _END_ of _TOTAL_ entries", | |
"infoEmpty": "@Resources.SelfServicePortalResources.Showing 0 to 0 of 0 @Resources.SelfServicePortalResources.Enteries", | |
"infoFiltered": "(@Resources.SelfServicePortalResources.Filtered from _MAX_ @Resources.SelfServicePortalResources.Enteries)", | |
"lengthMenu": "@Resources.SelfServicePortalResources.Show _MENU_ @Resources.SelfServicePortalResources.Enteries", | |
"paginate": { | |
"first": "@Resources.SelfServicePortalResources.First", | |
"last": "@Resources.SelfServicePortalResources.Last", | |
"next": "@Resources.SelfServicePortalResources.Next", | |
"previous": "@Resources.SelfServicePortalResources.Previous" | |
}, | |
} | |
}); | |
} | |
}); | |
}); | |
//window.alert('jetzt'); | |
$('.queryPickButton').click(); | |
}); | |
//var validateOnSubmit = function () { | |
// var ret; | |
// $('#submitButton').on('click', function (event, ret) { | |
// $('.queryResult').each(function (ret) { | |
// var required = $(this).attr("data-required"); | |
// if (required == "required") { | |
// if ($(this).find('input[type=checkbox]:checked').length == 0) { | |
// $(this).html = '<text>This field cannot be empty. Chose atleast one item'; | |
// ret = false; | |
// } | |
// } | |
// }); | |
// }); | |
// return ret; | |
//} | |
function pageLoaderActionOnSubmit() { | |
pageLoaderAction('show'); | |
return true; | |
} | |
function popup(link, windowname) { | |
if (!window.focus) | |
return true; | |
var href = link; | |
if (typeof (link) == 'string') | |
href = link; | |
else href = link.href; | |
href = href + "?bmeId=" + link.id; | |
window.open(href, windowname, 'width=600,height=600,resizable=yes,dependent=yes,scrollbars=yes'); | |
return false; | |
} | |
var stopCheckBoxClickEvent = function () { | |
$('body').on('click', '#query_table input[type=checkbox]', function (event) { | |
event.stopPropagation(); | |
}); | |
} | |
var queryRowClick = function () { | |
$('body').on('click', '#query_table tr td.details_link', function (event) { | |
var link = "/Home/DetailsPopUp"; | |
var docHeight = $(document).height(); | |
var width = $(window).width(); | |
var overlayDiv = $("<div id='overlay'></div>").height(docHeight); | |
$("body").append(overlayDiv); | |
var url = link + "?bmeId=" + $(this).closest('tr').attr('id'); | |
$('.query_pop_up').find('.title_content').text($(this).closest('tr').attr('data-name')); | |
$('.query_pop_up').show().find('.content').load(url, function () { | |
if (width < 786) { | |
$(function () { | |
$('.query_pop_up').find('#item_details_table').DataTable({ | |
searching: false, | |
ordering: false, | |
"scrollY": "25em", | |
"scrollCollapse": true, | |
"pageLength": 12, | |
"bLengthChange": false, | |
}); | |
}); | |
} else { | |
$(function () { | |
$('.query_pop_up').find('#item_details_table').DataTable({ | |
searching: false, | |
ordering: false, | |
"scrollY": "40em", | |
"scrollCollapse": true, | |
"pageLength": 12, | |
"bLengthChange": false, | |
}); | |
}); | |
} | |
$(window).scrollTop($('.query_pop_up .title').offset().top - 80); | |
}); | |
}); | |
} | |
var queryDailogClose = function () { | |
$('body').on('click', '.query_pop_up .close', function (event) { | |
$(this).closest('.query_pop_up').hide(); | |
$('#overlay').remove(); | |
}); | |
} | |
var getDialogTitle = function () { | |
var title = $('.query_dialog_title').show(); | |
return title; | |
} | |
var favIconAction = function () { | |
$('.fav_this').on('click', function (event) { | |
pageLoaderAction('show'); | |
var favDiv = $(this); | |
//If it is not already favourited | |
if (favDiv.find('.icon').hasClass('icon-HeartLegacy')) { | |
$.ajax({ | |
url: "/SelfServicePortalBase/EditFavorites", | |
type: "POST", | |
data: { "guid": '@BMEId', "type": '@SMPortalHelper.FavoritesTarget.RequestOfferings', "action": "add" }, | |
success: function (data) { | |
//Fill the fav icon | |
$('.fav_this').find('.icon').removeClass('icon-HeartLegacy').addClass('icon-HeartFillLegacy').addClass('icon-fill'); | |
pageLoaderAction('hide'); | |
}, | |
error: function (data) { | |
} | |
}); | |
} | |
else { | |
$.ajax({ | |
url: "/SelfServicePortalBase/EditFavorites", | |
type: "POST", | |
data: { "relationshipId": '@relationshipId', "type": '@SMPortalHelper.FavoritesTarget.RequestOfferings', "action": "delete" }, | |
success: function (data) { | |
//Fill the fav icon | |
$('.fav_this').find('.icon').addClass('icon-HeartLegacy').removeClass('icon-HeartFillLegacy').removeClass('icon-fill'); | |
pageLoaderAction('hide'); | |
}, | |
error: function (data) { | |
} | |
}); | |
} | |
}); | |
} | |
var shareMailAction = function () { | |
$('.share_this').on('click', function (event) { | |
window.location = 'mailto:?subject=@requestItem["Title"]&body=@requestItem["Title"]: ' + window.location + '?BMEID=' + '@BMEId'; | |
}); | |
} | |
</script> | |
</head> | |
<body class="main_body clr gutters"> | |
<!--p id="message"></p--> | |
@*<p id="response" style="background: yellow;"></p>*@ | |
<div class="fav_div_container col span_22 outer side_bar_margin top_bar_margin page"> | |
<div class="fav_heading span_22 section" style="margin-bottom:2.5em;"> | |
<div class="row"> | |
<div class="col span_24 heading"> | |
<span>@requestItem["DisplayName"]</span> | |
<span class="fav_this"> | |
<span class="icon-HeartLegacy icon" data-toggle="tooltip" title="@Resources.SelfServicePortalResources.FavouriteThis"></span> | |
</span> | |
<span class="share_this"> | |
<span class="icon-Share icon" data-toggle="tooltip" title="@Resources.SelfServicePortalResources.Share"></span> | |
</span> | |
</div> | |
</div> | |
</div> | |
<div class="fav_desc section"> | |
<div class="row sub_heading">@Resources.SelfServicePortalResources.Description</div> | |
<p>@requestItem["BriefDescription"]</p> | |
</div> | |
@if (KAs.Count != 0) | |
{ | |
<div class="fav_help_articles section"> | |
<div class="row sub_heading">@Resources.SelfServicePortalResources.RelatedHelpArticles</div> | |
@foreach (Dictionary<string, object> item in KAs) | |
{ | |
<a href='~/KnowledgeBase/Article?id=@item["ArticleId"]'>@item["Title"]</a> | |
} | |
</div> | |
} | |
<hr> | |
<div class="fav_instructions section"> | |
<div class="row sub_heading">@Resources.SelfServicePortalResources.Instructions</div> | |
<p> | |
@requestItem["Overview"] | |
</p> | |
</div> | |
<form method="post" action="/Home/makeform" id="formLink" enctype="multipart/form-data" onsubmit="return (pageLoaderActionOnSubmit())"> | |
<div class="fav_name_email section"> | |
@foreach (var item in formData) | |
{ | |
if (item["Type"].ToString().Equals("PortalControl")) | |
{ | |
@*<input type="hidden" name="@item["PathSend"].ToString()" value="@item["PortalUserName"].ToString()" />*@ | |
} | |
else if (item["Type"].ToString().Equals("select")) | |
{ | |
<label for="@item["Prompt"].ToString()" data-required="@item["Optional"].ToString()">@item["Prompt"].ToString()</label> | |
<select name="@item["PathSend"].ToString()"> | |
@if (item["Optional"].ToString().Equals("optional")) | |
{ | |
<option value='' selected></option> | |
} | |
@foreach (var element in item["listEntries"] as Dictionary<string, string>) | |
{ | |
<option value='@element.Key'>@element.Value</option> | |
} | |
</select> | |
<div class="error-text">@ErrorResults.Find(m => m.MemberNames.ElementAt(0).Equals(item["PathSend"].ToString()))</div> | |
} | |
else if (item["BaseType"].ToString().Equals("Double")) | |
{ | |
<label for="@item["Prompt"].ToString()" data-required="@item["Optional"].ToString()">@item["Prompt"].ToString()</label> | |
<input type="@item["Type"].ToString()" name="@item["PathSend"].ToString()" id="@item["Prompt"].ToString()" step="any" @item["Optional"].ToString() @item["ReadOnly"].ToString() value='@Request[item["PathSend"].ToString()]'> | |
<div class="error-text">@ErrorResults.Find(m => m.MemberNames.ElementAt(0).Equals(item["PathSend"].ToString()))</div> | |
} | |
else if (item["Type"].ToString().Equals("InstancePicker")) | |
{ | |
<div class="row query_picker_heading"> | |
<span class="title" data-required="@item["Optional"].ToString()">@item["Prompt"].ToString()</span> | |
@if (item["Metadata"].ToString() != "") | |
{ | |
<span class="depend_text">@Resources.SelfServicePortalResources.QueryPickerMeta @item["Metadata"].ToString()</span> | |
} | |
</div> | |
<button type="button" class="queryPickButton btn" data-idsource="@item["PathSend"].ToString()">@Resources.SelfServicePortalResources.Refresh</button> | |
<div class="error-text">@ErrorResults.Find(m => m.MemberNames.ElementAt(0).Equals(item["PathSend"].ToString()))</div> | |
<div class="queryResult" id="@item["PathSend"].ToString()" data-required="@item["Optional"].ToString()"> | |
<table class="query_table cell-border"> | |
<thead> | |
<tr> | |
<th></th> | |
@foreach (string column in item["DisplayColumns"] as List<string>) | |
{ | |
<th>@column</th> | |
} | |
</tr> | |
</thead> | |
<tbody></tbody> | |
</table> | |
</div> | |
} | |
else if (item["Type"].ToString().Equals("checkbox")) | |
{ | |
<span class="title" data-required="@item["Optional"].ToString()"> | |
<input style="margin-bottom:1em;margin-top:1em;" type="checkbox" name="@item["PathSend"].ToString()" id="@item["Prompt"].ToString()" @item["Optional"].ToString() @item["ReadOnly"].ToString() value='@Request[item["PathSend"].ToString()]' /> | |
@item["Prompt"].ToString() | |
</span> | |
} | |
else if (item["Type"].ToString().Equals("date")) | |
{ | |
<label for="@item["Prompt"].ToString()" data-required="@item["Optional"].ToString()">@item["Prompt"].ToString()</label> | |
<input type="text" name="@item["PathSend"].ToString()" data-type="datepicker" placeholder="mm/dd/yyyy" id="@item["Prompt"].ToString()" @item["Optional"].ToString() /> | |
<div class="error-text">@ErrorResults.Find(m => m.MemberNames.ElementAt(0).Equals(item["PathSend"].ToString()))</div> | |
} | |
else | |
{ | |
string regexToolTip = string.Empty; | |
if (item.ContainsKey("ToolTip")) | |
{ | |
regexToolTip = item["ToolTip"].ToString(); | |
} | |
<label for="@item["Prompt"].ToString()" data-required="@item["Optional"].ToString()">@item["Prompt"].ToString()</label> | |
<input type="@item["Type"].ToString()" name="@item["PathSend"].ToString()" id="@item["Prompt"].ToString()" @item["Optional"].ToString() @item["ReadOnly"].ToString() value='@Request[item["PathSend"].ToString()]' data-toggle="tooltip" title="@regexToolTip" /> | |
<div class="error-text">@ErrorResults.Find(m => m.MemberNames.ElementAt(0).Equals(item["PathSend"].ToString()))</div> | |
} | |
} | |
</div> | |
<div class="fav_action_btn_bar section"> | |
<button class="btn fav_submit" id="submitButton" name="submitButton">@Resources.SelfServicePortalResources.SubmitForm</button> | |
<button class="btn fav_cancel" name="cancel">@Resources.SelfServicePortalResources.Cancel</button> | |
</div> | |
<input type="hidden" class="BMEId" name="BMEId" value="@BMEId" hidden> | |
<input type="hidden" name="DisplayName" value="@DisplayName" hidden> | |
</form> | |
</div> | |
<div class="query_pop_up pop_up" style="display:none;"> | |
<div class="title"> | |
<span class="title_content"></span> | |
<span class="close icon-ChromeClose icon"></span> | |
</div> | |
<div class="content"></div> | |
</div> | |
<div id="page_loader" style="display:none;"> | |
<img src="/Content/images/loading.gif" alt=@Resources.SelfServicePortalResources.Loading style="width: 5em; height: 5em;" /> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment