Skip to content

Commit 6b6c6bf

Browse files
committed
Updates and fixes in custom themes/plugins
1 parent c90ba30 commit 6b6c6bf

File tree

3 files changed

+98
-12
lines changed

3 files changed

+98
-12
lines changed

BlogEngine/BlogEngine.NET/admin/app/controllers/customPlugins.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,29 @@
9595
$scope.selectedRating = rating;
9696
}
9797

98+
$scope.submitRating = function () {
99+
var author = $("#txtAuthor").val().length > 0 ? $("#txtAuthor").val() : $scope.author;
100+
var review = { "Name": author, "Rating": $scope.selectedRating, "Body": $("#txtReview").val() };
101+
102+
dataService.updateItem("/api/packages/rate/" + $scope.package.Extra.Id, review)
103+
.success(function (data) {
104+
//if (data != null) {
105+
// data = JSON.parse(data);
106+
//}
107+
if (data.length === 0) {
108+
toastr.success($rootScope.lbl.completed);
109+
}
110+
else {
111+
toastr.error(data);
112+
}
113+
$("#modal-info").modal("hide");
114+
})
115+
.error(function () {
116+
toastr.error($rootScope.lbl.failed);
117+
$("#modal-info").modal("hide");
118+
});
119+
}
120+
98121
$scope.setPriority = function (upDown) {
99122
if (upDown == 'up') {
100123
$scope.package.Priority++;

BlogEngine/BlogEngine.NET/admin/app/controllers/customThemes.js

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,15 @@
4040
}
4141

4242
$scope.showInfo = function (id) {
43-
for (var i = 0, len = $scope.items.length; i < len; i++) {
44-
if ($scope.items[i].Id === id) {
45-
angular.copy($scope.items[i], $scope.package);
46-
47-
if ($scope.package) {
48-
if ($scope.package.SettingsUrl) {
49-
$scope.extEditSrc = $scope.package.SettingsUrl.replace("~/", SiteVars.RelativeWebRoot);
50-
}
51-
}
52-
}
53-
}
43+
dataService.getItems('/api/packages/' + id)
44+
.success(function (data) {
45+
angular.copy(data, $scope.package);
46+
$scope.selectedRating = $scope.package.Rating;
47+
$scope.removeEmptyReviews();
48+
})
49+
.error(function () {
50+
toastr.error($rootScope.lbl.errorLoadingPackages);
51+
});
5452
$("#modal-info").modal();
5553
}
5654

@@ -102,6 +100,29 @@
102100
$scope.selectedRating = rating;
103101
}
104102

103+
$scope.submitRating = function () {
104+
var author = $("#txtAuthor").val().length > 0 ? $("#txtAuthor").val() : $scope.author;
105+
var review = { "Name": author, "Rating": $scope.selectedRating, "Body": $("#txtReview").val() };
106+
107+
dataService.updateItem("/api/packages/rate/" + $scope.package.Extra.Id, review)
108+
.success(function (data) {
109+
//if (data != null) {
110+
// data = JSON.parse(data);
111+
//}
112+
if (data.length === 0) {
113+
toastr.success($rootScope.lbl.completed);
114+
}
115+
else {
116+
toastr.error(data);
117+
}
118+
$("#modal-info").modal("hide");
119+
})
120+
.error(function () {
121+
toastr.error($rootScope.lbl.failed);
122+
$("#modal-info").modal("hide");
123+
});
124+
}
125+
105126
$scope.sortBy = function (ord) {
106127
$scope.sortingOrder = ord;
107128
$scope.reverse = true;
@@ -138,6 +159,19 @@
138159
});
139160
}
140161

162+
$scope.removeEmptyReviews = function () {
163+
if ($scope.package.Extra != null && $scope.package.Extra.Reviews != null) {
164+
var reviews = [];
165+
for (var i = 0; i < $scope.package.Extra.Reviews.length; i++) {
166+
var review = $scope.package.Extra.Reviews[i];
167+
if (review.Body.length > 0) {
168+
reviews.push(review);
169+
}
170+
}
171+
$scope.package.Extra.Reviews = reviews;
172+
}
173+
}
174+
141175
$scope.load();
142176

143177
$(document).ready(function () {

BlogEngine/BlogEngine.NET/admin/views/custom/themes/local.html

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h4 class="modal-title">{{package.Title}}</h4>
99
</div>
1010
<div class="modal-body">
1111
<div class="modal-theme-info">
12-
<p ng-bind-html="package.Description"></p>
12+
<p ng-bind-html="package.Description"></p>
1313
<hr />
1414
<div class="form-horizontal">
1515
<div class="form-group">
@@ -45,6 +45,35 @@ <h4 class="modal-title">{{package.Title}}</h4>
4545
<img class="pkg-img" ng-src="{{package.IconUrl}}" alt="Package image" title="" />
4646
</a>
4747
</div>
48+
49+
<div ng-if="package.Extra != null">
50+
<div class="panel panel-default">
51+
<div class="panel-heading">
52+
<div class="panel-title">{{lbl.writeReview}}</div>
53+
</div>
54+
<div class="panel-body">
55+
<input class="form-control ltr-dir" style="margin-bottom: 10px" ng-model="author" id="txtAuthor" name="txtAuthor" focus-me="focusInput" type="text" placeholder="author">
56+
<textarea rows="3" maxlength="450" style="width: 100%; height: 68px; margin-bottom: 15px" class="form-control" id="txtReview" placeholder="{{lbl.typeHere}}"></textarea>
57+
<div class="text-right">
58+
<span class="star-rating">
59+
<input type="radio" name="rated" value="1" ng-checked="selectedRating == 1" ng-click="setRating(1)"><i></i>
60+
<input type="radio" name="rated" value="2" ng-checked="selectedRating == 2" ng-click="setRating(2)"><i></i>
61+
<input type="radio" name="rated" value="3" ng-checked="selectedRating == 3" ng-click="setRating(3)"><i></i>
62+
<input type="radio" name="rated" value="4" ng-checked="selectedRating == 4" ng-click="setRating(4)"><i></i>
63+
<input type="radio" name="rated" value="5" ng-checked="selectedRating == 5" ng-click="setRating(5)"><i></i>
64+
</span>
65+
<button data-ng-click="submitRating()" class="btn btn-success "><i class="fa fa-star"></i>Rate</button>
66+
</div>
67+
</div>
68+
<ul ng-if="package.Extra.Reviews != null" class="list-group">
69+
<li ng-repeat="review in package.Extra.Reviews" class="list-group-item">
70+
<span class="badge">{{review.Rating}}</span>
71+
<b>{{review.Name}}:</b> {{review.Body}}
72+
</li>
73+
</ul>
74+
</div>
75+
</div>
76+
4877
</div>
4978
</div>
5079
</div>

0 commit comments

Comments
 (0)