Skip to content

Commit

Permalink
Merge pull request #264 from collective/issue_212
Browse files Browse the repository at this point in the history
closes #212
  • Loading branch information
hvelarde committed Aug 26, 2013
2 parents 1deaa72 + 382bf0b commit 96e60ff
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 20 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ There's a frood who really knows where his towel is
1.0a5 (unreleased)
^^^^^^^^^^^^^^^^^^

- Auto add a column when adding a row (closes `#212`_).
[marcosfromero]

- Remove dependency on plone.batching to avoid ``IndexError: multiple_pages``
on Plone 4.2. [jpgimenez]

Expand Down Expand Up @@ -222,6 +225,7 @@ There's a frood who really knows where his towel is
.. _`#198`: https://github.com/collective/collective.cover/issues/198
.. _`#203`: https://github.com/collective/collective.cover/issues/203
.. _`#206`: https://github.com/collective/collective.cover/issues/206
.. _`#212`: https://github.com/collective/collective.cover/issues/212
.. _`#218`: https://github.com/collective/collective.cover/issues/218
.. _`#239`: https://github.com/collective/collective.cover/issues/239
.. _`#249`: https://github.com/collective/collective.cover/issues/249
1 change: 1 addition & 0 deletions docs/CREDITS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ the following people:
- Héctor Velarde
- Juan A. Díaz
- Juan Pablo Giménez
- Marcos F. Romero
- Ricardo Bánffy
- Rodrigo Ferreira de Souza
- Silvestre Huens
Expand Down
4 changes: 3 additions & 1 deletion src/collective/cover/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@ def update(self):

def get_tile_metadata(self, tile_name):
tile_type = getUtility(ITileType, tile_name)
tile = self.context.restrictedTraverse(str(tile_name))
tile_metadata = {
'icon': tile_type.icon,
'description': tile_type.description,
'title': tile_type.title
'title': tile_type.title,
'is_configurable': tile.is_configurable and 1 or 0
}

return tile_metadata
Expand Down
3 changes: 2 additions & 1 deletion src/collective/cover/layout_templates/tilelist.pt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<a class="btn-tile draggable" data-tile-type=""
tal:attributes="data-tile-type tile/tile_type;
data-tile-name metadata/title;
data-tile-configurable metadata/is_configurable;
title metadata/description;
id tile/tile_type">
<img src="" tal:attributes="src python:metadata['icon'] if metadata['icon'] else '++resource++collective.cover/tile-generic.png';
Expand All @@ -26,4 +27,4 @@
</div>

</body>
</html>
</html>
41 changes: 28 additions & 13 deletions src/collective/cover/static/layout_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@

self.row_events(row);
self.delete_manager(row);
// after adding the row, call its drop handler
// to automatically add a column (closes #212)
self.row_drop($(row));
}
le.trigger('modified.layout');
}
Expand All @@ -77,6 +80,23 @@

},

/**
* Row drop handler
* available from outside the droppable definition
**/
row_drop: function( $row ) {
//creates a new column
var column = column_dom.clone();
$row.prepend(column);
self.column_events(column);
self.delete_manager(column);
self.resize_columns_manager(column);

self.calculate_grid($row.find('.' + column_class));

le.trigger('modified.layout');
},

/**
* Row events binding
* makes the event setup in row/s
Expand All @@ -89,20 +109,12 @@
activeClass: 'ui-state-default',
hoverClass: 'ui-state-hover',
accept: '#btn-column',
drop: function( event, ui ) {
//creates a new column
var column = column_dom.clone();
$(this).prepend(column);
self.column_events(column);
self.delete_manager(column);
self.resize_columns_manager(column);

self.calculate_grid($(this).find('.' + column_class));

le.trigger('modified.layout');
drop: function(event, ui) {
self.row_drop($(this));
}
});


//allow sortable columns
rows.sortable({
items:'.' + column_class,
Expand Down Expand Up @@ -142,6 +154,7 @@
var column_elem = this;

var tile_type = ui.draggable.data('tile-type');
var is_configurable = ui.draggable.data('tile-configurable');
new_tile.attr("data-tile-type", tile_type);

$.ajax({
Expand All @@ -156,8 +169,10 @@
.append(config_icon);
var name_tag = $("<span />").addClass("tile-name")
.text(ui.draggable.data('tile-name'));
new_tile.append(config_link)
.append(name_tag);
if(is_configurable) {
new_tile.append(config_link)
}
new_tile.append(name_tag);

$(column_elem).append(new_tile);
self.delete_manager(new_tile);
Expand Down
11 changes: 6 additions & 5 deletions src/collective/cover/tests/test_layout.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,30 @@ Test Basic Layout Operations
Count Number of Rows 1

#add a row after the existing one.
#it comes with a new column
Add Row
#add a column in the latest row
Add Column at First Row
Add Column at Second Row
Add Column at Second Row

#2 columns and 2 rows
Count Number of Columns 4
#5 columns and 2 rows
Count Number of Columns 5
Count Number of Rows 2

Save Cover Layout

# load layout again, it has to be the new one
Click Link link=Layout

#2 columns and 2 rows
Count Number of Columns 4
#3 columns and 2 rows
Count Number of Columns 5
Count Number of Rows 2

Delete a Column in the First Row
Delete the First Row

Count Number of Columns 2
Count Number of Columns 3
Count Number of Rows 1

Save Cover Layout
Expand Down

0 comments on commit 96e60ff

Please sign in to comment.