Skip to content

Commit ad9c9c8

Browse files
committed
product review
1 parent babc5f4 commit ad9c9c8

File tree

13 files changed

+303
-66
lines changed

13 files changed

+303
-66
lines changed

miscellaneous/Icon.png

10.6 KB
Loading

miscellaneous/Icon.psd

96.3 KB
Binary file not shown.

src/Modules/SimplCommerce.Module.Core/Views/HomeAdmin/Index.cshtml

+3-2
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@
110110
<script src="~/search/admin/search.module.js"></script>
111111
<script src="~/search/admin/search-service.js"></script>
112112
<script src="~/search/admin/most-search-keywords.directive.js"></script>
113-
113+
114114
<script src="~/reviews/admin/reviews.module.js"></script>
115115
<script src="~/reviews/admin/review/review-service.js"></script>
116+
<script src="~/reviews/admin/review/review-list.js"></script>
116117
<script src="~/reviews/admin/review/review-widget.directive.js"></script>
117-
118118
</head>
119119
<body>
120120
<div class="navbar navbar-inverse">
@@ -130,6 +130,7 @@
130130
<div class="navbar-collapse collapse">
131131
<ul class="nav navbar-nav">
132132
<li><a ui-sref="user">Users</a></li>
133+
<li><a ui-sref="reviews">Reviews</a></li>
133134
<li class="dropdown">
134135
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Catalog <span class="caret"></span></a>
135136
<ul class="dropdown-menu">

src/Modules/SimplCommerce.Module.Core/wwwroot/admin/user/user-list.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ <h2>{{ ::vm.translate.get('User List')}}</h2>
4444
</tbody>
4545
<tbody ng-show="vm.isLoading">
4646
<tr>
47-
<td colspan="4" class="text-center">Loading ... </td>
47+
<td colspan="5" class="text-center">Loading ... </td>
4848
</tr>
4949
</tbody>
5050
<tfoot>
5151
<tr>
52-
<td class="text-center" st-pagination="" st-items-by-page="50" st-displayed-pages="10" colspan="4"></td>
52+
<td class="text-center" st-pagination="" st-items-by-page="50" st-displayed-pages="10" colspan="5"></td>
5353
</tr>
5454
</tfoot>
5555
</table>

src/Modules/SimplCommerce.Module.Orders/wwwroot/admin/order/order-list.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ <h2>Order List</h2>
5454
</tbody>
5555
<tbody ng-show="vm.isLoading">
5656
<tr>
57-
<td colspan="7" class="text-center">Loading ... </td>
57+
<td colspan="6" class="text-center">Loading ... </td>
5858
</tr>
5959
</tbody>
6060
<tfoot>
6161
<tr>
62-
<td class="text-center" st-pagination="" st-items-by-page="50" st-displayed-pages="10" colspan="7"></td>
62+
<td class="text-center" st-pagination="" st-items-by-page="50" st-displayed-pages="10" colspan="6"></td>
6363
</tr>
6464
</tfoot>
6565
</table>

src/Modules/SimplCommerce.Module.Reviews/Controllers/ReviewApiController.cs

+75-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using System.Linq;
1+
using System;
2+
using System.Linq;
23
using Microsoft.AspNetCore.Authorization;
34
using Microsoft.AspNetCore.Mvc;
45
using SimplCommerce.Infrastructure.Data;
6+
using SimplCommerce.Infrastructure.Web.SmartTable;
57
using SimplCommerce.Module.Reviews.Models;
68

79
namespace SimplCommerce.Module.Reviews.Controllers
@@ -44,5 +46,77 @@ public ActionResult Get(int status, int numRecords)
4446

4547
return Json(model);
4648
}
49+
50+
[HttpPost("grid")]
51+
public ActionResult List([FromBody] SmartTableParam param)
52+
{
53+
IQueryable<Review> query = _reviewRepository.Query();
54+
55+
if (param.Search.PredicateObject != null)
56+
{
57+
dynamic search = param.Search.PredicateObject;
58+
if (search.Id != null)
59+
{
60+
long id = search.Id;
61+
query = query.Where(x => x.Id == id);
62+
}
63+
64+
if (search.Status != null)
65+
{
66+
var status = (ReviewStatus)search.Status;
67+
query = query.Where(x => x.Status == status);
68+
}
69+
70+
if (search.CreatedOn != null)
71+
{
72+
if (search.CreatedOn.before != null)
73+
{
74+
DateTimeOffset before = search.CreatedOn.before;
75+
before = before.Date.AddDays(1);
76+
query = query.Where(x => x.CreatedOn <= before);
77+
}
78+
79+
if (search.CreatedOn.after != null)
80+
{
81+
DateTimeOffset after = search.CreatedOn.after;
82+
after = after.Date;
83+
query = query.Where(x => x.CreatedOn >= after);
84+
}
85+
}
86+
}
87+
88+
var reviews = query.ToSmartTableResult(
89+
param,
90+
x => new
91+
{
92+
x.Id,
93+
x.ReviewerName,
94+
x.Rating,
95+
x.Title,
96+
x.Comment,
97+
Status = x.Status.ToString(),
98+
x.CreatedOn
99+
});
100+
101+
return Json(reviews);
102+
}
103+
104+
[HttpPost("change-status/{id}")]
105+
public IActionResult ChangeStatus(long id, [FromBody] int statusId)
106+
{
107+
var review = _reviewRepository.Query().FirstOrDefault(x => x.Id == id);
108+
if (review == null)
109+
{
110+
return NotFound();
111+
}
112+
113+
if (Enum.IsDefined(typeof(ReviewStatus), statusId))
114+
{
115+
review.Status = (ReviewStatus)statusId;
116+
_reviewRepository.SaveChange();
117+
return Ok();
118+
}
119+
return BadRequest(new { Error = "unsupported order status" });
120+
}
47121
}
48122
}

src/Modules/SimplCommerce.Module.Reviews/Models/ReviewStatus.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
public enum ReviewStatus
44
{
5-
Pending = 0,
5+
Pending = 1,
66

77
Approved = 5,
88

src/Modules/SimplCommerce.Module.Reviews/Views/Components/Review.cshtml

+82-56
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,95 @@
33

44
<div class="container">
55
<div class="row">
6-
<div class="col-md-3">
7-
<h4>Rating Average</h4>
8-
<p>@(Model.RatingAverage)/5</p>
9-
<p>@Model.ReviewsCount reviewers</p>
10-
</div>
11-
<div class="col-md-5">
12-
<div class="progress">
13-
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="@Model.GetRatingPercent(Model.Rating1Count)" aria-valuemin="0" aria-valuemax="100" style="width: @Model.GetRatingPercent(Model.Rating1Count)%">
14-
<span class="sr-only">@Model.GetRatingPercent(Model.Rating1Count)%</span>
6+
@if (Model.ReviewsCount > 0)
7+
{
8+
<div class="col-md-5 rating-summary">
9+
<div class="row">
10+
<div class="col-md-5">
11+
<h4>Rating Average</h4>
12+
<p class="rating-average">@(Model.RatingAverage)/5</p>
13+
<p>(@Model.ReviewsCount reviewers)</p>
14+
</div>
15+
<div class="col-md-7">
16+
<div class="rating-item">
17+
<span>5 stars</span>
18+
<div class="progress">
19+
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="@Model.GetRatingPercent(Model.Rating5Count)" aria-valuemin="0" aria-valuemax="100" style="width: @Model.GetRatingPercent(Model.Rating5Count)%">
20+
<span class="sr-only">@Model.GetRatingPercent(Model.Rating5Count)%</span>
21+
</div>
22+
</div>
23+
<span>@Model.Rating5Count</span>
24+
</div>
25+
<div class="rating-item">
26+
<span>4 stars</span>
27+
<div class="progress">
28+
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="@Model.GetRatingPercent(Model.Rating4Count)" aria-valuemin="0" aria-valuemax="100" style="width: @Model.GetRatingPercent(Model.Rating4Count)%">
29+
<span class="sr-only">@Model.GetRatingPercent(Model.Rating2Count)%</span>
30+
</div>
31+
</div>
32+
<span>@Model.Rating4Count</span>
33+
</div>
34+
<div class="rating-item">
35+
<span>3 stars</span>
36+
<div class="progress">
37+
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="@Model.GetRatingPercent(Model.Rating3Count)" aria-valuemin="0" aria-valuemax="100" style="width: @Model.GetRatingPercent(Model.Rating3Count)%">
38+
<span class="sr-only">@Model.GetRatingPercent(Model.Rating3Count)%</span>
39+
</div>
40+
</div>
41+
<span>@Model.Rating3Count</span>
42+
</div>
43+
<div class="rating-item">
44+
<span>2 stars</span>
45+
<div class="progress">
46+
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="@Model.GetRatingPercent(Model.Rating2Count)" aria-valuemin="0" aria-valuemax="100" style="width: @Model.GetRatingPercent(Model.Rating2Count)%">
47+
<span class="sr-only">@Model.GetRatingPercent(Model.Rating2Count)%</span>
48+
</div>
49+
</div>
50+
<span>@Model.Rating2Count</span>
51+
</div>
52+
<div class="rating-item">
53+
<span>1 stars</span>
54+
<div class="progress">
55+
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="@Model.GetRatingPercent(Model.Rating1Count)" aria-valuemin="0" aria-valuemax="100" style="width: @Model.GetRatingPercent(Model.Rating1Count)%">
56+
<span class="sr-only">@Model.GetRatingPercent(Model.Rating1Count)%</span>
57+
</div>
58+
</div>
59+
<span>@Model.Rating1Count</span>
60+
</div>
61+
</div>
1562
</div>
1663
</div>
17-
<div class="progress">
18-
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="@Model.GetRatingPercent(Model.Rating2Count)" aria-valuemin="0" aria-valuemax="100" style="width: @Model.GetRatingPercent(Model.Rating2Count)%">
19-
<span class="sr-only">@Model.GetRatingPercent(Model.Rating2Count)%</span>
20-
</div>
64+
}
65+
<div class="col-md-7">
66+
<div id="addreview">
67+
@Html.Partial("/Modules/SimplCommerce.Module.Reviews/Views/Review/_ReviewForm.cshtml", new ReviewForm {EntityTypeId = Model.EntityTypeId, EntityId = Model.EntityId})
2168
</div>
22-
<div class="progress">
23-
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="@Model.GetRatingPercent(Model.Rating3Count)" aria-valuemin="0" aria-valuemax="100" style="width: @Model.GetRatingPercent(Model.Rating3Count)%">
24-
<span class="sr-only">@Model.GetRatingPercent(Model.Rating3Count)%</span>
25-
</div>
26-
</div>
27-
<div class="progress">
28-
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="@Model.GetRatingPercent(Model.Rating4Count)" aria-valuemin="0" aria-valuemax="100" style="width: @Model.GetRatingPercent(Model.Rating4Count)%">
29-
<span class="sr-only">@Model.GetRatingPercent(Model.Rating4Count)%</span>
30-
</div>
31-
</div>
32-
<div class="progress">
33-
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="@Model.GetRatingPercent(Model.Rating5Count)" aria-valuemin="0" aria-valuemax="100" style="width: @Model.GetRatingPercent(Model.Rating5Count)%">
34-
<span class="sr-only">@Model.GetRatingPercent(Model.Rating5Count)%</span>
35-
</div>
36-
</div>
37-
</div>
38-
<div class="col-md-4">
39-
4069
</div>
4170
</div>
42-
<div class="row">
43-
<div id="addreview">
44-
@Html.Partial("/Modules/SimplCommerce.Module.Reviews/Views/Review/_ReviewForm.cshtml", new ReviewForm { EntityTypeId = Model.EntityTypeId, EntityId = Model.EntityId })
45-
</div>
46-
</div>
47-
@foreach (var review in Model.Items)
48-
{
49-
<div>
50-
<ul class="list-inline product-ratings">
51-
@for (var i = 1; i < 6; i++)
71+
<hr/>
72+
<div class="review-item-list">
73+
@foreach (var review in Model.Items)
74+
{
75+
<div>
76+
<ul class="list-inline product-ratings">
77+
@for (var i = 1; i < 6; i++)
5278
{
5379
if (review.Rating >= i)
5480
{
55-
<li><i class="rating-selected fa fa-star"></i></li>
56-
}
57-
else
58-
{
59-
<li><i class="rating fa fa-star"></i></li>
81+
<li><i class="rating-selected fa fa-star"></i></li>
82+
}
83+
else
84+
{
85+
<li><i class="rating fa fa-star"></i></li>
86+
}
6087
}
61-
}
62-
<li class="product-review-list">
63-
@review.Title
64-
</li>
65-
</ul>
66-
<p>By: <strong>@review.ReviewerName</strong> on <span>@review.CreatedOn</span></p>
67-
<p>@review.Comment</p>
68-
</div>
69-
}
70-
88+
<li class="review-title">
89+
@review.Title
90+
</li>
91+
</ul>
92+
<p>@review.Comment</p>
93+
<p>By: <strong>@review.ReviewerName</strong> on <span>@review.CreatedOn</span></p>
94+
</div>
95+
}
96+
</div>
7197
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<div class="page-header">
2+
<div class="row">
3+
<div class="col-md-8">
4+
<h2>Review List</h2>
5+
</div>
6+
<div class="col-md-4 text-right">
7+
</div>
8+
</div>
9+
</div>
10+
11+
<table class="table" st-pipe="vm.getReviews" st-table="vm.reviews">
12+
<thead>
13+
<tr>
14+
<th>Customer Name</th>
15+
<th>Rating</th>
16+
<th>Title</th>
17+
<th>Comment</th>
18+
<th st-sort="CreatedOn" class="sortable">CreatedOn</th>
19+
<th>Status</th>
20+
<th>Actions</th>
21+
</tr>
22+
<tr>
23+
<th></th>
24+
<th></th>
25+
<th></th>
26+
<th></th>
27+
<th><st-date-range predicate="CreatedOn" before="query.before" after="query.after"></st-date-range></th>
28+
<th>
29+
<div class="form-group">
30+
<select class="form-control" st-search="Status">
31+
<option value="">All</option>
32+
<option value="1">Pending</option>
33+
<option value="5">Approved</option>
34+
<option value="8">Not Approved</option>
35+
</select>
36+
</div>
37+
</th>
38+
<th></th>
39+
</tr>
40+
</thead>
41+
<tbody ng-show="!vm.isLoading">
42+
<tr ng-repeat="review in vm.reviews">
43+
<td>{{review.reviewerName}}</td>
44+
<td>{{review.rating}}</td>
45+
<td>{{review.title}}</td>
46+
<td>{{review.comment}}</td>
47+
<td>{{review.createdOn | date:'medium'}}</td>
48+
<td>{{review.status }}</td>
49+
<td><button ng-if="review.status ==='Pending'" title="Approve" ng-click="vm.approve(review)" class="btn btn-primary btn-xs">Approve</button></td>
50+
</tr>
51+
</tbody>
52+
<tbody ng-show="vm.isLoading">
53+
<tr>
54+
<td colspan="7" class="text-center">Loading ... </td>
55+
</tr>
56+
</tbody>
57+
<tfoot>
58+
<tr>
59+
<td class="text-center" st-pagination="" st-items-by-page="50" st-displayed-pages="10" colspan="7"></td>
60+
</tr>
61+
</tfoot>
62+
</table>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*global angular*/
2+
(function () {
3+
angular
4+
.module('simplAdmin.reviews')
5+
.controller('ReviewListCtrl', ReviewListCtrl);
6+
7+
/* @ngInject */
8+
function ReviewListCtrl(reviewService) {
9+
var vm = this;
10+
vm.reviews = [];
11+
12+
vm.getReviews = function getReviews(tableState) {
13+
vm.isLoading = true;
14+
reviewService.getReviewsForGrid(tableState).then(function (result) {
15+
vm.reviews = result.data.items;
16+
tableState.pagination.numberOfPages = result.data.numberOfPages;
17+
vm.isLoading = false;
18+
});
19+
};
20+
21+
vm.approve = function approve(review) {
22+
reviewService.changeReviewStatus(review.id, 5)
23+
.then(function(result) {
24+
review.status = 'Approved';
25+
});
26+
};
27+
}
28+
})();

0 commit comments

Comments
 (0)