#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;
    
    #line 2 "..\..\Views\User\UserParts\_Flags.cshtml"
    using Disco.Services.Users.UserFlags;
    
    #line default
    #line hidden
    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/_Flags.cshtml")]
    public partial class _Flags : Disco.Services.Web.WebViewPage<Disco.Web.Models.User.ShowModel>
    {
        public _Flags()
        {
        }
        public override void Execute()
        {
            
            #line 3 "..\..\Views\User\UserParts\_Flags.cshtml"
  
    Authorization.Require(Claims.User.ShowFlagAssignments);

    var hasRemove = Authorization.Has(Claims.User.Actions.RemoveFlags);
    var hasEdit = Authorization.Has(Claims.User.Actions.EditFlags);

    var hasUserFlagShow = Authorization.Has(Claims.Config.UserFlag.Show);
    var activeAssignmentCount = Model.User.UserFlagAssignments == null ? 0 : Model.User.UserFlagAssignments.Count(a => !a.RemovedDate.HasValue);

    var flagAssignments = Model.User.UserFlagAssignments.Select(a => Tuple.Create(a, UserFlagService.GetUserFlag(a.UserFlagId))).ToList();

            
            #line default
            #line hidden
WriteLiteral("\r\n<div");

WriteLiteral(" id=\"UserDetailTab-Flags\"");

WriteLiteral(" class=\"UserPart\"");

WriteLiteral(">\r\n");

            
            #line 15 "..\..\Views\User\UserParts\_Flags.cshtml"
    
            
            #line default
            #line hidden
            
            #line 15 "..\..\Views\User\UserParts\_Flags.cshtml"
     if (flagAssignments.Count > 0)
    {

            
            #line default
            #line hidden
WriteLiteral("        <table");

WriteLiteral(" id=\"userFlags\"");

WriteLiteral(">\r\n            <tr>\r\n                <th");

WriteLiteral(" class=\"name\"");

WriteLiteral(">Name</th>\r\n                <th");

WriteLiteral(" class=\"added\"");

WriteLiteral(">Added</th>\r\n                <th");

WriteLiteral(" class=\"sla\"");

WriteLiteral(">Comments</th>\r\n                <th");

WriteLiteral(" class=\"removed\"");

WriteLiteral(">Removed</th>\r\n            </tr>\r\n");

            
            #line 24 "..\..\Views\User\UserParts\_Flags.cshtml"
            
            
            #line default
            #line hidden
            
            #line 24 "..\..\Views\User\UserParts\_Flags.cshtml"
             foreach (var fa in flagAssignments.OrderByDescending(a => a.Item1.AddedDate))
            {

            
            #line default
            #line hidden
WriteLiteral("                <tr");

WriteLiteral(" data-userflagassignmentid=\"");

            
            #line 26 "..\..\Views\User\UserParts\_Flags.cshtml"
                                          Write(fa.Item1.Id);

            
            #line default
            #line hidden
WriteLiteral("\"");

WriteLiteral(" data-flagassignmentaddeddate=\"");

            
            #line 26 "..\..\Views\User\UserParts\_Flags.cshtml"
                                                                                       Write(fa.Item1.AddedDate.ToString("s"));

            
            #line default
            #line hidden
WriteLiteral("\"");

WriteAttribute("class", Tuple.Create(" class=\"", 1240), Tuple.Create("\"", 1303)
            
            #line 26 "..\..\Views\User\UserParts\_Flags.cshtml"
                                                        , Tuple.Create(Tuple.Create("", 1248), Tuple.Create<System.Object, System.Int32>(!fa.Item1.RemovedDate.HasValue ? "added" : "removed"
            
            #line default
            #line hidden
, 1248), false)
);

WriteLiteral(">\r\n                    <td");

WriteLiteral(" class=\"name\"");

WriteLiteral(">\r\n                        <i");

WriteAttribute("class", Tuple.Create(" class=\"", 1372), Tuple.Create("\"", 1439)
, Tuple.Create(Tuple.Create("", 1380), Tuple.Create("fa", 1380), true)
, Tuple.Create(Tuple.Create(" ", 1382), Tuple.Create("fa-", 1383), true)
            
            #line 28 "..\..\Views\User\UserParts\_Flags.cshtml"
, Tuple.Create(Tuple.Create("", 1386), Tuple.Create<System.Object, System.Int32>(fa.Item2.Icon
            
            #line default
            #line hidden
, 1386), false)
, Tuple.Create(Tuple.Create(" ", 1402), Tuple.Create("fa-fw", 1403), true)
, Tuple.Create(Tuple.Create(" ", 1408), Tuple.Create("fa-lg", 1409), true)
, Tuple.Create(Tuple.Create(" ", 1414), Tuple.Create("d-", 1415), true)
            
            #line 28 "..\..\Views\User\UserParts\_Flags.cshtml"
, Tuple.Create(Tuple.Create("", 1417), Tuple.Create<System.Object, System.Int32>(fa.Item2.IconColour
            
            #line default
            #line hidden
, 1417), false)
);

WriteLiteral("></i>\r\n");

            
            #line 29 "..\..\Views\User\UserParts\_Flags.cshtml"
                        
            
            #line default
            #line hidden
            
            #line 29 "..\..\Views\User\UserParts\_Flags.cshtml"
                         if (hasUserFlagShow)
                        {
                            
            
            #line default
            #line hidden
            
            #line 31 "..\..\Views\User\UserParts\_Flags.cshtml"
                       Write(Html.ActionLink(fa.Item2.Name, MVC.Config.UserFlag.Index(fa.Item2.Id)));

            
            #line default
            #line hidden
            
            #line 31 "..\..\Views\User\UserParts\_Flags.cshtml"
                                                                                                   
                        }
                        else
                        {
                            
            
            #line default
            #line hidden
            
            #line 35 "..\..\Views\User\UserParts\_Flags.cshtml"
                       Write(fa.Item2.Name);

            
            #line default
            #line hidden
            
            #line 35 "..\..\Views\User\UserParts\_Flags.cshtml"
                                          
                        }

            
            #line default
            #line hidden
WriteLiteral("                    </td>\r\n                    <td");

WriteLiteral(" class=\"added\"");

WriteLiteral(">\r\n");

WriteLiteral("                        ");

            
            #line 39 "..\..\Views\User\UserParts\_Flags.cshtml"
                   Write(CommonHelpers.FriendlyDateAndUser(fa.Item1.AddedDate, fa.Item1.AddedUser));

            
            #line default
            #line hidden
WriteLiteral("\r\n");

            
            #line 40 "..\..\Views\User\UserParts\_Flags.cshtml"
                        
            
            #line default
            #line hidden
            
            #line 40 "..\..\Views\User\UserParts\_Flags.cshtml"
                         if (fa.Item1.OnAssignmentExpressionResult != null)
                        {

            
            #line default
            #line hidden
WriteLiteral("                            <div");

WriteLiteral(" class=\"expressionResult\"");

WriteLiteral(">");

            
            #line 42 "..\..\Views\User\UserParts\_Flags.cshtml"
                                                     Write(fa.Item1.OnAssignmentExpressionResult);

            
            #line default
            #line hidden
WriteLiteral("</div>\r\n");

            
            #line 43 "..\..\Views\User\UserParts\_Flags.cshtml"
                        }

            
            #line default
            #line hidden
WriteLiteral("                    </td>\r\n                    <td");

WriteLiteral(" class=\"comments\"");

WriteLiteral(">\r\n");

            
            #line 46 "..\..\Views\User\UserParts\_Flags.cshtml"
                        
            
            #line default
            #line hidden
            
            #line 46 "..\..\Views\User\UserParts\_Flags.cshtml"
                         if (hasEdit)
                        {

            
            #line default
            #line hidden
WriteLiteral("                            <div");

WriteLiteral(" class=\"editable\"");

WriteLiteral("><i");

WriteLiteral(" class=\"fa fa-fw fa-edit\"");

WriteLiteral(" title=\"Edit Comments\"");

WriteLiteral("></i></div>\r\n");

            
            #line 49 "..\..\Views\User\UserParts\_Flags.cshtml"
                        }

            
            #line default
            #line hidden
WriteLiteral("                        ");

            
            #line 50 "..\..\Views\User\UserParts\_Flags.cshtml"
                         if (fa.Item1.Comments == null)
                        {

            
            #line default
            #line hidden
WriteLiteral("                            <div");

WriteLiteral(" class=\"comments smallMessage\"");

WriteLiteral(">[no comments]</div>\r\n");

            
            #line 53 "..\..\Views\User\UserParts\_Flags.cshtml"
                        }
                        else
                        {

            
            #line default
            #line hidden
WriteLiteral("                            <div");

WriteLiteral(" class=\"comments\"");

WriteLiteral(">");

            
            #line 56 "..\..\Views\User\UserParts\_Flags.cshtml"
                                             Write(fa.Item1.Comments.ToHtmlComment());

            
            #line default
            #line hidden
WriteLiteral("</div>\r\n");

WriteLiteral("                            <div");

WriteLiteral(" class=\"commentsRaw\"");

WriteLiteral(">");

            
            #line 57 "..\..\Views\User\UserParts\_Flags.cshtml"
                                                Write(fa.Item1.Comments);

            
            #line default
            #line hidden
WriteLiteral("</div>\r\n");

            
            #line 58 "..\..\Views\User\UserParts\_Flags.cshtml"
                        }

            
            #line default
            #line hidden
WriteLiteral("                    </td>\r\n                    <td");

WriteAttribute("class", Tuple.Create(" class=\"", 2954), Tuple.Create("\"", 3017)
, Tuple.Create(Tuple.Create("", 2962), Tuple.Create("removed", 2962), true)
            
            #line 60 "..\..\Views\User\UserParts\_Flags.cshtml"
, Tuple.Create(Tuple.Create("", 2969), Tuple.Create<System.Object, System.Int32>(!fa.Item1.RemovedDate.HasValue ? " na" : null
            
            #line default
            #line hidden
, 2969), false)
);

WriteLiteral(">\r\n");

            
            #line 61 "..\..\Views\User\UserParts\_Flags.cshtml"
                        
            
            #line default
            #line hidden
            
            #line 61 "..\..\Views\User\UserParts\_Flags.cshtml"
                         if (fa.Item1.RemovedDate.HasValue)
                        {
                            
            
            #line default
            #line hidden
            
            #line 63 "..\..\Views\User\UserParts\_Flags.cshtml"
                       Write(CommonHelpers.FriendlyDateAndUser(fa.Item1.RemovedDate.Value, fa.Item1.RemovedUser));

            
            #line default
            #line hidden
            
            #line 63 "..\..\Views\User\UserParts\_Flags.cshtml"
                                                                                                                
                            if (fa.Item1.OnUnassignmentExpressionResult != null)
                            {

            
            #line default
            #line hidden
WriteLiteral("                                <div");

WriteLiteral(" class=\"expressionResult\"");

WriteLiteral(">");

            
            #line 66 "..\..\Views\User\UserParts\_Flags.cshtml"
                                                         Write(fa.Item1.OnUnassignmentExpressionResult);

            
            #line default
            #line hidden
WriteLiteral("</div>\r\n");

            
            #line 67 "..\..\Views\User\UserParts\_Flags.cshtml"
                            }
                        }
                        else if (fa.Item1.CanRemove())
                        {

            
            #line default
            #line hidden
WriteLiteral("                            <a");

WriteLiteral(" href=\"#\"");

WriteLiteral(" class=\"button small remove\"");

WriteLiteral(">Remove</a>\r\n");

            
            #line 72 "..\..\Views\User\UserParts\_Flags.cshtml"
                        }

            
            #line default
            #line hidden
WriteLiteral("                    </td>\r\n                </tr>\r\n");

            
            #line 75 "..\..\Views\User\UserParts\_Flags.cshtml"
            }

            
            #line default
            #line hidden
WriteLiteral("        </table>\r\n");

WriteLiteral("        <div");

WriteLiteral(" id=\"User_Show_Flags_Actions_Remove_Dialog\"");

WriteLiteral(" class=\"dialog\"");

WriteLiteral(" title=\"Remove this flag from the user?\"");

WriteLiteral(">\r\n");

            
            #line 78 "..\..\Views\User\UserParts\_Flags.cshtml"
            
            
            #line default
            #line hidden
            
            #line 78 "..\..\Views\User\UserParts\_Flags.cshtml"
             using (Html.BeginForm(MVC.API.UserFlagAssignment.RemoveUser()))
            {

            
            #line default
            #line hidden
WriteLiteral("                <input");

WriteLiteral(" id=\"User_Show_Flags_Actions_Remove_Dialog_Id\"");

WriteLiteral(" type=\"hidden\"");

WriteLiteral(" name=\"id\"");

WriteLiteral(" value=\"\"");

WriteLiteral(" />\r\n");

WriteLiteral("                <p>\r\n                    <i");

WriteLiteral(" class=\"fa fa-exclamation-triangle fa-lg\"");

WriteLiteral("></i>&nbsp;Are you sure?\r\n                </p>\r\n");

            
            #line 84 "..\..\Views\User\UserParts\_Flags.cshtml"
            }

            
            #line default
            #line hidden
WriteLiteral("        </div>\r\n");

WriteLiteral("        <div");

WriteLiteral(" id=\"User_Show_Flags_Actions_EditComments_Dialog\"");

WriteLiteral(" class=\"dialog\"");

WriteLiteral(" title=\"Edit the Comments\"");

WriteLiteral(">\r\n");

            
            #line 87 "..\..\Views\User\UserParts\_Flags.cshtml"
            
            
            #line default
            #line hidden
            
            #line 87 "..\..\Views\User\UserParts\_Flags.cshtml"
             using (Html.BeginForm(MVC.API.UserFlagAssignment.UpdateComments()))
            {

            
            #line default
            #line hidden
WriteLiteral("                <input");

WriteLiteral(" id=\"User_Show_Flags_Actions_EditComments_Dialog_Id\"");

WriteLiteral(" type=\"hidden\"");

WriteLiteral(" name=\"id\"");

WriteLiteral(" value=\"\"");

WriteLiteral(" />\r\n");

WriteLiteral("                <input");

WriteLiteral(" type=\"hidden\"");

WriteLiteral(" name=\"redirect\"");

WriteLiteral(" value=\"true\"");

WriteLiteral(" />\r\n");

WriteLiteral("                <h4>Comments:</h4>\r\n");

WriteLiteral("                <p>\r\n                    <textarea");

WriteLiteral(" id=\"User_Show_Flags_Actions_EditComments_Dialog_Comments\"");

WriteLiteral(" name=\"Comments\"");

WriteLiteral(" class=\"block\"");

WriteLiteral("></textarea>\r\n                </p>\r\n");

            
            #line 95 "..\..\Views\User\UserParts\_Flags.cshtml"
            }

            
            #line default
            #line hidden
WriteLiteral("        </div>\r\n");

WriteLiteral("        <script");

WriteLiteral(" type=\"text/javascript\"");

WriteLiteral(">\r\n            $(function () {\r\n                var userFlags = $(\'#userFlags\');\r" +
"\n\r\n                var dialog = null;\r\n                var dialogEditComments = " +
"null;\r\n\r\n                userFlags.on(\'click\', \'a.remove\', function (e) {\r\n     " +
"               var $this = $(this);\r\n                    var UserFlagAssignmentI" +
"d = $this.closest(\'tr\').attr(\'data-userflagassignmentid\');\r\n\r\n                  " +
"  if (!dialog) {\r\n                        dialog = $(\'#User_Show_Flags_Actions_R" +
"emove_Dialog\');\r\n                        dialog.dialog({\r\n                      " +
"      resizable: false,\r\n                            modal: true,\r\n             " +
"               autoOpen: false,\r\n                            buttons: {\r\n       " +
"                         \"Remove Flag\": function () {\r\n                         " +
"           var $this = $(this);\r\n                                    $this.dialo" +
"g(\"disable\");\r\n                                    $this.dialog(\"option\", \"butto" +
"ns\", null);\r\n                                    $this.find(\'form\').submit();\r\n " +
"                               },\r\n                                Cancel: funct" +
"ion () {\r\n                                    $(this).dialog(\"close\");\r\n        " +
"                        }\r\n                            }\r\n                      " +
"  });\r\n                    }\r\n\r\n                    $(\'#User_Show_Flags_Actions_" +
"Remove_Dialog_Id\').val(UserFlagAssignmentId);\r\n                    dialog.dialog" +
"(\'open\');\r\n\r\n                    e.preventDefault();\r\n                    return" +
" false;\r\n                });\r\n\r\n                userFlags.on(\'click\', \'td.commen" +
"ts i.fa-edit\', function (e) {\r\n                    var $this = $(this);\r\n       " +
"             var UserFlagAssignmentId = $this.closest(\'tr\').attr(\'data-userflaga" +
"ssignmentid\');\r\n\r\n                    if (!dialogEditComments) {\r\n              " +
"          dialogEditComments = $(\'#User_Show_Flags_Actions_EditComments_Dialog\')" +
";\r\n                        dialogEditComments.dialog({\r\n                        " +
"    resizable: false,\r\n                            modal: true,\r\n               " +
"             width: 320,\r\n                            autoOpen: false,\r\n        " +
"                    buttons: {\r\n                                \"Save Changes\": " +
"function () {\r\n                                    var $this = $(this);\r\n       " +
"                             $this.dialog(\"disable\");\r\n                         " +
"           $this.dialog(\"option\", \"buttons\", null);\r\n                           " +
"         $this.find(\'form\').submit();\r\n                                },\r\n     " +
"                           Cancel: function () {\r\n                              " +
"      $(this).dialog(\"close\");\r\n                                }\r\n             " +
"               }\r\n                        });\r\n                    }\r\n\r\n        " +
"            var $comments = $this.closest(\'td\').find(\'.commentsRaw\');\r\n         " +
"           if ($comments.hasClass(\'smallMessage\')) {\r\n                        $(" +
"\'#User_Show_Flags_Actions_EditComments_Dialog_Comments\').val(\'\');\r\n             " +
"       } else {\r\n                        $(\'#User_Show_Flags_Actions_EditComment" +
"s_Dialog_Comments\').val($comments.text());\r\n                    }\r\n\r\n           " +
"         $(\'#User_Show_Flags_Actions_EditComments_Dialog_Id\').val(UserFlagAssign" +
"mentId);\r\n                    dialogEditComments.dialog(\'open\');\r\n              " +
"      e.preventDefault();\r\n                    return false;\r\n                })" +
";\r\n            });\r\n        </script>\r\n");

            
            #line 174 "..\..\Views\User\UserParts\_Flags.cshtml"
    }
    else
    {

            
            #line default
            #line hidden
WriteLiteral("        <div");

WriteLiteral(" class=\"none\"");

WriteLiteral(">This user has no associated flags</div>\r\n");

            
            #line 178 "..\..\Views\User\UserParts\_Flags.cshtml"
    }

            
            #line default
            #line hidden
WriteLiteral("    <script>\r\n        $(\'#UserDetailTabItems\').append(\'<li><a href=\"#UserDetailTa" +
"b-Flags\">Flags [");

            
            #line 180 "..\..\Views\User\UserParts\_Flags.cshtml"
                                                                              Write(activeAssignmentCount);

            
            #line default
            #line hidden
WriteLiteral("]</a></li>\');\r\n    </script>\r\n</div>\r\n");

        }
    }
}
#pragma warning restore 1591
