Merge branch 'master' of github.com:ONLYOFFICE/CommunityServer-AspNetCore

This commit is contained in:
Alexey Safronov 2019-08-14 17:52:12 +03:00
commit 4e70bd627f
5 changed files with 20 additions and 26 deletions

View File

@ -90,8 +90,8 @@ const SectionPagingContent = ({
);
const pageItems = useMemo(() => {
if (filter.total < filter.pageCount) return [];
const totalPages = Math.ceil(filter.total / filter.pageCount);
console.log(totalPages);
return [...Array(totalPages).keys()].map(
item => {
return { key: item, label: `${item+1} of ${totalPages}` };
@ -99,18 +99,18 @@ const SectionPagingContent = ({
);
}, [filter.total, filter.pageCount]);
const defaultPage = {
const emptyPageSelection = {
key: 0,
label: '1 of 1'
}
const defaultCount = {
key: 25,
const emptyCountSelection = {
key: 0,
label: "25 per page"
};
const defaultPageItem = pageItems.find(x => x.key === filter.page) || defaultPage;
const defaultCountItem = countItems.find(x => x.key === filter.pageCount) || defaultCount;
const selectedPageItem = pageItems.find(x => x.key === filter.page) || emptyPageSelection;
const selectedCountItem = countItems.find(x => x.key === filter.pageCount) || emptyCountSelection;
console.log("SectionPagingContent render", filter);
@ -128,8 +128,8 @@ const SectionPagingContent = ({
previousAction={onPrevClick}
nextAction={onNextClick}
openDirection="top"
defaultPageItem={defaultPageItem} //FILTER CURRENT PAGE
defaultCountItem={defaultCountItem} //FILTER PAGE COUNT
selectedPageItem={selectedPageItem} //FILTER CURRENT PAGE
selectedCountItem={selectedCountItem} //FILTER PAGE COUNT
/>
);
};

View File

@ -258,7 +258,7 @@ class FilterInput extends React.Component {
options={this.props.getSortData()}
isDisabled={this.props.isDisabled}
onSelect={this.onClickSortItem}
selectedOption={this.state.sortId}
selectedOption={this.props.getSortData().length > 0 ? this.props.getSortData()[0] : {}}
onButtonClick={this.onSortDirectionClick}
sortDirection={this.state.sortDirection}
/>

View File

@ -42,7 +42,7 @@ const nextAction = () => {
const Paging = props => {
//console.log("Paging render");
const { previousLabel, nextLabel, previousAction, nextAction, pageItems, countItems,
openDirection, disablePrevious, disableNext, defaultPageItem, defaultCountItem} = props;
openDirection, disablePrevious, disableNext, selectedPageItem, selectedCountItem} = props;
const onSelectPageAction = (option) => {
props.onSelectPage(option);
@ -68,7 +68,7 @@ const Paging = props => {
directionY={openDirection}
options={pageItems}
onSelect={onSelectPageAction}
selectedOption={defaultPageItem}
selectedOption={selectedPageItem}
{...setDropDownMaxHeight} />
</StyledPage>
}
@ -84,7 +84,7 @@ const Paging = props => {
directionY={openDirection}
options={countItems}
onSelect={onSelectCountAction}
selectedOption={defaultCountItem}/>
selectedOption={selectedCountItem}/>
</StyledOnPage>
}
</StyledPaging>
@ -101,8 +101,8 @@ Paging.propTypes = {
disablePrevious: PropTypes.bool,
disableNext: PropTypes.bool,
defaultPageItem: PropTypes.object,
defaultCountItem: PropTypes.object,
selectedPageItem: PropTypes.object,
selectedCountItem: PropTypes.object,
onSelectPage: PropTypes.func,
onSelectCount: PropTypes.func

View File

@ -19,10 +19,6 @@ import { Paging } from 'asc-web-components';
openDirection='bottom'
disablePrevious={false}
disableNext={false}
selectedPage={1}
selectedCount={25}
emptyPagePlaceholder='1 of 1'
emptyCountPlaceholder='25 per page'
/>
```
@ -39,7 +35,5 @@ import { Paging } from 'asc-web-components';
| `openDirection` | `string` | - | `top`, `bottom` | `bottom`| Indicates opening direction of combo box |
| `disablePrevious` | `bool` | - | - | `false` | Set previous button disabled |
| `disableNext` | `bool` | - | - | `false` | Set next button disabled |
| `selectedPage` | `string`,`number` | - | - | - | Initial value for pageItems |
| `selectedCount` | `string`,`number` | - | - | - | Initial value for countItems |
| `emptyPagePlaceholder` | `string` | - | - | - | Value that will be displayed in page selection when collection is empty|
| `emptyCountPlaceholder`| `string` | - | - | - | Value that will be displayed in count selection when collection is empty|
| `selectedPageItem` | `object` | - | - | - | Initial value for pageItems |
| `selectedCountItem` | `object` | - | - | - | Initial value for countItems |

View File

@ -42,16 +42,16 @@ storiesOf('Components|Paging', module)
const selectedCount = select('selectedCount', [25, 50, 100], 100);
const pageCount = number('Count of pages', 10);
const pageItems = createPageItems(pageCount);
const defaultPageItem = pageItems[0];
const defaultCountItem = countItems[0];
const selectedPageItem = pageItems[0];
const selectedCountItem = countItems[0];
return (
<Section>
<Paging previousLabel={text('previousLabel', 'Previous')}
nextLabel={text('nextLabel', 'Next')}
pageItems={displayItems ? pageItems : undefined}
defaultPageItem={defaultPageItem}
defaultCountItem={defaultCountItem}
selectedPageItem={selectedPageItem}
selectedCountItem={selectedCountItem}
countItems={displayCount ? countItems : undefined}
disablePrevious={boolean('disablePrevious', false)}
disableNext={boolean('disableNext', false)}