Files

441 lines
19 KiB
C#

#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Web.Views.User.UserParts
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using Disco.Web;
using Disco.Web.Extensions;
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Views/User/UserParts/_Comments.cshtml")]
public partial class _Comments : Disco.Services.Web.WebViewPage<Disco.Web.Models.User.ShowModel>
{
public _Comments()
{
}
public override void Execute()
{
#line 2 "..\..\Views\User\UserParts\_Comments.cshtml"
Authorization.Require(Claims.User.ShowComments);
var canAddComments = Authorization.Has(Claims.User.Actions.AddComments);
var canRemoveAnyComments = Authorization.Has(Claims.User.Actions.RemoveAnyComments);
var canRemoveOwnComments = Authorization.Has(Claims.User.Actions.RemoveOwnComments);
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" id=\"Comments\"");
WriteAttribute("class", Tuple.Create(" class=\"", 377), Tuple.Create("\"", 597)
#line 8 "..\..\Views\User\UserParts\_Comments.cshtml"
, Tuple.Create(Tuple.Create("", 385), Tuple.Create<System.Object, System.Int32>(canAddComments ? "canAddComments" : "cannotAddComments"
#line default
#line hidden
, 385), false)
#line 8 "..\..\Views\User\UserParts\_Comments.cshtml"
, Tuple.Create(Tuple.Create(" ", 443), Tuple.Create<System.Object, System.Int32>(canRemoveAnyComments ? "canRemoveAnyComments" : "cannotRemoveAnyComments"
#line default
#line hidden
, 444), false)
#line 8 "..\..\Views\User\UserParts\_Comments.cshtml"
, Tuple.Create(Tuple.Create(" ", 520), Tuple.Create<System.Object, System.Int32>(canRemoveOwnComments ? "canRemoveOwnComments" : "cannotRemoveOwnComments"
#line default
#line hidden
, 521), false)
);
WriteLiteral(" data-id=\"");
#line 8 "..\..\Views\User\UserParts\_Comments.cshtml"
Write(Model.User.UserId);
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" data-userid=\"");
#line 8 "..\..\Views\User\UserParts\_Comments.cshtml"
Write(CurrentUser.UserId);
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" data-addurl=\"");
#line 8 "..\..\Views\User\UserParts\_Comments.cshtml"
Write(Url.Action(MVC.API.User.CommentAdd(Model.User.UserId)));
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" data-removeurl=\"");
#line 8 "..\..\Views\User\UserParts\_Comments.cshtml"
Write(Url.Action(MVC.API.User.CommentRemove()));
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" data-geturl=\"");
#line 8 "..\..\Views\User\UserParts\_Comments.cshtml"
Write(Url.Action(MVC.API.User.Comment()));
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(">\r\n");
#line 9 "..\..\Views\User\UserParts\_Comments.cshtml"
#line default
#line hidden
#line 9 "..\..\Views\User\UserParts\_Comments.cshtml"
if (canAddComments)
{
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"commentInput\"");
WriteLiteral(">\r\n <textarea");
WriteLiteral(" class=\"commentInput\"");
WriteLiteral(" placeholder=\"add comment...\"");
WriteLiteral(" accesskey=\"l\"");
WriteLiteral("></textarea>\r\n <button");
WriteLiteral(" type=\"button\"");
WriteLiteral(" title=\"Add Comment\"");
WriteLiteral(" disabled><i");
WriteLiteral(" class=\"fa fa-comment\"");
WriteLiteral("></i></button>\r\n </div>\r\n");
#line 15 "..\..\Views\User\UserParts\_Comments.cshtml"
}
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"commentOutput\"");
WriteLiteral(">\r\n");
#line 17 "..\..\Views\User\UserParts\_Comments.cshtml"
#line default
#line hidden
#line 17 "..\..\Views\User\UserParts\_Comments.cshtml"
foreach (var c in Model.User.UserComments.OrderBy(m => m.Timestamp))
{
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"comment\"");
WriteLiteral(" data-commentid=\"");
#line 19 "..\..\Views\User\UserParts\_Comments.cshtml"
Write(c.Id);
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(">\r\n <span");
WriteLiteral(" class=\"author\"");
WriteLiteral(">");
#line 20 "..\..\Views\User\UserParts\_Comments.cshtml"
Write(c.TechUser.ToStringFriendly());
#line default
#line hidden
WriteLiteral("</span>");
#line 20 "..\..\Views\User\UserParts\_Comments.cshtml"
if (canRemoveAnyComments || (canRemoveOwnComments && c.TechUserId.Equals(CurrentUser.UserId, StringComparison.OrdinalIgnoreCase)))
{
#line default
#line hidden
WriteLiteral("<span");
WriteLiteral(" class=\"remove fa fa-times-circle\"");
WriteLiteral("></span>");
#line 21 "..\..\Views\User\UserParts\_Comments.cshtml"
}
#line default
#line hidden
WriteLiteral("<span");
WriteLiteral(" class=\"timestamp\"");
WriteLiteral(" data-livestamp=\"");
#line 21 "..\..\Views\User\UserParts\_Comments.cshtml"
Write(c.Timestamp.ToUnixEpoc());
#line default
#line hidden
WriteLiteral("\"");
WriteAttribute("title", Tuple.Create(" title=\"", 1671), Tuple.Create("\"", 1708)
#line 21 "..\..\Views\User\UserParts\_Comments.cshtml"
, Tuple.Create(Tuple.Create("", 1679), Tuple.Create<System.Object, System.Int32>(c.Timestamp.ToFullDateTime()
#line default
#line hidden
, 1679), false)
);
WriteLiteral(">");
#line 21 "..\..\Views\User\UserParts\_Comments.cshtml"
Write(c.Timestamp.ToFullDateTime());
#line default
#line hidden
WriteLiteral("</span>\r\n <div");
WriteLiteral(" class=\"comment\"");
WriteLiteral(">");
#line 22 "..\..\Views\User\UserParts\_Comments.cshtml"
Write(c.Comments.ToHtmlComment());
#line default
#line hidden
WriteLiteral("</div>\r\n </div>\r\n");
#line 24 "..\..\Views\User\UserParts\_Comments.cshtml"
}
#line default
#line hidden
WriteLiteral(" </div>\r\n</div>\r\n<script>\r\n if (!document.DiscoFunctions) {\r\n docume" +
"nt.DiscoFunctions = {};\r\n }\r\n\r\n $(function () {\r\n const $comments =" +
" $(\'#Comments\');\r\n const $commentOutput = $comments.find(\'.commentOutput\'" +
");\r\n\r\n window.setTimeout(function () {\r\n $commentOutput[0].scr" +
"ollTop = $commentOutput[0].scrollHeight; // Scroll to Bottom\r\n }, 0);\r\n " +
" $(\'#UserDetailTabs\').on(\'tabsactivate\', function (event, ui) {\r\n " +
" if (ui.newPanel && ui.newPanel.is(\'#UserDetailTab-CommentsAndJobs\')) {\r\n " +
" $commentOutput[0].scrollTop = $commentOutput[0].scrollHeight; // Scrol" +
"l to Bottom\r\n }\r\n });\r\n\r\n function onCommentAdded(id) {" +
"\r\n onCommentAddedAsync(id);\r\n }\r\n async function onComm" +
"entAddedAsync(id) {\r\n const formData = new FormData();\r\n f" +
"ormData.append(\'__RequestVerificationToken\', document.body.dataset.antiforgery);" +
"\r\n formData.append(\'id\', id);\r\n\r\n const response = await f" +
"etch($comments.attr(\'data-geturl\'), {\r\n method: \'POST\',\r\n " +
" body: formData\r\n });\r\n\r\n if (!response.ok) {\r\n " +
" alert(\'Unable to load live comment \' + id + \': \' + response.statusTe" +
"xt);\r\n } else {\r\n const comment = await response.json(" +
");\r\n\r\n if ($comments.hasClass(\'canRemoveAnyComments\'))\r\n " +
" renderComment(comment, false, true);\r\n else if ($comme" +
"nts.hasClass(\'canRemoveOwnComments\'))\r\n renderComment(comment" +
", false, (comment.AuthorId === $comments.attr(\'data-userid\')));\r\n " +
" else\r\n renderComment(comment, false, false);\r\n }\r" +
"\n }\r\n function onCommentRemoved(id) {\r\n $commentOutput." +
"children(\'div[data-commentid=\"\' + id + \'\"]\').slideUp(300).delay(300).queue(funct" +
"ion () {\r\n const $this = $(this);\r\n $this.find(\'.t" +
"imestamp\').livestamp(\'destroy\');\r\n $this.remove();\r\n }" +
");\r\n }\r\n function renderComment(c, quick, canRemove) {\r\n " +
" let t = \'<div><span class=\"author\"></span>\';\r\n if (canRemove)\r\n " +
" t += \'<span class=\"remove fa fa-times-circle\"></span>\';\r\n " +
" t += \'<span class=\"timestamp\"></span><div class=\"comment\"></div></div>\';\r\n\r\n " +
" const e = $(t);\r\n e.attr(\'data-commentid\', c.Id);\r\n " +
" e.find(\'.author\').text(c.Author);\r\n e.find(\'.timestamp\').text(c.Ti" +
"mestampFull).attr(\'title\', c.TimestampFull).livestamp(c.TimestampUnixEpoc);\r\n " +
" e.find(\'.comment\').html(c.HtmlComments);\r\n\r\n $commentOutput." +
"append(e);\r\n\r\n if (!quick) {\r\n e.animate({ backgroundC" +
"olor: \'#ffff99\' }, 500, function () {\r\n e.animate({ backgroun" +
"dColor: \'#fafafa\' }, 500, function () {\r\n e.css(\'backgrou" +
"nd-color\', \'\');\r\n });\r\n });\r\n $" +
"commentOutput.animate({ scrollTop: $commentOutput[0].scrollHeight }, 250)\r\n " +
" }\r\n }\r\n\r\n document.DiscoFunctions.onCommentAdded = onCommen" +
"tAdded;\r\n document.DiscoFunctions.onCommentRemoved = onCommentRemoved;\r\n " +
" });\r\n</script>\r\n");
#line 106 "..\..\Views\User\UserParts\_Comments.cshtml"
if (canAddComments)
{
#line default
#line hidden
WriteLiteral(" <script>\r\n $(function () {\r\n const $comments = $(\'#Comments" +
"\');\r\n const $commentInput = $comments.find(\'textarea.commentInput\');\r" +
"\n const $commentInputButton = $comments.find(\'button\');\r\n " +
"$commentInputButton.on(\'click\', postComment);\r\n $commentInput.on(\'key" +
"press\', function (e) {\r\n if (e.which == 13 && !e.shiftKey) {\r\n " +
" postComment();\r\n return false;\r\n " +
" }\r\n });\r\n\r\n async function postComment() {\r\n " +
" if ($commentInputButton.prop(\'disabled\')) {\r\n alert(\'Di" +
"sconnected from the Disco ICT Server, please refresh this page and try again\');\r" +
"\n return;\r\n }\r\n\r\n const comment" +
" = $commentInput.val();\r\n\r\n if (comment == \'\') {\r\n " +
" alert(\'Enter a comment to post\');\r\n $commentInput.focus(" +
");\r\n return;\r\n }\r\n\r\n $commentIn" +
"put.prop(\'disabled\', true);\r\n\r\n const formData = new FormData();\r" +
"\n formData.append(\'__RequestVerificationToken\', document.body.dat" +
"aset.antiforgery);\r\n formData.append(\'comment\', comment);\r\n\r\n " +
" const response = await fetch($comments.attr(\'data-addurl\'), {\r\n " +
" method: \'POST\',\r\n body: formData\r\n " +
" });\r\n\r\n if (response.ok) {\r\n $commentInput" +
".val(\'\').prop(\'disabled\', false).focus();\r\n } else {\r\n " +
" alert(\'Unable to add comment: \' + response.statusText);\r\n " +
" $commentInput.prop(\'disabled\', false).focus();\r\n }\r\n " +
" }\r\n });\r\n </script>\r\n");
#line 155 "..\..\Views\User\UserParts\_Comments.cshtml"
}
#line default
#line hidden
#line 156 "..\..\Views\User\UserParts\_Comments.cshtml"
if (canRemoveAnyComments || canRemoveOwnComments)
{
#line default
#line hidden
WriteLiteral(" <script>\r\n $(function () {\r\n const $comments = $(\'#Comments" +
"\');\r\n const $commentOutput = $comments.find(\'.commentOutput\');\r\n " +
" let $dialogRemove = null;\r\n\r\n $commentOutput.on(\'click\', \'span" +
".remove\', removeComment);\r\n\r\n function removeComment(e) {\r\n " +
" e.preventDefault();\r\n\r\n const commentId = $(this).closest(\'" +
"div\').attr(\'data-commentid\');\r\n\r\n if (!$dialogRemove) {\r\n " +
" $dialogRemove = $(\'<div class=\"dialog\" title=\"Remove this Comment?\">" +
"<p><i class=\"fa fa-exclamation-triangle fa-lg\"></i>&nbsp;Are you sure?</p></div>" +
"\')\r\n .appendTo(document.body)\r\n .d" +
"ialog({\r\n resizable: false,\r\n " +
" height: 140,\r\n modal: true,\r\n " +
" autoOpen: false\r\n });\r\n }\r\n\r\n " +
" $dialogRemove.dialog(\"enable\").dialog(\'option\', \'buttons\', {\r\n " +
" \"Remove\": function () {\r\n $dialogRemove.dial" +
"og(\"disable\");\r\n $dialogRemove.dialog(\"option\", \"buttons\"" +
", null);\r\n\r\n removeCommentAsync(commentId);\r\n " +
" },\r\n \"Cancel\": function () {\r\n " +
" $dialogRemove.dialog(\"close\");\r\n }\r\n }).dialo" +
"g(\'open\');\r\n }\r\n async function removeCommentAsync(comment" +
"Id) {\r\n const formData = new FormData();\r\n formDat" +
"a.append(\'__RequestVerificationToken\', document.body.dataset.antiforgery);\r\n " +
" formData.append(\'id\', commentId);\r\n\r\n const response " +
"= await fetch($comments.attr(\'data-removeurl\'), {\r\n method: \'" +
"POST\',\r\n body: formData\r\n });\r\n\r\n " +
" if (!response.ok) {\r\n alert(\'Unable to remove comment: \' +" +
" response.statusText);\r\n }\r\n $dialogRemove.dialog(" +
"\"close\");\r\n }\r\n });\r\n </script>\r\n");
#line 211 "..\..\Views\User\UserParts\_Comments.cshtml"
}
#line default
#line hidden
}
}
}
#pragma warning restore 1591