Skip to content

Commit

Permalink
Resolves #1793 Add field for manufacturer bottom description like for…
Browse files Browse the repository at this point in the history
… categories.

Added database index for PermissionRecord.SystemName.
  • Loading branch information
mgesing committed Jan 22, 2020
1 parent 91c6b55 commit 5a1ef00
Show file tree
Hide file tree
Showing 18 changed files with 276 additions and 44 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* #1733 Add ability to hide products from catalog, but not search.
* #1754 Implement hidden boolean setting that controls which catalog search engine implementation should be used in backend.
* #1776 Enable images and color values for search filters to be stored for specification attribute options.
* #1793 Add field for manufacturer bottom description like for categories.

### Improvements
* #1663 Make MeasureDimension and MeasureWeight localizable.
Expand Down
6 changes: 6 additions & 0 deletions src/Libraries/SmartStore.Core/Domain/Catalog/Manufacturer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public partial class Manufacturer : BaseEntity, IAuditable, ISoftDeletable, ILoc
[DataMember]
public string Description { get; set; }

/// <summary>
/// Gets or sets a description displayed at the bottom of the manufacturer page.
/// </summary>
[DataMember]
public string BottomDescription { get; set; }

/// <summary>
/// Gets or sets a value of used manufacturer template identifier
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace SmartStore.Core.Domain.Security
{
Expand All @@ -12,6 +13,7 @@ public class PermissionRecord : BaseEntity
/// <summary>
/// Gets or sets the permission system name.
/// </summary>
[Index]
public string SystemName { get; set; }

/// <summary>
Expand Down
17 changes: 9 additions & 8 deletions src/Libraries/SmartStore.Data/Mapping/Catalog/ManufacturerMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ public partial class ManufacturerMap : EntityTypeConfiguration<Manufacturer>
{
public ManufacturerMap()
{
this.ToTable("Manufacturer");
this.HasKey(m => m.Id);
this.Property(m => m.Name).IsRequired().HasMaxLength(400);
this.Property(m => m.Description).IsMaxLength();
this.Property(m => m.MetaKeywords).HasMaxLength(400);
this.Property(m => m.MetaTitle).HasMaxLength(400);
this.Property(m => m.PageSizeOptions).HasMaxLength(200).IsOptional();
this.HasOptional(p => p.Picture)
ToTable("Manufacturer");
HasKey(m => m.Id);
Property(m => m.Name).IsRequired().HasMaxLength(400);
Property(m => m.Description).IsMaxLength();
Property(c => c.BottomDescription).IsMaxLength();
Property(m => m.MetaKeywords).HasMaxLength(400);
Property(m => m.MetaTitle).HasMaxLength(400);
Property(m => m.PageSizeOptions).HasMaxLength(200).IsOptional();
HasOptional(p => p.Picture)
.WithMany()
.HasForeignKey(p => p.PictureId)
.WillCascadeOnDelete(false);
Expand Down

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace SmartStore.Data.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class ManufacturerBottomDescription : DbMigration
{
public override void Up()
{
AddColumn("dbo.Manufacturer", "BottomDescription", c => c.String());
CreateIndex("dbo.PermissionRecord", "SystemName");
}

public override void Down()
{
DropIndex("dbo.PermissionRecord", new[] { "SystemName" });
DropColumn("dbo.Manufacturer", "BottomDescription");
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
"Bild",
"Specifies an image as the selector element.",
"Legt ein Bild als Auswahlelement fest.");

builder.AddOrUpdate("Admin.Catalog.Manufacturers.Fields.BottomDescription",
"Bottom description",
"Untere Beschreibung",
"Optional second description displayed below products on the category page.",
"Optionale zweite Beschreibung, die auf der Herstellerseite unterhalb der Produkte angezeigt wird.");
}
}
}
7 changes: 7 additions & 0 deletions src/Libraries/SmartStore.Data/SmartStore.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,10 @@
<Compile Include="Migrations\202001141118171_SpecificationAttributeColorAndPicture.Designer.cs">
<DependentUpon>202001141118171_SpecificationAttributeColorAndPicture.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\202001221054109_ManufacturerBottomDescription.cs" />
<Compile Include="Migrations\202001221054109_ManufacturerBottomDescription.Designer.cs">
<DependentUpon>202001221054109_ManufacturerBottomDescription.cs</DependentUpon>
</Compile>
<Compile Include="ObjectContextBase.SaveChanges.cs" />
<Compile Include="Setup\Builder\ActivityLogTypeMigrator.cs" />
<Compile Include="Setup\Builder\SettingsBuilder.cs" />
Expand Down Expand Up @@ -1332,6 +1336,9 @@
<EmbeddedResource Include="Migrations\202001141118171_SpecificationAttributeColorAndPicture.resx">
<DependentUpon>202001141118171_SpecificationAttributeColorAndPicture.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\202001221054109_ManufacturerBottomDescription.resx">
<DependentUpon>202001221054109_ManufacturerBottomDescription.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Sql\Indexes.sql" />
<EmbeddedResource Include="Sql\StoredProcedures.sql" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,14 +586,16 @@ private dynamic ToDynamic(DataExporterContext ctx, Manufacturer manufacturer)
{
result.SeName = ctx.UrlRecords[nameof(Manufacturer)].GetSlug(ctx.LanguageId, manufacturer.Id);
result.Description = translations.GetValue(ctx.LanguageId, manufacturer.Id, nameof(manufacturer.Description)) ?? manufacturer.Description;
result.MetaKeywords = translations.GetValue(ctx.LanguageId, manufacturer.Id, nameof(manufacturer.MetaKeywords)) ?? manufacturer.MetaKeywords;
result.BottomDescription = translations.GetValue(ctx.LanguageId, manufacturer.Id, nameof(manufacturer.BottomDescription)) ?? manufacturer.BottomDescription;
result.MetaKeywords = translations.GetValue(ctx.LanguageId, manufacturer.Id, nameof(manufacturer.MetaKeywords)) ?? manufacturer.MetaKeywords;
result.MetaDescription = translations.GetValue(ctx.LanguageId, manufacturer.Id, nameof(manufacturer.MetaDescription)) ?? manufacturer.MetaDescription;
result.MetaTitle = translations.GetValue(ctx.LanguageId, manufacturer.Id, nameof(manufacturer.MetaTitle)) ?? manufacturer.MetaTitle;

result._Localized = GetLocalized(ctx, translations, urlRecords, manufacturer,
x => x.Name,
x => x.Description,
x => x.MetaKeywords,
x => x.BottomDescription,
x => x.MetaKeywords,
x => x.MetaDescription,
x => x.MetaTitle);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ public void WriteManufacturer(dynamic manufacturer, string node)
_writer.Write("Name", (string)manufacturer.Name);
_writer.Write("SeName", (string)manufacturer.SeName);
_writer.Write("Description", (string)manufacturer.Description);
_writer.Write("ManufacturerTemplateId", entity.ManufacturerTemplateId.ToString());
_writer.Write("BottomDescription", (string)manufacturer.BottomDescription);
_writer.Write("ManufacturerTemplateId", entity.ManufacturerTemplateId.ToString());
_writer.Write("MetaKeywords", (string)manufacturer.MetaKeywords);
_writer.Write("MetaDescription", (string)manufacturer.MetaDescription);
_writer.Write("MetaTitle", (string)manufacturer.MetaTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,32 +98,13 @@ protected void UpdateLocales(Manufacturer manufacturer, ManufacturerModel model)
{
foreach (var localized in model.Locales)
{
_localizedEntityService.SaveLocalizedValue(manufacturer,
x => x.Name,
localized.Name,
localized.LanguageId);

_localizedEntityService.SaveLocalizedValue(manufacturer,
x => x.Description,
localized.Description,
localized.LanguageId);

_localizedEntityService.SaveLocalizedValue(manufacturer,
x => x.MetaKeywords,
localized.MetaKeywords,
localized.LanguageId);

_localizedEntityService.SaveLocalizedValue(manufacturer,
x => x.MetaDescription,
localized.MetaDescription,
localized.LanguageId);

_localizedEntityService.SaveLocalizedValue(manufacturer,
x => x.MetaTitle,
localized.MetaTitle,
localized.LanguageId);

//search engine name
_localizedEntityService.SaveLocalizedValue(manufacturer, x => x.Name, localized.Name, localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(manufacturer, x => x.Description, localized.Description, localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(manufacturer, x => x.BottomDescription, localized.BottomDescription, localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(manufacturer, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(manufacturer, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(manufacturer, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId);

var seName = manufacturer.ValidateSeName(localized.SeName, localized.Name, false, localized.LanguageId);
_urlRecordService.SaveSlug(manufacturer, seName, localized.LanguageId);
}
Expand Down Expand Up @@ -344,6 +325,7 @@ public ActionResult Edit(int id)
{
locale.Name = manufacturer.GetLocalized(x => x.Name, languageId, false, false);
locale.Description = manufacturer.GetLocalized(x => x.Description, languageId, false, false);
locale.BottomDescription = manufacturer.GetLocalized(x => x.BottomDescription, languageId, false, false);
locale.MetaKeywords = manufacturer.GetLocalized(x => x.MetaKeywords, languageId, false, false);
locale.MetaDescription = manufacturer.GetLocalized(x => x.MetaDescription, languageId, false, false);
locale.MetaTitle = manufacturer.GetLocalized(x => x.MetaTitle, languageId, false, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public ManufacturerModel()
[AllowHtml]
public string Description { get; set; }

[SmartResourceDisplayName("Admin.Catalog.Manufacturers.Fields.BottomDescription")]
[AllowHtml]
public string BottomDescription { get; set; }

[SmartResourceDisplayName("Admin.Catalog.Manufacturers.Fields.ManufacturerTemplate")]
[AllowHtml]
public int ManufacturerTemplateId { get; set; }
Expand Down Expand Up @@ -138,7 +142,11 @@ public class ManufacturerLocalizedModel : ILocalizedModelLocal

[SmartResourceDisplayName("Admin.Catalog.Manufacturers.Fields.Description")]
[AllowHtml]
public string Description {get;set;}
public string Description { get; set; }

[SmartResourceDisplayName("Admin.Catalog.Manufacturers.Fields.BottomDescription")]
[AllowHtml]
public string BottomDescription { get; set; }

[SmartResourceDisplayName("Admin.Catalog.Manufacturers.Fields.MetaKeywords")]
[AllowHtml]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
@Html.ValidationMessageFor(model => model.Locales[item].Name)
</td>
</tr>
<tr>
<tr class="description-container">
<td class="adminTitle">
@Html.SmartLabelFor(model => model.Locales[item].Description)
</td>
Expand All @@ -70,6 +70,15 @@
@Html.ValidationMessageFor(model => model.Locales[item].Description)
</td>
</tr>
<tr class="description-container d-none">
<td class="adminTitle">
@Html.SmartLabelFor(model => model.Locales[item].BottomDescription)
</td>
<td class="adminData wide">
@Html.EditorFor(model => model.Locales[item].BottomDescription, "Html")
@Html.ValidationMessageFor(model => model.Locales[item].BottomDescription)
</td>
</tr>
</table>
,
@<table class="adminContent">
Expand All @@ -82,7 +91,7 @@
@Html.ValidationMessageFor(model => model.Name)
</td>
</tr>
<tr>
<tr class="description-container">
<td class="adminTitle">
@Html.SmartLabelFor(model => model.Description)
</td>
Expand All @@ -91,6 +100,24 @@
@Html.ValidationMessageFor(model => model.Description)
</td>
</tr>
<tr class="description-container d-none">
<td class="adminTitle">
@Html.SmartLabelFor(model => model.BottomDescription)
</td>
<td class="adminData wide">
@Html.EditorFor(x => x.BottomDescription, "Html")
@Html.ValidationMessageFor(model => model.BottomDescription)
</td>
</tr>
<tr>
<td class="adminTitle"></td>
<td class="adminData">
<button type="button" class="btn btn-secondary description-toggle-button">
<i class="fa fa-exchange-alt"></i>
<span>@T("Admin.Catalog.Categories.DescriptionToggle")</span>
</button>
</td>
</tr>
</table>
))

Expand Down Expand Up @@ -360,7 +387,12 @@
<script type="text/javascript">
$(function () {
$("#@Html.FieldIdFor(model => model.AllowCustomersToSelectPageSize)").change(togglePageSize);
togglePageSize();
togglePageSize();
// Toggle top\bottom description.
$('.description-toggle-button').click(function() {
$('.description-container').toggleClass('d-none');
});
});
function PickProducts_Completed(ids) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ public ActionResult Manufacturer(int manufacturerId, CatalogSearchQuery query)
if (query.IsSubPage && !_catalogSettings.ShowDescriptionInSubPages)
{
model.Description.ChangeValue(string.Empty);
}
model.BottomDescription.ChangeValue(string.Empty);
}

model.PictureModel = _helper.PrepareManufacturerPictureModel(manufacturer, model.Name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static ManufacturerModel ToModel(this Manufacturer entity)
Id = entity.Id,
Name = entity.GetLocalized(x => x.Name),
Description = entity.GetLocalized(x => x.Description, detectEmptyHtml: true),
BottomDescription = entity.GetLocalized(x => x.BottomDescription, detectEmptyHtml: true),
MetaKeywords = entity.GetLocalized(x => x.MetaKeywords),
MetaDescription = entity.GetLocalized(x => x.MetaDescription),
MetaTitle = entity.GetLocalized(x => x.MetaTitle),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using SmartStore.Services.Localization;
using SmartStore.Services.Localization;
using SmartStore.Services.Search;
using SmartStore.Web.Framework.Modelling;
using SmartStore.Web.Models.Media;
Expand All @@ -16,6 +15,7 @@ public ManufacturerModel()

public LocalizedValue<string> Name { get; set; }
public LocalizedValue<string> Description { get; set; }
public LocalizedValue<string> BottomDescription { get; set; }
public LocalizedValue<string> MetaKeywords { get; set; }
public LocalizedValue<string> MetaDescription { get; set; }
public LocalizedValue<string> MetaTitle { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
}
</div>

@if (Model.BottomDescription.Value.HasValue())
{
<div @Html.LanguageAttributes(Model.BottomDescription) class="manufacturer-description lead html-editor-content">
@Html.Raw(Html.CollapsedText(Model.BottomDescription))
</div>
}

@* TODO: (mc) find more intelligent way of rendering RecentlyViewedProductsBlock globally *@
@{ Html.RenderAction("RecentlyViewedProductsBlock", "Catalog", new { area = "" }); }

Expand Down

0 comments on commit 5a1ef00

Please sign in to comment.