Folder contents
===============

  >>> browser = self.browser

Viewing the folder contents
---------------------------

A user should first login before being able to access the folder contents view.
 
  >>> browser.open('http://nohost/plone/@@folder_contents')
  >>> 'Please log in' in browser.contents
  True

Log in and try again.

  >>> self.loginAsManager()
  >>> browser.open('http://nohost/plone/@@folder_contents')
  >>> 'Please log in' in browser.contents
  False

First clearout all portlets so that the rest of the test is easier to write.

  >>> browser.open('http://nohost/plone/@@manage-portlets')
  >>> browser.getLink(url='@@delete-portlet?name=recent').click()
  >>> browser.getLink(url='@@delete-portlet?name=navigation').click()

Because we have no content there should not be any batching.

  >>> browser.open('http://nohost/plone/@@folder_contents')
  >>> browser.getLink('Next 20 items')
  Traceback (most recent call last):
  ...
  LinkNotFoundError

Create a few pages so that we have some content to play with.

  >>> self.createDocuments(65)

  >>> browser.open('http://nohost/plone/@@folder_contents')
  >>> open('/tmp/output', 'w').write(browser.contents)
  >>> 'Testing' in browser.contents
  True

Now that we have a lot of pages we should also have some batching.

  >>> browser.getLink('Next 20 items')
  <Link ...>

One of the later pages should not be in our current screen.

  >>> 'Testing 20' in browser.contents
  False

Now when we go to the second screen it should show up.

  >>> browser.getLink('2').click()
  >>> 'Testing 20' in browser.contents
  True

We should also have at most four pages of batched items. So at page four there
should be no way to go further.

  >>> browser.getLink('4').click()
  >>> browser.getLink('Next 20 items')
  Traceback (most recent call last):
  ...
  LinkNotFoundError

The batching navigation also should allow us to go back to previous pages.

  >>> browser.getLink('Previous 20 items')
  <Link ...>

When we are at the first page this link should not be shown.

  >>> browser.open('http://nohost/plone/@@folder_contents')
  >>> browser.getLink('Previous 20 items')
  Traceback (most recent call last):
  ...
  LinkNotFoundError

Selection
---------

The folder contents view supports quite elaborate selection techniques. You can
select items individually or group wise. We will now demonstrate how the group
wise selection works.

  >>> browser.open('http://nohost/plone/@@folder_contents')

First we can select all items on screen.

  >>> browser.getLink(id='foldercontents-selectall').click()

This will show a message that only the items on the screen are selected.

  >>> self.textOnPage('All 20 items on this page are selected', browser.contents) 
  True

We now have a way to select all items in the batch.

  >>> browser.getLink(id='foldercontents-selectall-completebatch').click()

This should have selected everything.

  >>> self.textOnPage('All \d* items in this folder are selected', browser.contents)
  True

We can also clear the selection, this will deselect everything.

  >>> browser.getLink(id='foldercontents-clearselection').click()
  
Now we are back to square one and we can select all items on the screen again.

  >>> browser.getLink(id='foldercontents-selectall')
  <Link ...>

The steps described go a bit different for when we only have a few items. First
we clean up all items by removing everything.

  >>> browser.getLink(id='foldercontents-selectall').click()
  >>> browser.getLink(id='foldercontents-selectall-completebatch').click()
  >>> browser.getControl(name='folder_delete:method').click()

Now we will add some documents again.

  >>> self.createDocuments(3)

When we press the select all button it should no longer offer us to select the
whole batch because we are showing everything already.

  >>> browser.getLink(id='foldercontents-selectall').click()
  >>> self.textOnPage('All 2 items in this folder are selected',
  ...                 browser.contents) 
  True
  >>> browser.getLink(id='foldercontents-selectall-completebatch')
  Traceback (most recent call last):
  ...
  LinkNotFoundError

Instead we should now be able to clear the selection.

  >>> browser.getLink(id='foldercontents-clearselection')
  <Link ...>
