Skip to content

Commit

Permalink
Merge pull request #230 from tomaszrondio/feature/content-list-limit-…
Browse files Browse the repository at this point in the history
…trim

content list limit notification
  • Loading branch information
ahilles107 authored Jan 16, 2020
2 parents 2d587f4 + d9fe80d commit 8a95e02
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 48 deletions.
7 changes: 5 additions & 2 deletions client/components/ContentLists/Manual/ArticleItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const ArticleItem = ({
previewItem,
index,
showExtras = false,
remove
remove,
willBeTrimmed
}) => {
let thumbnail = null;

Expand All @@ -24,6 +25,7 @@ const ArticleItem = ({
className={classNames("sd-list-item", {
"sd-list-item--activated": previewItem && previewItem.id === item.id
})}
style={willBeTrimmed ? { opacity: 0.5 } : {}}
onClick={() => openPreview(item)}
>
{showExtras && item.isDuplicate && (
Expand Down Expand Up @@ -95,7 +97,8 @@ ArticleItem.propTypes = {
previewItem: PropTypes.object,
index: PropTypes.number,
showExtras: PropTypes.bool,
remove: PropTypes.func
remove: PropTypes.func,
willBeTrimmed: PropTypes.bool
};

export default ArticleItem;
79 changes: 45 additions & 34 deletions client/components/ContentLists/Manual/Manual.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,6 @@ class Manual extends React.Component {
let list = { ...this.state.list };
let articles = { ...this.state.articles };

if (
this.props.list.limit &&
this.props.list.limit < result.contentList.length
) {
this.props.api.notify.error(
"This list is limited to " + this.props.list.limit + " articles"
);
return null;
}

list.items = result.contentList;
articles.items = result.articles;
this.recordChange("add", destination.index, [...list.items]);
Expand Down Expand Up @@ -486,33 +476,54 @@ class Manual extends React.Component {
: {}
}
>
{filteredContentListItems.map((item, index) => (
<Draggable
key={"list" + item.id}
draggableId={this.getDraggableId(item)}
index={index}
>
{(provided, snapshot) => (
{filteredContentListItems.map((item, index) => {
let retArray = [];

if (index === this.props.list.limit) {
retArray.push(
<li
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
style={provided.draggableProps.style}
key={"limitnotification"}
className="listLimitNotification"
>
<ArticleItem
item={item.content ? item.content : item}
openPreview={item =>
this.props.openPreview(item)
}
previewItem={this.props.previewItem}
index={index}
showExtras={true}
remove={id => this.removeItem(id)}
/>
This list is limited to {this.props.list.limit}{" "}
items. Articles below will be removed.
</li>
)}
</Draggable>
))}
);
}

retArray.push(
<Draggable
key={"list" + item.id + "" + index}
draggableId={this.getDraggableId(item)}
index={index}
>
{(provided, snapshot) => (
<li
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
style={provided.draggableProps.style}
>
<ArticleItem
item={item.content ? item.content : item}
openPreview={item =>
this.props.openPreview(item)
}
previewItem={this.props.previewItem}
index={index}
showExtras={true}
remove={id => this.removeItem(id)}
willBeTrimmed={
this.props.list.limit &&
this.props.list.limit <= index
}
/>
</li>
)}
</Draggable>
);
return retArray;
})}
{provided.placeholder}

{this.state.list.loading && (
Expand Down
31 changes: 19 additions & 12 deletions client/styles/_publisher.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@
// Styling for the web publisher module
// ----------------------------------------------------------------------------------------

@import '~mixins.scss';
@import '~variables.scss';
@import 'uploadFix.scss';
@import 'treeList.scss';
@import 'listElement.scss';
@import 'helperElements.scss';
@import 'dragNdrop.scss';
@import 'articlePreview.scss';
@import 'wizardThemeBox.scss';
@import 'wizardThemeDetails.scss';
@import 'iconOnHover.scss';
@import "~mixins.scss";
@import "~variables.scss";
@import "uploadFix.scss";
@import "treeList.scss";
@import "listElement.scss";
@import "helperElements.scss";
@import "dragNdrop.scss";
@import "articlePreview.scss";
@import "wizardThemeBox.scss";
@import "wizardThemeDetails.scss";
@import "iconOnHover.scss";

.sd-list-item-group li + li .sd-list-item {
border-top: 1px solid rgba(123, 123, 123, 0.2);
border-top: 1px solid rgba(123, 123, 123, 0.2);
}

.listLimitNotification {
padding: 5px;
text-align: center;
border-top: 2px dashed red;
color: red;
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"moment": "^2.24.0",
"ng-file-upload": "^12.2.13",
"ng-infinite-scroll": "^1.3.0",
"owl.carousel": "^2.3.4",
"react-awesome-slider": "^1.2.0",
"react-beautiful-dnd": "^11.0.5",
"react-select": "^3.0.4",
Expand All @@ -61,6 +62,8 @@
"jest": "^24.8.0",
"jest-dom": "^3.4.0",
"jest-transform-css": "^2.0.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"superdesk-code-style": "^1.0.0",
"superdesk-core": "superdesk/superdesk-client-core#2d4ce24",
"wait-for-expect": "^1.2.0"
Expand Down

0 comments on commit 8a95e02

Please sign in to comment.