Skip to content

Commit

Permalink
Merge pull request #167 from diegosteiner/develop
Browse files Browse the repository at this point in the history
Release 22.9.1
  • Loading branch information
diegosteiner authored Sep 7, 2022
2 parents d90ec46 + 9170b65 commit c1acf40
Show file tree
Hide file tree
Showing 134 changed files with 1,592 additions and 1,497 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"prettier/prettier": "warn",
"react/jsx-uses-vars": "error",
"react/prop-types": "off",
"max-len": ["error", 120]
"max-len": ["error", 120],
"react/no-unknown-property": ["error", { "ignore": ["css"] }]
},
"env": {
"browser": true,
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

#### Unreleased

#### Version 22.9.1

Released on 07.09.2022

- Feature: Unify tarifs and usages in a single tab
- Feature: Set indiviual colors for occupancies through booking
- Feature: Define multiple invoice_types per tarif
- Fix: Show invoice_parts for missing usages

#### Version 22.8.2

Released on 24.08.2022
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source 'https://rubygems.org'

ruby '3.1.2'

gem 'active_flag'
gem 'aws-sdk-s3', require: false
gem 'barnes'
gem 'blueprinter'
Expand All @@ -14,15 +15,13 @@ gem 'cancancan'
gem 'connection_pool'
gem 'countries'
gem 'country_select', '~> 6.0'
gem 'dalli'
gem 'date_time_attribute'
gem 'devise'
gem 'devise-i18n'
gem 'discard'
gem 'factory_bot_rails', require: false
gem 'faker', require: false
gem 'faraday', require: false
gem 'hiredis'
gem 'icalendar'
gem 'inline_svg'
gem 'kramdown'
Expand Down
34 changes: 18 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ GEM
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_flag (1.6.0)
activerecord (>= 5)
activejob (7.0.3.1)
activesupport (= 7.0.3.1)
globalid (>= 0.3.6)
Expand All @@ -66,15 +68,15 @@ GEM
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
ast (2.4.2)
aws-eventstream (1.2.0)
aws-partitions (1.619.0)
aws-sdk-core (3.132.0)
aws-partitions (1.626.0)
aws-sdk-core (3.141.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -141,7 +143,6 @@ GEM
countries (~> 4.2)
sort_alphabetical (~> 1.1)
crass (1.0.6)
dalli (3.2.2)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
database_cleaner-active_record (2.0.1)
Expand Down Expand Up @@ -177,7 +178,7 @@ GEM
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
faker (2.22.0)
faker (2.23.0)
i18n (>= 1.8.11, < 2)
faraday (2.5.2)
faraday-net_http (>= 2.0, < 3.1)
Expand All @@ -188,7 +189,6 @@ GEM
globalid (1.0.0)
activesupport (>= 5.0)
highline (2.0.3)
hiredis (0.6.3)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
i18n-tasks (0.9.37)
Expand Down Expand Up @@ -239,7 +239,7 @@ GEM
mobility (1.2.9)
i18n (>= 0.6.10, < 2)
request_store (~> 1.0)
msgpack (1.5.4)
msgpack (1.5.6)
multi_json (1.15.0)
net-imap (0.2.3)
digest
Expand Down Expand Up @@ -268,7 +268,7 @@ GEM
prawn (2.4.0)
pdf-core (~> 0.9.0)
ttfunk (~> 1.7)
prawn-markup (0.3.6)
prawn-markup (0.3.7)
nokogiri
prawn
prawn-table
Expand All @@ -282,8 +282,8 @@ GEM
pry-rescue (1.5.2)
interception (>= 0.5)
pry (>= 0.12.0)
public_suffix (4.0.7)
puma (5.6.4)
public_suffix (5.0.0)
puma (5.6.5)
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.4)
Expand Down Expand Up @@ -326,7 +326,7 @@ GEM
rake (13.0.6)
ranked-model (0.4.8)
activerecord (>= 4.2)
rb-fsevent (0.11.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
react-rails (2.6.2)
Expand All @@ -335,7 +335,10 @@ GEM
execjs
railties (>= 3.2)
tilt
redis (4.7.1)
redis (5.0.3)
redis-client (>= 0.7.4)
redis-client (0.7.4)
connection_pool
regexp_parser (2.5.0)
request_store (1.5.1)
rack (>= 1.4)
Expand Down Expand Up @@ -367,7 +370,7 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.11.0)
rubocop (1.35.0)
rubocop (1.36.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
Expand Down Expand Up @@ -447,6 +450,7 @@ PLATFORMS
ruby

DEPENDENCIES
active_flag
annotate
aws-sdk-s3
barnes
Expand All @@ -465,7 +469,6 @@ DEPENDENCIES
connection_pool
countries
country_select (~> 6.0)
dalli
database_cleaner
date_time_attribute
devise
Expand All @@ -477,7 +480,6 @@ DEPENDENCIES
faker
faraday
foreman
hiredis
i18n-tasks
i18n-tasks-csv
icalendar
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Prepare a csv with these columns, including a header, as utf-8:
- tarif_group
- unit
- price
- invoice_type
- invoice_types

Then import data with:

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
V22.8.2
V22.9.1
3 changes: 2 additions & 1 deletion app/controllers/manage/bookings/contracts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def new
rich_text_template = current_organisation.rich_text_templates.enabled.by_key(:contract_text,
home_id: @booking.home_id)
I18n.with_locale(@booking.locale) do
@contract.text = rich_text_template&.interpolate('booking' => @booking)&.body
@contract.text = rich_text_template&.interpolate(booking: @booking, home: @booking.home,
organisation: @booking.organisation)&.body
end
respond_with :manage, @booking, @contract
end
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/manage/bookings/offers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def index
def new
@offer.valid_from = Time.zone.now
@offer.text = current_organisation.rich_text_templates.enabled.by_key(:offer_text)
&.interpolate('booking' => @booking)&.body
&.interpolate(booking: @booking, home: @booking.home,
organisation: @booking.organisation)&.body
respond_with :manage, @booking, @offer
end

Expand Down
40 changes: 0 additions & 40 deletions app/controllers/manage/bookings/tarifs_controller.rb

This file was deleted.

10 changes: 5 additions & 5 deletions app/controllers/manage/bookings/usages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class UsagesController < BaseController
load_and_authorize_resource :usage, through: :booking

def index
@usages = @usages.includes(:tarif)
@usages = @usages.includes(tarif: :tarif_selectors)
@suggested_usages = Usage::Factory.new(@booking).build(usages: @usages)
@suggested_usages = @suggested_usages.select(&:preselect) if suggest_usages?
respond_to do |format|
format.html
format.pdf do
Expand All @@ -31,7 +33,6 @@ def create
end

def update_many
set_usage_flags
@booking.update(booking_usages_params)
respond_with :manage, @booking, @usages,
responder_flash_messages(Usage.model_name.human(count: :other))
Expand All @@ -50,9 +51,8 @@ def destroy

private

def set_usage_flags
@booking.usages_entered ||= params[:usages_entered].present?
@booking.usages_presumed ||= params[:usages_presumed].present?
def suggest_usages?
@booking.usages.none?(&:persisted?) || params[:suggest_usages].present?
end

def usage_params
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/manage/tarifs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ module Manage
class TarifsController < BaseController
def create
@tarif.save
respond_with :manage, @tarif.parent, @tarif
respond_with :manage, @tarif.home, @tarif
end

def update
@tarif.update(tarif_params)
respond_with :manage, @tarif.parent, @tarif
respond_with :manage, @tarif.home, @tarif
end

protected
Expand Down
2 changes: 1 addition & 1 deletion app/domain/booking_states/definitive_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def relevant_time

def choose_tarifs_checklist_item
ChecklistItem.new(:choose_tarifs, booking.usages.any?,
manage_booking_tarifs_path(
manage_booking_usages_path(
booking, org: booking.organisation.slug, locale: I18n.locale
))
end
Expand Down
2 changes: 1 addition & 1 deletion app/domain/booking_states/past.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def relevant_time
protected

def enter_usages_checklist_item
ChecklistItem.new(:create_usages, booking.usages_entered?,
ChecklistItem.new(:create_usages, booking.usages.all?(&:committed),
manage_booking_usages_path(booking, org: booking.organisation.slug))
end

Expand Down
13 changes: 9 additions & 4 deletions app/javascript/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ function csrfForm() {

function toggleDisable() {
document.querySelectorAll('[data-bs-toggle="disable"]').forEach((element) => {
element.onclick = (ev) => {
const target = document.querySelector(element.getAttribute("href"));
if (target) target.disabled = false;
ev.preventDefault();
const handler = () => {
document.querySelectorAll(element.dataset.bsTarget).forEach((target) => {
target.disabled = !element.checked;
});
};
element.addEventListener("change", (event) => {
event.preventDefault;
handler();
});
handler();
});
}

Expand Down
6 changes: 6 additions & 0 deletions app/javascript/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ tr.disabled {
height: 500px;
}

.occupancy-info {
display: grid;
grid-template-columns: 2em auto;
grid-template-rows: auto auto auto;
}

.booking-nav {
justify-content: flex-start;
border-top-left-radius: 0.25rem;
Expand Down
4 changes: 3 additions & 1 deletion app/mailers/organisation_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def attach_active_storage_attachments(values)
end

def set_delivery_options
mail.delivery_method.settings.merge!(@organisation.smtp_settings.to_h) if @organisation.smtp_settings.present?
return unless Rails.env.production? && @organisation.smtp_settings.present?

mail.delivery_method.settings.merge!(@organisation.smtp_settings.to_h)
end

# rubocop:disable Naming/MemoizedInstanceVariableName
Expand Down
2 changes: 0 additions & 2 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Manage < Base
can :manage, DataDigest, organisation: organisation
can :manage, RichTextTemplate, organisation: organisation
can :manage, Tarif, home: { organisation: organisation }
can :manage, Tarif, booking: { organisation: organisation }
can :manage, TarifSelector, home: { organisation: organisation }
can :manage, Tenant, organisation: organisation
can :manage, Booking, organisation: organisation
Expand Down Expand Up @@ -63,7 +62,6 @@ class Manage < Base
can %i[read digest], DataDigest, organisation: organisation
can :read, RichTextTemplate, organisation: organisation
can :read, Tarif, home: { organisation: organisation }
can :read, Tarif, booking: { organisation: organisation }
can :read, TarifSelector, home: { organisation: organisation }
can :read, Tenant, organisation: organisation
can :read, Booking, organisation: organisation
Expand Down
Loading

0 comments on commit c1acf40

Please sign in to comment.