mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add template and basic controller for backoffice voucher pages
This commit is contained in:
10
app/controllers/admin/vouchers_controller.rb
Normal file
10
app/controllers/admin/vouchers_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class VouchersController < ResourceController
|
||||
|
||||
def new
|
||||
@enterprise = Enterprise.find_by permalink: params[:enterprise_id]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -34,6 +34,7 @@ module Admin
|
||||
{ name: 'shipping_methods', icon_class: "icon-truck", show: show_shipping_methods },
|
||||
{ name: 'payment_methods', icon_class: "icon-money", show: show_payment_methods },
|
||||
{ name: 'enterprise_fees', icon_class: "icon-tasks", show: show_enterprise_fees },
|
||||
{ name: 'vouchers', icon_class: "icon-ticket", show: true },
|
||||
{ name: 'enterprise_permissions', icon_class: "icon-plug", show: true,
|
||||
href: admin_enterprise_relationships_path },
|
||||
{ name: 'inventory_settings', icon_class: "icon-list-ol", show: is_shop },
|
||||
|
||||
33
app/views/admin/enterprises/form/_vouchers.html.haml
Normal file
33
app/views/admin/enterprises/form/_vouchers.html.haml
Normal file
@@ -0,0 +1,33 @@
|
||||
.text-right
|
||||
%a.button{ href: "#{new_admin_enterprise_voucher_path(@enterprise)}"}
|
||||
= t('.add_new')
|
||||
%br
|
||||
|
||||
- if @enterprise.vouchers.present?
|
||||
%table
|
||||
%thead
|
||||
%tr
|
||||
%th= t('.voucher_code')
|
||||
%th= t('.rate')
|
||||
%th= t('.label')
|
||||
%th= t('.purpose')
|
||||
%th= t('.expiry')
|
||||
%th= t('.use_limit')
|
||||
%th= t('.customers')
|
||||
%th= t('.net_value')
|
||||
%tbody
|
||||
- @enterprise.vouchers.each do |voucher|
|
||||
%tr
|
||||
%td= voucher.code
|
||||
%td= voucher.rate
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
|
||||
- else
|
||||
%p.text-center
|
||||
= t('.no_voucher_yet')
|
||||
|
||||
22
app/views/admin/vouchers/new.html.haml
Normal file
22
app/views/admin/vouchers/new.html.haml
Normal file
@@ -0,0 +1,22 @@
|
||||
.row
|
||||
.sixteen.columns.alpha
|
||||
.four.columns.alpha.text-right
|
||||
%a.button{ href: "#{edit_admin_enterprise_path(@enterprise)}#!#vouchers_panel"}
|
||||
= t('.back')
|
||||
.twelve.columns.omega
|
||||
.row
|
||||
.eight.columns.text-center
|
||||
%legend= t(".legend")
|
||||
.four.columns.text-right
|
||||
%input.red{ type: "button", value: t('.save') }
|
||||
.row
|
||||
.alpha.four.columns
|
||||
= label :voucher, :code, t('.voucher_code')
|
||||
.omega.eight.columns
|
||||
%textarea.fullwidth{ id: 'voucher_code', name: 'voucher_code', rows: 6 }
|
||||
.row
|
||||
.alpha.four.columns
|
||||
= label :voucher, :amount, t('.voucher_amount')
|
||||
.omega.eight.columns
|
||||
$
|
||||
%input{ type: 'text', id: 'voucher_amount', name: 'voucher_amount', value: 10, disabled: true }
|
||||
@@ -4,7 +4,7 @@
|
||||
= tab :orders, :subscriptions, :customer_details, :adjustments, :payments, :return_authorizations, url: admin_orders_path('q[s]' => 'completed_at desc'), icon: 'icon-shopping-cart'
|
||||
= tab :reports, url: main_app.admin_reports_path, icon: 'icon-file'
|
||||
= tab :general_settings, :mail_methods, :tax_categories, :tax_rates, :tax_settings, :zones, :countries, :states, :payment_methods, :taxonomies, :shipping_methods, :shipping_categories, :enterprise_fees, :contents, :invoice_settings, :matomo_settings, :stripe_connect_settings, label: 'configuration', icon: 'icon-wrench', url: edit_admin_general_settings_path
|
||||
= tab :enterprises, :enterprise_relationships, :oidc_settings, url: main_app.admin_enterprises_path
|
||||
= tab :enterprises, :enterprise_relationships, :vouchers, :oidc_settings, url: main_app.admin_enterprises_path
|
||||
= tab :customers, url: main_app.admin_customers_path
|
||||
= tab :enterprise_groups, url: main_app.admin_enterprise_groups_path, label: 'groups'
|
||||
- if can? :admin, Spree::User
|
||||
|
||||
@@ -1144,6 +1144,17 @@ en:
|
||||
add_unregistered_user: "Add an unregistered user"
|
||||
email_confirmed: "Email confirmed"
|
||||
email_not_confirmed: "Email not confirmed"
|
||||
vouchers:
|
||||
legend: Vouchers
|
||||
rate: Rate
|
||||
label: Label
|
||||
purpose: Purpose
|
||||
expiry: Expiry
|
||||
use_limit: Use/Limit
|
||||
customers: Customer
|
||||
net_value: Net Value
|
||||
add_new: Add New
|
||||
no_voucher_yet: No Vouchers yet
|
||||
actions:
|
||||
edit_profile: Settings
|
||||
properties: Properties
|
||||
@@ -1382,6 +1393,7 @@ en:
|
||||
tag_rules: "Tag Rules"
|
||||
shop_preferences: "Shop Preferences"
|
||||
users: "Users"
|
||||
vouchers: Vouchers
|
||||
enterprise_group:
|
||||
primary_details: "Primary Details"
|
||||
users: "Users"
|
||||
@@ -1590,6 +1602,13 @@ en:
|
||||
schedules:
|
||||
destroy:
|
||||
associated_subscriptions_error: This schedule cannot be deleted because it has associated subscriptions
|
||||
vouchers:
|
||||
new:
|
||||
legend: New Voucher
|
||||
back: Back
|
||||
save: Save
|
||||
voucher_code: Voucher Code
|
||||
voucher_amount: Amount
|
||||
|
||||
# Admin controllers
|
||||
controllers:
|
||||
|
||||
@@ -40,6 +40,9 @@ Openfoodnetwork::Application.routes.draw do
|
||||
end
|
||||
|
||||
resources :tag_rules, only: [:destroy]
|
||||
|
||||
# TODO do we need to remove more routes
|
||||
resources :vouchers, only: [:new, :create]
|
||||
end
|
||||
|
||||
resources :enterprise_relationships
|
||||
|
||||
Reference in New Issue
Block a user