Skip to content

Commit

Permalink
Merge pull request #1572 from PiranhaCMS/features/1562-content-blocks
Browse files Browse the repository at this point in the history
Added support for blocks, fixes #1562. Added basic support for taxono…
  • Loading branch information
tidyui authored Apr 2, 2021
2 parents 5ee1276 + d2f8d3a commit 0de6bd0
Show file tree
Hide file tree
Showing 53 changed files with 3,564 additions and 149 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup Label="Package information">
<Version>9.0.0</Version>
<Version>9.1.0-alpha1</Version>
<Authors>Piranha CMS</Authors>
<Company>Piranha CMS</Company>
<Copyright>Copyright (c) .NET Foundation and Contributors</Copyright>
Expand Down
4 changes: 0 additions & 4 deletions core/Piranha.AspNetCore/Piranha.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
<Description>Piranha CMS middleware components for AspNetCore</Description>
</PropertyGroup>

<PropertyGroup Label="Package information">
<Version>9.0.1</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
Expand Down
13 changes: 5 additions & 8 deletions core/Piranha.AttributeBuilder/ContentTypeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ private ContentGroup GetContentGroup(Type type)
Id = attr.Id,
Title = attr.Title,
CLRType = type.Name, // type.AssemblyQualifiedName,
Icon = attr.Icon
Icon = attr.Icon,
IsHidden = attr.IsHidden
};
}
return null;
Expand Down Expand Up @@ -323,13 +324,9 @@ private ContentType GetContentType(Type type)
Group = group.Id,
UseExcerpt = attr.UseExcerpt,
UsePrimaryImage = attr.UsePrimaryImage,
//
// TODO
//
// Categories & Tags will be removed in this version as they
// need to be localized properly and handled in the manager.
UseCategory = false, // typeof(ICategorizedContent).IsAssignableFrom(type),
UseTags = false, // typeof(ITaggedContent).IsAssignableFrom(type),
UseBlocks = typeof(IBlockContent).IsAssignableFrom(type),
UseCategory = typeof(ICategorizedContent).IsAssignableFrom(type),
UseTags = typeof(ITaggedContent).IsAssignableFrom(type),
CustomEditors = GetEditors(type),
Regions = GetRegions(type)
};
Expand Down
4 changes: 0 additions & 4 deletions core/Piranha.AttributeBuilder/Piranha.AttributeBuilder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
<Description>Library for defining content types with Attributes</Description>
</PropertyGroup>

<PropertyGroup Label="Package information">
<Version>9.0.1</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
<Description>Localization for the Piranha CMS manager panel</Description>
</PropertyGroup>

<PropertyGroup Label="Package information">
<Version>9.0.1</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
Expand Down
76 changes: 72 additions & 4 deletions core/Piranha.Manager/Areas/Manager/Pages/ContentEdit.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@page "~/manager/content/{action}/{contentType}/{id?}/{langId?}"
@model ContentListViewModel
@inject ManagerLocalizer Localizer
@inject Piranha.Config Config
@{
ViewBag.Title = "Add/Edit";
ViewBag.MenuItem = "Add/Edit";
Expand Down Expand Up @@ -74,7 +75,12 @@

<div class="container-fluid app" :class="{ ready: !loading }">
<!-- Content navigation -->
<ul v-if="editors.length + contentRegions.length > 1" class="nav nav-pills nav-pills-card justify-content-center">
<ul v-if="(useBlocks && (editors.length + contentRegions.length > 0)) || editors.length + contentRegions.length > 1" class="nav nav-pills nav-pills-card justify-content-center">
<li v-if="useBlocks" class="nav-item">
<a class="nav-link" v-on:click.prevent="selectRegion({ uid: 'uid-blocks' })" :class="{ active: selectedRegion.uid === 'uid-blocks' }" href="#">
<i class="fas fa-pen-alt"></i>@Localizer.General["Main content"]
</a>
</li>
<li v-for="editor in editors" class="nav-item">
<a class="nav-link" v-on:click.prevent="selectRegion(editor)" :class="{ active: selectedRegion.uid == editor.uid }" href="#">
<i :class="editor.icon"></i>{{ editor.name }}
Expand All @@ -90,12 +96,30 @@
<!-- Title -->
<div class="card">
<div class="card-body" :class="{ 'pb-0': regions.length > 0 }">
<div class="row">
<div class="col">
<div class="form-group title">
<div class="form-group title">
<div class="row">
<div class="col">
<input v-model="title" type="text" class="form-control form-control-lg" placeholder="@Localizer.General["Title"]">
</div>
</div>
<div v-if="useCategory || useTags" class="row mt-3">
<div v-if="useCategory" class="col">
<div class="form-group mb-0">
<label style="display:none">@Localizer.Post["Category"]</label>
<select id="selectedCategory" class="form-control select2" v-model="selectedCategory">
<option :value="item" v-for="item in categories">{{ item }}</option>
</select>
</div>
</div>
<div v-if="useTags" class="col">
<div class="form-group mb-0">
<label style="display:none">@Localizer.Post["Tags"]</label>
<select id="selectedTags" class="form-control select2" multiple="multiple" v-model="selectedTags">
<option :value="item" v-for="item in tags">{{ item }}</option>
</select>
</div>
</div>
</div>
</div>
<div class="region-center content-center">
<div class="row">
Expand Down Expand Up @@ -143,6 +167,50 @@
</div>
</div>

<!-- Blocks -->
<div class="card" :class="{ 'd-none': selectedRegion.uid != 'uid-blocks' }">
<div class="card-body">
<div id="content-blocks" class="blocks@(Config.ManagerOutlined ? " blocks-outline" : "")">
<a href="#" class="block-add unsortable" v-on:click.prevent="piranha.blockpicker.open(piranha.contentedit.addBlock, 0)">
<hr>
<i class="fas fa-plus-circle"></i>
</a>
<div v-for="(block, index) in blocks" v-bind:key="block.meta.uid">
<div :class="'block ' + block.meta.component + (block.meta.isCollapsed ? ' collapsed' : '') + (block.meta.width === 'full' ? ' block-full' : '')">
<div :id="'tb-' + block.meta.uid" class="component-toolbar"></div>
<div class="block-header">
<div class="title">
<i :class="block.meta.icon"></i><strong>{{ block.meta.name }}</strong> <span v-if="!block.meta.isGroup && block.meta.isCollapsed">- {{ block.meta.title }}</span>
</div>
<div class="actions">
<span v-on:click.prevent="collapseBlock(block)" class="btn btn-sm">
<i v-if="block.meta.isCollapsed" class="fas fa-chevron-down"></i>
<i v-else class="fas fa-chevron-up"></i>
</span>
<span class="btn btn-sm handle">
<i class="fas fa-ellipsis-v"></i>
</span>
<button v-on:click.prevent="removeBlock(block)" class="btn btn-sm danger block-remove" tabindex="-1">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
<component v-if="!block.meta.isGroup" v-bind:is="block.meta.component" v-bind:uid="block.meta.uid" v-bind:toolbar="'tb-' + block.meta.uid" v-bind:model="block.model" v-on:update-title='updateBlockTitle($event)'></component>
<component v-if="block.meta.isGroup" v-bind:is="block.meta.component" v-bind:uid="block.meta.uid" v-bind:toolbar="'tb-' + block.meta.uid" v-bind:model="block"></component>
<div class="content-blocker"></div>
</div>
<a href="#" class="block-add" v-on:click.prevent="piranha.blockpicker.open(piranha.contentedit.addBlock, index + 1)">
<hr>
<i class="fas fa-plus-circle"></i>
</a>
</div>
<div v-if="blocks.length == 0" class="empty-info">
<p>@Localizer.Page["Welcome to your new page. Click on the button above to add your first block of content!"]</p>
</div>
</div>
</div>
</div>

<!-- Custom Editors -->
<div class="card" :class="{ 'd-none': selectedRegion.uid != editor.uid }" v-for="editor in editors">
<div class="card-body pt-0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
@if (group.InternalId == "Content")
{
foreach (var item in Piranha.App.ContentGroups)
foreach (var item in Piranha.App.ContentGroups.Where(g => !g.IsHidden))
{
<li class="nav-item@(ViewBag.MenuItem == item.Id ? " active" :"")"><a href="@Url.Content($"~/manager/content/{ item.Id }")" class="nav-link" tabindex="-1"><i class="@item.Icon"></i>@item.Title</a></li>
}
Expand Down
30 changes: 30 additions & 0 deletions core/Piranha.Manager/Models/ContentEditModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ public class ContentEditModel : AsyncResult
/// </summary>
public string State { get; set; }

/// <summary>
/// Gets/sets if blocks should be used.
/// </summary>
public bool UseBlocks { get; set; } = true;

/// <summary>
/// Gets/sets the available blocks.
/// </summary>
public IList<Content.BlockModel> Blocks { get; set; } = new List<Content.BlockModel>();

/// <summary>
/// Gets/sets the available regions.
/// </summary>
Expand All @@ -115,5 +125,25 @@ public class ContentEditModel : AsyncResult
/// Gets/sets the available languages.
/// </summary>
public IEnumerable<Language> Languages { get; set; } = new List<Language>();

/// <summary>
/// Gets/sets the selected category.
/// </summary>
public string SelectedCategory { get; set; }

/// <summary>
/// Gets/sets the selected tags.
/// </summary>
public List<string> SelectedTags { get; set; } = new List<string>();

/// <summary>
/// Gets/sets the available categories.
/// </summary>
public IEnumerable<string> Categories { get; set; } = new List<string>();

/// <summary>
/// Gets/sets the available tags.
/// </summary>
public IEnumerable<string> Tags { get; set; } = new List<string>();
}
}
4 changes: 0 additions & 4 deletions core/Piranha.Manager/Piranha.Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
<Description>Manager panel for Piranha CMS for AspNetCore</Description>
</PropertyGroup>

<PropertyGroup Label="Package information">
<Version>9.0.1</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
Expand Down
Loading

0 comments on commit 0de6bd0

Please sign in to comment.