Compare commits

..

8 commits

Author SHA1 Message Date
4dd45b7b2f include foodsoft-article-import
use filetypes for manual uploading bnn, odin, foodsoft file

use opts in .parse

adapt specs to include file format

add specs for odin, bnn, foodsoft files

adapt localize input to remove ',' separator and replace with '.'

remove depr foodsoftfile.rb and spreadsheet.rb

remove todo
2023-02-22 14:46:14 +01:00
91a38bc73b move BigDecimal.new to BigDecimal() 2023-02-17 13:16:28 +01:00
782194cd08 change .search to .ransack for updated ransack gem 2023-02-17 13:16:19 +01:00
Philipp Rothmann
78da4feafe fix: assets precompile by using terser
importmaps broke precompiliation with uglifier
see: https://github.com/rails/importmap-rails/issues/5
2023-02-10 13:07:02 +01:00
Philipp Rothmann
666e7934a6 introduce importmaps
This commit introduces importmaps. They allow to use modern javacript ESM within rails without webpack, yarn etc.
see https://github.com/rails/importmap-rails for more details.

Co-authored-by: Philipp Rothmann <philipprothmann@posteo.de>
Co-authored-by: FGU <fgu@pragma-shift.net>
2023-02-10 12:24:42 +01:00
Philipp Rothmann
82d4ff0284 improve dockerfile caching 2023-02-09 17:22:38 +01:00
Philipp Rothmann
c487f0368a upgrade dockerfile to rails7 2023-02-09 17:21:05 +01:00
FGU
a7747c9e84 fix docker-compose 2023-02-02 10:14:26 +01:00
16 changed files with 38 additions and 17 deletions

View file

@ -1,4 +1,4 @@
FROM ruby:2.6 FROM ruby:2.7
RUN supercronicUrl=https://github.com/aptible/supercronic/releases/download/v0.1.3/supercronic-linux-amd64 && \ RUN supercronicUrl=https://github.com/aptible/supercronic/releases/download/v0.1.3/supercronic-linux-amd64 && \
supercronicBin=/usr/local/bin/supercronic && \ supercronicBin=/usr/local/bin/supercronic && \
@ -15,13 +15,16 @@ ENV PORT=3000 \
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY . ./ COPY Gemfile Gemfile.lock ./
COPY plugins/ ./plugins
COPY config/ ./config
# install dependencies and generate crontab # install dependencies and generate crontab
RUN buildDeps='libmagic-dev' && \ RUN buildDeps='libmagic-dev' && \
apt-get update && \ apt-get update && \
apt-get install --no-install-recommends -y $buildDeps && \ apt-get install --no-install-recommends -y $buildDeps && \
echo 'gem: --no-document' >> ~/.gemrc && \ echo 'gem: --no-document' >> ~/.gemrc && \
gem install bundler && \
bundle config build.nokogiri "--use-system-libraries" && \ bundle config build.nokogiri "--use-system-libraries" && \
bundle install --deployment --without development test -j 4 && \ bundle install --deployment --without development test -j 4 && \
apt-get purge -y --auto-remove $buildDeps && \ apt-get purge -y --auto-remove $buildDeps && \
@ -29,6 +32,8 @@ RUN buildDeps='libmagic-dev' && \
\ \
bundle exec whenever >crontab bundle exec whenever >crontab
COPY . ./
# compile assets with temporary mysql server # compile assets with temporary mysql server
RUN export DATABASE_URL=mysql2://localhost/temp?encoding=utf8 && \ RUN export DATABASE_URL=mysql2://localhost/temp?encoding=utf8 && \
export SECRET_KEY_BASE=thisisnotimportantnow && \ export SECRET_KEY_BASE=thisisnotimportantnow && \

View file

@ -7,7 +7,6 @@ gem 'mail', '~> 2.7.1' # bug with mail 2.8.0 https://github.com/mikel/mail/issue
gem 'sassc-rails' gem 'sassc-rails'
gem 'less-rails' gem 'less-rails'
gem 'uglifier'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes # See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby gem 'therubyracer', platforms: :ruby
@ -127,3 +126,7 @@ group :test do
gem 'rswag-specs' gem 'rswag-specs'
gem 'hashie', '~> 3.4.6', require: false # https://github.com/westfieldlabs/apivore/issues/114 gem 'hashie', '~> 3.4.6', require: false # https://github.com/westfieldlabs/apivore/issues/114
end end
gem "importmap-rails", "~> 1.1"
gem "terser", "~> 1.1"

View file

@ -264,6 +264,9 @@ GEM
i18n-spec (0.6.0) i18n-spec (0.6.0)
iso iso
ice_cube (0.16.4) ice_cube (0.16.4)
importmap-rails (1.1.5)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
inherited_resources (1.13.1) inherited_resources (1.13.1)
actionpack (>= 5.2, < 7.1) actionpack (>= 5.2, < 7.1)
has_scope (~> 0.6) has_scope (~> 0.6)
@ -553,6 +556,8 @@ GEM
sqlite3 (>= 1.3.3) sqlite3 (>= 1.3.3)
table_print (1.5.7) table_print (1.5.7)
temple (0.9.1) temple (0.9.1)
terser (1.1.13)
execjs (>= 0.3.0, < 3)
therubyracer (0.12.3) therubyracer (0.12.3)
libv8 (~> 3.16.14.15) libv8 (~> 3.16.14.15)
ref ref
@ -573,8 +578,6 @@ GEM
unf (~> 0.1.0) unf (~> 0.1.0)
tzinfo (2.0.5) tzinfo (2.0.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4) unf (0.1.4)
unf_ext unf_ext
unf_ext (0.0.8.2) unf_ext (0.0.8.2)
@ -638,6 +641,7 @@ DEPENDENCIES
i18n-js (~> 3.0.0.rc8) i18n-js (~> 3.0.0.rc8)
i18n-spec i18n-spec
ice_cube ice_cube
importmap-rails (~> 1.1)
inherited_resources inherited_resources
jquery-rails jquery-rails
kaminari kaminari
@ -689,11 +693,11 @@ DEPENDENCIES
sprockets (< 4) sprockets (< 4)
sqlite3 (~> 1.3.6) sqlite3 (~> 1.3.6)
table_print table_print
terser (~> 1.1)
therubyracer therubyracer
twitter-bootstrap-rails (~> 2.2.8) twitter-bootstrap-rails (~> 2.2.8)
uglifier
web-console web-console
whenever whenever
BUNDLED WITH BUNDLED WITH
2.4.2 2.4.5

View file

@ -18,7 +18,7 @@ class Finance::FinancialTransactionsController < ApplicationController
sort = "created_on DESC" sort = "created_on DESC"
end end
@q = FinancialTransaction.search(params[:q]) @q = FinancialTransaction.ransack(params[:q])
@financial_transactions_all = @q.result(distinct: true).includes(:user).order(sort) @financial_transactions_all = @q.result(distinct: true).includes(:user).order(sort)
@financial_transactions_all = @financial_transactions_all.visible unless params[:show_hidden] @financial_transactions_all = @financial_transactions_all.visible unless params[:show_hidden]
@financial_transactions_all = @financial_transactions_all.where(ordergroup_id: @ordergroup.id) if @ordergroup @financial_transactions_all = @financial_transactions_all.where(ordergroup_id: @ordergroup.id) if @ordergroup

View file

@ -0,0 +1 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails

View file

@ -32,8 +32,8 @@ class GroupOrder < ApplicationRecord
# Generate some data for the javascript methods in ordering view # Generate some data for the javascript methods in ordering view
def load_data def load_data
data = {} data = {}
data[:account_balance] = ordergroup.nil? ? BigDecimal.new('+Infinity') : ordergroup.account_balance data[:account_balance] = ordergroup.nil? ? BigDecimal('+Infinity') : ordergroup.account_balance
data[:available_funds] = ordergroup.nil? ? BigDecimal.new('+Infinity') : ordergroup.get_available_funds(self) data[:available_funds] = ordergroup.nil? ? BigDecimal('+Infinity') : ordergroup.get_available_funds(self)
# load prices and other stuff.... # load prices and other stuff....
data[:order_articles] = {} data[:order_articles] = {}

View file

@ -8,10 +8,10 @@
= csrf_meta_tags = csrf_meta_tags
= stylesheet_link_tag "application", :media => "all" = stylesheet_link_tag "application", :media => "all"
//%link(href="images/favicon.ico" rel="shortcut icon") //%link(href="images/favicon.ico" rel="shortcut icon")
= yield(:head) = yield(:head)
= foodcoop_css_tag = foodcoop_css_tag
%body %body
= yield = yield
@ -19,7 +19,9 @@
Javascripts Javascripts
\================================================== \==================================================
/ Placed at the end of the document so the pages load faster / Placed at the end of the document so the pages load faster
= javascript_include_tag "application" = javascript_importmap_tags
= javascript_include_tag "application_legacy"
:javascript :javascript
I18n.defaultLocale = "#{I18n.default_locale}"; I18n.defaultLocale = "#{I18n.default_locale}";
I18n.locale = "#{I18n.locale}"; I18n.locale = "#{I18n.locale}";

4
bin/importmap Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative "../config/application"
require "importmap/commands"

View file

@ -29,7 +29,7 @@ Rails.application.configure do
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :terser
config.assets.css_compressor = :sass config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed. # Do not fallback to assets pipeline if a precompiled asset is missed.

2
config/importmap.rb Normal file
View file

@ -0,0 +1,2 @@
# Pin npm packages by running ./bin/importmap
pin "application", preload: true

View file

@ -9,4 +9,4 @@ Rails.application.config.assets.version = '1.0'
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets # application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added. # folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css ) Rails.application.config.assets.precompile += %w( application_legacy.js jquery.min.js )

View file

@ -3,7 +3,7 @@ class String
# remove comma from decimal inputs # remove comma from decimal inputs
def self.delocalized_decimal(string) def self.delocalized_decimal(string)
if !string.blank? and string.is_a?(String) if !string.blank? and string.is_a?(String)
BigDecimal.new(string.sub(',', '.')) BigDecimal(string.sub(',', '.'))
else else
string string
end end

View file

@ -32,7 +32,7 @@ class CurrentOrders::ArticlesController < ApplicationController
else else
@order_articles = OrderArticle.where(order_id: @current_orders.all.map(&:id)) @order_articles = OrderArticle.where(order_id: @current_orders.all.map(&:id))
end end
@q = OrderArticle.search(params[:q]) @q = OrderArticle.ransack(params[:q])
@order_articles = @order_articles.ordered.merge(@q.result).includes(:article, :article_price) @order_articles = @order_articles.ordered.merge(@q.result).includes(:article, :article_price)
@order_article = @order_articles.where(id: params[:id]).first @order_article = @order_articles.where(id: params[:id]).first
end end

0
vendor/javascript/.keep vendored Normal file
View file