Description:
change announcement toggle into bootstrap button with processing state
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r557:47db9776ed2e - - 8 files changed: 75 inserted, 56 deleted
@@ -0,0 +1,15 | |||||
|
|
1 | + #js for announcement | ||
|
|
2 | + $ -> | ||
|
|
3 | + $('.ajax-toggle').on 'click', (event) -> | ||
|
|
4 | + console.log event.target.id | ||
|
|
5 | + target = $(event.target) | ||
|
|
6 | + target.removeClass 'btn-default' | ||
|
|
7 | + target.removeClass 'btn-success' | ||
|
|
8 | + target.addClass 'btn-warning' | ||
|
|
9 | + target.text '...' | ||
|
|
10 | + return | ||
|
|
11 | + | ||
|
|
12 | + $(document).ajaxError (event, jqxhr, settings, exception) -> | ||
|
|
13 | + if jqxhr.status | ||
|
|
14 | + alert 'We\'re sorry, but something went wrong (' + jqxhr.status + ')' | ||
|
|
15 | + return |
@@ -0,0 +1,37 | |||||
|
|
1 | + %h1 Listing announcements | ||
|
|
2 | + | ||
|
|
3 | + = link_to '+ Add announcement', new_announcement_path, class: 'btn btn-success' | ||
|
|
4 | + %br | ||
|
|
5 | + %br | ||
|
|
6 | + | ||
|
|
7 | + %table.table.table-striped | ||
|
|
8 | + %tr | ||
|
|
9 | + %th Updated | ||
|
|
10 | + %th Announcement | ||
|
|
11 | + %th Author | ||
|
|
12 | + %th Published | ||
|
|
13 | + %th | ||
|
|
14 | + %th | ||
|
|
15 | + - for announcement in @announcements | ||
|
|
16 | + %tr | ||
|
|
17 | + - @announcement = announcement | ||
|
|
18 | + %td= time_ago_in_words announcement.updated_at | ||
|
|
19 | + %td | ||
|
|
20 | + - if !announcement.title.blank? | ||
|
|
21 | + %b Title: | ||
|
|
22 | + = h announcement.title | ||
|
|
23 | + %br/ | ||
|
|
24 | + - if !announcement.notes.blank? | ||
|
|
25 | + %b | ||
|
|
26 | + Notes: #{h announcement.notes} | ||
|
|
27 | + %br/ | ||
|
|
28 | + = h announcement.body | ||
|
|
29 | + %td= h announcement.author | ||
|
|
30 | + // %td= check_box_tag :published, 1, announcement.published, { class: 'bootstrap-toggle', id: "published-#{announcement.id}", data: {remote: true, method: 'PUT', url: url_for(controller: :announcements, action: :toggle, id: announcement), size: 'small', toggle: 'toggle' } } | ||
|
|
31 | + // <td><haml_loud> in_place_editor_field :announcement, :published, {}, :rows => 1 </haml_loud></td> | ||
|
|
32 | + %td= link_to (announcement.published? ? "Yes" : "No"), url_for(controller: :announcements, action: :toggle, id: announcement), { class: "btn btn-block btn-sm btn-#{(announcement.published? ? 'success' : 'default')} ajax-toggle", id: "published-#{announcement.id}", data: {remote: true, method: 'post' } } | ||
|
|
33 | + %td= link_to 'Edit', edit_announcement_path(announcement), class: 'btn btn-block btn-sm btn-info' | ||
|
|
34 | + %td= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete, class: "btn btn-block btn-sm btn-danger" | ||
|
|
35 | + %br | ||
|
|
36 | + | ||
|
|
37 | + = link_to '+ Add announcement', new_announcement_path, class: 'btn btn-success' |
@@ -0,0 +1,8 | |||||
|
|
1 | + :plain | ||
|
|
2 | + var t = $("#published-#{@announcement.id}"); | ||
|
|
3 | + t.removeClass('btn-default'); | ||
|
|
4 | + t.removeClass('btn-success'); | ||
|
|
5 | + t.removeClass('btn-warning'); | ||
|
|
6 | + t.addClass("btn-#{@announcement.published? ? 'success' : 'default'}"); | ||
|
|
7 | + t.attr("data-params","published=#{!@announcement.published?}"); | ||
|
|
8 | + t.text("#{@announcement.published? ? "Yes" : "No"}"); |
@@ -64,59 +64,59 | |||||
|
64 | padding-top: 100px |
|
64 | padding-top: 100px |
|
65 |
|
65 | ||
|
66 |
|
66 | ||
|
67 | input |
|
67 | input |
|
68 | font-family: Tahoma, "sans-serif" |
|
68 | font-family: Tahoma, "sans-serif" |
|
69 |
|
69 | ||
|
70 |
|
70 | ||
|
71 | h1 |
|
71 | h1 |
|
72 | font-size: 24px |
|
72 | font-size: 24px |
|
73 | color: #334488 |
|
73 | color: #334488 |
|
74 | line-height: 2em |
|
74 | line-height: 2em |
|
75 |
|
75 | ||
|
76 |
|
76 | ||
|
77 | h2 |
|
77 | h2 |
|
78 | font-size: 18px |
|
78 | font-size: 18px |
|
79 | color: #5566bb |
|
79 | color: #5566bb |
|
80 | line-height: 1.5em |
|
80 | line-height: 1.5em |
|
81 |
|
81 | ||
|
82 |
|
82 | ||
|
83 | hr |
|
83 | hr |
|
84 | border-top: 1px solid #dddddd |
|
84 | border-top: 1px solid #dddddd |
|
85 | border-bottom: 1px solid #eeeeee |
|
85 | border-bottom: 1px solid #eeeeee |
|
86 |
|
86 | ||
|
87 |
|
87 | ||
|
88 | - a |
|
88 | + //#a |
|
89 |
- |
|
89 | + // color: #6666cc |
|
90 |
- |
|
90 | + // text-decoration: none |
|
91 | - |
|
91 | + // |
|
92 |
- |
|
92 | + // &:link, &:visited |
|
93 |
- |
|
93 | + // color: #6666cc |
|
94 |
- |
|
94 | + // text-decoration: none |
|
95 | - |
|
95 | + // |
|
96 |
- |
|
96 | + // &:hover, &:focus |
|
97 |
- |
|
97 | + // color: #111166 |
|
98 |
- |
|
98 | + // text-decoration: none |
|
99 |
|
99 | ||
|
100 |
|
100 | ||
|
101 | div |
|
101 | div |
|
102 | &.userbar |
|
102 | &.userbar |
|
103 | line-height: 1.5em |
|
103 | line-height: 1.5em |
|
104 | text-align: right |
|
104 | text-align: right |
|
105 | font-size: 12px |
|
105 | font-size: 12px |
|
106 |
|
106 | ||
|
107 | &.title |
|
107 | &.title |
|
108 | padding: 10px 0px |
|
108 | padding: 10px 0px |
|
109 | line-height: 1.5em |
|
109 | line-height: 1.5em |
|
110 | font-size: 13px |
|
110 | font-size: 13px |
|
111 |
|
111 | ||
|
112 | span.contest-over-msg |
|
112 | span.contest-over-msg |
|
113 | font-size: 15px |
|
113 | font-size: 15px |
|
114 | color: red |
|
114 | color: red |
|
115 |
|
115 | ||
|
116 | table |
|
116 | table |
|
117 | width: 100% |
|
117 | width: 100% |
|
118 | font-weight: bold |
|
118 | font-weight: bold |
|
119 |
|
119 | ||
|
120 | td |
|
120 | td |
|
121 | &.left-col |
|
121 | &.left-col |
|
122 | text-align: left |
|
122 | text-align: left |
@@ -60,42 +60,42 | |||||
|
60 | end |
|
60 | end |
|
61 | end |
|
61 | end |
|
62 |
|
62 | ||
|
63 | # PUT /announcements/1 |
|
63 | # PUT /announcements/1 |
|
64 | # PUT /announcements/1.xml |
|
64 | # PUT /announcements/1.xml |
|
65 | def update |
|
65 | def update |
|
66 | @announcement = Announcement.find(params[:id]) |
|
66 | @announcement = Announcement.find(params[:id]) |
|
67 |
|
67 | ||
|
68 | respond_to do |format| |
|
68 | respond_to do |format| |
|
69 | if @announcement.update_attributes(params[:announcement]) |
|
69 | if @announcement.update_attributes(params[:announcement]) |
|
70 | flash[:notice] = 'Announcement was successfully updated.' |
|
70 | flash[:notice] = 'Announcement was successfully updated.' |
|
71 | format.html { redirect_to(@announcement) } |
|
71 | format.html { redirect_to(@announcement) } |
|
72 | format.js {} |
|
72 | format.js {} |
|
73 | format.xml { head :ok } |
|
73 | format.xml { head :ok } |
|
74 | else |
|
74 | else |
|
75 | format.html { render :action => "edit" } |
|
75 | format.html { render :action => "edit" } |
|
76 | format.js {} |
|
76 | format.js {} |
|
77 | format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity } |
|
77 | format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity } |
|
78 | end |
|
78 | end |
|
79 | end |
|
79 | end |
|
80 | end |
|
80 | end |
|
81 |
|
81 | ||
|
82 | def toggle |
|
82 | def toggle |
|
83 | @announcement = Announcement.find(params[:id]) |
|
83 | @announcement = Announcement.find(params[:id]) |
|
84 |
- @announcement.update_attributes( published: |
|
84 | + @announcement.update_attributes( published: !@announcement.published? ) |
|
85 | respond_to do |format| |
|
85 | respond_to do |format| |
|
86 | format.js {} |
|
86 | format.js {} |
|
87 | end |
|
87 | end |
|
88 | end |
|
88 | end |
|
89 |
|
89 | ||
|
90 | # DELETE /announcements/1 |
|
90 | # DELETE /announcements/1 |
|
91 | # DELETE /announcements/1.xml |
|
91 | # DELETE /announcements/1.xml |
|
92 | def destroy |
|
92 | def destroy |
|
93 | @announcement = Announcement.find(params[:id]) |
|
93 | @announcement = Announcement.find(params[:id]) |
|
94 | @announcement.destroy |
|
94 | @announcement.destroy |
|
95 |
|
95 | ||
|
96 | respond_to do |format| |
|
96 | respond_to do |format| |
|
97 | format.html { redirect_to(announcements_url) } |
|
97 | format.html { redirect_to(announcements_url) } |
|
98 | format.xml { head :ok } |
|
98 | format.xml { head :ok } |
|
99 | end |
|
99 | end |
|
100 | end |
|
100 | end |
|
101 | end |
|
101 | end |
@@ -1,15 +1,15 | |||||
|
1 | <!DOCTYPE html> |
|
1 | <!DOCTYPE html> |
|
2 | %html |
|
2 | %html |
|
3 | %head |
|
3 | %head |
|
4 | %title= GraderConfiguration['contest.name'] |
|
4 | %title= GraderConfiguration['contest.name'] |
|
5 | - = stylesheet_link_tag "application", :media => "all" |
|
5 | + = stylesheet_link_tag "application", params[:controller], :media => "all" |
|
6 | - = javascript_include_tag "application" |
|
6 | + = javascript_include_tag "application", params[:controller] |
|
7 | = csrf_meta_tags |
|
7 | = csrf_meta_tags |
|
8 | = content_for :header |
|
8 | = content_for :header |
|
9 | = yield :head |
|
9 | = yield :head |
|
10 |
|
10 | ||
|
11 | %body |
|
11 | %body |
|
12 | = render 'layouts/header' |
|
12 | = render 'layouts/header' |
|
13 |
|
13 | ||
|
14 | = content_tag(:p,flash[:notice],:style => "color:green") if flash[:notice]!=nil |
|
14 | = content_tag(:p,flash[:notice],:style => "color:green") if flash[:notice]!=nil |
|
15 | = yield |
|
15 | = yield |
@@ -1,27 +1,27 | |||||
|
1 | CafeGrader::Application.routes.draw do |
|
1 | CafeGrader::Application.routes.draw do |
|
2 | root :to => 'main#login' |
|
2 | root :to => 'main#login' |
|
3 |
|
3 | ||
|
4 | get "report/login" |
|
4 | get "report/login" |
|
5 |
|
5 | ||
|
6 | resources :contests |
|
6 | resources :contests |
|
7 |
|
7 | ||
|
8 | resources :announcements |
|
8 | resources :announcements |
|
9 |
- match 'announcements/toggle/:id' => 'announcements#toggle' |
|
9 | + match 'announcements/toggle/:id' => 'announcements#toggle' |
|
10 |
|
10 | ||
|
11 | resources :sites |
|
11 | resources :sites |
|
12 |
|
12 | ||
|
13 | resources :grader_configuration, controller: 'configurations' |
|
13 | resources :grader_configuration, controller: 'configurations' |
|
14 |
|
14 | ||
|
15 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
15 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
16 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
16 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
17 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
17 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
18 |
|
18 | ||
|
19 | #main |
|
19 | #main |
|
20 | get "main/list" |
|
20 | get "main/list" |
|
21 |
|
21 | ||
|
22 | # See how all your routes lay out with "rake routes" |
|
22 | # See how all your routes lay out with "rake routes" |
|
23 |
|
23 | ||
|
24 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
24 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
25 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
25 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
26 | match ':controller(/:action(/:id))(.:format)' |
|
26 | match ':controller(/:action(/:id))(.:format)' |
|
27 | end |
|
27 | end |
deleted file |
You need to be logged in to leave comments.
Login now