start output of element content in nestedcontent property editor
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"text": {
|
||||||
|
"html": "text"
|
||||||
|
},
|
||||||
|
"button": {
|
||||||
|
"text": "text",
|
||||||
|
"link": "url"
|
||||||
|
},
|
||||||
|
"images": {
|
||||||
|
"items": "media"
|
||||||
|
},
|
||||||
|
"xblocks": {
|
||||||
|
"items": "list"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +1,101 @@
|
|||||||
|
|
||||||
angular.module("umbraco").controller("brothers.uNesting.PropertyEditorController", function ($scope, $controller)
|
angular.module("umbraco").controller("brothers.uNesting.PropertyEditorController", function ($scope, $controller, $http)
|
||||||
{
|
{
|
||||||
angular.extend(this, $controller('Umbraco.PropertyEditors.NestedContent.PropertyEditorController', { $scope: $scope }));
|
angular.extend(this, $controller('Umbraco.PropertyEditors.NestedContent.PropertyEditorController', { $scope: $scope }));
|
||||||
|
|
||||||
$scope.getView = function (node, idx)
|
var elementsConfig = {};
|
||||||
|
|
||||||
|
var init = function ()
|
||||||
{
|
{
|
||||||
if ($scope.model.value[idx])
|
$http.get("/App_Plugins/brothers.uNesting/elements.json").then(function (res)
|
||||||
{
|
{
|
||||||
var contentType = $scope.getContentTypeConfig($scope.model.value[idx].ncContentTypeAlias);
|
elementsConfig = res.data;
|
||||||
|
|
||||||
if (contentType !== null && contentType.nameExp)
|
_.each($scope.nodes, function (node, idx)
|
||||||
{
|
{
|
||||||
// Run the expression against the stored dictionary value, NOT the node object
|
node.uNestingContent = getContent(node, $scope.model.value[idx], elementsConfig[node.contentTypeAlias]);
|
||||||
var item = $scope.model.value[idx];
|
});
|
||||||
var newName = contentType.nameExp(item);
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (newName && (newName = $.trim(newName)))
|
$scope.$watch("inited", function (newVal)
|
||||||
|
{
|
||||||
|
if (newVal)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var getContent = function (node, item, config)
|
||||||
|
{
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if (!config)
|
||||||
|
{
|
||||||
|
return node.documentType.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
var lines = [];
|
||||||
|
|
||||||
|
_.each(config, function (type, alias)
|
||||||
|
{
|
||||||
|
var value = item[alias];
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
if (type === 'text')
|
||||||
{
|
{
|
||||||
return newName;
|
lines.push(stripHtml(value));
|
||||||
|
}
|
||||||
|
if (type === 'url')
|
||||||
|
{
|
||||||
|
lines.push(value[0].url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (lines.length < 1)
|
||||||
|
{
|
||||||
|
return node.documentType.description;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return lines.join('<br>');
|
||||||
}
|
}
|
||||||
return node.documentType.description || 'Enter data ...';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var stripHtml = function (html)
|
||||||
|
{
|
||||||
|
if (!html)
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
var stripped = html.replace('<br>', ' ').replace('<br />', ' ').replace('<br/>', ' ').replace(/<[^>]+>/gm, '');
|
||||||
|
|
||||||
|
return stripped.length > 120 ? (stripped.substring(0, 120) + '...') : stripped;
|
||||||
|
};
|
||||||
|
|
||||||
|
//$scope.getView = function (node, idx)
|
||||||
|
//{
|
||||||
|
// if ($scope.model.value[idx])
|
||||||
|
// {
|
||||||
|
// var contentType = $scope.getContentTypeConfig($scope.model.value[idx].ncContentTypeAlias);
|
||||||
|
|
||||||
|
// if (contentType !== null && contentType.nameExp)
|
||||||
|
// {
|
||||||
|
// // Run the expression against the stored dictionary value, NOT the node object
|
||||||
|
// var item = $scope.model.value[idx];
|
||||||
|
// var newName = contentType.nameExp(item);
|
||||||
|
|
||||||
|
// if (newName && (newName = $.trim(newName)))
|
||||||
|
// {
|
||||||
|
// return newName;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return node.documentType.description || 'Enter data ...';
|
||||||
|
//};
|
||||||
});
|
});
|
||||||
@@ -72,6 +72,7 @@
|
|||||||
{
|
{
|
||||||
color: #817f85;
|
color: #817f85;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* icons */
|
/* icons */
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<i ng-if="showIcons" class="icon" ng-class="$parent.getIcon($index)"></i>
|
<i ng-if="showIcons" class="icon" ng-class="$parent.getIcon($index)"></i>
|
||||||
<div class="unesting-item-header-content" ng-class="{'--has-icon': showIcons}">
|
<div class="unesting-item-header-content" ng-class="{'--has-icon': showIcons}">
|
||||||
<div class="unesting-item-header-content-name" ng-bind="node.contentTypeName"></div>
|
<div class="unesting-item-header-content-name" ng-bind="node.contentTypeName"></div>
|
||||||
<div class="unesting-item-header-content-text" ng-bind-html="getView(node, $index)"></div>
|
<div class="unesting-item-header-content-text" ng-if="node.uNestingContent" ng-bind-html="node.uNestingContent"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -395,6 +395,10 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="App_Plugins\brothers.uNesting\interceptor.js" />
|
||||||
|
<Content Include="App_Plugins\brothers.uNesting\uNesting.controller.js" />
|
||||||
|
<Content Include="App_Plugins\brothers.uNesting\uNesting.css" />
|
||||||
|
<Content Include="App_Plugins\brothers.uNesting\uNesting.html" />
|
||||||
<Content Include="App_Plugins\brothers.uNesting\_nc.js" />
|
<Content Include="App_Plugins\brothers.uNesting\_nc.js" />
|
||||||
<Content Include="App_Plugins\Cultiv.Tabify\directives\ct-tabbed-content.html" />
|
<Content Include="App_Plugins\Cultiv.Tabify\directives\ct-tabbed-content.html" />
|
||||||
<Content Include="App_Plugins\Cultiv.Tabify\directives\cttabbedcontent.directive.js" />
|
<Content Include="App_Plugins\Cultiv.Tabify\directives\cttabbedcontent.directive.js" />
|
||||||
@@ -486,6 +490,8 @@
|
|||||||
<Content Include="App_Plugins\StarterKit\backoffice\tours\create-content.json" />
|
<Content Include="App_Plugins\StarterKit\backoffice\tours\create-content.json" />
|
||||||
<Content Include="App_Plugins\StarterKit\backoffice\tours\data-structure.json" />
|
<Content Include="App_Plugins\StarterKit\backoffice\tours\data-structure.json" />
|
||||||
<Content Include="App_Plugins\StarterKit\package.manifest" />
|
<Content Include="App_Plugins\StarterKit\package.manifest" />
|
||||||
|
<Content Include="App_Plugins\brothers.uNesting\elements.json" />
|
||||||
|
<None Include="App_Plugins\brothers.uNesting\package.manifest" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<Content Include="Views\Web.config" />
|
<Content Include="Views\Web.config" />
|
||||||
<Content Include="Views\Partials\Grid\Editors\Textstring.cshtml" />
|
<Content Include="Views\Partials\Grid\Editors\Textstring.cshtml" />
|
||||||
|
|||||||
Reference in New Issue
Block a user