Skip to content

Commit c85185b

Browse files
kjacnul800sebastiaan
authored andcommitted
Visual improvements to Nested Content (U4-10742) (#2457)
1 parent 43fd34a commit c85185b

File tree

3 files changed

+76
-20
lines changed

3 files changed

+76
-20
lines changed

src/Umbraco.Web.UI.Client/src/common/filters/nestedcontent.filter.js

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ var ncNodeNameCache = {
99

1010
angular.module("umbraco.filters").filter("ncNodeName", function (editorState, entityResource) {
1111

12+
function formatLabel(firstNodeName, totalNodes) {
13+
return totalNodes <= 1
14+
? firstNodeName
15+
// If there is more than one item selected, append the additional number of items selected to hint that
16+
: firstNodeName + " (+" + (totalNodes - 1) + ")";
17+
}
18+
1219
return function (input) {
1320

1421
// Check we have a value at all
@@ -25,23 +32,38 @@ angular.module("umbraco.filters").filter("ncNodeName", function (editorState, en
2532
ncNodeNameCache.keys = {};
2633
}
2734

35+
// MNTP values are comma separated IDs. We'll only fetch the first one for the NC header.
36+
var ids = input.split(',');
37+
var lookupId = ids[0];
38+
2839
// See if there is a value in the cache and use that
29-
if (ncNodeNameCache.keys[input]) {
30-
return ncNodeNameCache.keys[input];
40+
if (ncNodeNameCache.keys[lookupId]) {
41+
return formatLabel(ncNodeNameCache.keys[lookupId], ids.length);
3142
}
3243

3344
// No value, so go fetch one
3445
// We'll put a temp value in the cache though so we don't
3546
// make a load of requests while we wait for a response
36-
ncNodeNameCache.keys[input] = "Loading...";
47+
ncNodeNameCache.keys[lookupId] = "Loading...";
3748

38-
entityResource.getById(input, "Document")
39-
.then(function (ent) {
40-
ncNodeNameCache.keys[input] = ent.name;
41-
});
49+
var type = lookupId.indexOf("umb://media/") === 0
50+
? "Media"
51+
: lookupId.indexOf("umb://member/") === 0
52+
? "Member"
53+
: "Document";
54+
entityResource.getById(lookupId, type)
55+
.then(
56+
function (ent) {
57+
ncNodeNameCache.keys[lookupId] = ent.name;
58+
}
59+
);
4260

4361
// Return the current value for now
44-
return ncNodeNameCache.keys[input];
62+
return formatLabel(ncNodeNameCache.keys[lookupId], ids.length);
4563
};
4664

47-
});
65+
}).filter("ncRichText", function () {
66+
return function(input) {
67+
return $("<div/>").html(input).text();
68+
};
69+
});

src/Umbraco.Web.UI.Client/src/less/components/umb-nested-content.less

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,63 @@
6767
-o-user-select: none;
6868
}
6969

70-
.nested-content__heading
71-
{
72-
float: left;
70+
.nested-content__heading {
7371
line-height: 20px;
74-
}
72+
position: relative;
7573

76-
.nested-content__heading i
77-
{
78-
vertical-align: text-top;
79-
color: #999; /* same icon color as the icons in the item type picker */
80-
margin-right: 10px;
74+
&.-with-icon
75+
{
76+
padding-left: 20px;
77+
}
78+
79+
i
80+
{
81+
color: #999; /* same icon color as the icons in the item type picker */
82+
position: absolute;
83+
left: 0;
84+
}
85+
86+
.nested-content__item-name
87+
{
88+
max-height: 20px;
89+
text-align: left;
90+
white-space: nowrap;
91+
overflow: hidden;
92+
text-overflow: ellipsis;
93+
display: block;
94+
}
8195
}
8296

8397
.nested-content__icons
8498
{
85-
margin: -6px 0;
8699
opacity: 0;
87100

88101
transition: opacity .15s ease-in-out;
89102
-moz-transition: opacity .15s ease-in-out;
90103
-webkit-transition: opacity .15s ease-in-out;
104+
105+
position: absolute;
106+
right: 0px;
107+
top: 2px;
108+
background-color: white;
109+
padding: 5px;
110+
111+
&:before
112+
{
113+
content: ' ';
114+
position: absolute;
115+
display: block;
116+
width: 30px;
117+
left: -30px;
118+
top: 0;
119+
bottom: 0;
120+
background: -webkit-linear-gradient(90deg, rgba(255,255,255,0), white);
121+
background: -moz-linear-gradient(90deg, rgba(255,255,255,0), white);
122+
background: linear-gradient(90deg, rgba(255,255,255,0), white);
123+
}
91124
}
92125

126+
93127
.nested-content__header-bar:hover .nested-content__icons,
94128
.nested-content__item--active > .nested-content__header-bar .nested-content__icons
95129
{

src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<div class="nested-content__header-bar" ng-click="$parent.editNode($index)" ng-hide="$parent.singleMode">
1111

12-
<div class="nested-content__heading"><i ng-if="showIcons" class="icon" ng-class="$parent.getIcon($index)"></i><span ng-bind="$parent.getName($index)"></span></div>
12+
<div class="nested-content__heading" ng-class="{'-with-icon': showIcons}"><i ng-if="showIcons" class="icon" ng-class="$parent.getIcon($index)"></i><span class="nested-content__item-name" ng-bind="$parent.getName($index)"></span></div>
1313

1414
<div class="nested-content__icons">
1515
<a class="nested-content__icon nested-content__icon--edit" title="{{editIconTitle}}" ng-class="{ 'nested-content__icon--active' : $parent.realCurrentNode.id == node.id }" ng-click="$parent.editNode($index); $event.stopPropagation();" ng-show="$parent.maxItems > 1" prevent-default>

0 commit comments

Comments
 (0)