OSDN Git Service

Ability to remvoe broadcast messages
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Tue, 12 Nov 2013 13:20:31 +0000 (15:20 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Tue, 12 Nov 2013 13:20:31 +0000 (15:20 +0200)
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/assets/stylesheets/sections/admin.scss
app/controllers/admin/broadcast_messages_controller.rb
app/views/admin/broadcast_messages/index.html.haml
config/routes.rb

index e189fd2..82556e9 100644 (file)
@@ -21,3 +21,9 @@
   .controls { margin-left: 130px; }
   .form-actions { padding-left: 130px; background: #fff }
 }
+
+.broadcast-messages {
+  .message {
+    line-height: 2;
+  }
+}
index 3ba8d09..9a70ef9 100644 (file)
@@ -15,6 +15,15 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
     end
   end
 
+  def destroy
+    BroadcastMessage.find(params[:id]).destroy
+
+    respond_to do |format|
+      format.html { redirect_to :back }
+      format.js { render nothing: true }
+    end
+  end
+
   protected
 
   def broadcast_messages
index 22f7b71..fc750a4 100644 (file)
@@ -25,7 +25,7 @@
     = f.submit "Add broadcast message", class: "btn btn-create"
 
 -if @broadcast_messages.any?
-  %ul.bordered-list
+  %ul.bordered-list.broadcast-messages
     - @broadcast_messages.each do |broadcast_message|
       %li
         .pull-right
           - if broadcast_message.ends_at
             %strong
               #{broadcast_message.ends_at.to_s(:short)}
+          &nbsp;
+          = link_to [:admin, broadcast_message], method: :delete, remote: true, class: 'remove-row btn btn-tiny' do
+            %i.icon-remove.cred
+
         .message= broadcast_message.message
 
+
   = paginate @broadcast_messages
index d41a078..3b69239 100644 (file)
@@ -86,7 +86,7 @@ Gitlab::Application.routes.draw do
       get :test
     end
 
-    resources :broadcast_messages, only: [:index, :create]
+    resources :broadcast_messages, only: [:index, :create, :destroy]
     resource :logs, only: [:show]
     resource :background_jobs, controller: 'background_jobs', only: [:show]
     resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show]