Skip to content

Commit

Permalink
Auto add a column when adding a row (closes #212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos F. Romero committed Aug 24, 2013
1 parent b5de2fa commit 819fc02
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 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 @@ -225,3 +228,4 @@ There's a frood who really knows where his towel is
.. _`#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
.. _`#212`: https://github.com/collective/collective.cover/issues/212
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
34 changes: 23 additions & 11 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

0 comments on commit 819fc02

Please sign in to comment.