Skip to content

Commit

Permalink
Merge pull request #49 from KalikoCMS/1.0.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
fschultz committed Aug 14, 2015
2 parents 981b30b + edf0de3 commit 6154b4c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 13 deletions.
30 changes: 20 additions & 10 deletions KalikoCMS.Admin/Admin/Content/Dialogs/SelectPagetypeDialog.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace KalikoCMS.Admin.Content.Dialogs {
using System;
using System.Linq;
using System.Text;
using Configuration;
using KalikoCMS.Core;

public partial class SelectPagetypeDialog : System.Web.UI.Page {
Expand All @@ -31,22 +32,31 @@ protected void Page_Load(object sender, EventArgs e) {
return;
}

var pageId = new Guid(Request.QueryString["pageId"]);
var parent = PageFactory.GetPage(pageId);
var parentPageType = pageTypes.Find(p => p.PageTypeId == parent.PageTypeId);
var allowAll = parentPageType.AllowedTypes == null;
Type[] allowedTypes = null;
Guid pageId;

Guid.TryParse(Request.QueryString["pageId"], out pageId);

var allowAll = true;

if (parentPageType.AllowedTypes != null && parentPageType.AllowedTypes.Length == 0) {
PageTypeList.Text = "No pages can be created under the selected page.";
return;
if (pageId != SiteSettings.RootPage) {
var parent = PageFactory.GetPage(pageId);
var parentPageType = pageTypes.Find(p => p.PageTypeId == parent.PageTypeId);
allowedTypes = parentPageType.AllowedTypes;
allowAll = parentPageType.AllowedTypes == null;

if (parentPageType.AllowedTypes != null && parentPageType.AllowedTypes.Length == 0) {
PageTypeList.Text = "No pages can be created under the selected page.";
return;
}
}

var stringBuilder = new StringBuilder();
var count = 0;

foreach (var pageType in pageTypes) {
if (allowAll || parentPageType.AllowedTypes.Contains(pageType.Type)) {
if (count > 0 && count % 2 == 0) {
if (allowAll || allowedTypes.Contains(pageType.Type)) {
if (count > 0 && count%2 == 0) {
stringBuilder.Append("</div><div class=\"row\">");
}
var previewImage = string.IsNullOrEmpty(pageType.PreviewImage) ? "assets/images/defaultpagetype.png" : pageType.PreviewImage;
Expand Down
9 changes: 7 additions & 2 deletions KalikoCMS.Admin/Admin/Content/EditPage.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@
<div class="form-group">
<label class="control-label col-xs-2" for="PageId">Page Id</label>
<div class="controls col-xs-10">
<span class="static-text">
<asp:Literal ID="PageId" runat="server" /></span>
<span class="static-text"><asp:Literal ID="PageId" runat="server" /></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-2" for="PageTypeName">Pagetype</label>
<div class="controls col-xs-10">
<span class="static-text"><asp:Literal ID="PageTypeName" runat="server" /></span>
</div>
</div>
<div class="form-actions">
Expand Down
7 changes: 7 additions & 0 deletions KalikoCMS.Admin/Admin/Content/EditPage.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ private void LoadChildSortOrderLists() {

private void LoadFormForRootPage() {
PageHeader.Text = "Root";
PageTypeName.Text = "Root";
PageId.Text = Guid.Empty.ToString();
PageName.Visible = false;
StartPublishDate.Visible = false;
StopPublishDate.Visible = false;
VisibleInMenu.Visible = false;
SaveButton.Visible = false;
PublishButton.Visible = false;
AdvancedOptionButton.Visible = false;
}

Expand All @@ -120,6 +123,8 @@ private void LoadFormForNewPage() {
AddControl(propertyDefinition.Name, null, propertyDefinition.PropertyTypeId, propertyDefinition.Header, propertyDefinition.Parameters);
}

PageTypeName.Text = PageType.GetPageType(_pageTypeId).DisplayName;

var pageType = PageType.GetPageType(_pageTypeId);
ChildSortDirection.SelectedValue = ((int)pageType.DefaultChildSortDirection).ToString();
ChildSortOrder.SelectedValue = ((int)pageType.DefaultChildSortOrder).ToString();
Expand Down Expand Up @@ -174,6 +179,8 @@ private void LoadFormForExistingPage() {

PageId.Text = cmsPage.PageId.ToString();

PageTypeName.Text = PageType.GetPageType(cmsPage.PageTypeId).DisplayName;

var propertyDefinitions = PageType.GetPropertyDefinitions(cmsPage.PageTypeId);

foreach (var propertyDefinition in propertyDefinitions) {
Expand Down
9 changes: 9 additions & 0 deletions KalikoCMS.Admin/Admin/Content/EditPage.aspx.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion KalikoCMS.Admin/Admin/Content/PageTree/PageTreeControl.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
success: function (r) {
if (!r.status) {
refreshParentNode(currentPageId);
selectParentNode(currentPageId);
}
}
});
Expand All @@ -66,6 +66,15 @@
$("#maincontent").attr("src", "Content/EditPage.aspx?id=&parentId=" + currentPageId + "&pageTypeId=" + pageTypeId);
}
function selectParentNode(node) {
var instance = $.jstree.reference('#pagetree');
var parent = instance.get_parent(node);
instance.load_node(parent, function (n, s) {
instance.deselect_all();
instance.select_node(parent);
});
}
function refreshNode(node) {
var instance = $.jstree.reference('#pagetree');
var parent = instance.get_parent(node);
Expand Down

0 comments on commit 6154b4c

Please sign in to comment.