1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00

add support for zero editions in piece list

This commit is contained in:
Tim Daubenschütz 2015-07-16 12:11:05 +02:00
parent 39ec4c5b91
commit e9ea24aed3
2 changed files with 24 additions and 10 deletions

View File

@ -6,6 +6,10 @@ import classNames from 'classnames';
import EditionListActions from '../../actions/edition_list_actions'; import EditionListActions from '../../actions/edition_list_actions';
import EditionListStore from '../../stores/edition_list_store'; import EditionListStore from '../../stores/edition_list_store';
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
import Tooltip from 'react-bootstrap/lib/Tooltip';
import Button from 'react-bootstrap/lib/Button';
import CreateEditionsButton from '../ascribe_buttons/create_editions_button'; import CreateEditionsButton from '../ascribe_buttons/create_editions_button';
import { getLangText } from '../../utils/lang_utils'; import { getLangText } from '../../utils/lang_utils';
@ -97,6 +101,17 @@ let AccordionListItemEditionWidget = React.createClass({
return null; return null;
} }
} else {
if(piece.first_edition === null) {
// user has deleted all his editions and only the piece is showing
return (
<Button
disabled
title={getLangText('All editions for this have been deleted already.')}
className={classNames('btn', 'btn-default', 'btn-xs', 'ascribe-accordion-list-item-edition-widget', this.props.className)}>
{'0 ' + getLangText('Editions')}
</Button>
);
} else { } else {
let editionMapping = piece && piece.first_edition ? piece.first_edition.num_editions_available + '/' + piece.num_editions : ''; let editionMapping = piece && piece.first_edition ? piece.first_edition.num_editions_available + '/' + piece.num_editions : '';
@ -109,6 +124,7 @@ let AccordionListItemEditionWidget = React.createClass({
); );
} }
} }
}
}); });
export default AccordionListItemEditionWidget; export default AccordionListItemEditionWidget;

View File

@ -79,8 +79,6 @@ class EditionListStore {
// http://davidwalsh.name/empty-array // http://davidwalsh.name/empty-array
this.editionList[pieceId].length = 0; this.editionList[pieceId].length = 0;
// refetch editions with adjusted page size // refetch editions with adjusted page size
EditionsListActions.fetchEditionList(pieceId, 1, prevEditionListLength, this.editionList[pieceId].orderBy, this.editionList[pieceId].orderAsc) EditionsListActions.fetchEditionList(pieceId, 1, prevEditionListLength, this.editionList[pieceId].orderBy, this.editionList[pieceId].orderAsc)
.then(() => { .then(() => {