@@ -65,22 +65,7 @@ angular.module('blogAdmin').controller('CustomController', ["$rootScope", "$scop
65
65
66
66
$scope . loadCustomFields = function ( id ) {
67
67
$scope . editId = id ;
68
- //$scope.extEditSrc = SiteVars.RelativeWebRoot + "admin/Extensions/Settings.aspx?ext=" + id + "&enb=False";
69
- //$scope.customFields = [];
70
-
71
- //for (var i = 0, len = $scope.items.length; i < len; i++) {
72
- // if ($scope.items[i].Id === id) {
73
- // angular.copy($scope.items[i], $scope.package);
74
-
75
- // if ($scope.package) {
76
- // $scope.removeEmptyReviews();
77
-
78
- // if($scope.package.SettingsUrl){
79
- // $scope.extEditSrc = $scope.package.SettingsUrl.replace("~/", SiteVars.RelativeWebRoot);
80
- // }
81
- // }
82
- // }
83
- //}
68
+
84
69
dataService . getItems ( '/api/customfields' , { filter : 'CustomType == "THEME" && ObjectId == "' + id + '"' } )
85
70
. success ( function ( data ) {
86
71
angular . copy ( data , $scope . customFields ) ;
@@ -198,13 +183,52 @@ angular.module('blogAdmin').controller('CustomController', ["$rootScope", "$scop
198
183
} ) ;
199
184
}
200
185
186
+ $scope . setPriority = function ( upDown ) {
187
+ if ( upDown == 'up' ) {
188
+ $scope . package . Priority ++ ;
189
+ }
190
+ else {
191
+ if ( $scope . package . Priority > 0 ) {
192
+ $scope . package . Priority -- ;
193
+ }
194
+ }
195
+ $scope . save ( ) ;
196
+ }
197
+
198
+ $scope . submitRating = function ( ) {
199
+ var author = $ ( "#txtAuthor" ) . val ( ) . length > 0 ? $ ( "#txtAuthor" ) . val ( ) : $scope . author ;
200
+ var review = { "Name" : author , "Rating" : $scope . selectedRating , "Body" : $ ( "#txtReview" ) . val ( ) } ;
201
+
202
+ dataService . updateItem ( "/api/packages/rate/" + $scope . package . Extra . Id , review )
203
+ . success ( function ( data ) {
204
+ //if (data != null) {
205
+ // data = JSON.parse(data);
206
+ //}
207
+ if ( data . length === 0 ) {
208
+ toastr . success ( $rootScope . lbl . completed ) ;
209
+ }
210
+ else {
211
+ toastr . error ( data ) ;
212
+ }
213
+ $ ( "#modal-info" ) . modal ( "hide" ) ;
214
+ } )
215
+ . error ( function ( ) {
216
+ toastr . error ( $rootScope . lbl . failed ) ;
217
+ $ ( "#modal-info" ) . modal ( "hide" ) ;
218
+ } ) ;
219
+ }
220
+
201
221
$scope . checkStar = function ( item , rating ) {
202
222
if ( item === rating ) {
203
223
return true ;
204
224
}
205
225
return false ;
206
226
}
207
227
228
+ $scope . setRating = function ( rating ) {
229
+ $scope . selectedRating = rating ;
230
+ }
231
+
208
232
$scope . sortBy = function ( ord ) {
209
233
$scope . sortingOrder = ord ;
210
234
$scope . reverse = true ;
@@ -224,8 +248,6 @@ angular.module('blogAdmin').controller('CustomController', ["$rootScope", "$scop
224
248
angular . copy ( $scope . items [ i ] , $scope . package ) ;
225
249
226
250
if ( $scope . package ) {
227
- //$scope.removeEmptyReviews();
228
-
229
251
if ( $scope . package . SettingsUrl ) {
230
252
$scope . extEditSrc = $scope . package . SettingsUrl . replace ( "~/" , SiteVars . RelativeWebRoot ) ;
231
253
}
@@ -241,8 +263,6 @@ angular.module('blogAdmin').controller('CustomController', ["$rootScope", "$scop
241
263
angular . copy ( $scope . items [ i ] , $scope . package ) ;
242
264
243
265
if ( $scope . package ) {
244
- //$scope.removeEmptyReviews();
245
-
246
266
if ( $scope . package . SettingsUrl ) {
247
267
$scope . extEditSrc = $scope . package . SettingsUrl . replace ( "~/" , SiteVars . RelativeWebRoot ) ;
248
268
}
@@ -253,20 +273,36 @@ angular.module('blogAdmin').controller('CustomController', ["$rootScope", "$scop
253
273
}
254
274
255
275
$scope . showPluginInfo = function ( id ) {
256
- for ( var i = 0 , len = $scope . items . length ; i < len ; i ++ ) {
257
- if ( $scope . items [ i ] . Id === id ) {
258
- angular . copy ( $scope . items [ i ] , $scope . package ) ;
276
+ dataService . getItems ( '/api/packages/' + id )
277
+ . success ( function ( data ) {
278
+ angular . copy ( data , $scope . package ) ;
279
+ $scope . selectedRating = $scope . package . Rating ;
259
280
260
- if ( $scope . package ) {
261
- //$scope.removeEmptyReviews();
281
+ $scope . extEditSrc = SiteVars . RelativeWebRoot + "admin/Extensions/Settings.aspx?ext=" + $scope . id + "&enb=False" ;
282
+ if ( $scope . package . SettingsUrl ) {
283
+ $scope . extEditSrc = $scope . package . SettingsUrl . replace ( "~/" , SiteVars . RelativeWebRoot ) ;
284
+ }
285
+ $scope . removeEmptyReviews ( ) ;
286
+ } )
287
+ . error ( function ( ) {
288
+ toastr . error ( $rootScope . lbl . errorLoadingPackages ) ;
289
+ $scope . spin = false ;
290
+ } ) ;
262
291
263
- if ( $scope . package . SettingsUrl ) {
264
- $scope . extEditSrc = $scope . package . SettingsUrl . replace ( "~/" , SiteVars . RelativeWebRoot ) ;
265
- }
292
+ $ ( "#modal-info" ) . modal ( ) ;
293
+ }
294
+
295
+ $scope . removeEmptyReviews = function ( ) {
296
+ if ( $scope . package . Extra != null && $scope . package . Extra . Reviews != null ) {
297
+ var reviews = [ ] ;
298
+ for ( var i = 0 ; i < $scope . package . Extra . Reviews . length ; i ++ ) {
299
+ var review = $scope . package . Extra . Reviews [ i ] ;
300
+ if ( review . Body . length > 0 ) {
301
+ reviews . push ( review ) ;
266
302
}
267
303
}
304
+ $scope . package . Extra . Reviews = reviews ;
268
305
}
269
- $ ( "#modal-info" ) . modal ( ) ;
270
306
}
271
307
272
308
$scope . load ( ) ;
0 commit comments