Skip to content

Commit b2cafa0

Browse files
committed
EZP-31408: 'This Location has no Sub-items' msg is displayed above location
1 parent 7db1c4a commit b2cafa0

File tree

4 files changed

+34
-23
lines changed

4 files changed

+34
-23
lines changed

Resources/public/scss/modules/content-tree/_list.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
margin: 0;
33
padding: 0 0 0 calculateRem(12px);
44
list-style: none;
5+
6+
&__no-items-message {
7+
padding: calculateRem(10px);
8+
font-size: calculateRem(12px);
9+
font-style: italic;
10+
color: $ez-color-base-dark;
11+
}
512
}
613

714
.m-tree__scrollable-wrapper {

Resources/public/scss/modules/content-tree/_main.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,4 @@
4141
color: $ez-color-base-light;
4242
cursor: pointer;
4343
}
44-
45-
&__no-items-message {
46-
padding: calculateRem(10px);
47-
font-size: calculateRem(12px);
48-
font-style: italic;
49-
color: $ez-color-base-dark;
50-
}
5144
}

src/modules/content-tree/components/content-tree/content.tree.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,6 @@ export default class ContentTree extends Component {
6161
window.document.body.classList.remove(CLASS_IS_TREE_RESIZING);
6262
}
6363

64-
renderNoSubitemMessage() {
65-
const { items } = this.props;
66-
const rootLocation = items[0];
67-
const isRootLoaded = rootLocation;
68-
const noSubitemsMessage = Translator.trans(/*@Desc("This location has no sub-items")*/ 'no_subitems', {}, 'content_tree');
69-
70-
if (!isRootLoaded || (rootLocation.subitems && rootLocation.subitems.length)) {
71-
return;
72-
}
73-
74-
return <div className="m-tree__no-items-message">{noSubitemsMessage}</div>;
75-
}
76-
7764
renderCollapseAllBtn() {
7865
const collapseAllLabel = Translator.trans(/*@Desc("Collapse all")*/ 'collapse_all', {}, 'content_tree');
7966

@@ -137,7 +124,6 @@ export default class ContentTree extends Component {
137124

138125
return (
139126
<div {...containerAttrs}>
140-
{this.renderNoSubitemMessage()}
141127
{this.renderList()}
142128
{this.renderLoadingSpinner()}
143129
{this.renderCollapseAllBtn()}

src/modules/content-tree/components/list/list.component.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,31 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import ListItem from '../list-item/list.item.component';
44

5-
const List = ({ items, loadMoreSubitems, currentLocationId, path, subitemsLoadLimit, subitemsLimit, treeMaxDepth, afterItemToggle, isRoot }) => {
5+
const List = ({
6+
items,
7+
loadMoreSubitems,
8+
currentLocationId,
9+
path,
10+
subitemsLoadLimit,
11+
subitemsLimit,
12+
treeMaxDepth,
13+
afterItemToggle,
14+
isRoot,
15+
}) => {
616
const commonAttrs = { loadMoreSubitems, subitemsLoadLimit, subitemsLimit, treeMaxDepth, afterItemToggle };
717
const listAttrs = { ...commonAttrs, currentLocationId };
818
const listItemAttrs = commonAttrs;
19+
const renderNoSubitemMessage = () => {
20+
const rootLocation = items[0];
21+
const isRootLoaded = rootLocation;
22+
const noSubitemsMessage = Translator.trans(/*@Desc("This location has no sub-items")*/ 'no_subitems', {}, 'content_tree');
23+
24+
if (!isRoot || !isRootLoaded || (rootLocation.subitems && rootLocation.subitems.length)) {
25+
return null;
26+
}
27+
28+
return <div className="c-list__no-items-message">{noSubitemsMessage}</div>;
29+
};
930

1031
return (
1132
<ul className="c-list">
@@ -24,7 +45,11 @@ const List = ({ items, loadMoreSubitems, currentLocationId, path, subitemsLoadLi
2445
href={locationHref}
2546
isRootItem={isRoot}
2647
path={itemPath}>
27-
{subitems.length ? <List path={itemPath} items={subitems} isRoot={false} {...listAttrs} /> : null}
48+
{subitems.length ? (
49+
<List path={itemPath} items={subitems} isRoot={false} {...listAttrs} />
50+
) : (
51+
renderNoSubitemMessage()
52+
)}
2853
</ListItem>
2954
);
3055
})}

0 commit comments

Comments
 (0)