Skip to content
Browse files

If nothing can be added to the current object the Add menu should

not render the dropdown menu, instead it should be disabled.
  • Loading branch information...
1 parent 818036e commit 1946e24419901a322d2b02881b331fe7f652184a @j23d committed Feb 29, 2012
Showing with 39 additions and 4 deletions.
  1. +4 −0 kotti/static/view.css
  2. +4 −1 kotti/templates/add-dropdown.pt
  3. +7 −0 kotti/testing.py
  4. +24 −3 kotti/tests/browser.txt
View
4 kotti/static/view.css
@@ -15,3 +15,7 @@ a.site-title {
font-size: 30px;
}
}
+
+.navbar .nav > li.disabled > a:hover {
+ color: #999;
+}
View
5 kotti/templates/add-dropdown.pt
@@ -1,6 +1,9 @@
<ul class="nav"
i18n:domain="Kotti">
- <li class="dropdown">
+ <li class="disabled" tal:condition="not:factories">
+ <a><span i18n:translate="">Add</span></a>
+ </li>
+ <li class="dropdown" tal:condition="factories">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span i18n:translate="">Add</span>
<b class="caret"></b>
View
7 kotti/testing.py
@@ -184,3 +184,10 @@ def registerDummyMailer():
mailer = DummyMailer()
_inject_mailer.append(mailer)
return mailer
+
+
+def dc(content, filename='/tmp/test_content.html'):
+ """ Dumps the given something into a file. """
+ handle = open(filename, 'w')
+ handle.write(content)
+ handle.close()
View
27 kotti/tests/browser.txt
@@ -5,7 +5,7 @@ Setup
-----
>>> from kotti import testing, DBSession
- >>> from kotti.resources import Node, Document
+ >>> from kotti.resources import Node, Document, File
Get a handle for some useful objects:
@@ -15,11 +15,18 @@ Get a handle for some useful objects:
>>> session = DBSession()
>>> root = session.query(Node).get(1)
>>> mailer = testing.registerDummyMailer()
+ >>> save_addable_document = Document.type_info.addable_to
+ >>> save_addable_file = File.type_info.addable_to
Open the frontpage:
>>> browser.open(testing.BASE_URL)
+Dump the content to make coverage happy:
+
+ >>> testing.dc(browser.contents)
+
+
Login
-----
@@ -151,6 +158,21 @@ Add another grandchild with the same name:
>>> browser.url == testing.BASE_URL + '/second-child/grandchild-1/@@edit'
True
+
+If it's not possible to add something, the add menu is disabled:
+
+ >>> browser.open(testing.BASE_URL + '/second-child/grandchild-1')
+ >>> 'class="disabled"' in browser.contents
+ False
+ >>> Document.type_info.addable_to = ()
+ >>> File.type_info.addable_to = ()
+ >>> browser.reload()
+ >>> 'class="disabled"' in browser.contents
+ True
+ >>> Document.type_info.addable_to = save_addable_document
+ >>> File.type_info.addable_to = save_addable_file
+
+
Reorder documents
-----------------
@@ -267,13 +289,12 @@ property:
>>> browser.open(testing.BASE_URL + '/child-one/second-child/@@move')
>>> ctrl(name="paste")
<SubmitControl name='paste' type='submitbutton'>
- >>> save_addable = Document.type_info.addable_to
>>> Document.type_info.addable_to = ()
>>> browser.reload()
>>> ctrl(name="paste")
Traceback (most recent call last):
LookupError: name 'paste'
- >>> Document.type_info.addable_to = save_addable
+ >>> Document.type_info.addable_to = save_addable_document
We can rename an item:

0 comments on commit 1946e24

Please sign in to comment.
Something went wrong with that request. Please try again.