On 01/03/2012 02:14 PM, Jan Provaznik wrote:
On 01/02/2012 04:28 PM, ifarkas(a)redhat.com wrote:
> From: Imre Farkas<ifarkas(a)redhat.com>
>
> ---
> src/app/views/pools/_deployments.html.haml | 33
> ++++++++++++++-------------
> src/public/javascripts/backbone/views.js | 15 ++++++++++--
> 2 files changed, 29 insertions(+), 19 deletions(-)
>
> diff --git a/src/app/views/pools/_deployments.html.haml
> b/src/app/views/pools/_deployments.html.haml
> index af0b8b8..60b7fc6 100644
> --- a/src/app/views/pools/_deployments.html.haml
> +++ b/src/app/views/pools/_deployments.html.haml
> @@ -1,20 +1,21 @@
> -- deployments.in_groups_of(5, false) do |group|
> - %ul.deployment-array.small
> - - group.each do |deployment|
> - %li.deployment
> - %h3.name
> - = link_to deployment.name, deployment_path(deployment)
> - = t 'pools.index.global_uptime'
> - = count_uptime(deployment.uptime_all)
> - %dl.statistics
> - %ul
> - %li.right
> - %dt.instances.count= t 'instances.instances'
> - %dd= deployment.instances.count || 0
> +#deployment-arrays
> + - deployments.in_groups_of(5, false) do |group|
> + %ul.deployment-array.small
> + - group.each do |deployment|
> + %li.deployment
> + %h3.name
> + = link_to deployment.name, deployment_path(deployment)
> + = t 'pools.index.global_uptime'
> + = count_uptime(deployment.uptime_all)
> + %dl.statistics
> + %ul
> + %li.right
> + %dt.instances.count= t 'instances.instances'
> + %dd= deployment.instances.count || 0
>
> - %li.left
> - %dt=t :uptime
> - %dd= count_uptime(deployment.uptime_1st_instance)
> + %li.left
> + %dt=t :uptime
> + %dd= count_uptime(deployment.uptime_1st_instance)
>
> %script#deploymentPrettyTemplate{ :type => 'text/x-jquery-tmpl' }
> :plain
> diff --git a/src/public/javascripts/backbone/views.js
> b/src/public/javascripts/backbone/views.js
> index f6076e1..680ca9d 100644
> --- a/src/public/javascripts/backbone/views.js
> +++ b/src/public/javascripts/backbone/views.js
> @@ -51,9 +51,18 @@ Conductor.Views.PoolsIndex = Backbone.View.extend({
> $table.find('tr:odd').addClass('stripe');
> }
> else if (this.currentView() == 'pretty') {
> - $deployments = this.$('ul.deployment-array');
> - var $template = this.template();
> - $deployments.empty().append($template.tmpl(this.collection.toJSON()))
> + var $rows = this.$('#deployment-arrays').empty();
> + var cardsPerRow = 5;
> + var deployments = this.collection.models.map(function(model) {
> + return model.attributes;
> + });
> +
> + for(var i = 0; i< deployments.length; i += cardsPerRow) {
> + var $row = this.make('ul',
> + {class: 'deployment-array small'},
> + $template.tmpl(deployments.slice(i, i + cardsPerRow)));
> + $rows.append($row);
> + }
> }
> },
> });
ACK, though same problem is probably with
app/views/deployments/_pretty_view.html.haml (in_groups_of is used there
too) - it would be great to fix it too (as part of this patch or
separate, whatever you prefer).
Jan
As discussed in person, the pretty_view partial is only used in
Pools#show and the usage of in_groups_of in that view is handled by the
Backbone correctly. I have also checked in the browser and found no
error or mis-displaying.
Imre