Sort,Filter and showing IsManaged Admin UI

This commit is contained in:
mahsaro
2015-07-28 18:37:22 +01:00
parent 6718f1902b
commit 8ef3ca1eac
5 changed files with 41 additions and 47 deletions

View File

@@ -45,13 +45,7 @@ namespace Orchard.Alias.Controllers {
if (options == null)
options = new AdminIndexOptions();
switch (options.Filter) {
case AliasFilter.All:
break;
default:
throw new ArgumentOutOfRangeException();
}
var aliases = _aliasHolder.GetMaps().SelectMany(x => x.GetAliases());
if (!String.IsNullOrWhiteSpace(options.Search)) {
@@ -61,6 +55,19 @@ namespace Orchard.Alias.Controllers {
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());
switch (options.Order) {
@@ -76,7 +83,7 @@ namespace Orchard.Alias.Controllers {
var model = new AdminIndexViewModel {
Options = options,
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);
@@ -104,8 +111,7 @@ namespace Orchard.Alias.Controllers {
break;
default:
throw new ArgumentOutOfRangeException();
}
}
return RedirectToAction("Index");
}

View File

@@ -91,7 +91,7 @@ namespace Orchard.Alias.Implementation.Storage {
}
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) {

View File

@@ -21,8 +21,7 @@ namespace Orchard.Alias.Recipes.Executors {
get { return "Aliases"; }
}
public override void Execute(RecipeExecutionContext context) {
//var installedPermissions = _roleService.GetInstalledPermissions().SelectMany(p => p.Value).ToList();
public override void Execute(RecipeExecutionContext context) {
foreach (var aliasElement in context.RecipeStep.Step.Elements()) {
var aliasPath = aliasElement.Attribute("Path").Value;
@@ -41,40 +40,16 @@ namespace Orchard.Alias.Recipes.Executors {
rvd.Add(routeValue.Attribute("Key").Value, routeValue.Attribute("Value").Value);
}
}
//_aliasService.Set(aliasPath, rvd, "Custom",false);
try {
_aliasService.Set(aliasPath, rvd, "Custom", false);
//var role = _roleService.GetRoleByName(roleName);
//if (role == null) {
// _roleService.CreateRole(roleName);
// role = _roleService.GetRoleByName(roleName);
_aliasService.Set(aliasPath, rvd, "Custom", false);
}
// 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) {
Logger.Error(ex, "Error while processing alias '{0}'.", aliasPath);
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;
}
}

View File

@@ -11,8 +11,7 @@ namespace Orchard.Alias.ViewModels {
public class AliasEntry {
public AliasInfo Alias { get; set; }
public bool IsChecked { get; set; }
public bool IsManaged { get; set; }
public bool IsChecked { get; set; }
}
public class AdminIndexOptions {
public string Search { get; set; }
@@ -26,7 +25,9 @@ namespace Orchard.Alias.ViewModels {
}
public enum AliasFilter {
All
All,
Managed,
Custom
}
public enum AliasBulkAction {

View File

@@ -36,6 +36,12 @@
<label for="filterResults">@T("Sort by:")</label>
<select id="filterResults" name="@Html.NameOf(m => m.Options.Order)">
@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>
<input type="hidden" name="Page" value="1" />
<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">@T("Alias")</th>
<th scope="col">@T("Route")</th>
<th scope="col">@T("IsManaged")</th>
<th scope="col">&nbsp;</th>
</tr>
</thead>
@@ -79,9 +86,14 @@
@Html.Link(url, Href("~/" + urlPrefix + "/" + url))
</td>
<td>
@Html.ActionLink(T("Edit").Text, "Edit", new { path = alias.Path == String.Empty ? "/" : alias.Path })
|
@Html.ActionLink(T("Delete").Text, "Delete", new { path = alias.Path }, new { itemprop = "UnsafeUrl RemoveUrl" })
<input type="checkbox" checked="@alias.IsManaged" value="true" name="@Html.FieldNameFor(m => Model.AliasEntries[index].Alias.IsManaged)" disabled="disabled" />
</td>
<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>
</tr>
}