mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -63,6 +63,7 @@ namespace Lists.Controllers {
|
|||||||
if (container == null || !container.Has<ContainerPart>()) {
|
if (container == null || !container.Has<ContainerPart>()) {
|
||||||
return HttpNotFound();
|
return HttpNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
var restrictedContentType = container.As<ContainerPart>().Record.ItemContentType;
|
var restrictedContentType = container.As<ContainerPart>().Record.ItemContentType;
|
||||||
var hasRestriction = !string.IsNullOrEmpty(restrictedContentType);
|
var hasRestriction = !string.IsNullOrEmpty(restrictedContentType);
|
||||||
if (hasRestriction) {
|
if (hasRestriction) {
|
||||||
@@ -80,11 +81,9 @@ namespace Lists.Controllers {
|
|||||||
return new HttpNotFoundResult();
|
return new HttpNotFoundResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasRestriction) {
|
model.Options.FilterOptions = GetContainableTypes()
|
||||||
model.Options.FilterOptions = GetContainableTypes()
|
.Select(ctd => new KeyValuePair<string, string>(ctd.Name, ctd.DisplayName))
|
||||||
.Select(ctd => new KeyValuePair<string, string>(ctd.Name, ctd.DisplayName))
|
.ToList().OrderBy(kvp => kvp.Key);
|
||||||
.ToList().OrderBy(kvp => kvp.Key);
|
|
||||||
}
|
|
||||||
|
|
||||||
var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count());
|
var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count());
|
||||||
var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList();
|
var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList();
|
||||||
@@ -97,8 +96,8 @@ namespace Lists.Controllers {
|
|||||||
.Pager(pagerShape)
|
.Pager(pagerShape)
|
||||||
.ContainerId(model.ContainerId)
|
.ContainerId(model.ContainerId)
|
||||||
.Options(model.Options)
|
.Options(model.Options)
|
||||||
.HasRestriction(hasRestriction)
|
|
||||||
.ContainerDisplayName(model.ContainerDisplayName)
|
.ContainerDisplayName(model.ContainerDisplayName)
|
||||||
|
.HasRestriction(hasRestriction)
|
||||||
.ContainerContentType(container.ContentType)
|
.ContainerContentType(container.ContentType)
|
||||||
.ContainerItemContentType(hasRestriction ? restrictedContentType : (model.FilterByContentType ?? ""))
|
.ContainerItemContentType(hasRestriction ? restrictedContentType : (model.FilterByContentType ?? ""))
|
||||||
.OtherLists(_contentManager.Query<ContainerPart>(VersionOptions.Latest).List()
|
.OtherLists(_contentManager.Query<ContainerPart>(VersionOptions.Latest).List()
|
||||||
@@ -301,6 +300,7 @@ namespace Lists.Controllers {
|
|||||||
Services.Notifier.Information(T("Please select the list to move the items to."));
|
Services.Notifier.Information(T("Please select the list to move the items to."));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemContentType = targetContainer.Record.ItemContentType;
|
var itemContentType = targetContainer.Record.ItemContentType;
|
||||||
|
|
||||||
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
||||||
@@ -309,6 +309,7 @@ namespace Lists.Controllers {
|
|||||||
}
|
}
|
||||||
// ensure the item can be in that container.
|
// ensure the item can be in that container.
|
||||||
if (!string.IsNullOrEmpty(itemContentType) && item.ContentType != itemContentType) {
|
if (!string.IsNullOrEmpty(itemContentType) && item.ContentType != itemContentType) {
|
||||||
|
Services.TransactionManager.Cancel();
|
||||||
Services.Notifier.Information(T("One or more items could not be moved to '{0}' because it is restricted to containing items of type '{1}'.", _contentManager.GetItemMetadata(targetContainer).DisplayText, itemContentType));
|
Services.Notifier.Information(T("One or more items could not be moved to '{0}' because it is restricted to containing items of type '{1}'.", _contentManager.GetItemMetadata(targetContainer).DisplayText, itemContentType));
|
||||||
return true; // todo: transactions
|
return true; // todo: transactions
|
||||||
}
|
}
|
||||||
@@ -323,6 +324,7 @@ namespace Lists.Controllers {
|
|||||||
private bool BulkRemoveFromList(IEnumerable<int> itemIds) {
|
private bool BulkRemoveFromList(IEnumerable<int> itemIds) {
|
||||||
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.EditContent, item, T("Couldn't remove selected content from the list."))) {
|
if (!Services.Authorizer.Authorize(Permissions.EditContent, item, T("Couldn't remove selected content from the list."))) {
|
||||||
|
Services.TransactionManager.Cancel();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
item.As<CommonPart>().Record.Container = null;
|
item.As<CommonPart>().Record.Container = null;
|
||||||
@@ -334,6 +336,7 @@ namespace Lists.Controllers {
|
|||||||
private bool BulkRemove(IEnumerable<int> itemIds) {
|
private bool BulkRemove(IEnumerable<int> itemIds) {
|
||||||
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.DeleteContent, item, T("Couldn't remove selected content."))) {
|
if (!Services.Authorizer.Authorize(Permissions.DeleteContent, item, T("Couldn't remove selected content."))) {
|
||||||
|
Services.TransactionManager.Cancel();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,6 +349,7 @@ namespace Lists.Controllers {
|
|||||||
private bool BulkUnpublish(IEnumerable<int> itemIds) {
|
private bool BulkUnpublish(IEnumerable<int> itemIds) {
|
||||||
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't unpublish selected content."))) {
|
if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't unpublish selected content."))) {
|
||||||
|
Services.TransactionManager.Cancel();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,8 +361,10 @@ namespace Lists.Controllers {
|
|||||||
|
|
||||||
private bool BulkPublishNow(IEnumerable<int> itemIds) {
|
private bool BulkPublishNow(IEnumerable<int> itemIds) {
|
||||||
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't publish selected content.")))
|
if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't publish selected content."))) {
|
||||||
|
Services.TransactionManager.Cancel();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
_contentManager.Publish(item);
|
_contentManager.Publish(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,15 +43,13 @@
|
|||||||
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
|
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="bulk-actions">
|
<fieldset class="bulk-actions">
|
||||||
@if(!Model.HasRestriction) {
|
|
||||||
<label for="filterResults" class="bulk-filter">@T("Show")</label>
|
<label for="filterResults" class="bulk-filter">@T("Show")</label>
|
||||||
<select id="filterResults" name="Options.SelectedFilter">
|
<select id="filterResults" name="Options.SelectedFilter"@Html.Raw(Model.HasRestriction ? " disabled=\"disabled\"" : "")>
|
||||||
@Html.SelectOption((string)Model.Options.SelectedFilter, "", T("any (show all)").ToString())
|
@Html.SelectOption((string)Model.Options.SelectedFilter, "", T("any (show all)").ToString())
|
||||||
@foreach(var filterOption in Model.Options.FilterOptions) {
|
@foreach(var filterOption in Model.Options.FilterOptions) {
|
||||||
@Html.SelectOption((string)Model.Options.SelectedFilter, (string)filterOption.Key, (string)filterOption.Value)
|
@Html.SelectOption((string)Model.Options.SelectedFilter, (string)filterOption.Key, (string)filterOption.Value)
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
}
|
|
||||||
<label for="orderResults" class="bulk-order">@T("Ordered by")</label>
|
<label for="orderResults" class="bulk-order">@T("Ordered by")</label>
|
||||||
<select id="orderResults" name="Options.OrderBy">
|
<select id="orderResults" name="Options.OrderBy">
|
||||||
@Html.SelectOption((ContentsOrder)Model.Options.OrderBy, ContentsOrder.Created, T("recently created").ToString())
|
@Html.SelectOption((ContentsOrder)Model.Options.OrderBy, ContentsOrder.Created, T("recently created").ToString())
|
||||||
@@ -69,4 +67,4 @@
|
|||||||
}
|
}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@Display(Model.Pager)
|
@Display(Model.Pager)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user