Skip to content

Commit

Permalink
Merge pull request #38 from it3s/lists
Browse files Browse the repository at this point in the history
Basic lists
  • Loading branch information
andersoncardoso committed Jun 11, 2014
2 parents 46b5d27 + fc0c614 commit d60d5d6
Show file tree
Hide file tree
Showing 41 changed files with 1,266 additions and 30 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ gem 'carrierwave_backgrounder' # delegate uploads to background jobs
gem 'mini_magick' # image processing for uploaders
gem 'fog' # upload images to amazon S3
gem 'remotipart' # enable ajax file uploads on remote forms
gem 'kaminari' # paginator

group :doc do
gem 'sdoc', :require => false
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ GEM
json (1.8.1)
jwt (0.1.11)
multi_json (>= 1.5)
kaminari (0.16.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
konacha (3.2.0)
actionpack (>= 3.1, < 5)
capybara
Expand Down Expand Up @@ -372,6 +375,7 @@ DEPENDENCIES
jquery-fileupload-rails
jquery-rails
jquery-ui-rails
kaminari
konacha
letter_opener
letter_opener_web
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#= require jquery_ujs
#= require jquery.remotipart
#= require jquery.ui.autocomplete
#= require jquery.infinitescroll

#= require base

Expand Down
25 changes: 25 additions & 0 deletions app/assets/javascripts/components/list.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
App.components.list = (container) ->
{
container: container
list: container.find("ul.list")

infiniteScrollDefaults:
navSelector: "nav.pagination"
nextSelector: "nav.pagination a[rel=next]"
itemSelector: ".list .list-item"
prefill: on
dataType: "html"

init: ->
@handleOptions()
@startInfiniteScroll(@infiniteScrollOptions)

handleOptions: ->
data = @container.data('list') ? {}
@infiniteScrollOptions = _.defaults(data.scroll ? {}, @infiniteScrollDefaults)
if @infiniteScrollOptions['behavior'] is 'local'
@infiniteScrollOptions.binder ?= container

startInfiniteScroll: (opts) ->
@list.infinitescroll opts
}
4 changes: 3 additions & 1 deletion app/assets/stylesheets/_settings.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ $text-link-visited-color: #004047;
$stick-color-bg: $white;
$stick-color-shadow: $meppit-blue;

$list-item-separator-color: $soft-grey;

// Typography
$main-font: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif;
$highlight-font: Cambria, Georgia, serif;
$base-font-size: 14px;
$base-font-size: 13px;
$secondary-content-font-size: 0.85em;


Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
@import "shared/stick";
@import "shared/tabs";
@import "shared/counters";
@import "shared/lists";

@import "sessions/sign_in";

Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/geo_data.css.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.page.data-view {
.site-page.data-view {
.data-logo {
width: 50px;
height:50px;
Expand Down
29 changes: 26 additions & 3 deletions app/assets/stylesheets/shared/_counters.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,45 @@
display: inline-block;
margin: 0 5px 0 0;
vertical-align: middle;
font-size: 1.7em;
font-size: 1.8em;
}

.counter-value {
display: inline-block;
vertical-align: middle;
text-align: center;
font-size: 0.8em;
font-size: 0.9em;
line-height: 1em;

em {
display: block;
color: $text-color;
font-weight: bold;
font-size: 1.2em;
font-size: 1.3em;
}
}

&.small, &.medium {
margin: 0 0 0 5px;
font-size: 0.9em;

a {
padding: 5px;
}

i {
font-size: 1em;
}

.counter-value {
min-width: 1.5em;
text-align: inherit;
}
}

&.medium {
font-size: 1.15em;
}

}
}
81 changes: 81 additions & 0 deletions app/assets/stylesheets/shared/_lists.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
nav.pagination { display: none; } // We are using infinite scroll

.list-item {
clear: both;
padding: 15px 0;
border-bottom: 1px solid $list-item-separator-color;

&:hover { background: $dark-white; }

a, a:hover { text-decoration: none; }

.item-checkbox { float: left; }

.item-avatar {
display: block;
float: left;
margin: 0 10px 0 0;
background: $soft-grey;
color: #fff;
text-align: center;

i { margin: 2px 0; }
}

&.small {
.item-avatar, img {
font-size: 30px;
width: 32px;
height: 32px;
border-radius: 5px;
}

.item {
width: 400px;
}

.item-excerpt { font-size: 0.95em; }
}

&.big {
.item-checkbox { margin: 22px 15px; }

.item-avatar, img {
font-size: 54px;
width: 64px;
height: 64px;
border-radius: 7px;
}

.item {
min-height: 64px;
width: 620px;
}
}

.item {
float: left;

.item-title {
font-family: inherit;
font-size: 1.15em;
color: $text-link-color;
margin: 0 0 2px;
}

.item-excerpt { color: $text-color; }
}

&.map {
.item-avatar { background: $meppit-maps-color; }
.item .item-title { color: $meppit-maps-color; }
}
&.data {
.item-avatar { background: $meppit-data-color; }
.item .item-title { color: $meppit-data-color; }
}

.item-controls {
.counters { margin: 8px 0; }
}
}
18 changes: 17 additions & 1 deletion app/assets/stylesheets/shared/_page.css.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.page {
.site-page {
@include span-columns($page-columns);

.side-pane {
Expand All @@ -13,4 +13,20 @@
font-size: 1.6em;
letter-spacing: -0.02em;
}
&.full {
@include span-columns(12);

.side-pane {
@include span-columns(3 of 12);
}

.central-pane {
@include span-columns(9 of 12);
}

h1.name {
font-size: 1.6em;
letter-spacing: -0.02em;
}
}
}
2 changes: 1 addition & 1 deletion app/assets/stylesheets/shared/_stick.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
z-index: 2000;
}

.page .stick > * {
.site-page .stick > * {
box-shadow: $stick-color-shadow 0px 5px 3px -3px;
}
1 change: 1 addition & 0 deletions app/assets/stylesheets/shared/_toolbar.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.toolbar-buttons {
background: url('imgs/toolbar-bg.png') no-repeat right top;
padding: 0 5px;
min-height: 430px;
float: left;
}
Expand Down
9 changes: 7 additions & 2 deletions app/assets/stylesheets/users/_profile.css.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.page.user-profile {
.site-page.user-profile {

// left pane
.avatar {
Expand Down Expand Up @@ -27,7 +27,7 @@
// Central pane
.main-title {
float:left;
max-width: 435px;
max-width: 425px;
}

.location {
Expand All @@ -47,6 +47,11 @@
margin: 0 0 20px;
}

.involvement > div {
overflow-y: auto;
height: 400px;
}

&.edit {
.field {
padding: 0;
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/geo_data_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ class GeoDataController < ApplicationController
before_action :require_login, :only => [:edit, :update]
before_action :find_data, :only => [:show, :edit, :update]

def index
@list = GeoData.page(params[:page]).per(params[:per])
respond_to do |format|
format.html { render :layout => !request.xhr? }
format.js
end
end

def show
end

Expand Down
9 changes: 8 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class UsersController < ApplicationController
include PasswordResets

before_action :require_login, :only => [:edit, :update]
before_action :find_user, :only => [:show, :edit, :update]
before_action :find_user, :only => [:show, :edit, :update, :contributions]
before_action :is_current_user, :only => [:edit, :update]

def new
Expand Down Expand Up @@ -49,6 +49,13 @@ def update
end
end

def contributions
respond_to do |format|
format.html { render :layout => !request.xhr? }
format.js
end
end

private

def user_params
Expand Down
31 changes: 31 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,35 @@ def counters_list(obj, only=:all)
available_counters = counters.select {|key, counter| obj.respond_to? counter[:method] }
only == :all ? available_counters.values() : only.map {|name| available_counters[name] }
end

def contributions_list(obj)
#TODO: get real objects
list = [
GeoData.find(1),
GeoData.find(1),
User.find(2),
GeoData.find(1),
User.find(2),
GeoData.find(1),
GeoData.find(1),
GeoData.find(1),
GeoData.find(1),
GeoData.find(1),
User.find(2),
GeoData.find(1)
]
Kaminari.paginate_array(list).page(params[:page]).per(5)
end

def object_type(obj)
if obj.kind_of? User
:user
elsif obj.kind_of? GeoData
:data
#elsif obj.kind_of? Map
#:map
else
:unknown
end
end
end
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def geojson_properties
end

def followers_count
# TODO
#TODO refactor to concern
0
end

def maps_count
# TODO
#TODO refactor to concern
0
end
end
1 change: 1 addition & 0 deletions app/views/geo_data/_geo_data.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= render 'shared/lists/item', :object => geo_data, :size => local_assigns[:size], :checkbox => local_assigns[:checkbox], :control => :counters %>
2 changes: 1 addition & 1 deletion app/views/geo_data/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= render 'shared/toolbar', :object => @data, :only => data_tools(@data) %>

<div class="page data-view edit" >
<div class="site-page data-view edit" >
<%= remote_form_for @data do |f| %>

<div class="form-actions" data-components="stick" data-stick='{ "get_width_from": ".data-view.page" }'>
Expand Down
9 changes: 9 additions & 0 deletions app/views/geo_data/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="site-page full data-list">
<div data-components="list">
<h1 class="title"><%= raw t('geo_data.list.title', :count => "<em>#{@list.total_count}</em>") %></h1>
<div id="geodata-pagination"><%= paginate @list, :remote => true %></div>
<ul id="geodata-list" class="list data-list">
<%= render @list, :checkbox => true %>
</ul>
</div>
</div>
Loading

0 comments on commit d60d5d6

Please sign in to comment.