Lots of layout fixes

James Peret vor 10 Jahren
Ursprung
Commit
a6069a5fa3

+ 1 - 1
app/assets/stylesheets/avalanche_theme.css.less

@@ -215,7 +215,7 @@ h4 {
215 215
 }
216 216
 
217 217
 .thumbnail-mission-description { height: 110px;}
218
-.box-mission-description { height:386px;}
218
+.box-mission-description { height:333px;}
219 219
 
220 220
 .thumbnails.mission-list, .box {
221 221
 	margin-bottom: 60px;

+ 20 - 0
app/assets/stylesheets/missions.css.less

@@ -142,6 +142,8 @@
142 142
 	margin-top: 25px;
143 143
 }
144 144
 
145
+
146
+
145 147
 // Rewards
146 148
 
147 149
 .rewards {
@@ -197,6 +199,18 @@
197 199
 	margin-bottom: 4px;
198 200
 }
199 201
 
202
+.thumbnail-task.single {
203
+	height: 156px;
204
+	overflow-y: hidden;
205
+}
206
+
207
+.thumbnail-task.single p:nth-child(2) {
208
+	font-family: Helvetica-LightOblique;
209
+	font-size: 14px;
210
+	color: #1D1D26;
211
+	line-height: 17px;
212
+}
213
+
200 214
 .task-number {
201 215
 	font-family: Avenir-Black;
202 216
 	font-size: 36px;
@@ -205,6 +219,8 @@
205 219
 	float: left;
206 220
 }
207 221
 
222
+.task-number.solo { font-size: 28px; line-height: 32px; margin-top: 10px; margin-left: -6px;}
223
+
208 224
 .task-text {
209 225
 	font-family: Avenir-Medium;
210 226
 	font-size: 14px;
@@ -215,6 +231,10 @@
215 231
 	padding-left: 5px;
216 232
 }
217 233
 
234
+.thumbnail-task .task-icon {
235
+	float: right;
236
+}
237
+
218 238
 .task-icon {
219 239
 	font-size: 24px;
220 240
 	padding-top: 13px;

+ 19 - 0
app/models/agent_step.rb

@@ -35,4 +35,23 @@ class AgentStep < ActiveRecord::Base
35 35
     end
36 36
   end
37 37
   
38
+  def icons
39
+    icons = ''
40
+    if self.step_validations.count > 0
41
+      self.step_validations.each do |validation|
42
+        case validation.validation_type
43
+        when 'ValidationText'
44
+          icons = icons + '<i class="fa fa-comment"></i>'
45
+        when 'ValidationImage'
46
+          icons = icons + '<i class="fa fa-picture-o"></i>'
47
+        else
48
+          icons = icons + '<i class="fa fa-coffee"></i>'
49
+        end
50
+      end
51
+    else
52
+      icons = icons + '<i class="fa fa-coffee"></i>'
53
+    end
54
+    return icons
55
+  end
56
+  
38 57
 end

+ 17 - 0
app/models/mission.rb

@@ -54,6 +54,23 @@ class Mission < ActiveRecord::Base
54 54
     return String.new("#{self.completed_steps_count}/#{self.step_count}")
55 55
   end
56 56
   
57
+  def percentage_completed
58
+    steps_mod  = 0.8
59
+    agents_mod = 0.3
60
+    completed  = (completed_steps_count * steps_mod) + (confirmed_agent_count * agents_mod)
61
+    total      = (step_count * steps_mod) + (agent_count * agents_mod)
62
+    if total > 0
63
+      percentage = (100/total) * completed
64
+    else
65
+      if self.status == 3
66
+        percentage = 100
67
+      else
68
+        percentage = 0
69
+      end
70
+    end
71
+    return percentage
72
+  end
73
+  
57 74
   def is_agent(user)
58 75
     if user
59 76
       if self.mission_agents.find_all_by_user_id(user.id).count > 0

+ 12 - 0
app/models/step_validation.rb

@@ -2,4 +2,16 @@ class StepValidation < ActiveRecord::Base
2 2
   belongs_to :agent_step
3 3
   has_many :submission_contents
4 4
   belongs_to :validation, polymorphic: true
5
+  
6
+  def icon
7
+    case self.validation_type
8
+    when 'ValidationText'
9
+      return '<i class="fa fa-comment"></i>'
10
+    when 'ValidationImage'
11
+      return '<i class="fa fa-picture-o"></i>'
12
+    else
13
+      return '<i class="fa fa-coffee"></i>'
14
+    end
15
+  end
16
+  
5 17
 end

+ 3 - 7
app/views/agents/dashboard.html.erb

@@ -104,7 +104,7 @@
104 104
 										<%= content_tag(:p) do %>
105 105
 											<%= content_tag(:span, step.step, class: 'task-number') %>
106 106
 											<%= content_tag(:span, step.title, class: 'task-text') %>
107
-											<%= content_tag(:span, '<i class="fa fa-picture-o"></i>'.html_safe, class: 'task-icon') %>
107
+											<%= content_tag(:span, step.icons.html_safe, class: 'task-icon') %>
108 108
 										<% end %>
109 109
 									<% end %>
110 110
 								<% else %>
@@ -118,13 +118,9 @@
118 118
 									<% end %>
119 119
 								<% end %>
120 120
 							<% end %>
121
+							<% # Progress bar %>
121 122
 							<%= content_tag(:div, class: 'thumbnail-content mission-agent-percentage') do %>
122
-								<div class="progress-bar">
123
-									<div class="progress progress-striped">
124
-									  <div class="bar bar-success" style="width: 30%;"></div>
125
-									</div>
126
-									<div class="percentage">30%</div>
127
-								</div>
123
+								<%= render :partial => 'missions/mission_percentage_bar', locals: { mission: agent.mission, size: '' } %>
128 124
 							<% end %>
129 125
 							<%= content_tag(:div, class: 'thumbnail-content mission-status-timer') do%>
130 126
 								<%= content_tag(:div) do %>

+ 4 - 0
app/views/missions/_mission_box.html.erb

@@ -8,6 +8,10 @@
8 8
 			<%= content_tag(:p, mission.owner.full_name, class: 'mission-director-name') %>
9 9
 	          <%= content_tag(:p, mission.objective, class: 'thumbnail-mission-description') %>
10 10
 		<% end %>
11
+		<% # Progress bar %>
12
+		<%= content_tag(:div, class: 'thumbnail-content mission-agent-percentage') do %>
13
+			<%= render :partial => 'missions/mission_percentage_bar', locals: { mission: mission, size: '' } %>
14
+		<% end %>
11 15
 		<%= content_tag(:div, class: 'thumbnail-content mission-status-timer') do%>
12 16
 			<%= content_tag(:div) do %>
13 17
 				<% mission_agent_counter(mission, 'center_position') %>

+ 4 - 6
app/views/missions/_mission_details.html.erb

@@ -40,12 +40,10 @@
40 40
 				<%= content_tag(:span, mission.days_left.html_safe, class: 'mission-timer timer-large') %>
41 41
 				<%= content_tag(:br) %>
42 42
 				<%= content_tag(:div, (t 'mission.days_left'), class: 'timer-legend') %>
43
-				<div class="progress-bar progress-bar-mission-stats">
44
-					<div class="progress progress-striped">
45
-					  <div class="bar bar-success" style="width: 30%;"></div>
46
-					</div>
47
-					<div class="percentage">30%</div>
48
-				</div>
43
+				
44
+				<% # Progress bar %>
45
+				<%= render :partial => 'mission_percentage_bar', locals: { mission: mission, size: 'progress-bar-mission-stats' } %>
46
+
49 47
 				<%= content_tag(:div, class: 'mission-completion-stats') do %>
50 48
 					<%= mission_agent_counter(mission, 'pull-left') %>
51 49
 					<%= mission_steps_counter(mission, 'pull-right') %>

+ 6 - 0
app/views/missions/_mission_percentage_bar.html.erb

@@ -0,0 +1,6 @@
1
+<%= content_tag(:div, class: "progress-bar #{size}") do %>
2
+	<%= content_tag(:div, class: 'progress progress-striped') do %>
3
+		<%= content_tag(:div, '', class: 'bar bar-success', style: "width: #{mission.percentage_completed.to_s}%") %>
4
+	<% end %>
5
+	<%= content_tag(:div, "#{mission.percentage_completed.round.to_s}%", class: 'percentage') %>
6
+<% end %>

+ 36 - 0
app/views/missions/_step_quick_list.html.erb

@@ -0,0 +1,36 @@
1
+<% step_count = 0 %>
2
+<% has_shown_more_tasks = false %>
3
+
4
+<% agent.agent_steps.order('step ASC').each do |step| %>
5
+	<% if agent.agent_steps.count > 1 %>
6
+		<% step_count = step_count + 1 %>
7
+		<% if step_count <= 2 || agent.agent_steps.count <= 3 %>
8
+			<%= content_tag(:div, class: 'thumbnail-task') do %>
9
+				<%= content_tag(:p) do %>
10
+					<%= content_tag(:span, step.step, class: 'task-number') %>
11
+					<%= content_tag(:span, step.title, class: 'task-text') %>
12
+					<%= content_tag(:span, step.icons.html_safe, class: 'task-icon pull-right') %>
13
+				<% end %>
14
+			<% end %>
15
+		<% else %>
16
+			<% if has_shown_more_tasks == false %>
17
+				<% has_shown_more_tasks = true %>
18
+				<%= content_tag(:div, class: 'thumbnail-task') do %>
19
+					<%= content_tag(:p, class: 'task-show-all') do %>
20
+						<%= content_tag(:span, ('+ ' + (agent.agent_steps.count - step_count).to_s + ' ' + (t 'mission.steps')).html_safe) %>
21
+					<% end %>
22
+				<% end %>
23
+			<% end %>
24
+		<% end %>
25
+	<% elsif agent.agent_steps.count == 1 %>
26
+		<%= content_tag(:div, class: 'thumbnail-task single') do %>
27
+			<%= content_tag(:p) do %>
28
+				<%= content_tag(:span, '<i class="icon-task"></i>'.html_safe, class: 'task-number solo') %>
29
+				<%= content_tag(:span, step.title, class: 'task-text') %>
30
+				<%= content_tag(:span, step.icons.html_safe, class: 'task-icon pull-right') %>
31
+			<% end %>
32
+			<%= content_tag(:p, strip_tags(step.description).truncate(330, separator: '...'))%>
33
+		<% end %>
34
+	<% end %>
35
+
36
+<% end %>

+ 1 - 1
app/views/missions/_step_submission.html.erb

@@ -5,7 +5,7 @@
5 5
 		<%= content_tag(:div, class: 'panel-heading panel-divider') do %>
6 6
 			<%= content_tag(:div, class: 'panel-title') do %>
7 7
 				<%= link_to(('#'+ validation_id), class: 'accordion-toggle', :data => {toggle: 'collapse', parent: submission_id}) do %>
8
-					<%= content_tag(:span, '<i class="fa fa-picture-o"></i>'.html_safe, class: 'task-icon pull-left') %>
8
+					<%= content_tag(:span, validation.icon.html_safe, class: 'task-icon pull-left') %>
9 9
 					<%= content_tag(:span, '', class: 'caret caret-center') %>
10 10
 					<%= content_tag(:span, (step.step_validations.first != nil ? step.step_validations.first.validation.description : 'test'), class: 'task-text') %>
11 11
 				<% end %>

+ 6 - 2
app/views/missions/index.html.erb

@@ -14,7 +14,7 @@
14 14
 
15 15
 			<%= content_tag(:h2, (t 'mission.featured_missions'))%>
16 16
 
17
-			<%= content_tag(:div, class: 'row-fluid box') do %>
17
+			<%= content_tag(:div, class: 'row-fluid box ') do %>
18 18
 				<%= content_tag(:div, class: 'span8') do %>
19 19
 					<%= link_to mission_path(@featured_missions) do %>
20 20
 						<%= @featured_missions.cover_img? ? (image_tag @featured_missions.cover_img.feature) : image_tag('http://placehold.it/1200x780') %>
@@ -25,7 +25,11 @@
25 25
 				          <%= content_tag(:h3, link_to(@featured_missions.title, @featured_missions)) %>
26 26
 						<%= content_tag(:p, @featured_missions.owner.full_name, class: 'mission-director-name') %>
27 27
 				          <%= content_tag(:p, @featured_missions.objective, class: 'box-mission-description') %>
28
-						<%= content_tag(:div) do %>
28
+						<% # Progress bar %>
29
+						<%= content_tag(:div, class: 'thumbnail-content mission-agent-percentage') do %>
30
+							<%= render :partial => 'missions/mission_percentage_bar', locals: { mission: @featured_missions, size: '' } %>
31
+						<% end %>
32
+						<%= content_tag(:div, class: 'feature-stats') do %>
29 33
 							<% mission_agent_counter(@featured_missions) %>
30 34
 							<%= status(@featured_missions.status) %>
31 35
 							<% mission_steps_counter(@featured_missions) %>

+ 3 - 24
app/views/missions/show_agents.html.erb

@@ -21,29 +21,8 @@
21 21
 						          <%= content_tag(:p, agent.objective, class: 'thumbnail-agent-description') %>
22 22
 							<% end %>
23 23
 							<% # Steps %>
24
-							<% step_count = 0 %>
25
-							<% has_shown_more_tasks = false %>
26
-							<% agent.agent_steps.order('step ASC').each do |step| %>
27
-								<% step_count = step_count + 1 %>
28
-								<% if step_count <= 2 || agent.agent_steps.count <= 3 %>
29
-									<%= content_tag(:div, class: 'thumbnail-task') do %>
30
-										<%= content_tag(:p) do %>
31
-											<%= content_tag(:span, step.step, class: 'task-number') %>
32
-											<%= content_tag(:span, step.title, class: 'task-text') %>
33
-											<%= content_tag(:span, '<i class="fa fa-picture-o"></i>'.html_safe, class: 'task-icon pull-right') %>
34
-										<% end %>
35
-									<% end %>
36
-								<% else %>
37
-									<% if has_shown_more_tasks == false %>
38
-										<% has_shown_more_tasks = true %>
39
-										<%= content_tag(:div, class: 'thumbnail-task') do %>
40
-											<%= content_tag(:p, class: 'task-show-all') do %>
41
-												<%= content_tag(:span, ('+ ' + (agent.agent_steps.count - step_count).to_s + ' ' + (t 'mission.steps')).html_safe) %>
42
-											<% end %>
43
-										<% end %>
44
-									<% end %>
45
-								<% end %>
46
-							<% end %>
24
+							<%= render :partial => 'step_quick_list', locals: {agent: agent} %>
25
+
47 26
 							<% # Rewards %>
48 27
 							<%= content_tag(:div, class: 'thumbnail-content') do%>
49 28
 						          <%= content_tag(:h4, (t 'mission.rewards')) %>
@@ -74,7 +53,7 @@
74 53
 									<% end %>
75 54
 									<%= content_tag(:div, class: '') do %>
76 55
 										<%= content_tag(:p, agent.user.full_name, class: 'name') %>
77
-										<%= content_tag(:p, 'Hacker from São Paulo Brazil. Avalanche programer and Designer.', class: 'bio') %>
56
+										<%= content_tag(:p, agent.user.bio, class: 'bio') %>
78 57
 									<% end %>
79 58
 								<% end %>
80 59
 							<% end %>

+ 5 - 0
db/migrate/20150222233545_add_bio_to_users.rb

@@ -0,0 +1,5 @@
1
+class AddBioToUsers < ActiveRecord::Migration
2
+  def change
3
+    add_column :users, :bio, :string
4
+  end
5
+end

+ 2 - 1
db/schema.rb

@@ -11,7 +11,7 @@
11 11
 #
12 12
 # It's strongly recommended that you check this file into your version control system.
13 13
 
14
-ActiveRecord::Schema.define(version: 20150219012955) do
14
+ActiveRecord::Schema.define(version: 20150222233545) do
15 15
 
16 16
   # These are extensions that must be enabled in order to support this database
17 17
   enable_extension "plpgsql"
@@ -225,6 +225,7 @@ ActiveRecord::Schema.define(version: 20150219012955) do
225 225
     t.string   "avatar"
226 226
     t.string   "avatar_tmp"
227 227
     t.boolean  "avatar_processing",      default: false, null: false
228
+    t.string   "bio"
228 229
   end
229 230
 
230 231
   add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree