Skip to content

Commit

Permalink
Merge pull request #285 from dew326/no-subitems-message
Browse files Browse the repository at this point in the history
EZP-31408: 'This Location has no Sub-items' msg is displayed above location
  • Loading branch information
lserwatka authored Mar 31, 2020
2 parents 8ca89ab + b2cafa0 commit 568e7a2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
7 changes: 7 additions & 0 deletions Resources/public/scss/modules/content-tree/_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
margin: 0;
padding: 0 0 0 calculateRem(12px);
list-style: none;

&__no-items-message {
padding: calculateRem(10px);
font-size: calculateRem(12px);
font-style: italic;
color: $ez-color-base-dark;
}
}

.m-tree__scrollable-wrapper {
Expand Down
7 changes: 0 additions & 7 deletions Resources/public/scss/modules/content-tree/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,4 @@
color: $ez-color-base-light;
cursor: pointer;
}

&__no-items-message {
padding: calculateRem(10px);
font-size: calculateRem(12px);
font-style: italic;
color: $ez-color-base-dark;
}
}
14 changes: 0 additions & 14 deletions src/modules/content-tree/components/content-tree/content.tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,6 @@ export default class ContentTree extends Component {
window.document.body.classList.remove(CLASS_IS_TREE_RESIZING);
}

renderNoSubitemMessage() {
const { items } = this.props;
const rootLocation = items[0];
const isRootLoaded = rootLocation;
const noSubitemsMessage = Translator.trans(/*@Desc("This location has no sub-items")*/ 'no_subitems', {}, 'content_tree');

if (!isRootLoaded || (rootLocation.subitems && rootLocation.subitems.length)) {
return;
}

return <div className="m-tree__no-items-message">{noSubitemsMessage}</div>;
}

renderCollapseAllBtn() {
const collapseAllLabel = Translator.trans(/*@Desc("Collapse all")*/ 'collapse_all', {}, 'content_tree');

Expand Down Expand Up @@ -137,7 +124,6 @@ export default class ContentTree extends Component {

return (
<div {...containerAttrs}>
{this.renderNoSubitemMessage()}
{this.renderList()}
{this.renderLoadingSpinner()}
{this.renderCollapseAllBtn()}
Expand Down
29 changes: 27 additions & 2 deletions src/modules/content-tree/components/list/list.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,31 @@ import React from 'react';
import PropTypes from 'prop-types';
import ListItem from '../list-item/list.item.component';

const List = ({ items, loadMoreSubitems, currentLocationId, path, subitemsLoadLimit, subitemsLimit, treeMaxDepth, afterItemToggle, isRoot }) => {
const List = ({
items,
loadMoreSubitems,
currentLocationId,
path,
subitemsLoadLimit,
subitemsLimit,
treeMaxDepth,
afterItemToggle,
isRoot,
}) => {
const commonAttrs = { loadMoreSubitems, subitemsLoadLimit, subitemsLimit, treeMaxDepth, afterItemToggle };
const listAttrs = { ...commonAttrs, currentLocationId };
const listItemAttrs = commonAttrs;
const renderNoSubitemMessage = () => {
const rootLocation = items[0];
const isRootLoaded = rootLocation;
const noSubitemsMessage = Translator.trans(/*@Desc("This location has no sub-items")*/ 'no_subitems', {}, 'content_tree');

if (!isRoot || !isRootLoaded || (rootLocation.subitems && rootLocation.subitems.length)) {
return null;
}

return <div className="c-list__no-items-message">{noSubitemsMessage}</div>;
};

return (
<ul className="c-list">
Expand All @@ -24,7 +45,11 @@ const List = ({ items, loadMoreSubitems, currentLocationId, path, subitemsLoadLi
href={locationHref}
isRootItem={isRoot}
path={itemPath}>
{subitems.length ? <List path={itemPath} items={subitems} isRoot={false} {...listAttrs} /> : null}
{subitems.length ? (
<List path={itemPath} items={subitems} isRoot={false} {...listAttrs} />
) : (
renderNoSubitemMessage()
)}
</ListItem>
);
})}
Expand Down

0 comments on commit 568e7a2

Please sign in to comment.