Fixes pickers to be backwards compatible - they by default in v6 stored as INT. Fixing MNTP with media/members.

This commit is contained in:
Shannon
2013-11-05 14:28:25 +11:00
parent 787f304de7
commit fbeff81128
10 changed files with 27 additions and 56 deletions

View File

@@ -6,19 +6,19 @@ angular.module('umbraco')
function($scope, dialogService, entityResource, $log, iconHelper){
$scope.renderModel = [];
$scope.ids = [];
$scope.cfg = {
multiPicker: false,
entityType: "Document",
type: "content",
treeAlias: "content"
};
$scope.cfg = {
multiPicker: false,
entityType: "Document",
type: "content",
treeAlias: "content"
};
if($scope.model.value){
$scope.ids = $scope.model.value.split(',');
entityResource.getByIds($scope.ids, $scope.cfg.entityType).then(function(data){
$(data).each(function(i, item){
_.each(data, function (item, i) {
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
$scope.renderModel.push({name: item.name, id: item.id, icon: item.icon});
});
@@ -69,7 +69,7 @@ angular.module('umbraco')
function populate(data){
if(angular.isArray(data)){
$(data).each(function(i, item){
_.each(data, function (item, i) {
$scope.add(item);
});
}else{

View File

@@ -1,27 +0,0 @@
angular.module("umbraco").controller("Umbraco.PropertyEditors.CodeMirrorController",
function ($scope, $rootScope, assetsService) {
/*
require(
[
'css!../lib/codemirror/js/lib/codemirror.css',
'css!../lib/codemirror/css/umbracoCustom.css',
'codemirrorHtml'
],
function () {
var editor = CodeMirror.fromTextArea(
document.getElementById($scope.alias),
{
mode: CodeMirror.modes.htmlmixed,
tabMode: "indent"
});
editor.on("change", function(cm) {
$rootScope.$apply(function(){
$scope.value = cm.getValue();
});
});
});*/
});

View File

@@ -1,4 +0,0 @@
<div ng-controller="Umbraco.PropertyEditors.CodeMirrorController">
<textarea id="{{model.alias}}">{{model.value}}</textarea>
<pre>{{model.value}}</pre>
</div>

View File

@@ -6,8 +6,7 @@ angular.module('umbraco')
function($scope, dialogService, entityResource, $log, iconHelper){
$scope.renderModel = [];
$scope.ids = $scope.model.value ? $scope.model.value.split(',') : [];
//configuration
$scope.cfg = {
multiPicker: false,
@@ -20,22 +19,25 @@ angular.module('umbraco')
if($scope.model.config){
$scope.cfg = angular.extend($scope.cfg, $scope.model.config);
}
//Umbraco persists boolean for prevalues as "0" or "1" so we need to convert that!
$scope.cfg.multiPicker = ($scope.cfg.multiPicker.toString() == "1" ? true : ($scope.cfg.multiPicker === true));
if($scope.cfg.type === "member"){
$scope.cfg.entityType = "Member";
}else if($scope.cfg.type === "media"){
$scope.cfg.entityType = "Member";
}
else if ($scope.cfg.type === "media") {
$scope.cfg.entityType = "Media";
}
$scope.cfg.callback = populate;
$scope.cfg.treeAlias = $scope.cfg.type;
$scope.cfg.section = $scope.cfg.type;
$scope.cfg.filterCssClass = "not-allowed not-published";
//$scope.cfg.scope = $scope;
//load current data
entityResource.getByIds($scope.ids, $scope.cfg.entityType).then(function(data){
$(data).each(function(i, item){
_.each(data, function (item, i) {
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
$scope.renderModel.push({name: item.name, id: item.id, icon: item.icon});
});
@@ -95,7 +97,7 @@ angular.module('umbraco')
function populate(data){
if(angular.isArray(data)){
$(data).each(function(i, item){
_.each(data, function (item, i) {
$scope.add(item);
});
}else{

View File

@@ -15,7 +15,7 @@
</li>
</ul>
<ul class="unstyled list-icons" ng-show="cfg.multiPicker || renderModel.length === 0">
<ul class="unstyled list-icons" ng-show="cfg.multiPicker === true || renderModel.length === 0">
<li>
<i class="icon icon-add blue"></i>
<a href="#" ng-click="openContentPicker()" prevent-default>

View File

@@ -75,7 +75,7 @@ angular.module('umbraco')
function populate(data){
if(angular.isArray(data)){
$(data).each(function(i, item){
_.each(data, function (item, i) {
$scope.add(item);
});
}else{

View File

@@ -13,7 +13,7 @@ angular.module('umbraco')
}
entityResource.getByIds($scope.ids, $scope.cfg.entityType).then(function(data){
$(data).each(function(i, item){
_.each(data, function (item, i) {
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
$scope.renderModel.push({name: item.name, id: item.id, icon: item.icon});
});
@@ -81,7 +81,7 @@ angular.module('umbraco')
function populate(data){
if(angular.isArray(data)){
$(data).each(function(i, item){
_.each(data, function (item, i) {
$scope.add(item);
});
}else{

View File

@@ -16,7 +16,7 @@
</li>
</ul>
<ul class="unstyled list-icons" ng-show="cfg.multiPicker || renderModel.length === 0">
<ul class="unstyled list-icons" ng-show="cfg.multiPicker === true || renderModel.length === 0">
<li>
<i class="icon icon-add blue"></i>
<a href="#" ng-click="openMemberPicker()" prevent-default>

View File

@@ -3,7 +3,7 @@ using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
{
[PropertyEditor(Constants.PropertyEditors.ContentPickerAlias, "Content Picker", "contentpicker", IsParameterEditor = true)]
[PropertyEditor(Constants.PropertyEditors.ContentPickerAlias, "Content Picker", "INT", "contentpicker", IsParameterEditor = true)]
public class ContentPickerPropertyEditor : PropertyEditor
{
}

View File

@@ -9,7 +9,7 @@ using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
{
[PropertyEditor(Constants.PropertyEditors.MediaPickerAlias, "Media Picker", "mediapicker")]
[PropertyEditor(Constants.PropertyEditors.MediaPickerAlias, "Media Picker", "INT", "mediapicker")]
public class MediaPickerPropertyEditor : PropertyEditor
{
protected override PropertyValueEditor CreateValueEditor()