Browse Source

In-place notes editing!

Maarten van den Berg 8 years ago
parent
commit
90002cc9f4

+ 3 - 0
Gemfile

@@ -31,6 +31,9 @@ gem 'bcrypt', '~> 3.1.7'
31 31
 gem 'bootstrap-sass', '~> 3.3.6'
32 32
 gem 'autoprefixer-rails'
33 33
 
34
+# In-place editing
35
+gem 'x-editable-rails'
36
+
34 37
 # Use HAML for templates
35 38
 gem 'haml'
36 39
 

+ 3 - 0
Gemfile.lock

@@ -159,6 +159,8 @@ GEM
159 159
     websocket-driver (0.6.4)
160 160
       websocket-extensions (>= 0.1.0)
161 161
     websocket-extensions (0.1.2)
162
+    x-editable-rails (1.5.5)
163
+      railties
162 164
     yard (0.9.5)
163 165
 
164 166
 PLATFORMS
@@ -185,6 +187,7 @@ DEPENDENCIES
185 187
   tzinfo-data
186 188
   uglifier (>= 1.3.0)
187 189
   web-console
190
+  x-editable-rails
188 191
   yard
189 192
 
190 193
 BUNDLED WITH

+ 3 - 0
app/assets/javascripts/application.js

@@ -14,4 +14,7 @@
14 14
 //= require jquery_ujs
15 15
 //= require turbolinks
16 16
 //= require bootstrap-sprockets
17
+//= require editable/bootstrap-editable
18
+//= require editable/rails
17 19
 //= require_tree .
20
+

+ 1 - 0
app/assets/javascripts/buttonhandlers.js

@@ -6,6 +6,7 @@ $(setup_handlers);
6 6
 function setup_handlers()
7 7
 {
8 8
   $('.btn-presence').on("click", change_presence);
9
+  $('.editable').editable();
9 10
 }
10 11
 
11 12
 // Callback that is triggered when a presence button is clicked.

+ 2 - 0
app/assets/stylesheets/application.scss

@@ -19,6 +19,8 @@
19 19
 @import "font-awesome-sprockets";
20 20
 @import "font-awesome";
21 21
 
22
+@import "editable/bootstrap-editable";
23
+
22 24
 /* Horizontally distribute ul items.
23 25
  *
24 26
  * Adapted from the following StackOverflow answer:

+ 3 - 0
app/controllers/activities_controller.rb

@@ -76,6 +76,9 @@ class ActivitiesController < ApplicationController
76 76
       render status: :forbidden
77 77
     end
78 78
 
79
+    if params[:participant]
80
+      params[:notes] = params[:participant][:notes]
81
+    end
79 82
     participant.update_attributes(params.permit(:notes, :attending))
80 83
   end
81 84
 

+ 4 - 0
app/helpers/dashboard_helper.rb

@@ -1,2 +1,6 @@
1 1
 module DashboardHelper
2
+  def xeditable? obj = nil
3
+    obj.activity.may_change? current_person
4
+    true
5
+  end
2 6
 end

+ 3 - 1
app/views/activities/show.html.erb

@@ -19,7 +19,9 @@
19 19
         <%= p.is_organizer %>
20 20
       </td>
21 21
       <td>
22
-        <%= p.attending %>
22
+        <%=
23
+          editable p, :notes, url: presence_group_activity_path(@activity.group, @activity, person_id: p.person_id), title: "Notes", value: p.notes
24
+        %>
23 25
       </td>
24 26
       <td>
25 27
         <%= render partial: "activities/presence_buttons", locals: {activity: @activity, person: p.person, state: p.attending} %>

+ 2 - 0
app/views/dashboard/home.html.haml

@@ -84,3 +84,5 @@
84 84
                     = e.public_name
85 85
                   %td
86 86
                     = render partial: "activities/presence_buttons", locals: {activity: e, person: current_person, state: p.attending}
87
+                  %td
88
+                    = editable p, :notes, url: presence_group_activity_path(e.group, e, person_id: current_person.id), title: "Notes", value: p.notes