woople-theme 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,6 +43,10 @@
43
43
  padding-top:@contentPadding + 1;
44
44
  }
45
45
 
46
+ .completed-item {
47
+ padding-bottom: @contentPadding !important;
48
+ }
49
+
46
50
  .content-item {
47
51
  position:relative;
48
52
  margin-left:0;
@@ -57,7 +61,7 @@
57
61
  -ms-tap-highlight-color: transparent;
58
62
  tap-highlight-color: transparent;
59
63
 
60
- > * {
64
+ > * {
61
65
  position:relative;
62
66
  z-index:2;
63
67
  }
@@ -76,6 +80,22 @@
76
80
 
77
81
  }
78
82
 
83
+ .content-item-spacer {
84
+ margin-left: 0;
85
+ }
86
+ .content-item-date {
87
+ .content-title();
88
+ margin-left: 0;
89
+ a {
90
+ color:@primaryTextColour;
91
+ }
92
+ }
93
+ .content-item-duration {
94
+ .content-title();
95
+ margin-right: 0;
96
+ text-align: right;
97
+ }
98
+
79
99
  .content-item-content {
80
100
  h2 {
81
101
  .content-title();
@@ -2,7 +2,7 @@
2
2
 
3
3
  #essentials-section {
4
4
 
5
- h2 {
5
+ > h2 {
6
6
  padding-left:@contentPadding;
7
7
  padding-right:@contentPadding;
8
8
  margin-top:0;
@@ -9,4 +9,13 @@ module DashboardHelper
9
9
  object: ThemePresentation.wrap(presenter, WoopleTheme::Dashboard::EssentialsSectionPresenter)
10
10
  end
11
11
 
12
+ def completed_essentials(items)
13
+ collection = ThemePresentation.wrap_collection(items, WoopleTheme::Dashboard::CompletedEssentialPresenter)
14
+ render partial: 'dashboard/completed_essential', collection: collection
15
+ end
16
+
17
+ def total_courses(total)
18
+ render partial: 'dashboard/total_courses', locals: {total: total}
19
+ end
20
+
12
21
  end
@@ -0,0 +1,7 @@
1
+ module WoopleTheme
2
+ module Dashboard
3
+ class CompletedContentItemPresenter < ExplicitDelegator
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ require 'duration'
2
+ module WoopleTheme
3
+ module Dashboard
4
+ class CompletedEssentialPresenter < CompletedContentItemPresenter
5
+
6
+ def date
7
+ completed_on.strftime('%b %d')
8
+ end
9
+
10
+ def formatted_time_total
11
+ Duration.format_time(time_total)
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -2,10 +2,29 @@ require 'action_view'
2
2
  module WoopleTheme
3
3
  module Dashboard
4
4
  class EssentialsSectionPresenter < SectionPresenter
5
- enforce_definitions :essentials_remaining
5
+ enforce_definitions :essentials_remaining,
6
+ :essentials_completed
6
7
 
7
8
  def render_remaining
8
- yield if section.essentials_remaining.size > 0
9
+ yield if render?(section.essentials_remaining)
10
+ end
11
+
12
+ def render_completed
13
+ yield if render?(section.essentials_completed)
14
+ end
15
+
16
+ def total_completed_courses
17
+ section.essentials_completed.count
18
+ end
19
+
20
+ def total_completed_minutes
21
+ Duration.format_time(section.essentials_completed.map(&:time_total).inject(0, :+))
22
+ end
23
+
24
+ private
25
+
26
+ def render?(tab)
27
+ tab.count > 0
9
28
  end
10
29
 
11
30
  end
@@ -0,0 +1,12 @@
1
+ <div class="content-item completed-item row">
2
+ <div class="content-item-date span1">
3
+ <a href="<%= completed_essential.url %>"><%= completed_essential.date %></a>
4
+ </div>
5
+ <div class="content-item-content span5">
6
+ <h2><a href="<%= completed_essential.url %>"><%= completed_essential.name %></a></h2>
7
+ </div>
8
+ <div class="content-item-duration span2">
9
+ <%= completed_essential.formatted_time_total %>
10
+ </div>
11
+ </div>
12
+
@@ -1,17 +1,34 @@
1
1
  <% essentials_section.render do %>
2
2
  <section id="<%= essentials_section.css_id %>">
3
3
  <h2><%= essentials_section.title %></h2>
4
- <ul class="nav nav-tabs">
4
+ <ul class="nav nav-tabs" id="essentials_tab_nav">
5
5
  <% essentials_section.render_remaining do %>
6
- <li class="active"><a href="#" data-toggle="tab"><%=t('woople_theme.dashboard.essentials.remaining')%></a></li>
6
+ <li><a href="#essentials_remaining" data-toggle="tab"><%=t('woople_theme.dashboard.essentials.remaining')%></a></li>
7
+ <% end %>
8
+ <% essentials_section.render_completed do %>
9
+ <li><a href="#essentials_completed" data-toggle="tab"><%=t('woople_theme.dashboard.essentials.completed')%></a></li>
7
10
  <% end %>
8
11
  </ul>
9
12
  <div class="tab-content">
10
13
  <% essentials_section.render_remaining do %>
11
- <div class="tab-pane active" id="essentials_remaining">
14
+ <div class="tab-pane" id="essentials_remaining">
12
15
  <%= content_items(essentials_section.essentials_remaining) %>
13
16
  </div>
14
17
  <% end %>
18
+ <% essentials_section.render_completed do %>
19
+ <div class="tab-pane" id="essentials_completed">
20
+ <%= completed_essentials(essentials_section.essentials_completed) %>
21
+ <div class="content-item row">
22
+ <div class="span1 content-item-spacer">
23
+ &nbsp;
24
+ </div>
25
+ <%= total_courses(essentials_section.total_completed_courses) %>
26
+ <div class="content-item-duration span2">
27
+ <%= I18n.t('woople_theme.dashboard.duration', count: essentials_section.total_completed_minutes) %>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ <% end %>
15
32
  </div>
16
33
  </section>
17
34
  <% end %>
@@ -0,0 +1,3 @@
1
+ <div class="content-item-content span5">
2
+ <h2 class="total"><%= I18n.t('woople_theme.dashboard.courses', count: total) %></h2>
3
+ </div>
@@ -57,6 +57,10 @@ en:
57
57
  dashboard:
58
58
  essentials:
59
59
  remaining: Remaining
60
+ completed: Completed
61
+ courses:
62
+ one: 1 Course
63
+ other: '%{count} Courses'
60
64
  search_results_more: See All >
61
65
  logged_in_as: Logged in as
62
66
  impersonating: impersonating
data/lib/duration.rb ADDED
@@ -0,0 +1,15 @@
1
+ class Duration
2
+ def self.format_time(milliseconds)
3
+ return "0:00" if milliseconds <= 0
4
+
5
+ hours = milliseconds.to_i / 3600000
6
+ minutes = milliseconds.to_i / 60000 % 60
7
+ seconds = milliseconds/1000.0 % 60
8
+
9
+ if hours > 0
10
+ "%i:%02i:%02i" % [ hours, minutes, seconds ]
11
+ else
12
+ "%i:%02i" % [ minutes, seconds ]
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module WoopleTheme
2
- VERSION = '0.5.3'
2
+ VERSION = '0.5.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woople-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-28 00:00:00.000000000 Z
12
+ date: 2012-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -209,6 +209,8 @@ files:
209
209
  - app/presenters/submitted_assessment_form_presenter.rb
210
210
  - app/presenters/theme_presentation.rb
211
211
  - app/presenters/woople_theme/answer_presenter.rb
212
+ - app/presenters/woople_theme/dashboard/completed_content_item_presenter.rb
213
+ - app/presenters/woople_theme/dashboard/completed_essential_presenter.rb
212
214
  - app/presenters/woople_theme/dashboard/essentials_section_presenter.rb
213
215
  - app/presenters/woople_theme/dashboard/section_presenter.rb
214
216
  - app/presenters/woople_theme/dashboard/status_alert_presenter.rb
@@ -216,8 +218,10 @@ files:
216
218
  - app/presenters/woople_theme/submitted_answer_presenter.rb
217
219
  - app/presenters/woople_theme/submitted_question_presenter.rb
218
220
  - app/presenters/woople_theme/video_presenter.rb
221
+ - app/views/dashboard/_completed_essential.html.erb
219
222
  - app/views/dashboard/_essentials_section.html.erb
220
223
  - app/views/dashboard/_status_alert.html.erb
224
+ - app/views/dashboard/_total_courses.html.erb
221
225
  - app/views/layouts/theme.html.erb
222
226
  - app/views/woople-theme/_assessment_form.html.erb
223
227
  - app/views/woople-theme/_assessment_form_answer.html.erb
@@ -240,6 +244,7 @@ files:
240
244
  - app/views/woople-theme/_video_modal.html.erb
241
245
  - config/locales/en.yml
242
246
  - config/routes.rb
247
+ - lib/duration.rb
243
248
  - lib/explicit_delegator.rb
244
249
  - lib/tasks/woople-theme_tasks.rake
245
250
  - lib/woople-theme/configuration.rb