More work on submitting issues

pull/13/head
tidusjar 9 years ago
parent 6c03e3f0ad
commit 3eaf1971ec

@ -98,12 +98,12 @@ namespace PlexRequests.UI.Tests
var plexFriends = new PlexFriends
{
User = new[]
{
new UserFriends
{
Username = "abc",
},
}
new UserFriends
{
Username = "abc",
},
}
};
AuthMock.Setup(x => x.GetSettings()).Returns(expectedSettings);
@ -144,12 +144,12 @@ namespace PlexRequests.UI.Tests
var plexFriends = new PlexFriends
{
User = new[]
{
new UserFriends
{
Username = "aaaa",
},
}
new UserFriends
{
Username = "aaaa",
},
}
};
AuthMock.Setup(x => x.GetSettings()).Returns(expectedSettings);
@ -193,12 +193,12 @@ namespace PlexRequests.UI.Tests
var plexFriends = new PlexFriends
{
User = new[]
{
new UserFriends
{
Username = "abc",
},
}
new UserFriends
{
Username = "abc",
}
}
};
var plexAuth = new PlexAuthentication
{
@ -249,12 +249,12 @@ namespace PlexRequests.UI.Tests
var plexFriends = new PlexFriends
{
User = new[]
{
new UserFriends
{
Username = "abc",
},
}
new UserFriends
{
Username = "abc",
},
}
};
var plexAuth = new PlexAuthentication
{

@ -13,7 +13,7 @@ var tvimer = 0;
movieLoad();
tvLoad();
$('#approveAll').click(function() {
$('#approveAll').click(function () {
$.ajax({
type: 'post',
url: '/approval/approveall',
@ -39,18 +39,20 @@ $(document).on("click", ".dropdownIssue", function (e) {
if (issue == 4) {
return;
}
e.preventDefault();
var $form = $('#form' + id);
var data = $form.serialize();
data = data + "&issue=" + issue;
$.ajax({
type: "post",
url: "/requests/reportissue",
data: $form.serialize(), // TODO pass in issue enum and Id
type: $form.prop('method'),
url: $form.prop('action'),
data: data,
dataType: "json",
success: function (response) {
if (checkJsonResponse(response)) {
generateNotify("Success!", "success");
$("#" + buttonId + "Template").slideUp();
}
},
error: function (e) {
@ -61,17 +63,40 @@ $(document).on("click", ".dropdownIssue", function (e) {
});
// Modal click
$('.theSaveButton').click(function() {
$(".theSaveButton").click(function () {
var comment = $("#commentArea").val();
e.preventDefault();
var $form = $("#form" + id);
var data = $form.serialize();
data = data + "&issue=" + 4 + "&comment="+comment;
$.ajax({
type: $form.prop("method"),
url: $form.prop("action"),
data: data,
dataType: "json",
success: function (response) {
if (checkJsonResponse(response)) {
generateNotify("Success!", "success");
$("#myModal").modal("hide");
}
},
error: function (e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
}
});
});
// Update the modal
$('#myModal').on('show.bs.modal', function(event) {
$('#myModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget); // Button that triggered the modal
var id = button.data('identifier'); // Extract info from data-* attributes
var modal = $(this);
modal.find('.theSaveButton').val(id);
modal.find('.theSaveButton').val(id); // Add ID to the button
modal.find('#requestId').val(id); // Add ID to the hidden field
});
$(document).on("click", ".delete", function (e) {
@ -141,7 +166,9 @@ function buildRequestContext(result, type) {
requestedBy: result.requestedBy,
requestedDate: result.requestedDate,
available: result.available,
admin: result.admin
admin: result.admin,
issues: result.issues,
otherMessage: result.otherMessage
};
return context;

@ -45,5 +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 OtherMessage { get; set; }
}
}

@ -60,6 +60,9 @@ namespace PlexRequests.UI.Modules
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);
}
private IRepository<RequestedModel> Service { get; }
private ISettingsService<PlexRequestSettings> PrSettings { get; }
@ -92,7 +95,9 @@ namespace PlexRequests.UI.Modules
RequestedBy = movie.RequestedBy,
ReleaseYear = movie.ReleaseDate.Year.ToString(),
Available = movie.Available,
Admin = isAdmin
Admin = isAdmin,
Issues = movie.Issues,
OtherMessage = movie.OtherMessage
}).ToList();
return Response.AsJson(viewModel);
@ -118,7 +123,9 @@ namespace PlexRequests.UI.Modules
RequestedBy = tv.RequestedBy,
ReleaseYear = tv.ReleaseDate.Year.ToString(),
Available = tv.Available,
Admin = isAdmin
Admin = isAdmin,
Issues = tv.Issues,
OtherMessage = tv.OtherMessage
}).ToList();
return Response.AsJson(viewModel);
@ -134,5 +141,19 @@ namespace PlexRequests.UI.Modules
}
return Response.AsJson(new JsonResponseModel { Result = false, Message = "You are not an Admin, so you cannot delete any requests." });
}
/// <summary>
/// Reports the issue.
/// Comment can be null if the <c>IssueState != Other</c>
/// </summary>
/// <param name="requestId">The request identifier.</param>
/// <param name="issue">The issue.</param>
/// <param name="comment">The comment.</param>
/// <returns></returns>
private Response ReportIssue(int requestId, IssueState issue, string comment)
{
return Response.AsJson(new JsonResponseModel());
}
}
}

@ -105,23 +105,24 @@
</form>
{{/if_eq}}
{{#if_eq admin false}}
<div class="dropdown">
<button id="{{id}}" 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>
</ul>
</div>
{{/if_eq}}
<form method="POST" action="/search/reportissue/" id="form{{id}}">
<input name="requestId" type="text" value="{{id}}" 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">
<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>
</ul>
</div>
</form>
</div>
@* // TODO add Issues to the view *@
</div>
<hr />
</div>
@ -132,15 +133,18 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary theSaveButton">Save changes</button>
<h4 class="modal-title">Add issue/comment</h4>
</div>
<form method="POST" action="/search/reportissuecomment/" id="commentForm">
<div class="modal-body">
<input name="requestId" type="text" hidden="hidden" />
<textarea class="form-control form-control-custom" rows="3" id="commentArea" name="commentArea"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary theSaveButton" data-dismiss="modal">Save changes</button>
</div>
</form>
</div>
</div>
</div>

Loading…
Cancel
Save