mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Sort,Filter and showing IsManaged Admin UI
This commit is contained in:
@@ -45,12 +45,6 @@ namespace Orchard.Alias.Controllers {
|
|||||||
if (options == null)
|
if (options == null)
|
||||||
options = new AdminIndexOptions();
|
options = new AdminIndexOptions();
|
||||||
|
|
||||||
switch (options.Filter) {
|
|
||||||
case AliasFilter.All:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException();
|
|
||||||
}
|
|
||||||
|
|
||||||
var aliases = _aliasHolder.GetMaps().SelectMany(x => x.GetAliases());
|
var aliases = _aliasHolder.GetMaps().SelectMany(x => x.GetAliases());
|
||||||
|
|
||||||
@@ -61,6 +55,19 @@ namespace Orchard.Alias.Controllers {
|
|||||||
|
|
||||||
aliases = aliases.ToList();
|
aliases = aliases.ToList();
|
||||||
|
|
||||||
|
switch (options.Filter)
|
||||||
|
{
|
||||||
|
case AliasFilter.Managed:
|
||||||
|
aliases = aliases.Where(x => x.IsManaged);
|
||||||
|
break;
|
||||||
|
case AliasFilter.Custom:
|
||||||
|
aliases = aliases.Where(x => !x.IsManaged);
|
||||||
|
break;
|
||||||
|
case AliasFilter.All:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
var pagerShape = Services.New.Pager(pager).TotalItemCount(aliases.Count());
|
var pagerShape = Services.New.Pager(pager).TotalItemCount(aliases.Count());
|
||||||
|
|
||||||
switch (options.Order) {
|
switch (options.Order) {
|
||||||
@@ -76,7 +83,7 @@ namespace Orchard.Alias.Controllers {
|
|||||||
var model = new AdminIndexViewModel {
|
var model = new AdminIndexViewModel {
|
||||||
Options = options,
|
Options = options,
|
||||||
Pager = pagerShape,
|
Pager = pagerShape,
|
||||||
AliasEntries = aliases.Select(x => new AliasEntry() { Alias = x, IsChecked = false }).ToList()
|
AliasEntries = aliases.Select(x => new AliasEntry() { Alias = x, IsChecked = false }).OrderBy(x => x.Alias.IsManaged).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
@@ -105,7 +112,6 @@ namespace Orchard.Alias.Controllers {
|
|||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace Orchard.Alias.Implementation.Storage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Remove(string path) {
|
public void Remove(string path) {
|
||||||
Remove(x => x.Path == path && x.Source == path);
|
Remove(x => x.Path == path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove(string path, string aliasSource) {
|
public void Remove(string path, string aliasSource) {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ namespace Orchard.Alias.Recipes.Executors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute(RecipeExecutionContext context) {
|
public override void Execute(RecipeExecutionContext context) {
|
||||||
//var installedPermissions = _roleService.GetInstalledPermissions().SelectMany(p => p.Value).ToList();
|
|
||||||
|
|
||||||
foreach (var aliasElement in context.RecipeStep.Step.Elements()) {
|
foreach (var aliasElement in context.RecipeStep.Step.Elements()) {
|
||||||
var aliasPath = aliasElement.Attribute("Path").Value;
|
var aliasPath = aliasElement.Attribute("Path").Value;
|
||||||
@@ -42,39 +41,15 @@ namespace Orchard.Alias.Recipes.Executors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//_aliasService.Set(aliasPath, rvd, "Custom",false);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_aliasService.Set(aliasPath, rvd, "Custom", false);
|
_aliasService.Set(aliasPath, rvd, "Custom", false);
|
||||||
//var role = _roleService.GetRoleByName(roleName);
|
|
||||||
//if (role == null) {
|
|
||||||
// _roleService.CreateRole(roleName);
|
|
||||||
// role = _roleService.GetRoleByName(roleName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// var permissions = roleElement.Attribute("Permissions").Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
// // Only import permissions for currenlty installed modules.
|
|
||||||
// var permissionsValid = permissions.Where(permission => installedPermissions.Any(x => x.Name == permission)).ToList();
|
|
||||||
|
|
||||||
// // Union to keep existing permissions.
|
|
||||||
// _roleService.UpdateRole(role.Id, role.Name, permissionsValid.Union(role.RolesPermissions.Select(p => p.Permission.Name)));
|
|
||||||
//}
|
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
Logger.Error(ex, "Error while processing alias '{0}'.", aliasPath);
|
Logger.Error(ex, "Error while processing alias '{0}'.", aliasPath);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
////remove all local pathys that are not present in the remote export
|
|
||||||
//var allRemotePaths = recipeContext.RecipeStep.Step.XPathSelectElements("Paths/Add").Select(e => e.Attribute("Path").Value);
|
|
||||||
//var allLocalPaths = _aliasService.List().Select(t => t.Item1).ToList();
|
|
||||||
|
|
||||||
//foreach (var path in allLocalPaths.Where(p => !allRemotePaths.Contains(p)))
|
|
||||||
//{
|
|
||||||
// _aliasService.Delete(path);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
//recipeContext.Executed = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ namespace Orchard.Alias.ViewModels {
|
|||||||
public class AliasEntry {
|
public class AliasEntry {
|
||||||
public AliasInfo Alias { get; set; }
|
public AliasInfo Alias { get; set; }
|
||||||
public bool IsChecked { get; set; }
|
public bool IsChecked { get; set; }
|
||||||
public bool IsManaged { get; set; }
|
|
||||||
}
|
}
|
||||||
public class AdminIndexOptions {
|
public class AdminIndexOptions {
|
||||||
public string Search { get; set; }
|
public string Search { get; set; }
|
||||||
@@ -26,7 +25,9 @@ namespace Orchard.Alias.ViewModels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum AliasFilter {
|
public enum AliasFilter {
|
||||||
All
|
All,
|
||||||
|
Managed,
|
||||||
|
Custom
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AliasBulkAction {
|
public enum AliasBulkAction {
|
||||||
|
|||||||
@@ -36,6 +36,12 @@
|
|||||||
<label for="filterResults">@T("Sort by:")</label>
|
<label for="filterResults">@T("Sort by:")</label>
|
||||||
<select id="filterResults" name="@Html.NameOf(m => m.Options.Order)">
|
<select id="filterResults" name="@Html.NameOf(m => m.Options.Order)">
|
||||||
@Html.SelectOption(options.Order, AliasOrder.Path, T("Path").ToString())
|
@Html.SelectOption(options.Order, AliasOrder.Path, T("Path").ToString())
|
||||||
|
</select>
|
||||||
|
<label for="filterResults">@T("Filter:")</label>
|
||||||
|
<select id="filterResults" name="@Html.NameOf(m => m.Options.Filter)">
|
||||||
|
@Html.SelectOption(Model.Options.Filter, AliasFilter.All, T("All").ToString())
|
||||||
|
@Html.SelectOption(Model.Options.Filter, AliasFilter.Managed, T("Managed").ToString())
|
||||||
|
@Html.SelectOption(Model.Options.Filter, AliasFilter.Custom, T("Custom").ToString())
|
||||||
</select>
|
</select>
|
||||||
<input type="hidden" name="Page" value="1" />
|
<input type="hidden" name="Page" value="1" />
|
||||||
<label for="pageSize">@T("Show:")</label>
|
<label for="pageSize">@T("Show:")</label>
|
||||||
@@ -54,6 +60,7 @@
|
|||||||
<th scope="col" class="checkbox"><input type="checkbox" class="check-all"/></th>
|
<th scope="col" class="checkbox"><input type="checkbox" class="check-all"/></th>
|
||||||
<th scope="col">@T("Alias")</th>
|
<th scope="col">@T("Alias")</th>
|
||||||
<th scope="col">@T("Route")</th>
|
<th scope="col">@T("Route")</th>
|
||||||
|
<th scope="col">@T("IsManaged")</th>
|
||||||
<th scope="col"> </th>
|
<th scope="col"> </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -79,9 +86,14 @@
|
|||||||
@Html.Link(url, Href("~/" + urlPrefix + "/" + url))
|
@Html.Link(url, Href("~/" + urlPrefix + "/" + url))
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.ActionLink(T("Edit").Text, "Edit", new { path = alias.Path == String.Empty ? "/" : alias.Path })
|
<input type="checkbox" checked="@alias.IsManaged" value="true" name="@Html.FieldNameFor(m => Model.AliasEntries[index].Alias.IsManaged)" disabled="disabled" />
|
||||||
|
|
</td>
|
||||||
@Html.ActionLink(T("Delete").Text, "Delete", new { path = alias.Path }, new { itemprop = "UnsafeUrl RemoveUrl" })
|
<td>
|
||||||
|
@if (!alias.IsManaged) {
|
||||||
|
@Html.ActionLink(T("Edit").Text, "Edit", new { path = alias.Path == String.Empty ? "/" : alias.Path })
|
||||||
|
<text>|</text>
|
||||||
|
@Html.ActionLink(T("Delete").Text, "Delete", new { path = alias.Path }, new { itemprop = "UnsafeUrl RemoveUrl" })
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user