Merge branch 'master' of github.com:ONLYOFFICE/CommunityServer-AspNetCore
This commit is contained in:
commit
e9861ee94d
@ -41,7 +41,7 @@ namespace ASC.Api.Core
|
||||
HttpContext = httpContext;
|
||||
|
||||
//TODO
|
||||
uint ItemsPerPage = 25;
|
||||
uint ItemsPerPage = 1000;
|
||||
Count = 0;
|
||||
//Try parse values
|
||||
string count = GetRequestValue("count");
|
||||
|
@ -28,103 +28,100 @@ const StyledComboBox = styled.div`
|
||||
`;
|
||||
|
||||
class ComboBox extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.ref = React.createRef();
|
||||
this.ref = React.createRef();
|
||||
|
||||
this.state = {
|
||||
isOpen: props.opened,
|
||||
boxLabel: props.options[props.selectedIndex].label,
|
||||
options: props.options
|
||||
};
|
||||
this.state = {
|
||||
isOpen: props.opened,
|
||||
boxLabel: props.options[props.selectedIndex].label,
|
||||
options: props.options
|
||||
};
|
||||
|
||||
this.handleClick = this.handleClick.bind(this);
|
||||
this.stopAction = this.stopAction.bind(this);
|
||||
this.toggle = this.toggle.bind(this);
|
||||
this.handleClick = this.handleClick.bind(this);
|
||||
this.stopAction = this.stopAction.bind(this);
|
||||
this.toggle = this.toggle.bind(this);
|
||||
this.comboBoxClick = this.comboBoxClick.bind(this);
|
||||
this.optionClick = this.optionClick.bind(this);
|
||||
}
|
||||
|
||||
handleClick = (e) => !this.ref.current.contains(e.target) && this.toggle(false);
|
||||
stopAction = (e) => e.preventDefault();
|
||||
toggle = (isOpen) => this.setState({ isOpen: isOpen });
|
||||
comboBoxClick = () => {
|
||||
this.setState({ option: this.props.option });
|
||||
this.toggle(!this.state.isOpen);
|
||||
};
|
||||
optionClick = (option) => {
|
||||
option.onClick && option.onClick();
|
||||
this.toggle(!this.state.isOpen);
|
||||
this.setState({ boxLabel: option.label });
|
||||
this.props.onSelect && this.props.onSelect(option);
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
if (this.ref.current) {
|
||||
document.addEventListener("click", this.handleClick);
|
||||
}
|
||||
}
|
||||
|
||||
handleClick = (e) => !this.ref.current.contains(e.target) && this.toggle(false);
|
||||
stopAction = (e) => e.preventDefault();
|
||||
toggle = (isOpen) => this.setState({ isOpen: isOpen });
|
||||
componentWillUnmount() {
|
||||
document.removeEventListener("click", this.handleClick)
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (this.ref.current) {
|
||||
document.addEventListener("click", this.handleClick);
|
||||
}
|
||||
componentDidUpdate(prevProps) {
|
||||
if (this.props.opened !== prevProps.opened) {
|
||||
this.toggle(this.props.opened);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
document.removeEventListener("click", this.handleClick)
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (this.props.opened !== prevProps.opened) {
|
||||
this.toggle(this.props.opened);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
//console.log("ComboBox render");
|
||||
return (
|
||||
<StyledComboBox ref={this.ref} {...this.props} data={this.state.boxLabel}
|
||||
onClick={
|
||||
!this.props.isDisabled
|
||||
? () => {
|
||||
this.setState({ option: this.props.option });
|
||||
this.toggle(!this.state.isOpen);
|
||||
}
|
||||
: this.stopAction
|
||||
}
|
||||
>
|
||||
<InputBlock placeholder={this.state.boxLabel}
|
||||
iconName='ExpanderDownIcon'
|
||||
iconSize={8}
|
||||
isIconFill={true}
|
||||
iconColor='#A3A9AE'
|
||||
scale={true}
|
||||
isDisabled={this.props.isDisabled}
|
||||
isReadOnly={true}
|
||||
onIconClick={() => false}
|
||||
>
|
||||
{this.props.children}
|
||||
<DropDown
|
||||
directionX={this.props.directionX}
|
||||
directionY={this.props.directionY}
|
||||
manualWidth='100%'
|
||||
manualY='102%'
|
||||
isOpen={this.state.isOpen}
|
||||
>
|
||||
{this.state.options.map((option, index) =>
|
||||
<DropDownItem {...option}
|
||||
disabled={option.label === this.state.boxLabel}
|
||||
onClick={() => {
|
||||
option.onClick && option.onClick();
|
||||
this.toggle(!this.state.isOpen);
|
||||
this.setState({ boxLabel: option.label });
|
||||
this.props.onSelect && this.props.onSelect(option);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</DropDown>
|
||||
</InputBlock>
|
||||
</StyledComboBox>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
//console.log("ComboBox render");
|
||||
return (
|
||||
<StyledComboBox ref={this.ref} {...this.props} data={this.state.boxLabel} onClick={this.comboBoxClick} onSelect={this.stopAction} >
|
||||
<InputBlock placeholder={this.state.boxLabel}
|
||||
iconName='ExpanderDownIcon'
|
||||
iconSize={8}
|
||||
isIconFill={true}
|
||||
iconColor='#A3A9AE'
|
||||
scale={true}
|
||||
isDisabled={this.props.isDisabled}
|
||||
isReadOnly={true}
|
||||
>
|
||||
{this.props.children}
|
||||
<DropDown
|
||||
directionX={this.props.directionX}
|
||||
directionY={this.props.directionY}
|
||||
manualWidth='100%'
|
||||
manualY='102%'
|
||||
isOpen={this.state.isOpen}
|
||||
>
|
||||
{this.state.options.map((option) =>
|
||||
<DropDownItem {...option}
|
||||
disabled={option.label === this.state.boxLabel}
|
||||
onClick={() => this.optionClick(option)}
|
||||
/>
|
||||
)}
|
||||
</DropDown>
|
||||
</InputBlock>
|
||||
</StyledComboBox>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
ComboBox.propTypes = {
|
||||
isDisabled: PropTypes.bool,
|
||||
withBorder: PropTypes.bool,
|
||||
selectedIndex: PropTypes.number,
|
||||
options: PropTypes.array,
|
||||
onSelect: PropTypes.func
|
||||
isDisabled: PropTypes.bool,
|
||||
withBorder: PropTypes.bool,
|
||||
selectedIndex: PropTypes.number,
|
||||
options: PropTypes.array,
|
||||
onSelect: PropTypes.func
|
||||
}
|
||||
|
||||
ComboBox.defaultProps = {
|
||||
isDisabled: false,
|
||||
withBorder: true,
|
||||
selectedIndex: 0
|
||||
isDisabled: false,
|
||||
withBorder: true,
|
||||
selectedIndex: 0
|
||||
}
|
||||
|
||||
export default ComboBox;
|
@ -34,18 +34,26 @@ const Paging = props => {
|
||||
//console.log("Paging render");
|
||||
const { previousLabel, nextLabel, previousAction, nextAction, pageItems, perPageItems, openDirection, disablePrevious, disableNext } = props;
|
||||
|
||||
const onSelectPageAction = (option) => {
|
||||
props.onSelectPage(option);
|
||||
}
|
||||
|
||||
const onSelectPerPageAction = (option) => {
|
||||
props.onSelectPerPage(option)
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledPaging>
|
||||
<Button size='medium' label={previousLabel} onClick={previousAction} isDisabled={disablePrevious} />
|
||||
{pageItems &&
|
||||
<StyledPage>
|
||||
<ComboBox directionY={openDirection} options={pageItems} onSelect={(a)=> props.onSelectPage(a)} />
|
||||
<ComboBox directionY={openDirection} options={pageItems} onSelect={onSelectPageAction} />
|
||||
</StyledPage>
|
||||
}
|
||||
<Button size='medium' label={nextLabel} onClick={nextAction} isDisabled={disableNext} />
|
||||
{perPageItems &&
|
||||
<StyledOnPage>
|
||||
<ComboBox directionY={openDirection} options={perPageItems} onSelect={(a) => props.onSelectPerPage(a)} />
|
||||
<ComboBox directionY={openDirection} options={perPageItems} onSelect={onSelectPerPageAction} />
|
||||
</StyledOnPage>
|
||||
}
|
||||
</StyledPaging>
|
||||
|
@ -9,18 +9,15 @@ import { ComboBox } from 'asc-web-components'
|
||||
let options = [
|
||||
{
|
||||
key: '0',
|
||||
label: '25 per page',
|
||||
onClick: (e) => console.log(e.target)
|
||||
label: '25 per page'
|
||||
},
|
||||
{
|
||||
key: '1',
|
||||
label: '50 per page',
|
||||
onClick: (e) => console.log(e.target)
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: '100 per page',
|
||||
onClick: (e) => console.log(e.target)
|
||||
label: '100 per page'
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -8,65 +8,65 @@ import Section from '../../../.storybook/decorators/section';
|
||||
import { isUndefined } from 'util';
|
||||
|
||||
storiesOf('Components|Paging', module)
|
||||
.addDecorator(withKnobs)
|
||||
.addDecorator(withReadme(Readme))
|
||||
.add('base', () => {
|
||||
.addDecorator(withKnobs)
|
||||
.addDecorator(withReadme(Readme))
|
||||
.add('base', () => {
|
||||
|
||||
const pageItems = [
|
||||
{
|
||||
key: '1',
|
||||
label: '1 of 5'
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: '2 of 5'
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
label: '3 of 5'
|
||||
},
|
||||
{
|
||||
key: '4',
|
||||
label: '4 of 5'
|
||||
},
|
||||
{
|
||||
key: '5',
|
||||
label: '5 of 5'
|
||||
}
|
||||
];
|
||||
const pageItems = [
|
||||
{
|
||||
key: '1',
|
||||
label: '1 of 5'
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: '2 of 5'
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
label: '3 of 5'
|
||||
},
|
||||
{
|
||||
key: '4',
|
||||
label: '4 of 5'
|
||||
},
|
||||
{
|
||||
key: '5',
|
||||
label: '5 of 5'
|
||||
}
|
||||
];
|
||||
|
||||
const perPageItems = [
|
||||
{
|
||||
key: '1-1',
|
||||
label: '25 per page'
|
||||
},
|
||||
{
|
||||
key: '1-2',
|
||||
label: '50 per page'
|
||||
},
|
||||
{
|
||||
key: '1-3',
|
||||
label: '100 per page'
|
||||
}
|
||||
];
|
||||
const perPageItems = [
|
||||
{
|
||||
key: '1-1',
|
||||
label: '25 per page'
|
||||
},
|
||||
{
|
||||
key: '1-2',
|
||||
label: '50 per page'
|
||||
},
|
||||
{
|
||||
key: '1-3',
|
||||
label: '100 per page'
|
||||
}
|
||||
];
|
||||
|
||||
const displayItems = boolean('Display pageItems', true);
|
||||
const displayPerPage = boolean('Display perPageItems', true);
|
||||
|
||||
return (
|
||||
<Section>
|
||||
<Paging previousLabel={text('previousLabel', 'Previous')}
|
||||
nextLabel={text('nextLabel', 'Next')}
|
||||
pageItems={displayItems ? pageItems : undefined}
|
||||
perPageItems={displayPerPage ? perPageItems : undefined}
|
||||
disablePrevious={boolean('disablePrevious', false)}
|
||||
disableNext={boolean('disableNext', false)}
|
||||
previousAction={ () => console.log('Prev')}
|
||||
nextAction={ () => console.log('Next')}
|
||||
openDirection='bottom'
|
||||
onSelectPage={(a) => console.log(a)}
|
||||
onSelectPerPage={(a) => console.log(a)}
|
||||
/>
|
||||
</Section>
|
||||
)
|
||||
});
|
||||
const displayItems = boolean('Display pageItems', true);
|
||||
const displayPerPage = boolean('Display perPageItems', true);
|
||||
|
||||
return (
|
||||
<Section>
|
||||
<Paging previousLabel={text('previousLabel', 'Previous')}
|
||||
nextLabel={text('nextLabel', 'Next')}
|
||||
pageItems={displayItems ? pageItems : undefined}
|
||||
perPageItems={displayPerPage ? perPageItems : undefined}
|
||||
disablePrevious={boolean('disablePrevious', false)}
|
||||
disableNext={boolean('disableNext', false)}
|
||||
previousAction={() => console.log('Prev')}
|
||||
nextAction={() => console.log('Next')}
|
||||
openDirection='bottom'
|
||||
onSelectPage={(a) => console.log(a)}
|
||||
onSelectPerPage={(a) => console.log(a)}
|
||||
/>
|
||||
</Section>
|
||||
)
|
||||
});
|
Loading…
Reference in New Issue
Block a user