mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Add an API endpoint for EnterpriseFeesController#destroy
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
angular.module('admin.enterpriseFees').directive 'spreeDeleteResource', ->
|
||||
(scope, element, attrs) ->
|
||||
if scope.enterprise_fee.id
|
||||
url = '/admin/enterprise_fees/' + scope.enterprise_fee.id
|
||||
url = '/api/enterprise_fees/' + scope.enterprise_fee.id
|
||||
html = '<a href="' + url + '" class="delete-resource icon_link icon-trash no-text" data-action="remove" data-confirm="' + t('are_you_sure') + '" url="' + url + '"></a>'
|
||||
#var html = '<a href="'+url+'" class="delete-resource" data-confirm="Are you sure?"><img alt="Delete" src="/assets/admin/icons/delete.png" /> Delete</a>';
|
||||
element.append html
|
||||
|
||||
21
app/controllers/api/enterprise_fees_controller.rb
Normal file
21
app/controllers/api/enterprise_fees_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
module Api
|
||||
class EnterpriseFeesController < BaseController
|
||||
respond_to :json
|
||||
|
||||
def destroy
|
||||
authorize! :destroy, enterprise_fee
|
||||
|
||||
if enterprise_fee.destroy
|
||||
render text: I18n.t(:successfully_removed), status: 204
|
||||
else
|
||||
render text: enterprise_fee.errors.full_messages.first, status: 403
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def enterprise_fee
|
||||
@enterprise_fee ||= EnterpriseFee.find_by_id params[:id]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -111,6 +111,8 @@ Openfoodnetwork::Application.routes.draw do
|
||||
|
||||
resources :customers, only: [:index, :update]
|
||||
|
||||
resources :enterprise_fees, only: [:destroy]
|
||||
|
||||
post '/product_images/:product_id', to: 'product_images#update_product_image'
|
||||
end
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ Openfoodnetwork::Application.routes.draw do
|
||||
resources :enterprise_relationships
|
||||
resources :enterprise_roles
|
||||
|
||||
resources :enterprise_fees do
|
||||
resources :enterprise_fees, except: :destroy do
|
||||
collection do
|
||||
get :for_order_cycle
|
||||
post :bulk_update, :as => :bulk_update
|
||||
|
||||
Reference in New Issue
Block a user