Skip to content

Commit

Permalink
Merge 20a4ee2 into 8c8cdfb
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Aug 24, 2016
2 parents 8c8cdfb + 20a4ee2 commit 926c13b
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 302 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -13,6 +13,9 @@ There's a frood who really knows where his towel is.
All Layout tab helper views use now ``collective.cover.CanEditLayout`` permission.
The ``BaseGrid`` class is now located in the ``collective.cover.grids`` module.

- Remove dependency on ``portal_calendar`` tool for calendar tile.
[rodfersou, hvelarde]

- Remove dependency on plone.directives.form.
[l34marr]

Expand Down
19 changes: 6 additions & 13 deletions src/collective/cover/static/css/cover.css
Expand Up @@ -249,30 +249,23 @@ table.invisible
}

/* Tile Calendar */
.cover-calendar-tile .calendar-tile-header
.cover-calendar-tile .portletCalendar
{
font-weight: bold;
line-height: normal;

padding: .42em 1em;

text-align: center;

background: #ddd;
font-size: 1em;
}
#content .cover-calendar-tile a.calendar-tile-prev,
#content .cover-calendar-tile a.calendar-tile-next
#content .cover-calendar-tile a.calendarPrevious,
#content .cover-calendar-tile a.calendarNext
{
margin: 0 -.5em;
padding: 0 1em;

border-bottom: none;
}
.cover-calendar-tile a.calendar-tile-prev
.cover-calendar-tile a.calendarPrevious
{
float: left;
}
.cover-calendar-tile a.calendar-tile-next
.cover-calendar-tile a.calendarNext
{
float: right;
}
47 changes: 45 additions & 2 deletions src/collective/cover/static/js/main.js
@@ -1,8 +1,51 @@
$(function() {
// override jquery portlet event
// http://stackoverflow.com/a/14063574/2116850
function refreshPortlet(hash, _options){
var options = {
data: {},
success: function(){},
error: function(){},
ajaxOptions: {}};
$.extend(options, _options);
options.data.portlethash = hash;
ajaxOptions = options.ajaxOptions;
ajaxOptions.url = $('base').attr('href') + '/@@render-portlet';
ajaxOptions.success = function(data){
var container = $('[data-portlethash="' + hash + '"]');
var portlet = $(data);
container.html(portlet);
options.success(data, portlet);
}
ajaxOptions.error = function(){
options.error();
}
ajaxOptions.data = options.data;
$.ajax(ajaxOptions);
}
$('body').undelegate('#calendar-next, #calendar-previous', 'click')
.delegate(
'.portletWrapper #calendar-next, ' +
'.portletWrapper #calendar-previous',
'click',
function(e) {
e.preventDefault();
var el = $(this);
var container = el.parents('.portletWrapper');
refreshPortlet(container.data('portlethash'), {
data: {
month: el.data('month'),
year: el.data('year')
}
});
return false;
});
// override jquery portlet event

$('#content').on(
'click',
'.cover-calendar-tile a.calendar-tile-prev, ' +
'.cover-calendar-tile a.calendar-tile-next',
'.cover-calendar-tile .calendarPrevious, ' +
'.cover-calendar-tile .calendarNext',
function(e) {
e.preventDefault();
var $a = $(this);
Expand Down
1 change: 0 additions & 1 deletion src/collective/cover/testing.py
Expand Up @@ -166,7 +166,6 @@ def setUpPloneSite(self, portal):
set_image_field(portal['my-image1'], generate_jpeg(50, 50))
set_image_field(portal['my-image2'], generate_jpeg(50, 50))
set_image_field(portal['my-news-item'], generate_jpeg(50, 50))

portal_workflow = portal.portal_workflow
portal_workflow.setChainForPortalTypes(
['Collection'], ['simple_publication_workflow'])
Expand Down
11 changes: 0 additions & 11 deletions src/collective/cover/tests/test_calendar_tile.py
Expand Up @@ -14,7 +14,6 @@ def setUp(self):
self.tile.__name__ = u'collective.cover.calendar'
self.tile.id = u'test'

@unittest.expectedFailure # FIXME: raises BrokenImplementation
def test_interface(self):
self.interface = ICalendarTile
self.klass = CalendarTile
Expand All @@ -27,13 +26,3 @@ def test_default_configuration(self):

def test_accepted_content_types(self):
self.assertEqual(self.tile.accepted_ct(), [])


# load tests only in Plone < 5
def test_suite():
# FIXME: https://github.com/collective/collective.cover/issues/633
from collective.cover.config import IS_PLONE_5
if IS_PLONE_5:
return unittest.TestSuite()

return unittest.defaultTestLoader.loadTestsFromName(__name__)
16 changes: 8 additions & 8 deletions src/collective/cover/tests/test_calendar_tile.robot
Expand Up @@ -35,20 +35,20 @@ Test Calendar Tile
# test next / prev buttons
${nextyear} = Execute Javascript
... return (function() {
... var $next = jQuery('a.calendar-tile-next');
... var $next = jQuery('a.calendarNext');
... return $next.attr('data-year');
... })();
${nextmonth} = Execute Javascript
... return (function() {
... var $next = jQuery('a.calendar-tile-next');
... var $next = jQuery('a.calendarNext');
... return $next.attr('data-month');
... })();
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendar-tile-next
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendar-tile-next
Page Should Contain Element xpath=.//a[@class='calendar-tile-prev'][@data-month='${nextmonth}'][@data-year='${nextyear}']
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendar-tile-prev
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendar-tile-prev
Page Should Contain Element xpath=.//a[@class='calendar-tile-next'][@data-month='${nextmonth}'][@data-year='${nextyear}']
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendarNext
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendarNext
Page Should Contain Element xpath=.//a[@class='calendarPrevious'][@data-month='${nextmonth}'][@data-year='${nextyear}']
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendarPrevious
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendarPrevious
Page Should Contain Element xpath=.//a[@class='calendarNext'][@data-month='${nextmonth}'][@data-year='${nextyear}']

# delete the tile
Open Layout Tab
Expand Down
1 change: 0 additions & 1 deletion src/collective/cover/tests/test_upgrades.py
Expand Up @@ -524,7 +524,6 @@ def test_registrations(self):
self.assertGreaterEqual(int(version), int(self.to_version))
self.assertEqual(self._how_many_upgrades_to_do(), 4)

# FIXME: https://github.com/collective/collective.cover/issues/633
@unittest.skipIf(IS_PLONE_5, 'Upgrade step not supported under Plone 5')
def test_register_calendar_tile(self):
# address also an issue with Setup permission
Expand Down
9 changes: 0 additions & 9 deletions src/collective/cover/tests/test_vocabularies.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from collective.cover.config import IS_PLONE_5
from collective.cover.controlpanel import ICoverSettings
from collective.cover.testing import INTEGRATION_TESTING
from plone.registry.interfaces import IRegistry
Expand Down Expand Up @@ -46,10 +45,6 @@ def test_available_tiles_vocabulary(self):
'collective.cover.richtext',
]

# FIXME: https://github.com/collective/collective.cover/issues/633
if IS_PLONE_5:
expected.remove('collective.cover.calendar')

self.assertEqual(len(tiles), len(expected))
for i in expected:
self.assertIn(i, tiles)
Expand All @@ -73,10 +68,6 @@ def test_enabled_tiles_vocabulary(self):
'collective.cover.richtext',
]

# FIXME: https://github.com/collective/collective.cover/issues/633
if IS_PLONE_5:
expected.remove('collective.cover.calendar')

self.assertEqual(len(tiles), len(expected))
for i in expected:
self.assertIn(i, tiles)
Expand Down

0 comments on commit 926c13b

Please sign in to comment.