mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Media Library: adding support for displaying draft items.
This commit is contained in:
parent
6477ddc828
commit
5888caa3d3
@ -85,8 +85,8 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
|
||||
[Themed(false)]
|
||||
public ActionResult MediaItems(string folderPath, int skip = 0, int count = 0, string order = "created", string mediaType = "") {
|
||||
var mediaParts = _mediaLibraryService.GetMediaContentItems(folderPath, skip, count, order, mediaType);
|
||||
var mediaPartsCount = _mediaLibraryService.GetMediaContentItemsCount(folderPath, mediaType);
|
||||
var mediaParts = _mediaLibraryService.GetMediaContentItems(folderPath, skip, count, order, mediaType, VersionOptions.Latest);
|
||||
var mediaPartsCount = _mediaLibraryService.GetMediaContentItemsCount(folderPath, mediaType, VersionOptions.Latest);
|
||||
|
||||
var mediaItems = mediaParts.Select(x => new MediaManagerMediaItemViewModel {
|
||||
MediaPart = x,
|
||||
@ -103,8 +103,8 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
|
||||
[Themed(false)]
|
||||
public ActionResult RecentMediaItems(int skip = 0, int count = 0, string order = "created", string mediaType = "") {
|
||||
var mediaParts = _mediaLibraryService.GetMediaContentItems(skip, count, order, mediaType);
|
||||
var mediaPartsCount = _mediaLibraryService.GetMediaContentItemsCount(mediaType);
|
||||
var mediaParts = _mediaLibraryService.GetMediaContentItems(skip, count, order, mediaType, VersionOptions.Latest);
|
||||
var mediaPartsCount = _mediaLibraryService.GetMediaContentItemsCount(mediaType, VersionOptions.Latest);
|
||||
|
||||
var mediaItems = mediaParts.Select(x => new MediaManagerMediaItemViewModel {
|
||||
MediaPart = x,
|
||||
@ -140,7 +140,7 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
try {
|
||||
foreach (var media in Services.ContentManager.Query().ForContentItems(mediaItemIds).List()) {
|
||||
foreach (var media in Services.ContentManager.Query(VersionOptions.Latest).ForContentItems(mediaItemIds).List()) {
|
||||
if (media != null) {
|
||||
Services.ContentManager.Remove(media);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ $(function () {
|
||||
var listWidth = $('#media-library-main-list').width();
|
||||
var listHeight = $('#media-library-main-list').height();
|
||||
var itemSize = $('.thumbnail').first().width();
|
||||
var draftText = $("#media-library").data("draft-text");
|
||||
|
||||
var itemsPerRow = Math.floor(listWidth / itemSize);
|
||||
var itemsPerColumn = Math.ceil(listHeight / itemSize);
|
||||
@ -53,6 +54,10 @@ $(function () {
|
||||
return css;
|
||||
});
|
||||
|
||||
self.publicationStatus = ko.computed(function() {
|
||||
return self.data.published ? "" : draftText;
|
||||
});
|
||||
|
||||
// operations
|
||||
self.setData = function(value) {
|
||||
self.data = value;
|
||||
|
@ -9,11 +9,11 @@ using Orchard.MediaLibrary.Models;
|
||||
namespace Orchard.MediaLibrary.Services {
|
||||
public interface IMediaLibraryService : IDependency {
|
||||
IEnumerable<ContentTypeDefinition> GetMediaTypes();
|
||||
IContentQuery<MediaPart, MediaPartRecord> GetMediaContentItems();
|
||||
IEnumerable<MediaPart> GetMediaContentItems(string folderPath, int skip, int count, string order, string mediaType);
|
||||
IEnumerable<MediaPart> GetMediaContentItems(int skip, int count, string order, string mediaType);
|
||||
int GetMediaContentItemsCount(string folderPath, string mediaType);
|
||||
int GetMediaContentItemsCount(string mediaType);
|
||||
IContentQuery<MediaPart, MediaPartRecord> GetMediaContentItems(VersionOptions versionOptions = null);
|
||||
IEnumerable<MediaPart> GetMediaContentItems(string folderPath, int skip, int count, string order, string mediaType, VersionOptions versionOptions = null);
|
||||
IEnumerable<MediaPart> GetMediaContentItems(int skip, int count, string order, string mediaType, VersionOptions versionOptions = null);
|
||||
int GetMediaContentItemsCount(string folderPath, string mediaType, VersionOptions versionOptions = null);
|
||||
int GetMediaContentItemsCount(string mediaType, VersionOptions versionOptions = null);
|
||||
MediaPart ImportMedia(string relativePath, string filename);
|
||||
MediaPart ImportMedia(string relativePath, string filename, string contentType);
|
||||
MediaPart ImportMedia(Stream stream, string relativePath, string filename);
|
||||
|
@ -44,12 +44,12 @@ namespace Orchard.MediaLibrary.Services {
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public IContentQuery<MediaPart, MediaPartRecord> GetMediaContentItems() {
|
||||
return _orchardServices.ContentManager.Query<MediaPart, MediaPartRecord>();
|
||||
public IContentQuery<MediaPart, MediaPartRecord> GetMediaContentItems(VersionOptions versionOptions = null) {
|
||||
return _orchardServices.ContentManager.Query<MediaPart, MediaPartRecord>(versionOptions);
|
||||
}
|
||||
|
||||
public IEnumerable<MediaPart> GetMediaContentItems(string folderPath, int skip, int count, string order, string mediaType) {
|
||||
var query = _orchardServices.ContentManager.Query<MediaPart>();
|
||||
public IEnumerable<MediaPart> GetMediaContentItems(string folderPath, int skip, int count, string order, string mediaType, VersionOptions versionOptions = null) {
|
||||
var query = _orchardServices.ContentManager.Query<MediaPart>(versionOptions);
|
||||
|
||||
if (!String.IsNullOrEmpty(mediaType)) {
|
||||
query = query.ForType(new[] { mediaType });
|
||||
@ -86,12 +86,12 @@ namespace Orchard.MediaLibrary.Services {
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<MediaPart> GetMediaContentItems(int skip, int count, string order, string mediaType) {
|
||||
public IEnumerable<MediaPart> GetMediaContentItems(int skip, int count, string order, string mediaType, VersionOptions versionOptions = null) {
|
||||
return GetMediaContentItems(null, skip, count, order, mediaType);
|
||||
}
|
||||
|
||||
public int GetMediaContentItemsCount(string folderPath, string mediaType) {
|
||||
var query = _orchardServices.ContentManager.Query<MediaPart>();
|
||||
public int GetMediaContentItemsCount(string folderPath, string mediaType, VersionOptions versionOptions = null) {
|
||||
var query = _orchardServices.ContentManager.Query<MediaPart>(versionOptions);
|
||||
|
||||
if (!String.IsNullOrEmpty(mediaType)) {
|
||||
query = query.ForType(new[] { mediaType });
|
||||
@ -104,8 +104,8 @@ namespace Orchard.MediaLibrary.Services {
|
||||
return query.Count();
|
||||
}
|
||||
|
||||
public int GetMediaContentItemsCount(string mediaType) {
|
||||
return GetMediaContentItemsCount(null, mediaType);
|
||||
public int GetMediaContentItemsCount(string mediaType, VersionOptions versionOptions = null) {
|
||||
return GetMediaContentItemsCount(null, mediaType, versionOptions);
|
||||
}
|
||||
|
||||
public MediaPart ImportMedia(Stream stream, string relativePath, string filename) {
|
||||
|
@ -337,6 +337,10 @@
|
||||
text-wrap: none;
|
||||
}
|
||||
|
||||
.media-library-main-list-overlay .publication-status {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.ui-draggable-dragging .media-library-main-list-overlay{
|
||||
display: none;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
Layout.Title = T("Media Library");
|
||||
}
|
||||
|
||||
<div id="media-library">
|
||||
<div id="media-library" data-draft-text="@T("(draft)")">
|
||||
<div id="media-library-toolbar">
|
||||
<a href="#" data-bind="visible: displayed(), click: importMedia" class="button" id="button-import">@T("Import")</a>
|
||||
<a href="#" data-bind="visible: displayed(), attr: { href: '@HttpUtility.JavaScriptStringEncode(Url.Action("Edit", "Folder", new { area = "Orchard.MediaLibrary"}))?folderPath=' + encodeURIComponent(displayed()) }" class="button" id="button-edit-folder">@T("Edit Folder")</a>
|
||||
@ -48,6 +48,7 @@
|
||||
</div>
|
||||
<div class="media-library-main-list-overlay">
|
||||
<p class="title" data-bind="text: data.title"></p>
|
||||
<p class="publication-status" data-bind="text: publicationStatus"></p>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -9,7 +9,8 @@
|
||||
id = x.MediaPart.Id,
|
||||
contentType = x.MediaPart.ContentItem.ContentType,
|
||||
contentTypeClass = x.MediaPart.ContentItem.ContentType.HtmlClassify(),
|
||||
title = x.MediaPart.Title,
|
||||
title = x.MediaPart.Title,
|
||||
published = x.MediaPart.ContentItem.VersionRecord.Published,
|
||||
alternateText = x.MediaPart.AlternateText,
|
||||
caption = x.MediaPart.Caption,
|
||||
resource = x.MediaPart.MediaUrl,
|
||||
|
@ -24,11 +24,13 @@
|
||||
<span>@mediaPart.Caption</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (HasText(mediaPart.AlternateText)) {
|
||||
<div class="alternate-text">
|
||||
<em>@T("Alternate Text:")</em>
|
||||
<span>@mediaPart.AlternateText</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="publication-status">
|
||||
<em>@T("Status:")</em>
|
||||
<span>@T("{0}", mediaPart.ContentItem.VersionRecord.Published ? "Published" : "Draft")</span>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user