diff --git a/app/assets/images/trash.png b/app/assets/images/trash.png new file mode 100644 index 00000000..ab757426 Binary files /dev/null and b/app/assets/images/trash.png differ diff --git a/app/controllers/campaigns_controller.rb b/app/controllers/campaigns_controller.rb index 162e12ab..b0d494da 100644 --- a/app/controllers/campaigns_controller.rb +++ b/app/controllers/campaigns_controller.rb @@ -201,6 +201,20 @@ def checkout_confirmation redirect_to campaign_home_url(@campaign) end end + + def delete_reward + if @campaign.expired? + redirect_to campaign_home_url(@campaign), :flash => { :error => "Reward can't be Deleted, Campaign is Expired !" } + else + @r = Reward.find(params[:reward]) + if(@r.payments.length == 0) + @r.destroy + redirect_to campaign_home_url(@campaign), :flash => { :notice => "Reward Deleted!" } + else + redirect_to campaign_home_url(@campaign), :flash => { :error => "Reward can't be Deleted it has Payments !" } + end + end + end private diff --git a/app/views/theme/assets/stylesheets/campaign.css.scss b/app/views/theme/assets/stylesheets/campaign.css.scss index 6e0540eb..d1851503 100644 --- a/app/views/theme/assets/stylesheets/campaign.css.scss +++ b/app/views/theme/assets/stylesheets/campaign.css.scss @@ -233,6 +233,35 @@ margin: 0px; li { border-bottom: 1px solid gray; + &:hover{ + .rewards_toolbox{display:block;} + } + .rewards_toolbox{width:80px;height:26px;float:right;margin-top: 10px;display:none; + .toolbox_container{ + top:0.5em;right:1em; + list-style-type:none; + float:right; + padding:2px; + a{ + display: inline; + padding: 0px 0px; + &:hover { + text-decoration: none; + background: none; + } + } + &:hover { + border :1px solid #eee; + } + .toolbox_item{ + float:left; + background-color:#fff;box-shadow:0 0 2px #000; + margin-right:4px; + height:26px; + width:27px; + } + } + } &:last-child { border-bottom: none; a { diff --git a/app/views/theme/views/campaign.html.erb b/app/views/theme/views/campaign.html.erb index 326dacd5..fb05ab65 100644 --- a/app/views/theme/views/campaign.html.erb +++ b/app/views/theme/views/campaign.html.erb @@ -168,6 +168,9 @@ <% @campaign.rewards.order("price ASC").each do |reward| %> <% if reward.visible? %>
$<%= number_with_precision(reward.price, precision: (reward.price*100%100==0.0 ? 0 : 2)) %>
<%= reward.title %>
diff --git a/config/routes.rb b/config/routes.rb index e9c2878b..58aefc5a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,6 +28,7 @@ match '/ajax/verify', to: 'admin#ajax_verify', as: :ajax_verify # CAMPAIGNS + match '/:id/reward/delete', to: 'campaigns#delete_reward', as: :reward_controller_delete match '/:id/checkout/amount', to: 'campaigns#checkout_amount', as: :checkout_amount match '/:id/checkout/payment', to: 'campaigns#checkout_payment', as: :checkout_payment match '/:id/checkout/process', to: 'campaigns#checkout_process', as: :checkout_process