WIP on better mediapicker view

This commit is contained in:
perploug
2013-11-19 11:10:58 +01:00
parent fb1d6436b7
commit 7cb496ee3c
2 changed files with 36 additions and 39 deletions

View File

@@ -165,41 +165,41 @@ function imageHelper() {
if (!options && !options.imageModel) {
throw "The options objet does not contain the required parameters: imageModel";
}
if (options.imageModel.contentTypeAlias.toLowerCase() === "image") {
//combine all props, TODO: we really need a better way then this
var props = [];
if(options.imageModel.properties){
props = options.imageModel.properties;
}else{
$(options.imageModel.tabs).each(function(i, tab){
props = props.concat(tab.properties);
});
}
var imageProp = _.find(props, function (item) {
return item.alias === 'umbracoFile';
});
if (!imageProp) {
return "";
}
var imageVal;
//our default images might store one or many images (as csv)
var split = imageProp.value.split(',');
var self = this;
imageVal = _.map(split, function(item) {
return { file: item, isImage: self.detectIfImageByExtension(item) };
});
//for now we'll just return the first image in the collection.
//TODO: we should enable returning many to be displayed in the picker if the uploader supports many.
if (imageVal.length && imageVal.length > 0 && imageVal[0].isImage) {
return imageVal[0].file;
}
//combine all props, TODO: we really need a better way then this
var props = [];
if(options.imageModel.properties){
props = options.imageModel.properties;
}else{
$(options.imageModel.tabs).each(function(i, tab){
props = props.concat(tab.properties);
});
}
var imageProp = _.find(props, function (item) {
return item.alias === 'umbracoFile';
});
if (!imageProp) {
return "";
}
var imageVal;
//our default images might store one or many images (as csv)
var split = imageProp.value.split(',');
var self = this;
imageVal = _.map(split, function(item) {
return { file: item, isImage: self.detectIfImageByExtension(item) };
});
//for now we'll just return the first image in the collection.
//TODO: we should enable returning many to be displayed in the picker if the uploader supports many.
if (imageVal.length && imageVal.length > 0 && imageVal[0].isImage) {
return imageVal[0].file;
}
return "";
},
/** formats the display model used to display the content to the model used to save the content */

View File

@@ -55,6 +55,7 @@ angular.module("umbraco")
_.each($scope.images, function(img) {
img.thumbnail = imageHelper.getThumbnail({ imageModel: img, scope: $scope });
});
//reject all images that have an empty thumbnail - this can occur if there's an image item
// that doesn't have an uploaded image.
$scope.images = _.reject($scope.images, function(item) {
@@ -75,9 +76,7 @@ angular.module("umbraco")
if (image.contentTypeAlias.toLowerCase() == 'folder') {
$scope.options.formData.currentFolder = image.id;
$scope.gotoFolder(image.id);
}
else if (image.contentTypeAlias.toLowerCase() == 'image') {
}else{
eventsService.publish("Umbraco.Dialogs.MediaPickerController.Select", image);
if (dialogOptions && dialogOptions.multiPicker) {
@@ -96,11 +95,9 @@ angular.module("umbraco")
if (image.contentTypeAlias.toLowerCase() == 'folder') {
$scope.options.formData.currentFolder = image.id;
$scope.gotoFolder(image.id);
}
else if (image.contentTypeAlias.toLowerCase() == 'image') {
}else{
eventsService.publish("Umbraco.Dialogs.MediaPickerController.Select", image);
if (dialogOptions && dialogOptions.multiPicker) {
$scope.select(image);
}