Skip to content

Commit

Permalink
If nothing can be added to the current object the Add menu should
Browse files Browse the repository at this point in the history
not render the dropdown menu, instead it should be disabled.
  • Loading branch information
j23d committed Feb 28, 2012
1 parent 818036e commit 1946e24
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
4 changes: 4 additions & 0 deletions kotti/static/view.css
Expand Up @@ -15,3 +15,7 @@ a.site-title {
font-size: 30px;
}
}

.navbar .nav > li.disabled > a:hover {
color: #999;
}
5 changes: 4 additions & 1 deletion 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>
Expand Down
7 changes: 7 additions & 0 deletions kotti/testing.py
Expand Up @@ -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()
27 changes: 24 additions & 3 deletions kotti/tests/browser.txt
Expand Up @@ -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:

Expand All @@ -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
-----

Expand Down Expand Up @@ -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
-----------------

Expand Down Expand Up @@ -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:

Expand Down

0 comments on commit 1946e24

Please sign in to comment.