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

Buttons
-------

With the folder contents view it is possible to copy, paste etc. a lot
of content objects at once.

An empty folder should only contain the paste button.

  >>> self.createFolder('empty-folder')
  >>> browser.open('http://nohost/plone/empty-folder/@@folder_contents')

  >>> browser.getControl('Copy')
  Traceback (most recent call last):
  ...
  LookupError: label 'Copy'

  >>> browser.getControl('Cut')
  Traceback (most recent call last):
  ...
  LookupError: label 'Cut'

  >>> browser.getControl('Rename')
  Traceback (most recent call last):
  ...
  LookupError: label 'Rename'

  >>> browser.getControl('Delete')
  Traceback (most recent call last):
  ...
  LookupError: label 'Delete'

  >>> browser.getControl('Change State')
  Traceback (most recent call last):
  ...
  LookupError: label 'Change State'

The paste button should not be there yet either. We only want to see
that when we have something copied.

  >>> browser.getControl('Paste')
  Traceback (most recent call last):
  ...
  LookupError: label 'Paste'

When we look at a folder with content in it we should see more
options.

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

  >>> button = browser.getControl('Copy')
  >>> button = browser.getControl('Cut')
  >>> button = browser.getControl('Rename')
  >>> button = browser.getControl('Delete')
  >>> button = browser.getControl('Change State')

Still the paste button should not be available.

  >>> browser.getControl('Paste')
  Traceback (most recent call last):
  ...
  LookupError: label 'Paste'

Now we shall copy something so we can paste it.

  >>> objects = browser.getControl(name='paths:list')
  >>> objects.value = objects.options[0:1]
  >>> browser.getControl('Copy').click()

Because we have copied something the paste button should show up.

  >>> button = browser.getControl('Paste')

It should also show up in our empty folder.

  >>> browser.open('http://nohost/plone/empty-folder/@@folder_contents')
  >>> button = browser.getControl('Paste')


Table headers
-------------

When viewing the folder contents we should not see them when there are
no items in it.

  >>> browser.open('http://nohost/plone/empty-folder/@@folder_contents')
  >>> 'foldercontents-title-column' in browser.contents
  False

The headers should be shown when we go to a non empty folder.

  >>> browser.open('http://nohost/plone/@@folder_contents')
  >>> 'foldercontents-title-column' in browser.contents
  True


Batching
--------

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=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')
  >>> '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.

  >>> print browser.contents
  <BLANKLINE>
  ... All 20 items on this page are selected...

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

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

This should have selected everything.

  >>> print browser.contents
  <BLANKLINE>
  ... All ... items in this folder are selected. ...

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 are 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()

Notice that is no way to select any items now. This is because there
is nothing to select.

  >>> browser.getLink(id='foldercontents-selectall')
  Traceback (most recent call last):
  ...
  LinkNotFoundError

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.reload()
  >>> browser.getLink(id='foldercontents-selectall').click()
  >>> print browser.contents
  <BLANKLINE>
  ... All ... items in this folder are selected...

  >>> 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 ...>


Going up
--------

When you are looking at the contents of a folder you might want to
navigate to a different folder. This can be done by going to the
parent folder.

To show this we will need to create a folder first.

  >>> self.createFolder()

Now we can go to this folder.

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

In this folder contents view we should have link to go to the site root.

  >>> browser.getLink('Up one level')
  <Link ...>

Now lets click it.

  >>> browser.getLink('Up one level').click()
  >>> browser.url
  'http://nohost/plone/folder_contents'

In the site root we should not be able to go up any further.

  >>> browser.getLink('Up one level')
  Traceback (most recent call last):
  ...
  LinkNotFoundError



