Skip to content

Commit bb5380b

Browse files
committed
Adjustments and fixes in post and page editors (custom fields)
1 parent 06bef26 commit bb5380b

File tree

6 files changed

+24
-49
lines changed

6 files changed

+24
-49
lines changed

BlogEngine/BlogEngine.NET/AppCode/Api/PackagesController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ public HttpResponseMessage SetTheme(string id)
153153
{
154154
if (!string.IsNullOrEmpty(id))
155155
{
156-
BlogEngine.Core.BlogSettings.Instance.Theme = id;
156+
var bs = BlogEngine.Core.BlogSettings.Instance;
157+
bs.Theme = id;
158+
bs.Save();
157159
}
158160
return Request.CreateResponse(HttpStatusCode.OK);
159161
}

BlogEngine/BlogEngine.NET/Web.sitemap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<siteMapNode url="default.aspx" title="Blog Engine" description="">
44
<siteMapNode url="~/admin/index.cshtml" title="dashboard" description="" rights="ViewDashboard" />
55
<siteMapNode url="~/admin/#/content/posts" title="content" description="" rightsAuthorizationCheck="HasAny" rights="CreateNewPosts, EditOwnPosts, EditOtherUsersPosts, PublishOwnPosts, PublishOtherUsersPosts" />
6-
<siteMapNode url="~/admin/#/custom/plugins" title="custom" description="" rightsAuthorizationCheck="HasAny" rights="ManageExtensions, ManageWidgets, ManageThemes, ManagePackages" />
6+
<siteMapNode url="~/admin/#/custom/themes" title="custom" description="" rightsAuthorizationCheck="HasAny" rights="ManageExtensions, ManageWidgets, ManageThemes, ManagePackages" />
77
<siteMapNode url="~/admin/#/settings/basic" title="settings" rights="AccessAdminSettingsPages" description="" />
88
</siteMapNode>
99
</siteMap>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
$("#mu-content").addClass("active");
4343
$("#mu-pages").addClass("active");
4444
}
45-
if ($location.$$absUrl.indexOf("about.cshtml") > -1) {
45+
if ($location.$$absUrl.indexOf("admin/about") > -1) {
4646
$(".nav-primary > li").removeClass("active");
4747
$("#mu-about").addClass("active");
4848
}

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

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
$scope.security = $rootScope.security;
88
$scope.UserVars = UserVars;
99
$scope.root = $rootScope.SiteVars.ApplicationRelativeWebRoot;
10+
$scope.customFields = [];
1011

1112
$scope.load = function () {
1213
var lookupsUrl = '/api/lookups';
@@ -93,7 +94,7 @@
9394
$log.log(data);
9495
if (data.Id) {
9596
angular.copy(data, $scope.page);
96-
var x = $scope.page.Id;
97+
$scope.updateCustom();
9798
}
9899
$("#modal-form").modal('hide');
99100
spinOff();
@@ -195,7 +196,7 @@
195196
});
196197
}
197198

198-
$scope.saveCustom = function () {
199+
$scope.addCustom = function () {
199200
var customField = {
200201
"CustomType": "PAGE",
201202
"ObjectId": $scope.page.Id,
@@ -206,19 +207,22 @@
206207
toastr.error("Custom key is required");
207208
return false;
208209
}
209-
dataService.addItem("/api/customfields", customField)
210-
.success(function (data) {
211-
toastr.success('New item added');
212-
$scope.loadCustom();
213-
$("#modal-custom-fields").modal('hide');
214-
})
215-
.error(function () {
216-
toastr.error($rootScope.lbl.updateFailed);
217-
$("#modal-custom-fields").modal('hide');
210+
$scope.customFields.push(customField);
211+
$("#modal-custom-fields").modal('hide');
212+
}
213+
214+
$scope.deleteCustom = function (key, objId) {
215+
$.each($scope.customFields, function (index, result) {
216+
if (result["Key"] == key && result["ObjectId"] == objId) {
217+
$scope.customFields.splice(index, 1);
218+
}
218219
});
219220
}
220221

221222
$scope.updateCustom = function () {
223+
for (var i = 0; i < $scope.customFields.length; i++) {
224+
$scope.customFields[i].ObjectId = $scope.page.Id;
225+
}
222226
dataService.updateItem("/api/customfields", $scope.customFields)
223227
.success(function (data) {
224228
spinOff();
@@ -229,37 +233,6 @@
229233
});
230234
}
231235

232-
$scope.deleteCustom = function (key, objId) {
233-
var customField = {
234-
"CustomType": "PAGE",
235-
"Key": key,
236-
"ObjectId": objId
237-
};
238-
spinOn();
239-
dataService.deleteItem("/api/customfields", customField)
240-
.success(function (data) {
241-
toastr.success("Item deleted");
242-
spinOff();
243-
$scope.loadCustom();
244-
})
245-
.error(function () {
246-
toastr.error($rootScope.lbl.couldNotDeleteItem);
247-
spinOff();
248-
});
249-
}
250-
251-
function findCustomItem(key) {
252-
var arr = $scope.profileCustomFields;
253-
if (arr && arr.length > 0) {
254-
for (var i = 0, len = arr.length; i < len; i++) {
255-
if (arr[i].Key == key) {
256-
return arr[i];
257-
}
258-
};
259-
}
260-
return null;
261-
}
262-
263236
/* end custom fields */
264237

265238
}]);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@
8989
if (!$('#form').valid()) {
9090
return false;
9191
}
92+
$scope.post.Content = editorGetHtml();
9293
if ($scope.post.Content.length == 0) {
9394
toastr.error('Content field is required');
9495
tinymce.execCommand('mceFocus', false, 'txtContent');
9596
return false;
9697
}
97-
spinOn();
98-
$scope.post.Content = editorGetHtml();
98+
spinOn();
9999
$scope.post.Author = $scope.selectedAuthor.OptionValue;
100100
if ($scope.post.Slug.length == 0) {
101101
$scope.post.Slug = toSlug($scope.post.Title);

BlogEngine/BlogEngine.NET/admin/themes/standard/sidebar.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555
{
5656
<li id="mu-custom" class="hasul">
5757
<i class="fa fa-icon fa-sliders"></i>
58-
<a href="{{SiteVars.RelativeWebRoot}}admin/#/custom/plugins"><span>@Resources.labels.custom</span></a>
58+
<a href="{{SiteVars.RelativeWebRoot}}admin/#/custom/themes"><span>@Resources.labels.custom</span></a>
5959
<ul>
60-
<li data-ng-class="{ active: isActive('/custom/plugins')}"><a class="ng-binding" href="{{SiteVars.RelativeWebRoot}}admin/#/custom/plugins">Plugins</a></li>
6160
<li data-ng-class="{ active: isActive('/custom/themes')}"><a class="ng-binding" href="{{SiteVars.RelativeWebRoot}}admin/#/custom/themes">@Resources.labels.themes</a></li>
61+
<li data-ng-class="{ active: isActive('/custom/plugins')}"><a class="ng-binding" href="{{SiteVars.RelativeWebRoot}}admin/#/custom/plugins">Plugins</a></li>
6262
</ul>
6363
</li>
6464
}

0 commit comments

Comments
 (0)