From de92e39d96d380f6d5ba42707c46482e56c83006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fatay=20=C3=87ivici?= Date: Tue, 13 Feb 2018 15:07:58 +0300 Subject: [PATCH] Revert "Fixed #311" This reverts commit 8529db9bf7b73b6511addc495d5962e71ecb21a4. --- src/components/dropdown/Dropdown.js | 2 +- src/components/orderlist/OrderList.d.ts | 2 - src/components/orderlist/OrderList.js | 6 +- .../orderlist/OrderListSubList.d.ts | 2 - src/components/orderlist/OrderListSubList.js | 71 +++---------------- src/components/utils/ObjectUtils.js | 1 - src/showcase/orderlist/OrderListDemo.js | 28 ++------ 7 files changed, 17 insertions(+), 95 deletions(-) diff --git a/src/components/dropdown/Dropdown.js b/src/components/dropdown/Dropdown.js index 4a936f5467..037c559d93 100644 --- a/src/components/dropdown/Dropdown.js +++ b/src/components/dropdown/Dropdown.js @@ -341,7 +341,7 @@ export class Dropdown extends Component { this.overlayClick = false; } - updateEditableLabel(option) { + updateEditableLabel(option): void { if(this.editableInput) { this.editableInput.value = (option ? this.getOptionLabel(option) : this.props.value||''); } diff --git a/src/components/orderlist/OrderList.d.ts b/src/components/orderlist/OrderList.d.ts index b0e5ea4451..b0fe4c9d7d 100644 --- a/src/components/orderlist/OrderList.d.ts +++ b/src/components/orderlist/OrderList.d.ts @@ -9,8 +9,6 @@ interface OrderListProps { listStyle?: object; responsive?: boolean; dragdrop?: boolean; - filterBy?: string[]; - filterPlaceholder?: string; onChange?(e: {originalEvent: Event, value: any}): void; itemTemplate?(item: any): void; } diff --git a/src/components/orderlist/OrderList.js b/src/components/orderlist/OrderList.js index 8e084a5b8f..4d13eee58f 100644 --- a/src/components/orderlist/OrderList.js +++ b/src/components/orderlist/OrderList.js @@ -17,8 +17,6 @@ export class OrderList extends Component { listStyle: null, responsive: false, dragdrop: false, - filterBy: null, - filterPlaceholder: null, onChange: null, itemTemplate: null } @@ -32,8 +30,6 @@ export class OrderList extends Component { listStyle: PropTypes.object, responsive: PropTypes.bool, dragdrop: PropTypes.func, - filterBy: PropTypes.array, - filterPlaceholder: PropTypes.string, onChange: PropTypes.func, itemTemplate: PropTypes.func } @@ -126,7 +122,7 @@ export class OrderList extends Component { this.subList = el} value={this.props.value} selection={this.state.selection} onItemClick={this.onItemClick} itemTemplate={this.props.itemTemplate} header={this.props.header} listStyle={this.props.listStyle} dragdrop={this.props.dragdrop} onDragStart={this.onDragStart} onDragEnter={this.onDragEnter} onDragEnd={this.onDragEnd} onDragLeave={this.onDragEnter} onDrop={this.onDrop} - onChange={this.props.onChange} filterPlaceholder={this.props.filterPlaceholder} filterBy={this.props.filterBy}/> + onChange={this.props.onChange} /> ); } diff --git a/src/components/orderlist/OrderListSubList.d.ts b/src/components/orderlist/OrderListSubList.d.ts index 004f34f79e..d73a8cf29e 100644 --- a/src/components/orderlist/OrderListSubList.d.ts +++ b/src/components/orderlist/OrderListSubList.d.ts @@ -6,8 +6,6 @@ interface OrderListSubListProps { header?: any; listStyle?: object; dragdrop?: boolean; - filterBy?: string[]; - filterPlaceholder?: string; onItemClick?(e: {originalEvent: Event, value: any, index: number}): void; itemTemplate?(item: any): void; onChange?(e: {originalEvent: Event, value: any}): void; diff --git a/src/components/orderlist/OrderListSubList.js b/src/components/orderlist/OrderListSubList.js index ebe501e55f..d20b97f86f 100644 --- a/src/components/orderlist/OrderListSubList.js +++ b/src/components/orderlist/OrderListSubList.js @@ -13,8 +13,6 @@ export class OrderListSubList extends Component { listStyle: null, itemTemplate: null, dragdrop: false, - filterBy: null, - filterPlaceholder: null, onItemClick: null, onChange: null } @@ -26,23 +24,17 @@ export class OrderListSubList extends Component { listStyle: PropTypes.object, itemTemplate: PropTypes.func, dragdrop: PropTypes.func, - filterBy: PropTypes.array, - filterPlaceholder: PropTypes.string, onItemClick: PropTypes.func, onChange: PropTypes.func } constructor(props) { super(props); - this.state = { - filter: '' - } this.onDragEnd = this.onDragEnd.bind(this); this.onDragLeave = this.onDragLeave.bind(this); this.onDrop = this.onDrop.bind(this); this.onListMouseMove = this.onListMouseMove.bind(this); - this.onFilterInputChange = this.onFilterInputChange.bind(this); } isSelected(item) { @@ -102,59 +94,24 @@ export class OrderListSubList extends Component { } } - onFilterInputChange(event) { - this.setState({ - filter: event.target.value - }); - } - - hasFilter() { - return this.state.filter && this.state.filter.trim().length > 0; - } - renderDropPoint(item, index, key) { return (
  • this.onDragOver(e, index + 1)} onDragLeave={this.onDragLeave} onDrop={this.onDrop}>
  • ); } + + render() { + let header = null; + let items = null; + let listClassName = classNames('ui-widget-content ui-orderlist-list', {'ui-corner-bottom': this.props.header, 'ui-corner-all': !this.props.header}); - renderFilter() { - if (this.props.filterBy) { - return ( -
    - - -
    - ); - } - else { - return null; - } - } - - renderHeader() { if (this.props.header) { - return ( -
    {this.props.header}
    - ); + header =
    {this.props.header}
    } - else { - return null; - } - } - - renderItems() { - let items = null; - let value = this.props.value; - - if (value) { - if (this.hasFilter()) { - value = ObjectUtils.filter(value, this.props.filterBy, this.state.filter); - } - - items = value.map((item, i) => { + + if (this.props.value) { + items = this.props.value.map((item, i) => { let content = this.props.itemTemplate ? this.props.itemTemplate(item) : item; let itemClassName = classNames('ui-orderlist-item', this.props.className, {'ui-state-highlight': this.isSelected(item)}); let key = JSON.stringify(item); @@ -179,20 +136,10 @@ export class OrderListSubList extends Component { } }); } - - return items; - } - render() { - let header = this.renderHeader(); - let items = this.renderItems(); - let filter = this.renderFilter(); - let listClassName = classNames('ui-widget-content ui-orderlist-list', {'ui-corner-bottom': this.props.header, 'ui-corner-all': !this.props.header}); - return (
    {header} - {filter}
      this.listElement = el} className={listClassName} style={this.props.listStyle} onDragOver={this.onListMouseMove}> {items}
    diff --git a/src/components/utils/ObjectUtils.js b/src/components/utils/ObjectUtils.js index 58aad80fa5..f306637ab1 100644 --- a/src/components/utils/ObjectUtils.js +++ b/src/components/utils/ObjectUtils.js @@ -72,7 +72,6 @@ export default class ObjectUtils { return null; } } - static filter(value, fields, filterValue) { var filteredItems=[]; diff --git a/src/showcase/orderlist/OrderListDemo.js b/src/showcase/orderlist/OrderListDemo.js index 22bea190ea..91de5bdc17 100644 --- a/src/showcase/orderlist/OrderListDemo.js +++ b/src/showcase/orderlist/OrderListDemo.js @@ -44,7 +44,7 @@ export class OrderListDemo extends Component {
    this.setState({cars: e.value})}>
    @@ -79,28 +79,18 @@ import {OrderList} from 'primereact/components/orderlist/OrderList';

    {` - this.setState({cars: e.value})}> + this.setState({cars: e.value})}> `}

    DragDrop

    -

    Items can be reordered using drag and drop by enabling dragdrop property.

    +

    Items can be reordered using drag and drop by enabling dragdrop property along with dragdropScope to avoid conflicts with other drag drop events on view.

    {` this.setState({cars: e.value})}> -`} - - -

    Filtering

    -

    Items can be filtered using an input field by enabling the filterBy property that specifies the fields to use in filtering.

    - -{` - this.setState({cars: e.value})} - filterBy={['brand', 'year']} filterPlaceholder="Filter by brand or year"> - `} @@ -174,16 +164,10 @@ import {OrderList} from 'primereact/components/orderlist/OrderList'; Whether to enable dragdrop based reordering. - filterBy - array - null - When specified displays an input field to filter the items on keyup and decides which fields to search against. - - - filterPlaceholder + dragdropScope string null - Placeholder text on filter input. + Unique key of drag drop events to avoid conflict with other drag drop events on the page. itemTemplate @@ -292,7 +276,7 @@ export class OrderListDemo extends Component { render() { return ( this.setState({cars: e.value})}> ); }