Skip to content

Commit

Permalink
Merge a4c9f14 into 8c8cdfb
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Aug 26, 2016
2 parents 8c8cdfb + a4c9f14 commit 713d9b4
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 303 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;
}
53 changes: 50 additions & 3 deletions src/collective/cover/static/js/main.js
@@ -1,14 +1,61 @@
$(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);
var $tile = $a.parents('.tile');
var url = '@@updatetile'
if ($a.hasClass('kssCalendarChange')) {
url = $a.attr('href');
}
$.ajax({
url: '@@updatetile',
url: url,
data: {
'tile-id': $tile.attr('id'),
'month:int': $a.attr('data-month'),
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__)
40 changes: 32 additions & 8 deletions src/collective/cover/tests/test_calendar_tile.robot
Expand Up @@ -35,20 +35,44 @@ Test Calendar Tile
# test next / prev buttons
${nextyear} = Execute Javascript
... return (function() {
... var $next = jQuery('a.calendar-tile-next');
... var $next = jQuery('a.calendarNext');
... var str_klasses = $next.attr('class');
... if (str_klasses.indexOf('kssattr') >= 0) {
... var klasses = str_klasses.split(' ');
... var i, klass, len, year, year_check;
... for (i = 0, len = klasses.length; i < len; i++) {
... klass = klasses[i];
... year_check = 'kssattr-year-';
... if (klass.indexOf(year_check) === 0) {
... return klass.slice(year_check.length);
... }
... }
... }
... return $next.attr('data-year');
... })();
${nextmonth} = Execute Javascript
... return (function() {
... var $next = jQuery('a.calendar-tile-next');
... var $next = jQuery('a.calendarNext');
... var str_klasses = $next.attr('class');
... if (str_klasses.indexOf('kssattr') >= 0) {
... var klasses = str_klasses.split(' ');
... var i, klass, len, month, month_check;
... for (i = 0, len = klasses.length; i < len; i++) {
... klass = klasses[i];
... month_check = 'kssattr-month-';
... if (klass.indexOf(month_check) === 0) {
... return klass.slice(month_check.length);
... }
... }
... }
... 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 2 sec Click Link css=a.calendarNext
Wait Until Keyword Succeeds 5 sec 2 sec Click Link css=a.calendarNext
Page Should Contain Element jquery=a.calendarPrevious[data-month=${nextmonth}][data-year=${nextyear}],a.calendarPrevious.kssattr-month-${nextmonth}.kssattr-year-${nextyear}
Wait Until Keyword Succeeds 5 sec 2 sec Click Link css=a.calendarPrevious
Wait Until Keyword Succeeds 5 sec 2 sec Click Link css=a.calendarPrevious
Page Should Contain Element jquery=a.calendarNext[data-month=${nextmonth}][data-year=${nextyear}],a.calendarNext.kssattr-month-${nextmonth}.kssattr-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 713d9b4

Please sign in to comment.