Browse Source

In-place notes editing!

Maarten van den Berg 8 years ago
parent
commit
90002cc9f4

+ 3 - 0
Gemfile

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

+ 3 - 0
Gemfile.lock

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

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

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

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

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

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

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

+ 3 - 0
app/controllers/activities_controller.rb

76
       render status: :forbidden
76
       render status: :forbidden
77
     end
77
     end
78
 
78
 
79
+    if params[:participant]
80
+      params[:notes] = params[:participant][:notes]
81
+    end
79
     participant.update_attributes(params.permit(:notes, :attending))
82
     participant.update_attributes(params.permit(:notes, :attending))
80
   end
83
   end
81
 
84
 

+ 4 - 0
app/helpers/dashboard_helper.rb

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

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

19
         <%= p.is_organizer %>
19
         <%= p.is_organizer %>
20
       </td>
20
       </td>
21
       <td>
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
       </td>
25
       </td>
24
       <td>
26
       <td>
25
         <%= render partial: "activities/presence_buttons", locals: {activity: @activity, person: p.person, state: p.attending} %>
27
         <%= render partial: "activities/presence_buttons", locals: {activity: @activity, person: p.person, state: p.attending} %>

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

84
                     = e.public_name
84
                     = e.public_name
85
                   %td
85
                   %td
86
                     = render partial: "activities/presence_buttons", locals: {activity: e, person: current_person, state: p.attending}
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