@@ -48,9 +48,10 @@ import {
4848 moveContent ,
4949 orderContent ,
5050 sortContent ,
51+ updateColumnsContent ,
5152} from '@plone/volto/actions' ;
5253import { getBaseUrl } from '@plone/volto/helpers' ;
53- import Indexes from '@plone/volto/constants/Indexes' ;
54+ import Indexes , { defaultIndexes } from '@plone/volto/constants/Indexes' ;
5455import {
5556 ContentsIndexHeader ,
5657 ContentsItem ,
@@ -86,7 +87,6 @@ import sortDownSVG from '@plone/volto/icons/sort-down.svg';
8687import sortUpSVG from '@plone/volto/icons/sort-up.svg' ;
8788import downKeySVG from '@plone/volto/icons/down-key.svg' ;
8889import moreSVG from '@plone/volto/icons/more.svg' ;
89- const defaultIndexes = [ 'review_state' , 'ModificationDate' , 'EffectiveDate' ] ;
9090
9191const messages = defineMessages ( {
9292 back : {
@@ -261,6 +261,7 @@ class Contents extends Component {
261261 moveContent : PropTypes . func . isRequired ,
262262 orderContent : PropTypes . func . isRequired ,
263263 sortContent : PropTypes . func . isRequired ,
264+ updateColumnsContent : PropTypes . func . isRequired ,
264265 clipboardRequest : PropTypes . shape ( {
265266 loading : PropTypes . bool ,
266267 loaded : PropTypes . bool ,
@@ -304,6 +305,14 @@ class Contents extends Component {
304305 items : [ ] ,
305306 action : null ,
306307 source : null ,
308+ index : {
309+ order : keys ( Indexes ) ,
310+ values : mapValues ( Indexes , ( value , key ) => ( {
311+ ...value ,
312+ selected : indexOf ( defaultIndexes , key ) !== - 1 ,
313+ } ) ) ,
314+ selectedCount : defaultIndexes . length + 1 ,
315+ } ,
307316 } ;
308317
309318 /**
@@ -363,7 +372,7 @@ class Contents extends Component {
363372 filter : '' ,
364373 currentPage : 0 ,
365374 pageSize : 15 ,
366- index : {
375+ index : this . props . index || {
367376 order : keys ( Indexes ) ,
368377 values : mapValues ( Indexes , ( value , key ) => ( {
369378 ...value ,
@@ -487,19 +496,21 @@ class Contents extends Component {
487496 * @returns {undefined }
488497 */
489498 onSelectIndex ( event , { value } ) {
499+ let newIndex = {
500+ ...this . state . index ,
501+ selectedCount :
502+ this . state . index . selectedCount +
503+ ( this . state . index . values [ value ] . selected ? - 1 : 1 ) ,
504+ values : mapValues ( this . state . index . values , ( indexValue , indexKey ) => ( {
505+ ...indexValue ,
506+ selected :
507+ indexKey === value ? ! indexValue . selected : indexValue . selected ,
508+ } ) ) ,
509+ } ;
490510 this . setState ( {
491- index : {
492- ...this . state . index ,
493- selectedCount :
494- this . state . index . selectedCount +
495- ( this . state . index . values [ value ] . selected ? - 1 : 1 ) ,
496- values : mapValues ( this . state . index . values , ( indexValue , indexKey ) => ( {
497- ...indexValue ,
498- selected :
499- indexKey === value ? ! indexValue . selected : indexValue . selected ,
500- } ) ) ,
501- } ,
511+ index : newIndex ,
502512 } ) ;
513+ this . props . updateColumnsContent ( getBaseUrl ( this . props . pathname ) , newIndex ) ;
503514 }
504515
505516 /**
@@ -571,6 +582,10 @@ class Contents extends Component {
571582 order : move ( this . state . index . order , index , index + delta ) ,
572583 } ,
573584 } ) ;
585+ this . props . updateColumnsContent (
586+ getBaseUrl ( this . props . pathname ) ,
587+ this . state . index ,
588+ ) ;
574589 }
575590
576591 /**
@@ -1297,7 +1312,7 @@ class Contents extends Component {
12971312 icon = {
12981313 < Icon name = { moreSVG } size = "24px" color = "#826a6a" />
12991314 }
1300- className = "right floating"
1315+ className = "right floating selectIndex "
13011316 >
13021317 < Dropdown . Menu className = "left" >
13031318 < Dropdown . Header
@@ -1624,24 +1639,25 @@ class Contents extends Component {
16241639export const __test__ = compose (
16251640 injectIntl ,
16261641 connect (
1627- ( state , props ) => {
1642+ ( store , props ) => {
16281643 return {
1629- token : state . userSession . token ,
1630- items : state . search . items ,
1631- sort : state . content . update . sort ,
1632- breadcrumbs : state . breadcrumbs . items ,
1633- total : state . search . total ,
1644+ token : store . userSession . token ,
1645+ items : store . search . items ,
1646+ sort : store . content . update . sort ,
1647+ index : store . content . updatecolumns . idx ,
1648+ breadcrumbs : store . breadcrumbs . items ,
1649+ total : store . search . total ,
16341650 searchRequest : {
1635- loading : state . search . loading ,
1636- loaded : state . search . loaded ,
1651+ loading : store . search . loading ,
1652+ loaded : store . search . loaded ,
16371653 } ,
16381654 pathname : props . location . pathname ,
1639- action : state . clipboard . action ,
1640- source : state . clipboard . source ,
1641- clipboardRequest : state . clipboard . request ,
1642- deleteRequest : state . content . delete ,
1643- updateRequest : state . content . update ,
1644- objectActions : state . actions . actions . object ,
1655+ action : store . clipboard . action ,
1656+ source : store . clipboard . source ,
1657+ clipboardRequest : store . clipboard . request ,
1658+ deleteRequest : store . content . delete ,
1659+ updateRequest : store . content . update ,
1660+ objectActions : store . actions . actions . object ,
16451661 } ;
16461662 } ,
16471663 {
@@ -1654,6 +1670,7 @@ export const __test__ = compose(
16541670 moveContent,
16551671 orderContent,
16561672 sortContent,
1673+ updateColumnsContent,
16571674 } ,
16581675 ) ,
16591676) ( Contents ) ;
@@ -1662,24 +1679,25 @@ export default compose(
16621679 DragDropContext ( HTML5Backend ) ,
16631680 injectIntl ,
16641681 connect (
1665- ( state , props ) => {
1682+ ( store , props ) => {
16661683 return {
1667- token : state . userSession . token ,
1668- items : state . search . items ,
1669- sort : state . content . update . sort ,
1670- breadcrumbs : state . breadcrumbs . items ,
1671- total : state . search . total ,
1684+ token : store . userSession . token ,
1685+ items : store . search . items ,
1686+ sort : store . content . update . sort ,
1687+ index : store . content . updatecolumns . idx ,
1688+ breadcrumbs : store . breadcrumbs . items ,
1689+ total : store . search . total ,
16721690 searchRequest : {
1673- loading : state . search . loading ,
1674- loaded : state . search . loaded ,
1691+ loading : store . search . loading ,
1692+ loaded : store . search . loaded ,
16751693 } ,
16761694 pathname : props . location . pathname ,
1677- action : state . clipboard . action ,
1678- source : state . clipboard . source ,
1679- clipboardRequest : state . clipboard . request ,
1680- deleteRequest : state . content . delete ,
1681- updateRequest : state . content . update ,
1682- objectActions : state . actions . actions . object ,
1695+ action : store . clipboard . action ,
1696+ source : store . clipboard . source ,
1697+ clipboardRequest : store . clipboard . request ,
1698+ deleteRequest : store . content . delete ,
1699+ updateRequest : store . content . update ,
1700+ objectActions : store . actions . actions . object ,
16831701 } ;
16841702 } ,
16851703 {
@@ -1692,6 +1710,7 @@ export default compose(
16921710 moveContent,
16931711 orderContent,
16941712 sortContent,
1713+ updateColumnsContent,
16951714 } ,
16961715 ) ,
16971716 asyncConnect ( [
0 commit comments