1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

Implement filter display for piece list

This commit is contained in:
Tim Daubenschütz 2015-09-16 21:21:30 +02:00
parent 36f7d8f3d3
commit 48508d5756
5 changed files with 75 additions and 4 deletions

View File

@ -21,7 +21,7 @@ let AccordionList = React.createClass({
); );
} else if(this.props.count === 0) { } else if(this.props.count === 0) {
return ( return (
<div> <div className="ascribe-accordion-list-placeholder">
<p className="text-center">{getLangText('We could not find any works related to you...')}</p> <p className="text-center">{getLangText('We could not find any works related to you...')}</p>
<p className="text-center">{getLangText('To register one, click')} <a href="register_piece">{getLangText('here')}</a>!</p> <p className="text-center">{getLangText('To register one, click')} <a href="register_piece">{getLangText('here')}</a>!</p>
</div> </div>

View File

@ -15,6 +15,8 @@ import AccordionListItemTableEditions from './ascribe_accordion_list/accordion_l
import Pagination from './ascribe_pagination/pagination'; import Pagination from './ascribe_pagination/pagination';
import PieceListFilterDisplay from './piece_list_filter_display';
import GlobalAction from './global_action'; import GlobalAction from './global_action';
import PieceListBulkModal from './ascribe_piece_list_bulk_modal/piece_list_bulk_modal'; import PieceListBulkModal from './ascribe_piece_list_bulk_modal/piece_list_bulk_modal';
import PieceListToolbar from './ascribe_piece_list_toolbar/piece_list_toolbar'; import PieceListToolbar from './ascribe_piece_list_toolbar/piece_list_toolbar';
@ -22,6 +24,8 @@ import PieceListToolbar from './ascribe_piece_list_toolbar/piece_list_toolbar';
import AppConstants from '../constants/application_constants'; import AppConstants from '../constants/application_constants';
import { mergeOptions } from '../utils/general_utils'; import { mergeOptions } from '../utils/general_utils';
import { getLangText } from '../utils/lang_utils';
let PieceList = React.createClass({ let PieceList = React.createClass({
propTypes: { propTypes: {
@ -149,9 +153,6 @@ let PieceList = React.createClass({
let loadingElement = (<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />); let loadingElement = (<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />);
let AccordionListItemType = this.props.accordionListItemType; let AccordionListItemType = this.props.accordionListItemType;
//<GlobalAction requestActions={this.state.requestActions} />
return ( return (
<div> <div>
<PieceListToolbar <PieceListToolbar
@ -166,6 +167,7 @@ let PieceList = React.createClass({
{this.props.customSubmitButton} {this.props.customSubmitButton}
</PieceListToolbar> </PieceListToolbar>
<PieceListBulkModal className="ascribe-piece-list-bulk-modal" /> <PieceListBulkModal className="ascribe-piece-list-bulk-modal" />
<PieceListFilterDisplay filterBy={this.state.filterBy} />
<AccordionList <AccordionList
className="ascribe-accordion-list" className="ascribe-accordion-list"
changeOrder={this.accordionChangeOrder} changeOrder={this.accordionChangeOrder}

View File

@ -0,0 +1,45 @@
'use strict';
import React from 'react';
import { getLangText } from '../utils/lang_utils';
let PieceListFilterDisplay = React.createClass({
propTypes: {
filterBy: React.PropTypes.string
},
getFilterText() {
let { filterBy } = this.props;
let filterText = '';
filterText += getLangText('Showing works that I can: ')
// take every filter, split it on acl_ and join the resulting array as a comma separated list
filterText += Object.keys(filterBy).map((filter) => filter.split('acl_')[1]).join(', ');
// there are acls, like acl_create_editions that still have underscores in them,
// therefore we need to replace all underscores with spaces
return filterText.replace(/_/g, ' ');
},
render() {
let { filterBy } = this.props;
// do not show the FilterDisplay if there are no filters applied
if(filterBy && Object.keys(filterBy).length === 0) {
return null;
} else {
return (
<div className="row">
<div className="ascribe-piece-list-filter-display col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2">
{this.getFilterText()}
<hr />
</div>
</div>
);
}
}
});
export default PieceListFilterDisplay;

View File

@ -5,6 +5,10 @@ $ascribe-accordion-list-item-height: 8em;
padding-right: 15px; padding-right: 15px;
} }
.ascribe-accordion-list-placeholder {
margin-top: 1em;
}
.ascribe-accordion-list-item { .ascribe-accordion-list-item {
background-color: white; background-color: white;
border: 1px solid black; border: 1px solid black;

View File

@ -487,3 +487,23 @@ hr {
.ascribe-progress-bar-xs { .ascribe-progress-bar-xs {
height: 12px; height: 12px;
} }
.ascribe-piece-list-filter-display {
padding-left: 0;
padding-right: 0;
> span {
font-size: 1.1em;
font-weight: 600;
color: #616161;
padding-left: .3em;
}
> hr {
margin-top: .15em;
margin-bottom: .1em;
border-color: #ccc;
}
}