replace default NC value converters with uNesting converters by using a composer
This commit is contained in:
@@ -67,7 +67,7 @@
|
|||||||
<i class="icon icon-trash-alt"></i>
|
<i class="icon icon-trash-alt"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="unesting-icon is-negative hidden-toggle" localize="title" title="general_visibility" ng-if="canHide(model.value[$index])" ng-click="clickHide($event, node, ncTabAlias);" prevent-default>
|
<a class="unesting-icon is-negative hidden-toggle" localize="title" title="general_visibility" ng-if="canHide(model.value[$index])" ng-click="clickHide($event, node, $index);" prevent-default>
|
||||||
<i class="icon icon-lock"></i>
|
<i class="icon icon-lock"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -637,7 +637,7 @@ angular.module("umbraco").controller("brothers.uNesting.PropertyEditorController
|
|||||||
unsubscribe();
|
unsubscribe();
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.clickHide = function ($event, node, alias)
|
$scope.clickHide = function ($event, node, $index)
|
||||||
{
|
{
|
||||||
$event.preventDefault();
|
$event.preventDefault();
|
||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
@@ -656,24 +656,13 @@ angular.module("umbraco").controller("brothers.uNesting.PropertyEditorController
|
|||||||
if (property)
|
if (property)
|
||||||
{
|
{
|
||||||
property.value = property.value === '1' ? '0' : '1';
|
property.value = property.value === '1' ? '0' : '1';
|
||||||
|
|
||||||
$scope.setDirty();
|
$scope.setDirty();
|
||||||
|
|
||||||
if ($scope.inited)
|
if ($scope.inited)
|
||||||
{
|
{
|
||||||
var newValues = [];
|
$scope.model.value[$index] = convertNodeIntoNCEntry(node);
|
||||||
for (var i = 0; i < $scope.nodes.length; i++)
|
|
||||||
{
|
|
||||||
newValues.push(convertNodeIntoNCEntry($scope.nodes[i]));
|
|
||||||
}
|
|
||||||
$scope.model.value = newValues;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if ($scope.realCurrentNode)
|
|
||||||
//{
|
|
||||||
// $scope.$broadcast("ncSyncInVal", { key: $scope.realCurrentNode.key });
|
|
||||||
//}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.canHide = function (item)
|
$scope.canHide = function (item)
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Umbraco.Core.Composing;
|
||||||
|
using Umbraco.Core.PropertyEditors;
|
||||||
|
using Umbraco.Web.PropertyEditors.ValueConverters;
|
||||||
|
|
||||||
|
namespace UmbracoPackages
|
||||||
|
{
|
||||||
|
public class UnestingComposer : IUserComposer
|
||||||
|
{
|
||||||
|
public void Compose(Composition composition)
|
||||||
|
{
|
||||||
|
composition.WithCollectionBuilder<PropertyValueConverterCollectionBuilder>()
|
||||||
|
.Remove<NestedContentManyValueConverter>()
|
||||||
|
.Remove<NestedContentSingleValueConverter>()
|
||||||
|
.Append<UnestingManyValueConverter>()
|
||||||
|
.Append<UnestingSingleValueConverter>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Umbraco.Core.Logging;
|
||||||
|
using Umbraco.Core.Models.PublishedContent;
|
||||||
|
using Umbraco.Core.PropertyEditors;
|
||||||
|
using Umbraco.Web;
|
||||||
|
using Umbraco.Web.PropertyEditors.ValueConverters;
|
||||||
|
using Umbraco.Web.PublishedCache;
|
||||||
|
|
||||||
|
namespace UmbracoPackages
|
||||||
|
{
|
||||||
|
public class UnestingManyValueConverter : NestedContentManyValueConverter
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public UnestingManyValueConverter(IPublishedSnapshotAccessor publishedSnapshotAccessor, IPublishedModelFactory publishedModelFactory, IProfilingLogger proflog) : base(publishedSnapshotAccessor, publishedModelFactory, proflog) { }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
|
||||||
|
{
|
||||||
|
return ((IList<IPublishedElement>)base.ConvertIntermediateToObject(owner, propertyType, referenceCacheLevel, inter, preview))
|
||||||
|
.Where(element => !element.HasValue("uNestingHide") || !element.Value<bool>("uNestingHide"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class UnestingSingleValueConverter : NestedContentSingleValueConverter
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public UnestingSingleValueConverter(IPublishedSnapshotAccessor publishedSnapshotAccessor, IPublishedModelFactory publishedModelFactory, IProfilingLogger proflog) : base(publishedSnapshotAccessor, publishedModelFactory, proflog) { }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
|
||||||
|
{
|
||||||
|
IPublishedElement element = (IPublishedElement)base.ConvertIntermediateToObject(owner, propertyType, referenceCacheLevel, inter, preview);
|
||||||
|
return element == null || (element.HasValue("uNestingHide") && element.Value<bool>("uNestingHide")) : null : element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user