/
foldercontents.txt
359 lines (246 loc) · 9.86 KB
/
foldercontents.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
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')
>>> 'Login Name' in browser.contents
True
>>> browser.open('http://nohost/plone/news/@@folder_contents')
>>> 'Login Name' in browser.contents
True
Log in and try again.
>>> from Products.PloneTestCase.setup import portal_owner
>>> from Products.PloneTestCase.setup import default_password
>>> browser.addHeader('Authorization',
... 'Basic %s:%s' % (portal_owner, default_password))
>>> browser.open('http://nohost/plone/@@folder_contents')
>>> 'Login Name' in browser.contents
False
>>> browser.open('http://nohost/plone/news/@@folder_contents')
>>> 'Login Name' 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
--------
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 \xc3\xa4 20' in browser.contents
False
Now when we go to the second screen it should show up.
>>> browser.getLink('2').click()
>>> 'Testing \xc3\xa4 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.open('http://nohost/plone/@@folder_contents')
>>> 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
Expanding the batch
-------------------
Sometimes you might want to see all the items in the folder. To make
this possible you can ask the folder contents to show everything
without enabling batching.
Before we demonstrate we need to clear out the existing contents and
create some new content.
>>> browser.getLink(id='foldercontents-selectall').click()
>>> browser.getControl(name='folder_delete:method').click()
Putting only one page into the folder will not show the option to
disable batching since there is no batching.
>>> self.createDocuments(1)
>>> browser.open('http://nohost/plone/@@folder_contents')
>>> browser.getLink('Show all items')
Traceback (most recent call last):
...
LinkNotFoundError
Create some more pages to show the batch disabling feature.
>>> browser.open('http://nohost/plone/@@folder_contents')
>>> browser.getLink(id='foldercontents-selectall').click()
>>> browser.getControl(name='folder_delete:method').click()
>>> self.createDocuments(60)
Now we can show all the items in the folder if we want to.
>>> browser.open('http://nohost/plone/@@folder_contents')
>>> browser.getLink('Show all items').click()
You can see all the items are now on the page.
>>> browser.contents
'...Testing \xc3\xa4 1...Testing \xc3\xa4 11...Testing \xc3\xa4 60...'
Selecting the current page should make the entire folder selected
(since we see everything).
>>> browser.getLink(id='foldercontents-selectall').click()
>>> print browser.contents
<BLANKLINE>
... All ... items in this folder are selected. ...
Folder contents of non-folders
------------------------------
The folder contents view is available on all content items, including
non-folders. Most non-folders have no content, but some (like
plone.app.collection collections) support folder-like operations and need to be
set up appropriately, e.g. with the correct base tag.
>>> _ = self.portal.invokeFactory('Document', 'doc')
>>> browser.open('http://nohost/plone/doc')
>>> '<base href="http://nohost/plone/doc" />' in browser.contents
True
>>> browser.open('http://nohost/plone/doc/@@folder_contents')
>>> '<base href="http://nohost/plone/doc/" />' in browser.contents
True