Added the issues to the requests page

pull/13/head
tidusjar 9 years ago
parent 759540c837
commit 0556e4d32b

@ -41,10 +41,10 @@ $(document).on("click", ".dropdownIssue", function (e) {
}
e.preventDefault();
var $form = $('#form' + id);
var $form = $('#report' + id);
var data = $form.serialize();
data = data + "&issue=" + issue;
$.ajax({
type: $form.prop('method'),
url: $form.prop('action'),
@ -63,13 +63,13 @@ $(document).on("click", ".dropdownIssue", function (e) {
});
// Modal click
$(".theSaveButton").click(function () {
$(".theSaveButton").click(function (e) {
var comment = $("#commentArea").val();
e.preventDefault();
var $form = $("#form" + id);
var id = e.target.value;
var $form = $("#commentForm");
var data = $form.serialize();
data = data + "&issue=" + 4 + "&comment="+comment;
data = data + "&issue=" + 4 + "&comment=" + comment;
$.ajax({
type: $form.prop("method"),
@ -96,13 +96,14 @@ $('#myModal').on('show.bs.modal', function (event) {
var modal = $(this);
modal.find('.theSaveButton').val(id); // Add ID to the button
modal.find('#requestId').val(id); // Add ID to the hidden field
var requestField = modal.find('input');
requestField.val(id); // Add ID to the hidden field
});
$(document).on("click", ".delete", function (e) {
e.preventDefault();
var buttonId = e.target.id;
var $form = $('#form' + buttonId);
var $form = $('#delete' + buttonId);
$.ajax({
type: $form.prop('method'),
@ -168,7 +169,8 @@ function buildRequestContext(result, type) {
available: result.available,
admin: result.admin,
issues: result.issues,
otherMessage: result.otherMessage
otherMessage: result.otherMessage,
requestId: result.id
};
return context;

@ -45,7 +45,7 @@ namespace PlexRequests.UI.Models
public string ReleaseYear { get; set; }
public bool Available { get; set; }
public bool Admin { get; set; }
public IssueState Issues { get; set; }
public string Issues { get; set; }
public string OtherMessage { get; set; }
}
}

@ -45,7 +45,8 @@ namespace PlexRequests.UI.Modules
{
dynamic model = new ExpandoObject();
model.Errored = Request.Query.error.HasValue;
var adminCreated = UserMapper.DoUsersExist();
model.AdminExists = adminCreated;
return View["Login/Index", model];
}

@ -55,13 +55,9 @@ namespace PlexRequests.UI.Modules
Get["/"] = _ => LoadRequests();
Get["/movies"] = _ => GetMovies();
Get["/tvshows"] = _ => GetTvShows();
Post["/delete"] = _ =>
{
var convertedType = (string)Request.Form.type == "movie" ? RequestType.Movie : RequestType.TvShow;
return DeleteRequest((int)Request.Form.id, convertedType);
};
Get["/reportissue"] = _ => ReportIssue((int)Request.Form.requestId, (IssueState)Request.Form.issue, null);
Get["/reportissuecomment"] = _ => ReportIssue((int)Request.Form.requestId, IssueState.Other, (string)Request.Form.commentArea);
Post["/delete"] = _ => DeleteRequest((int)Request.Form.id);
Post["/reportissue"] = _ => ReportIssue((int)Request.Form.requestId, (IssueState)(int)Request.Form.issue, null);
Post["/reportissuecomment"] = _ => ReportIssue((int)Request.Form.requestId, IssueState.Other, (string)Request.Form.commentArea);
}
private IRepository<RequestedModel> Service { get; }
@ -96,7 +92,7 @@ namespace PlexRequests.UI.Modules
ReleaseYear = movie.ReleaseDate.Year.ToString(),
Available = movie.Available,
Admin = isAdmin,
Issues = movie.Issues,
Issues = movie.Issues.Humanize(LetterCasing.Title),
OtherMessage = movie.OtherMessage
}).ToList();
@ -124,18 +120,18 @@ namespace PlexRequests.UI.Modules
ReleaseYear = tv.ReleaseDate.Year.ToString(),
Available = tv.Available,
Admin = isAdmin,
Issues = tv.Issues,
Issues = tv.Issues.Humanize(LetterCasing.Title),
OtherMessage = tv.OtherMessage
}).ToList();
return Response.AsJson(viewModel);
}
private Response DeleteRequest(int providerId, RequestType type)
private Response DeleteRequest(int requestid)
{
if (Context.CurrentUser.IsAuthenticated())
{
var currentEntity = Service.GetAll().FirstOrDefault(x => x.ProviderId == providerId && x.Type == type);
var currentEntity = Service.Get(requestid);
Service.Delete(currentEntity);
return Response.AsJson(new JsonResponseModel { Result = true });
}
@ -152,8 +148,20 @@ namespace PlexRequests.UI.Modules
/// <returns></returns>
private Response ReportIssue(int requestId, IssueState issue, string comment)
{
return Response.AsJson(new JsonResponseModel());
var originalRequest = Service.Get(requestId);
if (originalRequest == null)
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not add issue, please try again or contact the administrator!" });
}
originalRequest.Issues = issue;
originalRequest.OtherMessage = comment;
var result = Service.Update(originalRequest);
if (result)
{
return Response.AsJson(new JsonResponseModel { Result = true });
}
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not add issue, please try again or contact the administrator!" });
}
}
}

@ -7,9 +7,10 @@
<br/>
<input class="btn btn-success" type="submit" value="Login"/>
</form>
If you have not yet created an Admin account you can do here: <a href="/register">Register</a>
@if (!Model.AdminExists)
{
<div>If you have not yet created an Admin account you can do here: <a href="/register">Register</a></div>
}
@if (Model.Errored)
{
<div class="alert alert-dismissible alert-danger">

@ -93,31 +93,36 @@
</p>
<p>Requested By: {{requestedBy}}</p>
<p>Requested Date: {{requestedDate}}</p>
{{#if otherMessage}}
<p>Message: {{otherMessage}}</p>
{{else}}
<p>Issue: {{issues}}</p>
{{/if}}
</div>
<div class="col-sm-2 col-sm-push-3">
<br />
<br />
{{#if_eq admin true}}
<form method="POST" action="/requests/delete" id="form{{id}}">
<input name="Id" type="text" value="{{id}}" hidden="hidden" />
<input name="Type" type="text" value="{{type}}" hidden="hidden" />
<button id="{{id}}" style="text-align: right" class="btn btn-danger delete" type="submit"><i class="fa fa-plus"></i> Remove</button>
<form method="POST" action="/requests/delete" id="delete{{requestId}}">
<input name="Id" type="text" value="{{requestId}}" hidden="hidden" />
<button id="{{requestId}}" style="text-align: right" class="btn btn-danger delete" type="submit"><i class="fa fa-plus"></i> Remove</button>
</form>
{{/if_eq}}
<form method="POST" action="/search/reportissue/" id="form{{id}}">
<input name="requestId" type="text" value="{{id}}" hidden="hidden" />
<form method="POST" action="/requests/reportissue/" id="report{{requestId}}">
<input name="requestId" type="text" value="{{requestId}}" hidden="hidden" />
<div class="dropdown">
<button id="{{id}}" class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<button id="{{requestId}}" class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fa fa-plus"></i> Report Issue
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a id="{{id}}" issue-select="0" class="dropdownIssue" href="#">Wrong Audio</a></li>
<li><a id="{{id}}" issue-select="1" class="dropdownIssue" href="#">No Subtitles</a></li>
<li><a id="{{id}}" issue-select="2" class="dropdownIssue" href="#">Wrong Content</a></li>
<li><a id="{{id}}" issue-select="3" class="dropdownIssue" href="#">Playback Issues</a></li>
<li><a id="{{id}}" issue-select="4" class="dropdownIssue" data-identifier="{{id}}" href="#" data-toggle="modal" data-target="#myModal">Other</a></li>
<li><a id="{{requestId}}" issue-select="0" class="dropdownIssue" href="#">Wrong Audio</a></li>
<li><a id="{{requestId}}" issue-select="1" class="dropdownIssue" href="#">No Subtitles</a></li>
<li><a id="{{requestId}}" issue-select="2" class="dropdownIssue" href="#">Wrong Content</a></li>
<li><a id="{{requestId}}" issue-select="3" class="dropdownIssue" href="#">Playback Issues</a></li>
<li><a id="{{requestId}}" issue-select="4" class="dropdownIssue" data-identifier="{{requestId}}" href="#" data-toggle="modal" data-target="#myModal">Other</a></li>
</ul>
</div>
</form>
@ -135,9 +140,9 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
<h4 class="modal-title">Add issue/comment</h4>
</div>
<form method="POST" action="/search/reportissuecomment/" id="commentForm">
<form method="POST" action="/requests/reportissuecomment" id="commentForm">
<div class="modal-body">
<input name="requestId" type="text" hidden="hidden" />
<input name="requestId" class="requestId" type="text" hidden="hidden" value="" />
<textarea class="form-control form-control-custom" rows="3" id="commentArea" name="commentArea"></textarea>
</div>
<div class="modal-footer">

@ -6,24 +6,28 @@
</label>
</div>
<form method="POST" id="loginForm">
<div class="col-md-2">
<label style="padding-top: 8px"> Username </label>
<div class="row">
<div class="col-md-2">
<label style="padding-top: 8px"> Username </label>
</div>
<div class="col-md-5">
<input class="form-control form-control-custom col-md-5" type="text" name="Username" />
</div>
</div>
<div class="col-md-5">
<input class="form-control form-control-custom col-md-5" type="text" name="Username"/>
</div>
<br />
@if (Model.UsePassword)
{
<br />
@if (Model.UsePassword)
{
<div class="row">
<div class="col-md-2">
<label style="padding-top: 8px"> Password </label>
</div>
<div class="col-md-5">
<input class="form-control form-control-custom col-md-5" name="Password" type="password" />
</div>
}
<br />
<input id="loginBtn" class="btn btn-success" type="submit" value="Login" />
</div>
}
<br />
<input id="loginBtn" class="btn btn-success" type="submit" value="Login" />
</form>

Loading…
Cancel
Save