mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Convert search module to new shapes
--HG-- branch : dev
This commit is contained in:
@@ -24,8 +24,8 @@ namespace Orchard.Search.Drivers {
|
|||||||
protected override string Prefix { get { return "SearchSettings"; } }
|
protected override string Prefix { get { return "SearchSettings"; } }
|
||||||
|
|
||||||
protected override DriverResult Editor(SearchSettingsPart part, dynamic shapeHelper) {
|
protected override DriverResult Editor(SearchSettingsPart part, dynamic shapeHelper) {
|
||||||
var model = new SearchSettingsViewModel();
|
SearchSettingsViewModel model = new SearchSettingsViewModel();
|
||||||
var searchedFields = part.SearchedFields;
|
String [] searchedFields = part.SearchedFields;
|
||||||
|
|
||||||
if (_indexManager.HasIndexProvider()) {
|
if (_indexManager.HasIndexProvider()) {
|
||||||
model.Entries = new List<SearchSettingsEntry>();
|
model.Entries = new List<SearchSettingsEntry>();
|
||||||
@@ -34,11 +34,12 @@ namespace Orchard.Search.Drivers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ContentPartTemplate(model, "Parts/Search.SiteSettings");
|
return ContentShape("Parts_Search_SiteSettings",
|
||||||
|
() => shapeHelper.EditorTemplate(TemplateName: "Parts/Search.SiteSettings", Model: model));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(SearchSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
protected override DriverResult Editor(SearchSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||||
var model = new SearchSettingsViewModel();
|
SearchSettingsViewModel model = new SearchSettingsViewModel();
|
||||||
|
|
||||||
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||||
part.SearchedFields = model.Entries.Where(e => e.Selected).Select(e => e.Field).ToArray();
|
part.SearchedFields = model.Entries.Where(e => e.Selected).Select(e => e.Field).ToArray();
|
||||||
|
@@ -106,6 +106,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Views\Parts\Search.SearchForm.cshtml" />
|
<Content Include="Views\Parts\Search.SearchForm.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Placement.info" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
3
src/Orchard.Web/Modules/Orchard.Search/Placement.info
Normal file
3
src/Orchard.Web/Modules/Orchard.Search/Placement.info
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<Placement>
|
||||||
|
<Place Parts_Search_SiteSettings="Primary:1"/>
|
||||||
|
</Placement>
|
@@ -4,18 +4,16 @@
|
|||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>@T("Search")</legend>
|
<legend>@T("Search")</legend>
|
||||||
<div>
|
<div>
|
||||||
@{var entryIndex = 0;}
|
|
||||||
@if (Model.Entries != null && Model.Entries.Any()) {
|
@if (Model.Entries != null && Model.Entries.Any()) {
|
||||||
foreach(var modelEntry in Model.Entries) {
|
foreach(SearchSettingsEntry modelEntry in Model.Entries) {
|
||||||
if(Model.Entries[entryIndex].Selected) {
|
if(modelEntry.Selected) {
|
||||||
<input type="checkbox" value="true" checked="checked" name="@Html.FieldNameFor(m => m.Entries[entryIndex].Selected)" id="@Html.FieldIdFor(m => m.Entries[entryIndex].Selected)"/>
|
<input type="checkbox" value="true" checked="checked" name="@Html.FieldNameFor(m => modelEntry.Selected)" id="@Html.FieldIdFor(m => modelEntry.Selected)"/>
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
<input type="checkbox" value="true" name="@Html.FieldNameFor(m => m.Entries[entryIndex].Selected)" id="@Html.FieldIdFor(m => m.Entries[entryIndex].Selected)"/>
|
<input type="checkbox" value="true" name="@Html.FieldNameFor(m => modelEntry.Selected)" id="@Html.FieldIdFor(m => modelEntry.Selected)"/>
|
||||||
}
|
}
|
||||||
@Html.HiddenFor(m => m.Entries[entryIndex].Field)
|
@Html.HiddenFor(m => modelEntry.Field)
|
||||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Entries[entryIndex].Selected)">@Model.Entries[entryIndex].Field</label>
|
<label class="forcheckbox" for="@Html.FieldIdFor(m => modelEntry.Selected)">@modelEntry.Field</label>
|
||||||
entryIndex = entryIndex + 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Reference in New Issue
Block a user