Skip to content

Commit ed75c40

Browse files
Closes smartstore#428 Implement category option to override global list view type
1 parent 103b73e commit ed75c40

10 files changed

Lines changed: 219 additions & 4 deletions

File tree

changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
# Release Notes
1+
# Release Notes
22
## SmartStore.NET 2.5
33

4+
### New Features
5+
* #428 Implement category option to override global list view type
6+
47
### Bugfixes
58
* Amazon payments: Declined authorization IPN did not void the payment status
69
* Fixed „Payment method couldn't be loaded“ when order amount is zero
710

811

12+
13+
14+
# Release Notes
915
## SmartStore.NET 2.1.1
1016

1117
### New Features

src/Libraries/SmartStore.Core/Domain/Catalog/Category.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ public partial class Category : BaseEntity, ISoftDeletable, ILocalizedEntity, IS
163163
[DataMember]
164164
public DateTime UpdatedOnUtc { get; set; }
165165

166+
/// <summary>
167+
/// Gets or sets the date and time of instance update
168+
/// </summary>
169+
[DataMember]
170+
public string DefaultViewMode { get; set; }
171+
166172
/// <summary>
167173
/// Gets or sets the collection of applied discounts
168174
/// </summary>

src/Libraries/SmartStore.Data/Migrations/201501221417371_DefaultViewModeForCategories.Designer.cs

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace SmartStore.Data.Migrations
2+
{
3+
using System;
4+
using System.Data.Entity.Migrations;
5+
6+
public partial class DefaultViewModeForCategories : DbMigration
7+
{
8+
public override void Up()
9+
{
10+
AddColumn("dbo.Category", "DefaultViewMode", c => c.String());
11+
}
12+
13+
public override void Down()
14+
{
15+
DropColumn("dbo.Category", "DefaultViewMode");
16+
}
17+
}
18+
}

src/Libraries/SmartStore.Data/Migrations/201501221417371_DefaultViewModeForCategories.resx

Lines changed: 126 additions & 0 deletions
Large diffs are not rendered by default.

src/Libraries/SmartStore.Data/SmartStore.Data.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@
211211
<Compile Include="Migrations\201501191849483_WidgetWrapContent.Designer.cs">
212212
<DependentUpon>201501191849483_WidgetWrapContent.cs</DependentUpon>
213213
</Compile>
214+
<Compile Include="Migrations\201501221417371_DefaultViewModeForCategories.cs" />
215+
<Compile Include="Migrations\201501221417371_DefaultViewModeForCategories.Designer.cs">
216+
<DependentUpon>201501221417371_DefaultViewModeForCategories.cs</DependentUpon>
217+
</Compile>
214218
<Compile Include="Setup\Builder\SettingsBuilder.cs" />
215219
<Compile Include="Setup\Builder\SettingsMigrator.cs" />
216220
<Compile Include="Setup\DbMigrationContext.cs" />
@@ -424,6 +428,9 @@
424428
<EmbeddedResource Include="Migrations\201501191849483_WidgetWrapContent.resx">
425429
<DependentUpon>201501191849483_WidgetWrapContent.cs</DependentUpon>
426430
</EmbeddedResource>
431+
<EmbeddedResource Include="Migrations\201501221417371_DefaultViewModeForCategories.resx">
432+
<DependentUpon>201501221417371_DefaultViewModeForCategories.cs</DependentUpon>
433+
</EmbeddedResource>
427434
<EmbeddedResource Include="Sql\Indexes.sql" />
428435
<EmbeddedResource Include="Sql\StoredProcedures.sql" />
429436
</ItemGroup>

src/Presentation/SmartStore.Web/Administration/Controllers/CategoryController.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ protected void PrepareCategoryModel(CategoryModel model, Category category, bool
184184
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(category.CreatedOnUtc, DateTimeKind.Utc);
185185
model.UpdatedOn = _dateTimeHelper.ConvertToUserTime(category.UpdatedOnUtc, DateTimeKind.Utc);
186186
}
187+
188+
model.AvailableDefaultViewModes.Add(
189+
new SelectListItem { Value = "grid", Text = _localizationService.GetResource("Common.Grid"), Selected = model.DefaultViewMode.IsCaseInsensitiveEqual("grid") }
190+
);
191+
model.AvailableDefaultViewModes.Add(
192+
new SelectListItem { Value = "list", Text = _localizationService.GetResource("Common.List"), Selected = model.DefaultViewMode.IsCaseInsensitiveEqual("list") }
193+
);
187194
}
188195

189196
[NonAction]

src/Presentation/SmartStore.Web/Administration/Models/Catalog/CategoryModel.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public CategoryModel()
2626
}
2727
Locales = new List<CategoryLocalizedModel>();
2828
AvailableCategoryTemplates = new List<SelectListItem>();
29+
AvailableDefaultViewModes = new List<SelectListItem>();
2930
}
3031

3132
[SmartResourceDisplayName("Admin.Catalog.Categories.Fields.Name")]
@@ -117,14 +118,15 @@ public CategoryModel()
117118
public List<StoreModel> AvailableStores { get; set; }
118119
public int[] SelectedStoreIds { get; set; }
119120

120-
// codehint: sm-edit
121121
public string ParentCategoryBreadcrumb { get; set; }
122122

123-
124123
//discounts
125124
public List<Discount> AvailableDiscounts { get; set; }
126125
public int[] SelectedDiscountIds { get; set; }
127126

127+
[SmartResourceDisplayName("Admin.Configuration.Settings.Catalog.DefaultViewMode")]
128+
public string DefaultViewMode { get; set; }
129+
public IList<SelectListItem> AvailableDefaultViewModes { get; private set; }
128130

129131
#region Nested classes
130132

@@ -217,4 +219,5 @@ public class CategoryLocalizedModel : ILocalizedModelLocal
217219
[AllowHtml]
218220
public string SeName { get; set; }
219221
}
222+
220223
}

src/Presentation/SmartStore.Web/Administration/Views/Category/_CreateOrUpdate.cshtml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
</table>
6666
))
6767
<table class="adminContent">
68-
@* codehint: sm-edit *@
6968
<tr>
7069
<td class="adminTitle">
7170
@Html.SmartLabelFor(model => model.Alias)
@@ -84,6 +83,15 @@
8483
@Html.ValidationMessageFor(model => model.CategoryTemplateId)
8584
</td>
8685
</tr>
86+
<tr>
87+
<td class="adminTitle">
88+
@Html.SmartLabelFor(model => model.DefaultViewMode)
89+
</td>
90+
<td class="adminData">
91+
@Html.DropDownListFor(model => model.DefaultViewMode, Model.AvailableDefaultViewModes)
92+
@Html.ValidationMessageFor(model => model.DefaultViewMode)
93+
</td>
94+
</tr>
8795
<tr>
8896
<td class="adminTitle">
8997
@Html.SmartLabelFor(model => model.PictureId)

src/Presentation/SmartStore.Web/Controllers/CatalogController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ public ActionResult Category(int categoryId, CatalogPagingFilteringModel command
151151
if (command.PageNumber <= 0)
152152
command.PageNumber = 1;
153153

154+
if (!String.IsNullOrEmpty(category.DefaultViewMode))
155+
{
156+
command.ViewMode = category.DefaultViewMode;
157+
}
158+
154159
var model = category.ToModel();
155160

156161
_helper.PreparePagingFilteringModel(model.PagingFilteringContext, command, new PageSizeContext

0 commit comments

Comments
 (0)