mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Compare commits
116 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e658eb9dd | ||
|
|
c9d36e6f5c | ||
|
|
0f4c8d8ecc | ||
|
|
6553136d2d | ||
|
|
9cbdc8293d | ||
|
|
6d1d688b1d | ||
|
|
af1e26e9e1 | ||
|
|
6a50f68b52 | ||
|
|
a137bdd00e | ||
|
|
b593ef78ea | ||
|
|
9e5bc9ba0c | ||
|
|
1953d2164b | ||
|
|
e82e93e1cc | ||
|
|
78bbee49e9 | ||
|
|
5b5693dc26 | ||
|
|
f170b4241d | ||
|
|
bdc7444422 | ||
|
|
53ffdaf6de | ||
|
|
37c6f11e05 | ||
|
|
45fad30f7b | ||
|
|
3e689b46d0 | ||
|
|
98db38b0cc | ||
|
|
7348ceca64 | ||
|
|
ea21469ff6 | ||
|
|
6000d4c985 | ||
|
|
f2bd45162b | ||
|
|
536d4b9894 | ||
|
|
17d7270a32 | ||
|
|
a259444129 | ||
|
|
5c3e03b86b | ||
|
|
62fd374262 | ||
|
|
02a10ede15 | ||
|
|
58c0d30af3 | ||
|
|
4336350140 | ||
|
|
a3c31f7d86 | ||
|
|
cd992ee866 | ||
|
|
6ee9daf768 | ||
|
|
957f834694 | ||
|
|
d73df78f43 | ||
|
|
d086f7694a | ||
|
|
b2fb0366f7 | ||
|
|
f4c86a1b51 | ||
|
|
02bcb7bcc7 | ||
|
|
d55a3f3340 | ||
|
|
47346e9f2c | ||
|
|
f28200164b | ||
|
|
6e674b47ac | ||
|
|
0c879dc4c9 | ||
|
|
a1f7d8753b | ||
|
|
9d216f0cea | ||
|
|
16aeb16519 | ||
|
|
2f5f2a03dd | ||
|
|
8c78316718 | ||
|
|
841a7a31fa | ||
|
|
6d9173deba | ||
|
|
ba09618374 | ||
|
|
82a8eed652 | ||
|
|
77ca05ebe5 | ||
|
|
da912d2fdf | ||
|
|
297dc56fe5 | ||
|
|
b0b91c959e | ||
|
|
a7e9acd435 | ||
|
|
d75b03debd | ||
|
|
685a3eb14f | ||
|
|
757b7513ef | ||
|
|
94ff59ebab | ||
|
|
a065a92616 | ||
|
|
aed84912a3 | ||
|
|
1ec9cce439 | ||
|
|
5811b6e3d1 | ||
|
|
98a879a0e9 | ||
|
|
98ff3980f8 | ||
|
|
eb17c208f9 | ||
|
|
fa9f6432c3 | ||
|
|
6ac835de2e | ||
|
|
696d434979 | ||
|
|
48c1312cea | ||
|
|
0c240cee9a | ||
|
|
f90e34bb47 | ||
|
|
9de9b41575 | ||
|
|
60a8ae6675 | ||
|
|
5434b51f75 | ||
|
|
93118f9c32 | ||
|
|
43e6d1b933 | ||
|
|
10c2a1c55c | ||
|
|
9affc6a945 | ||
|
|
e013d81e3d | ||
|
|
868187aaaf | ||
|
|
12c154934d | ||
|
|
b352476301 | ||
|
|
4eda15fb71 | ||
|
|
95e294c9ec | ||
|
|
4806ba540f | ||
|
|
2de75ef7f4 | ||
|
|
d4f7b318e7 | ||
|
|
f883e66c96 | ||
|
|
44b870d248 | ||
|
|
1d5077061e | ||
|
|
086c5ab264 | ||
|
|
8bf3f72ad3 | ||
|
|
5ef34347a3 | ||
|
|
e48b9d84e5 | ||
|
|
03abc395f2 | ||
|
|
7fa9457550 | ||
|
|
edb599b426 | ||
|
|
062a3abc2d | ||
|
|
6b028ba849 | ||
|
|
23779fd5e4 | ||
|
|
20ff594014 | ||
|
|
9be73a8ff1 | ||
|
|
10f6368524 | ||
|
|
a23171ea51 | ||
|
|
658f0eccbb | ||
|
|
b29d88be25 | ||
|
|
79efa50a34 | ||
|
|
c156d0c2e6 |
3
Gemfile
3
Gemfile
@@ -57,7 +57,6 @@ gem 'oauth2', '~> 1.4.7' # Used for Stripe Connect
|
||||
|
||||
gem 'pagy', '~> 4.11'
|
||||
|
||||
gem 'andand'
|
||||
gem 'angularjs-rails', '1.8.0'
|
||||
gem 'aws-sdk', '1.67.0'
|
||||
gem 'bugsnag'
|
||||
@@ -90,6 +89,8 @@ gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
|
||||
gem 'sidekiq'
|
||||
gem 'sidekiq-scheduler'
|
||||
|
||||
gem "cable_ready", "5.0.0.pre2"
|
||||
|
||||
gem 'combine_pdf'
|
||||
gem 'wicked_pdf'
|
||||
gem 'wkhtmltopdf-binary'
|
||||
|
||||
31
Gemfile.lock
31
Gemfile.lock
@@ -102,7 +102,7 @@ GEM
|
||||
activejob (6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
globalid (>= 0.3.6)
|
||||
activemerchant (1.121.0)
|
||||
activemerchant (1.123.0)
|
||||
activesupport (>= 4.2)
|
||||
builder (>= 2.1.2, < 4.0.0)
|
||||
i18n (>= 0.6.9)
|
||||
@@ -142,7 +142,6 @@ GEM
|
||||
addressable (2.8.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
afm (0.2.2)
|
||||
andand (1.3.3)
|
||||
angular-rails-templates (1.1.0)
|
||||
railties (>= 4.2, < 7)
|
||||
sprockets (>= 3.0, < 5)
|
||||
@@ -163,15 +162,18 @@ GEM
|
||||
bcrypt (3.1.16)
|
||||
bigdecimal (3.0.2)
|
||||
bindex (0.8.1)
|
||||
bootsnap (1.8.1)
|
||||
bootsnap (1.9.1)
|
||||
msgpack (~> 1.0)
|
||||
bugsnag (6.22.1)
|
||||
bugsnag (6.23.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
builder (3.2.4)
|
||||
bullet (6.1.5)
|
||||
activesupport (>= 3.0.0)
|
||||
uniform_notifier (~> 1.11)
|
||||
byebug (11.1.3)
|
||||
cable_ready (5.0.0.pre2)
|
||||
rails (>= 5.2)
|
||||
thread-local (>= 1.1.0)
|
||||
cancancan (1.15.0)
|
||||
capybara (3.35.3)
|
||||
addressable
|
||||
@@ -388,7 +390,7 @@ GEM
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
nio4r (2.5.8)
|
||||
nokogiri (1.12.3)
|
||||
nokogiri (1.12.5)
|
||||
mini_portile2 (~> 2.6.1)
|
||||
racc (~> 1.4)
|
||||
oauth2 (1.4.7)
|
||||
@@ -408,7 +410,7 @@ GEM
|
||||
activesupport (>= 3.0.0)
|
||||
cocaine (~> 0.5.0)
|
||||
mime-types
|
||||
parallel (1.20.1)
|
||||
parallel (1.21.0)
|
||||
paranoia (2.4.3)
|
||||
activerecord (>= 4.0, < 6.2)
|
||||
parser (3.0.2.0)
|
||||
@@ -433,7 +435,7 @@ GEM
|
||||
byebug (~> 11.0)
|
||||
pry (~> 0.13.0)
|
||||
public_suffix (4.0.6)
|
||||
puma (5.4.0)
|
||||
puma (5.5.0)
|
||||
nio4r (~> 2.0)
|
||||
raabro (1.4.0)
|
||||
racc (1.5.2)
|
||||
@@ -472,7 +474,7 @@ GEM
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.4.1)
|
||||
rails-html-sanitizer (1.4.2)
|
||||
loofah (~> 2.3)
|
||||
rails-i18n (6.0.0)
|
||||
i18n (>= 0.7, < 2)
|
||||
@@ -547,7 +549,7 @@ GEM
|
||||
rswag-ui (2.4.0)
|
||||
actionpack (>= 3.1, < 7.0)
|
||||
railties (>= 3.1, < 7.0)
|
||||
rubocop (1.20.0)
|
||||
rubocop (1.21.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.0.0.0)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
@@ -558,7 +560,7 @@ GEM
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.11.0)
|
||||
parser (>= 3.0.1.1)
|
||||
rubocop-rails (2.12.0)
|
||||
rubocop-rails (2.12.2)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
@@ -620,9 +622,10 @@ GEM
|
||||
stripe (5.38.0)
|
||||
temple (0.8.2)
|
||||
test-prof (1.0.7)
|
||||
test-unit (3.4.5)
|
||||
test-unit (3.4.7)
|
||||
power_assert
|
||||
thor (1.1.0)
|
||||
thread-local (1.1.0)
|
||||
thwait (0.2.0)
|
||||
e2mmap
|
||||
tilt (2.0.10)
|
||||
@@ -637,7 +640,7 @@ GEM
|
||||
valid_email2 (4.0.0)
|
||||
activemodel (>= 3.2)
|
||||
mail (~> 2.5)
|
||||
view_component (2.39.0)
|
||||
view_component (2.40.0)
|
||||
activesupport (>= 5.0.0, < 8.0)
|
||||
method_source (~> 1.0)
|
||||
view_component_storybook (0.10.1)
|
||||
@@ -657,7 +660,7 @@ GEM
|
||||
addressable (>= 2.8.0)
|
||||
crack (>= 0.3.2)
|
||||
hashdiff (>= 0.4.0, < 2.0.0)
|
||||
webpacker (5.4.2)
|
||||
webpacker (5.4.3)
|
||||
activesupport (>= 5.2)
|
||||
rack-proxy (>= 0.6.1)
|
||||
railties (>= 5.2)
|
||||
@@ -687,7 +690,6 @@ DEPENDENCIES
|
||||
activerecord-session_store
|
||||
acts-as-taggable-on (~> 8.1)
|
||||
acts_as_list (= 1.0.4)
|
||||
andand
|
||||
angular-rails-templates (>= 0.3.0)
|
||||
angular_rails_csrf
|
||||
angularjs-file-upload-rails (~> 2.4.1)
|
||||
@@ -700,6 +702,7 @@ DEPENDENCIES
|
||||
bugsnag
|
||||
bullet
|
||||
byebug
|
||||
cable_ready (= 5.0.0.pre2)
|
||||
cancancan (~> 1.15.0)
|
||||
capybara
|
||||
catalog!
|
||||
|
||||
@@ -48,7 +48,7 @@ angular.module("admin.products").factory "OptionValueNamer", (VariantUnitManager
|
||||
option_value_value_unit_scaled: ->
|
||||
[unit_scale, unit_name] = @scale_for_unit_value()
|
||||
|
||||
value = @variant.unit_value / unit_scale
|
||||
value = Math.round((@variant.unit_value / unit_scale) * 100) / 100
|
||||
|
||||
[value, unit_name]
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
initAlert()
|
||||
initConfirm()
|
||||
|
||||
if ($('#variant_autocomplete_template').length > 0) {
|
||||
window.variantTemplate = Handlebars.compile($('#variant_autocomplete_template').text());
|
||||
window.variantStockTemplate = Handlebars.compile($('#variant_autocomplete_stock_template').text());
|
||||
@@ -45,7 +48,7 @@ $(document).ready(function() {
|
||||
if (quantity > maxQuantity) {
|
||||
quantity = maxQuantity;
|
||||
save.parents('tr').find('input.line_item_quantity').val(maxQuantity);
|
||||
alert(t("js.admin.orders.quantity_adjusted"));
|
||||
ofnAlert(t("js.admin.orders.quantity_adjusted"));
|
||||
}
|
||||
toggleItemEdit();
|
||||
|
||||
@@ -54,18 +57,23 @@ $(document).ready(function() {
|
||||
}
|
||||
$('a.save-item').click(handle_save_click);
|
||||
|
||||
handle_delete_click = function(e, confirmed){
|
||||
if (confirmed) {
|
||||
var del = $(this);
|
||||
var shipment_number = del.data('shipment-number');
|
||||
var variant_id = del.data('variant-id');
|
||||
handle_delete_click = function(elementSelector){
|
||||
var del = $(elementSelector);
|
||||
del.hide()
|
||||
var shipment_number = del.data('shipment-number');
|
||||
var variant_id = del.data('variant-id');
|
||||
|
||||
toggleItemEdit();
|
||||
toggleItemEdit();
|
||||
|
||||
adjustItems(shipment_number, variant_id, 0);
|
||||
}
|
||||
adjustItems(shipment_number, variant_id, 0);
|
||||
}
|
||||
$('a.delete-item').on('confirm:complete', handle_delete_click);
|
||||
|
||||
$('a.delete-item').click((event) => {
|
||||
ofnConfirm(() => {
|
||||
handle_delete_click('#custom-confirm');
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -74,7 +82,7 @@ adjustItems = function(shipment_number, variant_id, quantity){
|
||||
var inventory_units = _.where(shipment.inventory_units, {variant_id: variant_id});
|
||||
|
||||
if (quantity == 0 && inventory_units.length == shipment.inventory_units.length) {
|
||||
alert(t("js.admin.orders.cannot_remove_last_item"));
|
||||
ofnAlert(t("js.admin.orders.cannot_remove_last_item"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -91,7 +99,7 @@ adjustItems = function(shipment_number, variant_id, quantity){
|
||||
url += '.json';
|
||||
|
||||
if (new_quantity == 0) {
|
||||
alert(t("js.admin.orders.quantity_unchanged"));
|
||||
ofnAlert(t("js.admin.orders.quantity_unchanged"));
|
||||
} else {
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
@@ -154,3 +162,27 @@ addVariantFromStockLocation = function() {
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
initAlert = function() {
|
||||
$('#custom-alert .confirm').click(function(e) {
|
||||
$('#custom-alert').hide();
|
||||
})
|
||||
}
|
||||
|
||||
initConfirm = function() {
|
||||
$('#custom-confirm button.cancel').click(function(e) {
|
||||
$('#custom-confirm').hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
ofnAlert = function(message) {
|
||||
$('#custom-alert .message').text(message);
|
||||
$('#custom-alert').show();
|
||||
}
|
||||
|
||||
ofnConfirm = function(callback) {
|
||||
$('#custom-confirm').data($(event.target).data());
|
||||
$('#custom-confirm button.confirm').click(callback);
|
||||
$('#custom-confirm').show();
|
||||
}
|
||||
|
||||
@@ -54,3 +54,23 @@
|
||||
#= require_tree ./mixins
|
||||
#= require_tree ./directives
|
||||
#= require_tree .
|
||||
|
||||
document.addEventListener "turbo:load", ->
|
||||
window.injector = angular.bootstrap document.body, ["Darkswarm"]
|
||||
true
|
||||
|
||||
document.addEventListener "turbo:before-render", ->
|
||||
if window.injector
|
||||
rootscope = window.injector.get("$rootScope")
|
||||
rootscope?.$destroy()
|
||||
rootscope = null
|
||||
window.injector = null
|
||||
true
|
||||
|
||||
document.addEventListener "ajax:beforeSend", (event) =>
|
||||
window.Turbo.navigator.adapter.progressBar.setValue(0)
|
||||
window.Turbo.navigator.adapter.progressBar.show()
|
||||
|
||||
document.addEventListener "ajax:complete", (event) =>
|
||||
window.Turbo.navigator.adapter.progressBar.setValue(100)
|
||||
window.Turbo.navigator.adapter.progressBar.hide()
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
angular.module('Darkswarm').directive "confirmLinkClick", ($window) ->
|
||||
restrict: 'A'
|
||||
scope:
|
||||
confirmMsg: '@confirmLinkClick'
|
||||
link: (scope, elem, attr) ->
|
||||
elem.bind 'click', (event) ->
|
||||
unless confirm(scope.confirmMsg)
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
@@ -134,3 +134,33 @@ table.index td.actions {
|
||||
color: $warning-red;
|
||||
}
|
||||
}
|
||||
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0,0,0,0.4);
|
||||
text-align: center;
|
||||
|
||||
.modal-content {
|
||||
background-color: $color-1;
|
||||
margin: 15% auto;
|
||||
padding: 1.2em;
|
||||
width: 30%;
|
||||
border-radius: 1em;
|
||||
border: 1px solid $color-border;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: $h4-size;
|
||||
}
|
||||
|
||||
.message {
|
||||
font-size: $h5-size;
|
||||
padding: 1.2em 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
@import "mixins";
|
||||
|
||||
.turbo-progress-bar {
|
||||
background-color: $teal-400;
|
||||
}
|
||||
|
||||
// ANIMATION FUNCTIONS
|
||||
|
||||
@keyframes fade-out-hide {
|
||||
0% {opacity: 1; visibility: visible;}
|
||||
99% {opacity: 0; visibility: visible;}
|
||||
100% {opacity: 0; visibility: hidden;}
|
||||
}
|
||||
|
||||
.animate-hide-500 {
|
||||
animation: fade-out-hide 0.5s;
|
||||
}
|
||||
|
||||
//
|
||||
@-webkit-keyframes slideInDown {
|
||||
0% {
|
||||
|
||||
@@ -6,7 +6,7 @@ module Admin
|
||||
# GET /admin/bulk_line_items.json
|
||||
#
|
||||
def index
|
||||
order_params = params[:q].andand.delete :order
|
||||
order_params = params[:q]&.delete :order
|
||||
orders = order_permissions.editable_orders.ransack(order_params).result
|
||||
|
||||
@line_items = order_permissions.
|
||||
|
||||
@@ -50,7 +50,7 @@ module Admin
|
||||
end
|
||||
|
||||
def load_object_data
|
||||
@owner_email = @enterprise_group.andand.owner.andand.email || ""
|
||||
@owner_email = @enterprise_group&.owner&.email || ""
|
||||
end
|
||||
|
||||
def collection
|
||||
|
||||
@@ -73,7 +73,7 @@ module Admin
|
||||
end
|
||||
|
||||
def bulk_update
|
||||
if order_cycle_set.andand.save
|
||||
if order_cycle_set&.save
|
||||
render_as_json @order_cycles,
|
||||
ams_prefix: 'index',
|
||||
current_user: spree_current_user,
|
||||
@@ -155,7 +155,7 @@ module Admin
|
||||
if json_request?
|
||||
# Split ransack params into all those that currently exist and new ones
|
||||
# to limit returned ocs to recent or undated
|
||||
orders_close_at_gt = raw_params[:q].andand.delete(:orders_close_at_gt) || 31.days.ago
|
||||
orders_close_at_gt = raw_params[:q]&.delete(:orders_close_at_gt) || 31.days.ago
|
||||
raw_params[:q] = {
|
||||
g: [raw_params.delete(:q) || {}, { m: 'or',
|
||||
orders_close_at_gt: orders_close_at_gt,
|
||||
@@ -217,7 +217,7 @@ module Admin
|
||||
|
||||
(order_cycle_bulk_params[:collection_attributes] || []).keep_if do |_index, hash|
|
||||
order_cycle = OrderCycle.find(hash[:id])
|
||||
managed_ids.include?(order_cycle.andand.coordinator_id)
|
||||
managed_ids.include?(order_cycle&.coordinator_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ module Admin
|
||||
def load_build_context
|
||||
@shop = Enterprise.managed_by(spree_current_user).find_by(id: params[:shop_id])
|
||||
@schedule = permissions.editable_schedules.find_by(id: params[:schedule_id])
|
||||
@order_cycle = @schedule.andand.current_or_next_order_cycle
|
||||
@order_cycle = @schedule&.current_or_next_order_cycle
|
||||
@variant = variant_if_eligible(subscription_line_item_params[:variant_id]) if @shop.present?
|
||||
end
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ module Api
|
||||
end
|
||||
|
||||
def customer
|
||||
@current_api_user.andand.customer_of(distributor) || nil
|
||||
@current_api_user&.customer_of(distributor) || nil
|
||||
end
|
||||
|
||||
def distributed_products
|
||||
|
||||
@@ -152,7 +152,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def check_order_cycle_expiry
|
||||
if current_order_cycle.andand.closed?
|
||||
if current_order_cycle&.closed?
|
||||
current_order.empty!
|
||||
current_order.set_order_cycle! nil
|
||||
flash[:info] = I18n.t('order_cycle_closed')
|
||||
|
||||
15
app/controllers/concerns/cablecar_responses.rb
Normal file
15
app/controllers/concerns/cablecar_responses.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module CablecarResponses
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
include CableReady::Broadcaster
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def partial(path, options = {})
|
||||
{ html: render_to_string(partial: path, **options) }
|
||||
end
|
||||
end
|
||||
@@ -31,7 +31,7 @@ class EnterprisesController < BaseController
|
||||
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
enterprises = @enterprise.andand.relatives.andand.activated
|
||||
enterprises = @enterprise&.relatives&.activated
|
||||
render(json: enterprises,
|
||||
each_serializer: Api::EnterpriseSerializer,
|
||||
data: OpenFoodNetwork::EnterpriseInjectionData.new)
|
||||
|
||||
@@ -8,6 +8,7 @@ class SplitCheckoutController < ::BaseController
|
||||
include OrderStockCheck
|
||||
include Spree::BaseHelper
|
||||
include CheckoutCallbacks
|
||||
include CablecarResponses
|
||||
|
||||
helper 'terms_and_conditions'
|
||||
helper 'checkout'
|
||||
@@ -25,7 +26,11 @@ class SplitCheckoutController < ::BaseController
|
||||
redirect_to_step
|
||||
else
|
||||
flash.now[:error] = I18n.t('split_checkout.errors.global')
|
||||
render :edit
|
||||
|
||||
render operations: cable_car.
|
||||
replace("#checkout", partial("split_checkout/checkout")).
|
||||
replace("#flashes", partial("shared/flashes", locals: { flashes: flash })),
|
||||
status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ module Spree
|
||||
raise "Suffix '#{ams_prefix}' not found in ams_prefix_whitelist for #{self.class.name}."
|
||||
end
|
||||
|
||||
prefix = ams_prefix.andand.classify || ""
|
||||
prefix = ams_prefix&.classify || ""
|
||||
name = controller_name.classify
|
||||
"::Api::Admin::#{prefix}#{name}Serializer".constantize
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ module Spree
|
||||
before_action :load_data
|
||||
before_action :validate_payment_method_provider, only: [:create]
|
||||
before_action :load_hubs, only: [:new, :edit, :update]
|
||||
before_action :validate_calculator_preferred_amount, only: [:update]
|
||||
before_action :validate_calculator_preferred_value, only: [:update]
|
||||
|
||||
respond_to :html
|
||||
|
||||
@@ -136,7 +136,7 @@ module Spree
|
||||
def restrict_stripe_account_change
|
||||
return unless @payment_method
|
||||
return unless stripe_payment_method?
|
||||
return unless @payment_method.preferred_enterprise_id.andand > 0
|
||||
return unless @payment_method.preferred_enterprise_id&.positive?
|
||||
|
||||
@stripe_account_holder = Enterprise.find(@payment_method.preferred_enterprise_id)
|
||||
return if spree_current_user.enterprises.include? @stripe_account_holder
|
||||
@@ -158,11 +158,14 @@ module Spree
|
||||
call.to_h.with_indifferent_access
|
||||
end
|
||||
|
||||
def gateway_params
|
||||
raw_params[ActiveModel::Naming.param_key(@payment_method)] || {}
|
||||
end
|
||||
|
||||
# Merge payment method params with gateway params like :gateway_stripe_connect
|
||||
# Also, remove password if present and blank
|
||||
def update_params
|
||||
@update_params ||= begin
|
||||
gateway_params = raw_params[ActiveModel::Naming.param_key(@payment_method)] || {}
|
||||
params_for_update = base_params.merge(gateway_params)
|
||||
|
||||
params_for_update.each do |key, value|
|
||||
@@ -175,15 +178,30 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
def validate_calculator_preferred_amount
|
||||
preferred_amount = params.dig(:payment_method_check, :calculator_attributes,
|
||||
:preferred_amount)
|
||||
return if preferred_amount.nil? || Float(preferred_amount,
|
||||
exception: false)
|
||||
def validate_calculator_preferred_value
|
||||
return if calculator_preferred_values.all? do |value|
|
||||
preferred_value_from_params = gateway_params.dig(:calculator_attributes, value)
|
||||
preferred_value_from_params.nil? || Float(preferred_value_from_params,
|
||||
exception: false)
|
||||
end
|
||||
|
||||
flash[:error] = I18n.t(:calculator_preferred_amount_error)
|
||||
flash[:error] = I18n.t(:calculator_preferred_value_error)
|
||||
redirect_to spree.edit_admin_payment_method_path(@payment_method)
|
||||
end
|
||||
|
||||
def calculator_preferred_values
|
||||
[
|
||||
:preferred_amount,
|
||||
:preferred_flat_percent,
|
||||
:preferred_flat_percent,
|
||||
:preferred_first_item,
|
||||
:preferred_additional_item,
|
||||
:preferred_max_items,
|
||||
:preferred_normal_amount,
|
||||
:preferred_discount_amount,
|
||||
:preferred_minimal_amount
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -82,7 +82,7 @@ module Spree
|
||||
|
||||
def create_before
|
||||
option_values = params[:new_variant]
|
||||
option_values.andand.each_value { |id| @object.option_values << OptionValue.find(id) }
|
||||
option_values&.each_value { |id| @object.option_values << OptionValue.find(id) }
|
||||
@object.save
|
||||
end
|
||||
|
||||
|
||||
@@ -171,16 +171,16 @@ module Spree
|
||||
# changes are allowed and the user has access. Return nil if not.
|
||||
def changeable_order_from_number
|
||||
order = Spree::Order.complete.find_by(number: params[:id])
|
||||
return nil unless order.andand.changes_allowed? && can?(:update, order)
|
||||
return nil unless order&.changes_allowed? && can?(:update, order)
|
||||
|
||||
order
|
||||
end
|
||||
|
||||
def check_at_least_one_line_item
|
||||
return unless order_to_update.andand.complete?
|
||||
return unless order_to_update&.complete?
|
||||
|
||||
items = params[:order][:line_items_attributes]
|
||||
.andand.select{ |_k, attrs| attrs["quantity"].to_i > 0 }
|
||||
&.select{ |_k, attrs| attrs["quantity"].to_i > 0 }
|
||||
|
||||
if items.empty?
|
||||
flash[:error] = I18n.t(:orders_cannot_remove_the_final_item)
|
||||
|
||||
@@ -4,7 +4,7 @@ require 'open_food_network/available_payment_method_filter'
|
||||
|
||||
module EnterprisesHelper
|
||||
def current_distributor
|
||||
@current_distributor ||= current_order(false).andand.distributor
|
||||
@current_distributor ||= current_order(false)&.distributor
|
||||
end
|
||||
|
||||
def current_customer
|
||||
@@ -19,7 +19,7 @@ module EnterprisesHelper
|
||||
shipping_methods = current_distributor.shipping_methods.display_on_checkout.to_a
|
||||
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor,
|
||||
"FilterShippingMethods", current_customer.andand.tag_list)
|
||||
"FilterShippingMethods", current_customer&.tag_list)
|
||||
applicator.filter!(shipping_methods)
|
||||
|
||||
shipping_methods.uniq
|
||||
@@ -34,7 +34,7 @@ module EnterprisesHelper
|
||||
filter.filter!(payment_methods)
|
||||
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor,
|
||||
"FilterPaymentMethods", current_customer.andand.tag_list)
|
||||
"FilterPaymentMethods", current_customer&.tag_list)
|
||||
applicator.filter!(payment_methods)
|
||||
|
||||
payment_methods
|
||||
@@ -90,7 +90,7 @@ module EnterprisesHelper
|
||||
end
|
||||
|
||||
def order_changes_allowed?
|
||||
current_order.andand.distributor.andand.allow_order_changes?
|
||||
current_order&.distributor&.allow_order_changes?
|
||||
end
|
||||
|
||||
def show_bought_items?
|
||||
@@ -100,4 +100,12 @@ module EnterprisesHelper
|
||||
def subscriptions_enabled?
|
||||
spree_current_user.admin? || spree_current_user.enterprises.where(enable_subscriptions: true).any?
|
||||
end
|
||||
|
||||
def enterprise_url_selector(enterprise)
|
||||
if enterprise.is_distributor
|
||||
main_app.enterprise_shop_url(enterprise)
|
||||
else
|
||||
main_app.producers_url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,6 +17,6 @@ module GroupsHelper
|
||||
end
|
||||
|
||||
def strip_url(url)
|
||||
url.andand.sub(%r{^https?://}i, '')
|
||||
url&.sub(%r{^https?://}i, '')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ require 'open_food_network/permissions'
|
||||
|
||||
module OrderCyclesHelper
|
||||
def current_order_cycle
|
||||
@current_order_cycle ||= current_order(false).andand.order_cycle
|
||||
@current_order_cycle ||= current_order(false)&.order_cycle
|
||||
end
|
||||
|
||||
def permitted_enterprises_for(order_cycle)
|
||||
|
||||
@@ -12,11 +12,11 @@ module SharedHelper
|
||||
end
|
||||
|
||||
def enterprise_user?
|
||||
spree_current_user.andand.enterprises.andand.count.to_i > 0
|
||||
spree_current_user&.enterprises&.count.to_i > 0
|
||||
end
|
||||
|
||||
def admin_user?
|
||||
spree_current_user.andand.has_spree_role? 'admin'
|
||||
spree_current_user&.has_spree_role? 'admin'
|
||||
end
|
||||
|
||||
def current_shop_products_path
|
||||
|
||||
@@ -12,7 +12,7 @@ module Spree
|
||||
end
|
||||
|
||||
def cart_count
|
||||
current_order.andand.line_items.andand.count || 0
|
||||
current_order&.line_items&.count || 0
|
||||
end
|
||||
|
||||
def changeable_orders
|
||||
@@ -30,7 +30,7 @@ module Spree
|
||||
end
|
||||
|
||||
def changeable_orders_link_path
|
||||
changeable_orders.one? ? order_path(changeable_orders.first) : spree.account_path
|
||||
changeable_orders.one? ? main_app.order_path(changeable_orders.first) : spree.account_path
|
||||
end
|
||||
|
||||
def shop_changeable_orders_alert_html
|
||||
|
||||
@@ -6,15 +6,15 @@ module Spree
|
||||
module ReportsHelper
|
||||
def report_order_cycle_options(order_cycles)
|
||||
order_cycles.map do |oc|
|
||||
orders_open_at = oc.orders_open_at.andand.to_s(:short) || 'NA'
|
||||
orders_close_at = oc.orders_close_at.andand.to_s(:short) || 'NA'
|
||||
orders_open_at = oc.orders_open_at&.to_s(:short) || 'NA'
|
||||
orders_close_at = oc.orders_close_at&.to_s(:short) || 'NA'
|
||||
["#{oc.name} (#{orders_open_at} - #{orders_close_at})".html_safe, oc.id]
|
||||
end
|
||||
end
|
||||
|
||||
def report_payment_method_options(orders)
|
||||
orders.map do |order|
|
||||
payment_method = order.payments.first.andand.payment_method
|
||||
payment_method = order.payments.first&.payment_method
|
||||
|
||||
next unless payment_method
|
||||
|
||||
@@ -25,7 +25,7 @@ module Spree
|
||||
def report_shipping_method_options(orders)
|
||||
orders.map do |o|
|
||||
sm = o.shipping_method
|
||||
[sm.andand.name, sm.andand.id]
|
||||
[sm&.name, sm&.id]
|
||||
end.uniq
|
||||
end
|
||||
|
||||
|
||||
@@ -50,9 +50,9 @@ module Calculator
|
||||
def weight_per_variant(line_item)
|
||||
if variant_unit(line_item) == 'weight'
|
||||
# Convert unit_value to the preferred unit
|
||||
convert_weight(line_item.variant.andand.unit_value)
|
||||
convert_weight(line_item.variant&.unit_value)
|
||||
else
|
||||
line_item.variant.andand.weight || 0
|
||||
line_item.variant&.weight || 0
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,7 +79,7 @@ module Calculator
|
||||
end
|
||||
|
||||
def variant_unit(line_item)
|
||||
line_item.variant.product.andand.variant_unit
|
||||
line_item.variant.product&.variant_unit
|
||||
end
|
||||
|
||||
def convert_weight(value)
|
||||
|
||||
@@ -35,7 +35,7 @@ class Customer < ApplicationRecord
|
||||
private
|
||||
|
||||
def downcase_email
|
||||
email.andand.downcase!
|
||||
email&.downcase!
|
||||
end
|
||||
|
||||
def empty_code
|
||||
|
||||
@@ -410,7 +410,7 @@ class Enterprise < ApplicationRecord
|
||||
end
|
||||
|
||||
def strip_url(url)
|
||||
url.andand.sub(%r{(https?://)?}, '')
|
||||
url&.sub(%r{(https?://)?}, '')
|
||||
end
|
||||
|
||||
def set_unused_address_fields
|
||||
|
||||
@@ -231,15 +231,15 @@ class OrderCycle < ApplicationRecord
|
||||
end
|
||||
|
||||
def receival_instructions_for(supplier)
|
||||
exchange_for_supplier(supplier).andand.receival_instructions
|
||||
exchange_for_supplier(supplier)&.receival_instructions
|
||||
end
|
||||
|
||||
def pickup_time_for(distributor)
|
||||
exchange_for_distributor(distributor).andand.pickup_time || distributor.next_collection_at
|
||||
exchange_for_distributor(distributor)&.pickup_time || distributor.next_collection_at
|
||||
end
|
||||
|
||||
def pickup_instructions_for(distributor)
|
||||
exchange_for_distributor(distributor).andand.pickup_instructions
|
||||
exchange_for_distributor(distributor)&.pickup_instructions
|
||||
end
|
||||
|
||||
def exchanges_carrying(variant, distributor)
|
||||
|
||||
@@ -424,7 +424,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def import_into_inventory?
|
||||
@import_settings[:settings].andand['import_into'] == 'inventories'
|
||||
@import_settings.dig(:settings, 'import_into') == 'inventories'
|
||||
end
|
||||
|
||||
def validate_inventory_item(entry, variant_override)
|
||||
|
||||
@@ -86,7 +86,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def enterprise_products
|
||||
@processor.andand.enterprise_products
|
||||
@processor&.enterprise_products
|
||||
end
|
||||
|
||||
def total_enterprise_products
|
||||
|
||||
@@ -37,7 +37,7 @@ module ProductImport
|
||||
private
|
||||
|
||||
def import_into_inventory?
|
||||
@import_settings[:settings].andand['import_into'] == 'inventories'
|
||||
@import_settings.dig(:settings, 'import_into') == 'inventories'
|
||||
end
|
||||
|
||||
def create_enterprises_index
|
||||
|
||||
@@ -33,7 +33,7 @@ class ProxyOrder < ApplicationRecord
|
||||
end
|
||||
|
||||
def cancel
|
||||
return false unless order_cycle.orders_close_at.andand > Time.zone.now
|
||||
return false unless order_cycle.orders_close_at&.>(Time.zone.now)
|
||||
|
||||
transaction do
|
||||
update_column(:canceled_at, Time.zone.now)
|
||||
@@ -43,7 +43,7 @@ class ProxyOrder < ApplicationRecord
|
||||
end
|
||||
|
||||
def resume
|
||||
return false unless order_cycle.orders_close_at.andand > Time.zone.now
|
||||
return false unless order_cycle.orders_close_at&.>(Time.zone.now)
|
||||
|
||||
transaction do
|
||||
update_column(:canceled_at, nil)
|
||||
@@ -72,7 +72,7 @@ class ProxyOrder < ApplicationRecord
|
||||
end
|
||||
|
||||
def cart?
|
||||
order.andand.state == 'complete' &&
|
||||
order&.state == 'complete' &&
|
||||
order_cycle.orders_close_at > Time.zone.now
|
||||
end
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ module Spree
|
||||
end
|
||||
|
||||
can [:admin, :index, :read, :update, :bulk_update, :bulk_reset], VariantOverride do |vo|
|
||||
next false unless vo.hub.present? && vo.variant.andand.product.andand.supplier.present?
|
||||
next false unless vo.hub.present? && vo.variant&.product&.supplier.present?
|
||||
|
||||
hub_auth = OpenFoodNetwork::Permissions.new(user).
|
||||
variant_override_hubs.
|
||||
@@ -212,7 +212,7 @@ module Spree
|
||||
|
||||
can [:admin, :create, :update], InventoryItem do |ii|
|
||||
next false unless ii.enterprise.present? &&
|
||||
ii.variant.andand.product.andand.supplier.present?
|
||||
ii.variant&.product&.supplier.present?
|
||||
|
||||
hub_auth = OpenFoodNetwork::Permissions.new(user).
|
||||
variant_override_hubs.
|
||||
@@ -267,7 +267,7 @@ module Spree
|
||||
# Enterprise User can access orders that they are a distributor for
|
||||
user.enterprises.include?(order.distributor) ||
|
||||
# Enterprise User can access orders that are placed inside a OC they coordinate
|
||||
order.order_cycle.andand.coordinated_by?(user)
|
||||
order.order_cycle&.coordinated_by?(user)
|
||||
end
|
||||
can [:admin, :bulk_management, :managed], Spree::Order do
|
||||
user.admin? || user.enterprises.any?(&:is_distributor)
|
||||
@@ -280,7 +280,7 @@ module Spree
|
||||
order = item.order
|
||||
user.admin? ||
|
||||
user.enterprises.include?(order.distributor) ||
|
||||
order.order_cycle.andand.coordinated_by?(user)
|
||||
order.order_cycle&.coordinated_by?(user)
|
||||
end
|
||||
|
||||
can [:admin, :index, :read, :create, :edit, :update, :fire], Spree::Payment
|
||||
@@ -293,7 +293,7 @@ module Spree
|
||||
else
|
||||
order = adjustment.order
|
||||
user.enterprises.include?(order.distributor) ||
|
||||
order.order_cycle.andand.coordinated_by?(user)
|
||||
order.order_cycle&.coordinated_by?(user)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ module Spree
|
||||
end
|
||||
|
||||
def full_address
|
||||
render_address([address1, address2, city, zipcode, state.andand.name])
|
||||
render_address([address1, address2, city, zipcode, state&.name])
|
||||
end
|
||||
|
||||
def address_part1
|
||||
@@ -98,7 +98,7 @@ module Spree
|
||||
end
|
||||
|
||||
def address_part2
|
||||
render_address([city, zipcode, state.andand.name])
|
||||
render_address([city, zipcode, state&.name])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -22,7 +22,7 @@ module Spree
|
||||
end
|
||||
|
||||
def stripe_account_id
|
||||
StripeAccount.find_by(enterprise_id: preferred_enterprise_id).andand.stripe_user_id
|
||||
StripeAccount.find_by(enterprise_id: preferred_enterprise_id)&.stripe_user_id
|
||||
end
|
||||
|
||||
# NOTE: the name of this method is determined by Spree::Payment::Processing
|
||||
@@ -100,7 +100,7 @@ module Spree
|
||||
end
|
||||
|
||||
def ensure_enterprise_selected
|
||||
return if preferred_enterprise_id.andand > 0
|
||||
return if preferred_enterprise_id&.positive?
|
||||
|
||||
errors.add(:stripe_account_owner, I18n.t(:error_required))
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ module Spree
|
||||
end
|
||||
|
||||
def stripe_account_id
|
||||
StripeAccount.find_by(enterprise_id: preferred_enterprise_id).andand.stripe_user_id
|
||||
StripeAccount.find_by(enterprise_id: preferred_enterprise_id)&.stripe_user_id
|
||||
end
|
||||
|
||||
# NOTE: the name of this method is determined by Spree::Payment::Processing
|
||||
@@ -169,7 +169,7 @@ module Spree
|
||||
end
|
||||
|
||||
def ensure_enterprise_selected
|
||||
return if preferred_enterprise_id.andand.positive?
|
||||
return if preferred_enterprise_id&.positive?
|
||||
|
||||
errors.add(:stripe_account_owner, I18n.t(:error_required))
|
||||
end
|
||||
|
||||
@@ -172,7 +172,7 @@ module Spree
|
||||
end
|
||||
|
||||
def tax_rates
|
||||
product.tax_category.andand.tax_rates || []
|
||||
product.tax_category&.tax_rates || []
|
||||
end
|
||||
|
||||
def price_with_adjustments
|
||||
@@ -251,8 +251,8 @@ module Spree
|
||||
def calculate_final_weight_volume
|
||||
if final_weight_volume.present? && quantity_was > 0
|
||||
self.final_weight_volume = final_weight_volume * quantity / quantity_was
|
||||
elsif variant.andand.unit_value.present?
|
||||
self.final_weight_volume = variant.andand.unit_value * quantity
|
||||
elsif variant&.unit_value.present?
|
||||
self.final_weight_volume = variant&.unit_value * quantity
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -192,7 +192,7 @@ module Spree
|
||||
end
|
||||
|
||||
def changes_allowed?
|
||||
complete? && distributor.andand.allow_order_changes? && order_cycle.andand.open?
|
||||
complete? && distributor&.allow_order_changes? && order_cycle&.open?
|
||||
end
|
||||
|
||||
# Is this a free order in which case the payment step should be skipped
|
||||
@@ -569,7 +569,7 @@ module Spree
|
||||
|
||||
def set_distributor!(distributor)
|
||||
self.distributor = distributor
|
||||
self.order_cycle = nil unless order_cycle.andand.has_distributor? distributor
|
||||
self.order_cycle = nil unless order_cycle&.has_distributor? distributor
|
||||
save!
|
||||
end
|
||||
|
||||
@@ -677,7 +677,7 @@ module Spree
|
||||
end
|
||||
|
||||
def using_guest_checkout?
|
||||
require_email && !user.andand.id
|
||||
require_email && !user&.id
|
||||
end
|
||||
|
||||
def registered_email?
|
||||
@@ -689,7 +689,7 @@ module Spree
|
||||
end
|
||||
|
||||
def skip_payment_for_subscription?
|
||||
subscription.present? && order_cycle.orders_close_at.andand > Time.zone.now
|
||||
subscription.present? && order_cycle.orders_close_at&.>(Time.zone.now)
|
||||
end
|
||||
|
||||
def require_customer?
|
||||
@@ -705,7 +705,7 @@ module Spree
|
||||
end
|
||||
|
||||
def email_for_customer
|
||||
(user.andand.email || email).andand.downcase
|
||||
(user&.email || email)&.downcase
|
||||
end
|
||||
|
||||
def associate_customer
|
||||
@@ -721,9 +721,9 @@ module Spree
|
||||
enterprise: distributor,
|
||||
email: email_for_customer,
|
||||
user: user,
|
||||
name: bill_address.andand.full_name,
|
||||
bill_address: bill_address.andand.clone,
|
||||
ship_address: ship_address.andand.clone
|
||||
name: bill_address&.full_name,
|
||||
bill_address: bill_address&.clone,
|
||||
ship_address: ship_address&.clone
|
||||
)
|
||||
customer.save
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ module Spree
|
||||
|
||||
def build_source
|
||||
return if source_attributes.nil?
|
||||
return unless payment_method.andand.payment_source_class
|
||||
return unless payment_method&.payment_source_class
|
||||
|
||||
self.source = payment_method.payment_source_class.new(source_attributes)
|
||||
source.payment_method_id = payment_method.id
|
||||
|
||||
@@ -28,7 +28,7 @@ module Spree
|
||||
|
||||
def line_item_shipment(line_item)
|
||||
return line_item.target_shipment if line_item.target_shipment
|
||||
return line_item.order.shipments.first if line_item.order.andand.shipments.any?
|
||||
return line_item.order.shipments.first if line_item.order&.shipments.any?
|
||||
end
|
||||
|
||||
# Overrides Spree v2.0.4 validate method version to:
|
||||
|
||||
@@ -60,13 +60,13 @@ module Spree
|
||||
if: proc { Spree::Config[:require_master_price] }
|
||||
|
||||
validates :unit_value, presence: true, if: ->(variant) {
|
||||
%w(weight volume).include?(variant.product.andand.variant_unit)
|
||||
%w(weight volume).include?(variant.product&.variant_unit)
|
||||
}
|
||||
|
||||
validates :unit_value, numericality: { greater_than: 0 }
|
||||
|
||||
validates :unit_description, presence: true, if: ->(variant) {
|
||||
variant.product.andand.variant_unit.present? && variant.unit_value.nil?
|
||||
variant.product&.variant_unit.present? && variant.unit_value.nil?
|
||||
}
|
||||
|
||||
before_validation :set_cost_currency
|
||||
|
||||
@@ -5,7 +5,7 @@ class TagRule::FilterOrderCycles < TagRule
|
||||
preference :exchange_tags, :string, default: ""
|
||||
|
||||
def tags_match?(order_cycle)
|
||||
exchange_tags = exchange_for(order_cycle).andand.tag_list || []
|
||||
exchange_tags = exchange_for(order_cycle)&.tag_list || []
|
||||
preferred_tags = preferred_exchange_tags.split(",")
|
||||
( exchange_tags & preferred_tags ).any?
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ class TagRule::FilterPaymentMethods < TagRule
|
||||
preference :payment_method_tags, :string, default: ""
|
||||
|
||||
def tags_match?(payment_method)
|
||||
payment_method_tags = payment_method.andand.tag_list || []
|
||||
payment_method_tags = payment_method&.tag_list || []
|
||||
preferred_tags = preferred_payment_method_tags.split(",")
|
||||
( payment_method_tags & preferred_tags ).any?
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class TagRule
|
||||
end
|
||||
|
||||
def tags_match?(variant)
|
||||
variant_tags = variant.andand["tag_list"] || []
|
||||
variant_tags = variant&.[]("tag_list") || []
|
||||
preferred_tags = preferred_variant_tags.split(",")
|
||||
(variant_tags & preferred_tags).any?
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class TagRule::FilterShippingMethods < TagRule
|
||||
end
|
||||
|
||||
def tags_match?(shipping_method)
|
||||
shipping_method_tags = shipping_method.andand.tag_list || []
|
||||
shipping_method_tags = shipping_method&.tag_list || []
|
||||
preferred_tags = preferred_shipping_method_tags.split(",")
|
||||
( shipping_method_tags & preferred_tags ).any?
|
||||
end
|
||||
|
||||
@@ -9,10 +9,10 @@ class Api::AddressSerializer < ActiveModel::Serializer
|
||||
:zipcode, :country_name
|
||||
|
||||
def country_name
|
||||
object.country.andand.name
|
||||
object.country&.name
|
||||
end
|
||||
|
||||
def state_name
|
||||
object.state.andand.abbr
|
||||
object.state&.abbr
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,11 +15,11 @@ module Api
|
||||
end
|
||||
|
||||
def orders_open_at
|
||||
object.orders_open_at.andand.strftime("%F %T %z")
|
||||
object.orders_open_at&.strftime("%F %T %z")
|
||||
end
|
||||
|
||||
def orders_close_at
|
||||
object.orders_close_at.andand.strftime("%F %T %z")
|
||||
object.orders_close_at&.strftime("%F %T %z")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ module Api
|
||||
has_one :bill_address, serializer: Api::AddressSerializer
|
||||
|
||||
def name
|
||||
object.name.presence || object.bill_address.andand.full_name
|
||||
object.name.presence || object.bill_address&.full_name
|
||||
end
|
||||
|
||||
def tag_list
|
||||
@@ -19,7 +19,7 @@ module Api
|
||||
|
||||
def tags
|
||||
customer_tag_list.map do |tag|
|
||||
tag_rule_map = options[:tag_rule_mapping].andand[tag]
|
||||
tag_rule_map = options.dig(:tag_rule_mapping, tag)
|
||||
tag_rule_map || { text: tag, rules: nil }
|
||||
end
|
||||
end
|
||||
@@ -35,7 +35,7 @@ module Api
|
||||
def customer_tag_list
|
||||
return object.tag_list unless options[:customer_tags]
|
||||
|
||||
options[:customer_tags].andand[object.id] || []
|
||||
options.dig(:customer_tags, object.id) || []
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,11 +7,11 @@ module Api
|
||||
:calculator_type, :enterprise_name, :calculator_description, :calculator_settings
|
||||
|
||||
def enterprise_name
|
||||
object.enterprise.andand.name
|
||||
object.enterprise&.name
|
||||
end
|
||||
|
||||
def calculator_description
|
||||
object.calculator.andand.description
|
||||
object.calculator&.description
|
||||
end
|
||||
|
||||
def calculator_settings
|
||||
|
||||
@@ -7,7 +7,7 @@ module Api
|
||||
attributes :name, :supplier_name, :image_url, :master_id, :variants
|
||||
|
||||
def supplier_name
|
||||
object.supplier.andand.name
|
||||
object.supplier&.name
|
||||
end
|
||||
|
||||
def image_url
|
||||
|
||||
@@ -17,7 +17,7 @@ module Api
|
||||
end
|
||||
|
||||
def distributor_name
|
||||
object.distributor.andand.name
|
||||
object.distributor&.name
|
||||
end
|
||||
|
||||
def display_outstanding_balance
|
||||
|
||||
@@ -13,7 +13,7 @@ module Api
|
||||
end
|
||||
|
||||
def update_issues
|
||||
options[:order_update_issues].andand[object.order_id] || []
|
||||
options[:order_update_issues]&.[](object.order_id) || []
|
||||
end
|
||||
|
||||
def completed_at
|
||||
|
||||
@@ -11,7 +11,7 @@ module Api
|
||||
end
|
||||
|
||||
def price_estimate
|
||||
object.price_estimate.andand.to_f || "?"
|
||||
object.price_estimate&.to_f || "?"
|
||||
end
|
||||
|
||||
def in_open_and_upcoming_order_cycles
|
||||
@@ -23,11 +23,11 @@ module Api
|
||||
private
|
||||
|
||||
def option_or_assigned_shop
|
||||
@options[:shop] || object.subscription.andand.shop
|
||||
@options[:shop] || object.subscription&.shop
|
||||
end
|
||||
|
||||
def option_or_assigned_schedule
|
||||
@options[:schedule] || object.subscription.andand.schedule
|
||||
@options[:schedule] || object.subscription&.schedule
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,31 +15,31 @@ module Api
|
||||
has_one :ship_address, serializer: Api::AddressSerializer
|
||||
|
||||
def begins_at
|
||||
object.begins_at.andand.strftime('%F')
|
||||
object.begins_at&.strftime('%F')
|
||||
end
|
||||
|
||||
def ends_at
|
||||
object.ends_at.andand.strftime('%F')
|
||||
object.ends_at&.strftime('%F')
|
||||
end
|
||||
|
||||
def paused_at
|
||||
object.paused_at.andand.strftime('%F')
|
||||
object.paused_at&.strftime('%F')
|
||||
end
|
||||
|
||||
def canceled_at
|
||||
object.canceled_at.andand.strftime('%F')
|
||||
object.canceled_at&.strftime('%F')
|
||||
end
|
||||
|
||||
def customer_email
|
||||
object.customer.andand.email
|
||||
object.customer&.email
|
||||
end
|
||||
|
||||
def customer_name
|
||||
object.customer.andand.name
|
||||
object.customer&.name
|
||||
end
|
||||
|
||||
def schedule_name
|
||||
object.schedule.andand.name
|
||||
object.schedule&.name
|
||||
end
|
||||
|
||||
def edit_path
|
||||
|
||||
@@ -9,7 +9,7 @@ module Api
|
||||
cached
|
||||
|
||||
def cache_key
|
||||
enterprise.andand.cache_key
|
||||
enterprise&.cache_key
|
||||
end
|
||||
|
||||
attributes :name, :id, :description, :latitude, :longitude,
|
||||
@@ -119,7 +119,7 @@ module Api
|
||||
end
|
||||
|
||||
def active
|
||||
@active ||= data.active_distributor_ids.andand.include? enterprise.id
|
||||
@active ||= data.active_distributor_ids&.include? enterprise.id
|
||||
end
|
||||
|
||||
# Map svg icons.
|
||||
|
||||
@@ -11,11 +11,11 @@ class Api::CurrentOrderSerializer < ActiveModel::Serializer
|
||||
has_many :finalised_line_items, serializer: Api::LineItemSerializer
|
||||
|
||||
def payment_method_id
|
||||
object.payments.first.andand.payment_method_id
|
||||
object.payments.first&.payment_method_id
|
||||
end
|
||||
|
||||
def shipping_method_id
|
||||
object.shipping_method.andand.id
|
||||
object.shipping_method&.id
|
||||
end
|
||||
|
||||
def display_total
|
||||
|
||||
@@ -16,7 +16,7 @@ module Api
|
||||
has_many :distributed_properties, serializer: Api::PropertySerializer
|
||||
|
||||
def orders_close_at
|
||||
OrderCycle.with_distributor(enterprise).soonest_closing.first.andand.orders_close_at
|
||||
OrderCycle.with_distributor(enterprise).soonest_closing.first&.orders_close_at
|
||||
end
|
||||
|
||||
def active
|
||||
|
||||
@@ -34,7 +34,7 @@ module Api
|
||||
def changes_allowed_until
|
||||
return I18n.t(:not_allowed) unless object.changes_allowed?
|
||||
|
||||
I18n.l(object.order_cycle.andand.orders_close_at, format: "%b %d, %Y %H:%M")
|
||||
I18n.l(object.order_cycle&.orders_close_at, format: "%b %d, %Y %H:%M")
|
||||
end
|
||||
|
||||
def shipment_state
|
||||
|
||||
@@ -11,7 +11,7 @@ module Api
|
||||
end
|
||||
|
||||
def active
|
||||
options[:data].active_distributor_ids.andand.include? object.id
|
||||
options[:data].active_distributor_ids&.include? object.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ class Api::VariantSerializer < ActiveModel::Serializer
|
||||
delegate :price, to: :object
|
||||
|
||||
def fees
|
||||
options[:enterprise_fee_calculator].andand.indexed_fees_by_type_for(object) ||
|
||||
options[:enterprise_fee_calculator]&.indexed_fees_by_type_for(object) ||
|
||||
object.fees_by_type_for(options[:current_distributor], options[:current_order_cycle])
|
||||
end
|
||||
|
||||
|
||||
22
app/services/image_importer.rb
Normal file
22
app/services/image_importer.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
class ImageImporter
|
||||
def import(url, product)
|
||||
attach(download(url), product)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def download(url)
|
||||
local_file = Tempfile.new
|
||||
remote_file = open(url)
|
||||
IO.copy_stream(remote_file, local_file)
|
||||
local_file
|
||||
end
|
||||
|
||||
def attach(file, product)
|
||||
Spree::Image.create(
|
||||
attachment: file,
|
||||
viewable_id: product.master.id,
|
||||
viewable_type: Spree::Variant,
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -13,7 +13,7 @@ class OrderSyncer
|
||||
|
||||
def sync!
|
||||
orders_in_order_cycles_not_closed.all? do |order|
|
||||
order.assign_attributes(customer_id: customer_id, email: customer.andand.email,
|
||||
order.assign_attributes(customer_id: customer_id, email: customer&.email,
|
||||
distributor_id: shop_id)
|
||||
update_associations_for(order)
|
||||
line_item_syncer.sync!(order)
|
||||
@@ -59,7 +59,7 @@ class OrderSyncer
|
||||
payment = order.payments.
|
||||
with_state('checkout').where(payment_method_id: payment_method_id_was).last
|
||||
if payment
|
||||
payment.andand.void_transaction!
|
||||
payment&.void_transaction!
|
||||
order.payments.create(payment_method_id: payment_method_id, amount: order.reload.total)
|
||||
else
|
||||
unless order.payments.with_state('checkout').where(payment_method_id: payment_method_id).any?
|
||||
|
||||
@@ -110,6 +110,6 @@ class ProductTagRulesFilterer
|
||||
end
|
||||
|
||||
def customer_tag_list
|
||||
customer.andand.tag_list || []
|
||||
customer&.tag_list || []
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,6 +24,7 @@ class SearchOrders
|
||||
|
||||
def search_query
|
||||
base_query = ::Permissions::Order.new(current_user).editable_orders.not_empty
|
||||
.or(::Permissions::Order.new(current_user).editable_orders.finalized)
|
||||
|
||||
return base_query unless params[:shipping_method_id]
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ module Sets
|
||||
end
|
||||
|
||||
if found_element.nil?
|
||||
@collection << @klass.new(attributes) unless @reject_if.andand.call(attributes)
|
||||
@collection << @klass.new(attributes) unless @reject_if&.call(attributes)
|
||||
else
|
||||
process(found_element, attributes)
|
||||
end
|
||||
@@ -64,12 +64,12 @@ module Sets
|
||||
# Allows us to render @model_set.collection without deleted elements
|
||||
deleted = []
|
||||
@collection = collection.to_a
|
||||
collection.delete_if { |e| deleted << e if @delete_if.andand.call(e.attributes) }
|
||||
collection.delete_if { |e| deleted << e if @delete_if&.call(e.attributes) }
|
||||
deleted
|
||||
end
|
||||
|
||||
def collection_to_keep
|
||||
collection.reject { |e| @delete_if.andand.call(e.attributes) }
|
||||
collection.reject { |e| @delete_if&.call(e.attributes) }
|
||||
end
|
||||
|
||||
def persisted?
|
||||
|
||||
@@ -22,7 +22,7 @@ module Shop
|
||||
def apply_tag_rules!(order_cycles)
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(@distributor,
|
||||
"FilterOrderCycles",
|
||||
@customer.andand.tag_list)
|
||||
@customer&.tag_list)
|
||||
applicator.filter!(order_cycles)
|
||||
|
||||
order_cycles
|
||||
|
||||
@@ -27,13 +27,13 @@ class UserDefaultAddressSetter
|
||||
|
||||
def set_bill_address_attributes(object, new_address)
|
||||
object.update(
|
||||
bill_address_attributes: new_address.merge('id' => object.bill_address.andand.id)
|
||||
bill_address_attributes: new_address.merge('id' => object.bill_address&.id)
|
||||
)
|
||||
end
|
||||
|
||||
def set_ship_address_attributes(object, new_address)
|
||||
object.update(
|
||||
ship_address_attributes: new_address.merge('id' => object.ship_address.andand.id)
|
||||
ship_address_attributes: new_address.merge('id' => object.ship_address&.id)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
- if spree_current_user.admin?
|
||||
= f.hidden_field :owner_id,
|
||||
class: "select2 fullwidth",
|
||||
'user-select' => "{id:'#{@enterprise_group.owner.andand.id}', email:'#{@enterprise_group.owner.andand.email}'}"
|
||||
'user-select' => "{id:'#{@enterprise_group.owner&.id}', email:'#{@enterprise_group.owner&.email}'}"
|
||||
- else
|
||||
= @enterprise_group.owner.andand.email
|
||||
= @enterprise_group.owner&.email
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
%tr
|
||||
%td.name= enterprise_group.name
|
||||
- if spree_current_user.admin?
|
||||
%td= enterprise_group.owner.andand.email || ""
|
||||
%td= enterprise_group.owner&.email || ""
|
||||
%td= enterprise_group.on_front_page ? 'Y' : 'N'
|
||||
%td= enterprise_group.enterprises.map(&:name).join ', '
|
||||
%td.actions
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
%div{'ofn-with-tip' => t('.owner_tip')}
|
||||
%a= t('admin.whats_this')
|
||||
.nine.columns.omega
|
||||
- owner_email = @enterprise.andand.owner.andand.email || ""
|
||||
- owner_email = @enterprise&.owner&.email || ""
|
||||
= f.hidden_field :owner_id, class: "select2 fullwidth", 'user-select' => 'Enterprise.owner'
|
||||
.row
|
||||
.three.columns.alpha
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
- owner_email = @enterprise.andand.owner.andand.email || ""
|
||||
- full_permissions = (spree_current_user.admin? || spree_current_user == @enterprise.andand.owner)
|
||||
- owner_email = @enterprise&.owner&.email || ""
|
||||
- full_permissions = (spree_current_user.admin? || spree_current_user == @enterprise&.owner)
|
||||
|
||||
.row
|
||||
.three.columns.alpha
|
||||
|
||||
@@ -15,17 +15,27 @@
|
||||
%link{href: "https://fonts.googleapis.com/css?family=Roboto:400,300italic,400italic,300,700,700italic|Oswald:300,400,700", rel: "stylesheet", type: "text/css"}
|
||||
%link{href: font_path("OFN-v2.woff"), rel: "preload", as: "font", crossorigin: "anonymous"}
|
||||
|
||||
= stylesheet_link_tag "darkswarm/all"
|
||||
= javascript_pack_tag "application"
|
||||
= csrf_meta_tags
|
||||
= stylesheet_link_tag "darkswarm/all", "data-turbo-track": "reload"
|
||||
= javascript_pack_tag "application", "data-turbo-track": "reload"
|
||||
|
||||
%body{ class: body_classes, "body-scroll" => true , ng: { app: 'Darkswarm' }}
|
||||
= render "layouts/shopfront_script" if @shopfront_layout
|
||||
= render "layouts/bugsnag_js"
|
||||
|
||||
- if Spree::Config.stripe_connect_enabled
|
||||
= render "shared/stripe_js"
|
||||
|
||||
= javascript_include_tag "darkswarm/all", "data-turbo-track": "reload"
|
||||
= javascript_include_tag "web/all", "data-turbo-track": "reload"
|
||||
= render "layouts/i18n_script"
|
||||
|
||||
= csrf_meta_tags
|
||||
%meta{name: "turbo-cache-control", content: "no-cache"}
|
||||
|
||||
%body{ class: body_classes, "body-scroll": "true", "data-turbo": "false" }
|
||||
/ [if lte IE 8]
|
||||
= render partial: "shared/ie_warning"
|
||||
= javascript_include_tag "iehack"
|
||||
|
||||
= render "layouts/shopfront_script" if @shopfront_layout
|
||||
|
||||
.off-canvas-wrap{ offcanvas: true }
|
||||
.fixed.off-canvas-fixed
|
||||
= render "shared/menu/menu" unless @hide_menu
|
||||
@@ -38,16 +48,7 @@
|
||||
#footer
|
||||
%loading
|
||||
|
||||
= render "layouts/bugsnag_js"
|
||||
|
||||
- if Spree::Config.stripe_connect_enabled
|
||||
= render "shared/stripe_js"
|
||||
= javascript_include_tag "darkswarm/all"
|
||||
= javascript_include_tag "web/all"
|
||||
= render "layouts/i18n_script"
|
||||
|
||||
= yield :scripts
|
||||
|
||||
= inject_current_hub
|
||||
= inject_current_user
|
||||
= inject_rails_flash
|
||||
|
||||
@@ -11,9 +11,12 @@
|
||||
%link{href: "https://fonts.googleapis.com/css?family=Roboto:400,300italic,400italic,300,700,700italic|Oswald:300,400,700", rel: "stylesheet", type: "text/css"}
|
||||
|
||||
= stylesheet_link_tag "darkswarm/all"
|
||||
= javascript_include_tag "darkswarm/all"
|
||||
= javascript_pack_tag "application"
|
||||
|
||||
= csrf_meta_tags
|
||||
|
||||
%body.off-canvas{"ng-app" => "Darkswarm", style: "background-image: url(#{image_path('tile-wide.png')})" }
|
||||
%body.off-canvas{ style: "background-image: url(#{image_path('tile-wide.png')})", "data-turbo": "false" }
|
||||
/ [if lte IE 8]
|
||||
= render partial: "shared/ie_warning"
|
||||
= javascript_include_tag "iehack"
|
||||
@@ -27,10 +30,7 @@
|
||||
#footer
|
||||
%loading
|
||||
|
||||
%script{src: "//maps.googleapis.com/maps/api/js?libraries=places#{ ENV['GOOGLE_MAPS_API_KEY'] ? '&key=' + ENV['GOOGLE_MAPS_API_KEY'] : ''}"}
|
||||
= javascript_include_tag "darkswarm/all"
|
||||
= yield :scripts
|
||||
|
||||
= inject_current_user
|
||||
= yield :injection_data
|
||||
|
||||
|
||||
7
app/views/shared/_flashes.html.haml
Normal file
7
app/views/shared/_flashes.html.haml
Normal file
@@ -0,0 +1,7 @@
|
||||
#flashes
|
||||
- if defined? flashes
|
||||
- flashes.each do |type, msg|
|
||||
%alert.animate-show{"data-controller": "flash"}
|
||||
%div{type: "#{type}", class: "alert-box #{type == 'error' ? 'alert' : type}"}
|
||||
%span= msg
|
||||
%a.small.close{"data-action": "click->flash#close"} ×
|
||||
@@ -1,6 +1,9 @@
|
||||
%div{'ng-controller' => 'CartDropdownCtrl'}
|
||||
= render "shared/menu/large_menu"
|
||||
|
||||
%ofn-flash
|
||||
= render partial: "shared/flashes"
|
||||
|
||||
= render "shared/menu/mobile_menu"
|
||||
= render "shared/menu/offcanvas_menu"
|
||||
= render "shared/menu/cart_sidebar"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- distributor = @order.andand.distributor || current_distributor
|
||||
- distributor = @order&.distributor || current_distributor
|
||||
|
||||
%navigation
|
||||
%distributor.details.row
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- if (@order.andand.distributor || current_distributor) == current_distributor
|
||||
- if (@order&.distributor || current_distributor) == current_distributor
|
||||
|
||||
- shop_tabs.each do |tab|
|
||||
= render "shopping_shared/tabs/#{tab[:name]}"
|
||||
|
||||
4
app/views/split_checkout/_checkout.html.haml
Normal file
4
app/views/split_checkout/_checkout.html.haml
Normal file
@@ -0,0 +1,4 @@
|
||||
%checkout.row#checkout
|
||||
.small-12.medium-12.columns
|
||||
= render partial: "split_checkout/tabs"
|
||||
= render partial: "split_checkout/form"
|
||||
@@ -2,5 +2,7 @@
|
||||
= inject_saved_credit_cards
|
||||
|
||||
%div.checkout-step
|
||||
= form_with url: checkout_update_path(checkout_step), model: @order, method: :put do |f|
|
||||
= render "split_checkout/#{checkout_step}", f: f
|
||||
= form_with url: checkout_update_path(checkout_step), model: @order, method: :put,
|
||||
data: { remote: "true" } do |form|
|
||||
|
||||
= render "split_checkout/#{checkout_step}", f: form
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
- content_for(:title) do
|
||||
= t :checkout_title
|
||||
|
||||
.darkswarm.footer-pad
|
||||
.darkswarm.footer-pad{"data-turbo": "true"}
|
||||
- content_for :order_cycle_form do
|
||||
%closing
|
||||
= t :checkout_now
|
||||
@@ -19,10 +19,6 @@
|
||||
.sub-header.show-for-medium-down
|
||||
= render partial: "shopping_shared/order_cycles"
|
||||
|
||||
%checkout.row
|
||||
.small-12.medium-12.columns
|
||||
= render partial: "split_checkout/tabs"
|
||||
= render partial: "split_checkout/form"
|
||||
|
||||
= render partial: "checkout"
|
||||
|
||||
= render partial: "shared/footer"
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
.alpha.six.columns
|
||||
%p
|
||||
%b= t('.distributor')
|
||||
= @order.distributor.andand.name || t(:none)
|
||||
%input{type: "hidden", id: "order_distributor_id", value: @order.distributor.andand.id}
|
||||
= @order.distributor&.name || t(:none)
|
||||
%input{type: "hidden", id: "order_distributor_id", value: @order.distributor&.id}
|
||||
.omega.six.columns
|
||||
%p
|
||||
%b= t('.order_cycle')
|
||||
= @order.order_cycle.andand.name || t(:none)
|
||||
%input{type: "hidden", id: "order_order_cycle_id", value: @order.order_cycle.andand.id}
|
||||
= @order.order_cycle&.name || t(:none)
|
||||
%input{type: "hidden", id: "order_order_cycle_id", value: @order.order_cycle&.id}
|
||||
- else
|
||||
.alpha.six.columns
|
||||
.field
|
||||
|
||||
@@ -22,4 +22,7 @@
|
||||
= link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => t('actions.save'), :style => 'display: none'
|
||||
= link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => t('actions.cancel'), :style => 'display: none'
|
||||
= link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => t('actions.edit')
|
||||
= link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove', :confirm => t(:are_you_sure)}, :title => t('actions.delete')
|
||||
= link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove'}, :title => t('actions.delete')
|
||||
|
||||
= render 'spree/admin/shared/custom-alert'
|
||||
= render 'spree/admin/shared/custom-confirm'
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
%td{width: "10%" }
|
||||
|
||||
%td{ :align => "right" }
|
||||
%h4= @order.order_cycle.andand.name
|
||||
%h4= @order.order_cycle&.name
|
||||
%tr{ valign: "top" }
|
||||
%td{ align: "left", colspan: 3 }
|
||||
%strong= "#{t('.from')}: #{@order.distributor.name}"
|
||||
@@ -35,14 +35,14 @@
|
||||
%br
|
||||
- if @order.bill_address
|
||||
= @order.bill_address.full_name
|
||||
- if @order.andand.customer.andand.code.present?
|
||||
- if @order&.customer&.code.present?
|
||||
%br
|
||||
= "#{t('.code')}: #{@order.customer.code}"
|
||||
%br
|
||||
- if @order.bill_address
|
||||
= @order.bill_address.full_address
|
||||
%br
|
||||
- if @order.andand.customer.andand.email.present?
|
||||
- if @order&.customer&.email.present?
|
||||
= "#{@order.customer.email},"
|
||||
- if @order.bill_address
|
||||
= "#{@order.bill_address.phone}"
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
%br
|
||||
- if @order.bill_address
|
||||
%strong= @order.bill_address.full_name
|
||||
- if @order.andand.customer.andand.code.present?
|
||||
- if @order&.customer&.code.present?
|
||||
%br
|
||||
= "Code: #{@order.customer.code}"
|
||||
%br
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
%span.icon-user
|
||||
= t "your_profil_live"
|
||||
.list
|
||||
%a.button.bottom{href: main_app.enterprise_shop_url(@enterprise), target: '_blank'}
|
||||
%a.button.bottom{href: enterprise_url_selector(@enterprise), target: '_blank'}
|
||||
= t "see"
|
||||
= @enterprise.name
|
||||
= t "live"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
placeholder: t(".enterprise_select_placeholder"),
|
||||
data: 'shops', ng: { model: 'paymentMethod.preferred_enterprise_id' } }
|
||||
- else
|
||||
%strong= Enterprise.find_by(id: @payment_method).andand.name
|
||||
%strong= Enterprise.find_by(id: @payment_method)&.name
|
||||
|
||||
#stripe-account-status{ ng: { show: "paymentMethod.preferred_enterprise_id" } }
|
||||
.alert-box.warning{ ng: { hide: "stripe_account.status" } }
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
= form_tag spree.users_and_enterprises_admin_reports_url do |f|
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_enterprises)
|
||||
.omega.fourteen.columns= select_tag(:enterprise_id_in, options_from_collection_for_select(Enterprise.all, :id, :name, params[:enterprise_id_in].andand.split(",")), {class: "select2 fullwidth", multiple: true})
|
||||
.omega.fourteen.columns= select_tag(:enterprise_id_in, options_from_collection_for_select(Enterprise.all, :id, :name, params[:enterprise_id_in]&.split(",")), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_users)
|
||||
.omega.fourteen.columns= select_tag(:user_id_in, options_from_collection_for_select(Spree::User.all, :id, :email, params[:user_id_in].andand.split(",")), {class: "select2 fullwidth", multiple: true})
|
||||
.omega.fourteen.columns= select_tag(:user_id_in, options_from_collection_for_select(Spree::User.all, :id, :email, params[:user_id_in]&.split(",")), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
-# Might need this later if we add different kinds of reports
|
||||
-# .row
|
||||
|
||||
8
app/views/spree/admin/shared/_custom-alert.html.haml
Normal file
8
app/views/spree/admin/shared/_custom-alert.html.haml
Normal file
@@ -0,0 +1,8 @@
|
||||
#custom-alert.modal
|
||||
.modal-content
|
||||
.modal-title
|
||||
%i.icon-warning-sign
|
||||
.message
|
||||
.action-buttons
|
||||
%button.confirm
|
||||
= t(:ok)
|
||||
11
app/views/spree/admin/shared/_custom-confirm.html.haml
Normal file
11
app/views/spree/admin/shared/_custom-confirm.html.haml
Normal file
@@ -0,0 +1,11 @@
|
||||
#custom-confirm.modal
|
||||
.modal-content
|
||||
.modal-title
|
||||
%i.icon-question-sign
|
||||
.message
|
||||
= t(:are_you_sure)
|
||||
.action-buttons
|
||||
%button.cancel
|
||||
= t(:cancel)
|
||||
%button.confirm.red
|
||||
= t(:ok)
|
||||
@@ -1,17 +1,17 @@
|
||||
- if @order.shipping_method.andand.delivery?
|
||||
- if @order.shipping_method&.delivery?
|
||||
/ Delivery details
|
||||
%p.callout
|
||||
%strong
|
||||
- if @order.shipping_method.andand.name
|
||||
- if @order.shipping_method&.name
|
||||
#{@order.shipping_method.name.html_safe}
|
||||
- else
|
||||
= t :email_shipping_delivery_details
|
||||
|
||||
- if @order.order_cycle.andand.pickup_time_for(@order.distributor)
|
||||
- if @order.order_cycle&.pickup_time_for(@order.distributor)
|
||||
%h4
|
||||
= t :email_shipping_delivery_time
|
||||
%strong #{@order.order_cycle.pickup_time_for(@order.distributor)}
|
||||
- if @order.shipping_method.andand.description
|
||||
- if @order.shipping_method&.description
|
||||
%p
|
||||
%em #{@order.shipping_method.description.html_safe}
|
||||
%br
|
||||
@@ -32,22 +32,22 @@
|
||||
/ Collection details
|
||||
%p.callout
|
||||
%strong
|
||||
- if @order.shipping_method.andand.name
|
||||
- if @order.shipping_method&.name
|
||||
#{@order.shipping_method.name.html_safe}
|
||||
- else
|
||||
= t :email_shipping_collection_details
|
||||
|
||||
- if @order.order_cycle.andand.pickup_time_for(@order.distributor).present?
|
||||
- if @order.order_cycle&.pickup_time_for(@order.distributor).present?
|
||||
%h4
|
||||
= t :email_shipping_collection_time
|
||||
%strong #{@order.order_cycle.pickup_time_for(@order.distributor)}
|
||||
|
||||
- if @order.shipping_method.andand.description.present?
|
||||
- if @order.shipping_method&.description.present?
|
||||
%p
|
||||
%em #{@order.shipping_method.description.html_safe}
|
||||
%br
|
||||
|
||||
- if @order.order_cycle.andand.pickup_instructions_for(@order.distributor).present?
|
||||
- if @order.order_cycle&.pickup_instructions_for(@order.distributor).present?
|
||||
%p
|
||||
%strong
|
||||
= t :email_shipping_collection_instructions
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
|
||||
= render 'spree/shared/line_item_name', line_item: line_item
|
||||
|
||||
- if @insufficient_stock_lines.andand.include? line_item
|
||||
- if @insufficient_stock_lines&.include? line_item
|
||||
%span.out-of-stock
|
||||
= variant.in_stock? ? t(".insufficient_stock", :on_hand => variant.on_hand) : t(".out_of_stock")
|
||||
%br/
|
||||
|
||||
- if @unavailable_order_variants.andand.include? line_item.variant
|
||||
- if @unavailable_order_variants&.include? line_item.variant
|
||||
%span.out-of-stock
|
||||
= t(".unavailable_item")
|
||||
%br/
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
- if order.changes_allowed?
|
||||
.columns.show-for-medium-up.medium-3
|
||||
.columns.small-12.medium-3
|
||||
= link_to main_app.cancel_order_path(@order), method: :put, :class => "button secondary expand", "confirm-link-click" => t('orders_confirm_cancel') do
|
||||
= link_to main_app.cancel_order_path(@order), method: :put, class: "button secondary expand", "data-confirm": t('orders_confirm_cancel') do
|
||||
%i.ofn-i_009-close
|
||||
= t(:cancel_order)
|
||||
.columns.small-12.medium-3
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
= order.bill_address.phone
|
||||
|
||||
.columns.large-6
|
||||
- if order.shipping_method.andand.require_ship_address
|
||||
- if order.shipping_method&.require_ship_address
|
||||
= render 'spree/shared/shipment_delivery_details', order: order
|
||||
- else
|
||||
= render 'spree/shared/shipment_pickup_details', order: order
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
= t :order_delivery_time
|
||||
%strong #{order.order_cycle.pickup_time_for(order.distributor)}
|
||||
%p.text-small.text-skinny.pre-line
|
||||
%em= order.shipping_method.description.andand.html_safe || ""
|
||||
%em= order.shipping_method.description&.html_safe || ""
|
||||
.order-summary.text-small
|
||||
%strong
|
||||
= t :order_delivery_address
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
= t :order_pickup_time
|
||||
%strong #{order.order_cycle.pickup_time_for(order.distributor)}
|
||||
%p.text-small.text-skinny.pre-line
|
||||
%em= order.shipping_method.description.andand.html_safe || ""
|
||||
%em= order.shipping_method.description&.html_safe || ""
|
||||
|
||||
- if order.order_cycle.pickup_instructions_for(order.distributor).present?
|
||||
%br
|
||||
|
||||
@@ -21,4 +21,4 @@
|
||||
%td.order6.text-right.brick
|
||||
%a{"ng-href" => "{{::order.path}}" }= t('.edit')
|
||||
%td.order7.show-for-large-up.text-right
|
||||
= link_to t('.cancel'), "", method: :put, "ng-href" => "{{::order.cancel_path}}", "confirm-link-click" => t('orders_confirm_cancel')
|
||||
= link_to t('.cancel'), "", method: :put, "ng-href": "{{::order.cancel_path}}", "data-confirm": t('orders_confirm_cancel')
|
||||
|
||||
20
app/webpacker/controllers/flash_controller.js
Normal file
20
app/webpacker/controllers/flash_controller.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Controller } from "stimulus"
|
||||
|
||||
document.addEventListener('turbolinks:before-cache', () =>
|
||||
document.getElementById('flash').remove()
|
||||
)
|
||||
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
setTimeout(this.fadeout.bind(this), 3000)
|
||||
}
|
||||
|
||||
fadeout() {
|
||||
this.element.classList.add("animate-hide-500")
|
||||
setTimeout(this.close.bind(this), 500)
|
||||
}
|
||||
|
||||
close() {
|
||||
this.element.remove()
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user