Skip to content

Commit

Permalink
v2.6.0 (#52)
Browse files Browse the repository at this point in the history
    Migrate to ruby 3.1
    Migrate to dart-sass

Added

    User tickets list updated dinamically with turbo stream
    admin list ticket updated dinamically with turbo stream
    Added fact filter by group
    Added foreman support for dev

Fixed

    Fixed RAILS-UJS load
    fixed fact's pagination and visualization

removed

    removed builded asset from git
    removed unused bin

fixed

    fixed fact's pagination and visualization
    fixed rails-ujs load
    clean unused broadcast
  • Loading branch information
MdreW authored Feb 11, 2022
1 parent 738668d commit d5da8e7
Show file tree
Hide file tree
Showing 39 changed files with 299 additions and 149 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ config/environments/*.local.yml
/yarn-error.log
yarn-debug.log*
.yarn-integrity

/app/assets/builds/*
!/app/assets/builds/.keep
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-3.0.3
ruby-3.1.0
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.6.0]
- Migrate to ruby 3.1
- Migrate to dart-sass
### Added
- User tickets list updated dinamically with turbo stream
- admin list ticket updated dinamically with turbo stream
- Added fact filter by group
- Added foreman support for dev
### Fixed
- Fixed RAILS-UJS load
- fixed fact's pagination and visualization
### removed
- removed builded asset from git
- removed unused bin

### fixed
- fixed fact's pagination and visualization
- fixed rails-ujs load
- clean unused broadcast

## [2.5.2]
- Migrate from webpack to importmap
- Docker go to production enviroment
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dockerfile.rails
FROM ruby:3.0.3-slim AS rails-toolbox
FROM ruby:3.1.0-slim AS rails-toolbox
MAINTAINER Marco Spasiano <[email protected]>

ARG USER_ID
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.0.3'
ruby '3.1.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'master'
gem "rails", "~> 7.0.1"
Expand Down Expand Up @@ -47,8 +47,8 @@ gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

# Use Sass to process CSS
gem 'sassc-rails'
# Use Sass to process
gem 'dartsass-rails'

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
gem "image_processing", "~> 1.2"
Expand Down
29 changes: 16 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ GEM
ast (2.4.2)
bcrypt (3.1.16)
bindex (0.8.1)
bootsnap (1.10.1)
bootsnap (1.10.3)
msgpack (~> 1.2)
builder (3.2.4)
capybara (3.36.0)
Expand All @@ -92,6 +92,8 @@ GEM
crass (1.0.6)
cssbundling-rails (1.0.0)
railties (>= 6.0.0)
dartsass-rails (0.2.0)
railties (>= 6.0.0)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
database_cleaner-active_record (2.0.1)
Expand All @@ -108,7 +110,7 @@ GEM
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise_cas_authenticatable (2.0.0)
devise_cas_authenticatable (2.0.1)
devise (>= 4.0.0)
rack-cas
digest (3.1.0)
Expand Down Expand Up @@ -153,11 +155,11 @@ GEM
ffi (1.15.5)
globalid (1.0.0)
activesupport (>= 5.0)
hamlit (2.15.2)
hamlit (2.16.0)
temple (>= 0.8.2)
thor
tilt
i18n (1.8.11)
i18n (1.9.1)
concurrent-ruby (~> 1.0)
image_processing (1.12.1)
mini_magick (>= 4.9.5, < 5)
Expand Down Expand Up @@ -187,7 +189,7 @@ GEM
mini_mime (1.1.2)
mini_portile2 (2.7.1)
minitest (5.15.0)
msgpack (1.4.3)
msgpack (1.4.4)
net-imap (0.2.3)
digest
net-protocol
Expand All @@ -208,14 +210,14 @@ GEM
mini_portile2 (~> 2.7.0)
racc (~> 1.4)
orm_adapter (0.5.0)
pagy (5.9.0)
pagy (5.10.1)
activesupport
parallel (1.21.0)
parser (3.1.0.0)
ast (~> 2.4.1)
pg (1.2.3)
pg (1.3.1)
public_suffix (4.0.6)
puma (5.5.2)
puma (5.6.1)
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.3)
Expand Down Expand Up @@ -253,15 +255,15 @@ GEM
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
redis (4.5.1)
redis (4.6.0)
regexp_parser (2.2.0)
reline (0.3.1)
io-console (~> 0.5)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5)
rubocop (1.25.0)
rubocop (1.25.1)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
Expand Down Expand Up @@ -333,7 +335,7 @@ GEM
nokogiri (~> 1.8)
yard (0.9.27)
webrick (~> 1.7.0)
zeitwerk (2.5.3)
zeitwerk (2.5.4)

PLATFORMS
ruby
Expand All @@ -343,6 +345,7 @@ DEPENDENCIES
capybara
config
cssbundling-rails
dartsass-rails
database_cleaner
debug
devise
Expand Down Expand Up @@ -372,7 +375,7 @@ DEPENDENCIES
yard

RUBY VERSION
ruby 3.0.3p157
ruby 3.1.0p0

BUNDLED WITH
2.2.32
2.3.3
1 change: 1 addition & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
web: bin/rails server -p 3000
js: yarn build --watch
css: yarn build:css --watch
css: bin/rails dartsass:watch
Empty file added app/assets/builds/.keep
Empty file.
96 changes: 96 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// @charset "utf-8";

$rgba-primary-0: rgba(135, 38, 67,1); // Main Primary color */
$rgba-primary-1: rgba(209,125,151,1);
$rgba-primary-2: rgba(169, 72,101,1);
$rgba-primary-3: rgba( 98, 12, 38,1);
$rgba-primary-4: rgba( 62, 0, 19,1);

$rgba-secondary-1-0: rgba(151,101, 43,1); // Main Secondary color (1) */
$rgba-secondary-1-1: rgba(233,190,140,1);
$rgba-secondary-1-2: rgba(189,139, 81,1);
$rgba-secondary-1-3: rgba(110, 65, 13,1);
$rgba-secondary-1-4: rgba( 69, 37, 0,1);

$rgba-secondary-2-0: rgba( 30, 74, 96,1); // Main Secondary color (2) */
$rgba-secondary-2-1: rgba( 92,129,148,1);
$rgba-secondary-2-2: rgba( 55, 98,119,1);
$rgba-secondary-2-3: rgba( 11, 50, 69,1);
$rgba-secondary-2-4: rgba( 2, 30, 44,1);

$rgba-complement-0: rgba( 82,134, 38,1); // Main Complement color */
$rgba-complement-1: rgba(162,208,125,1);
$rgba-complement-2: rgba(116,168, 72,1);
$rgba-complement-3: rgba( 51, 98, 12,1);
$rgba-complement-4: rgba( 28, 62, 0,1);

// Colori sito
$ispra: rgb(135, 38, 67);
$ispra-darker: rgb(66, 12, 24);
$ispra-secondary: rgb(30, 74, 96);
$ispra-secondary-darker: rgb(2, 30, 44);
$ispra-tertiary: rgb(151, 101, 43);
$ispra-tertiary-darker: rgb(69, 37, 0);
$ispra-opposite: rgb(82, 134, 38);
$ispra-opposite-darker: rgb(28, 62, 0);

// Update Bulma's global variables
$primary: $rgba-primary-0;
$primary-dark: #661224;
$secondary: $rgba-complement-0;
$secondary-darker: rgb(2, 30, 44);
$tertiary: rgb(151, 101, 43);
$grey-lighter: #e3e0d7;


// Import a Google Font
// @import url('https://fonts.googleapis.com/css?family=Nunito:400,700');

// Set your brand colors
// $purple: #8A4D76;
// $pink: #FA7C91;
// $brown: #757763;
// $beige-light: #D0D1CD;
// $beige-lighter: #EFF0EB;

// Update Bulma's global variables
// $family-sans-serif: "Nunito", sans-serif;
// $grey-dark: $brown;
// $grey-light: $beige-light;
// $primary: $purple;
// $link: $pink;
// $widescreen-enabled: false;
// $fullhd-enabled: false;

// Update some of Bulma's component variables
// $body-background-color: $beige-lighter;
// $control-border-width: 2px;
// $input-border-color: transparent;
// $input-shadow: none;

// Import only what you need from Bulma
// @import "bulma/sass/utilities/_all.sass";
// @import "bulma/sass/base/_all.sass";
// @import "bulma/sass/elements/button.sass";
// @import "bulma/sass/elements/container.sass";
// @import "bulma/sass/elements/title.sass";
// @import "bulma/sass/form/_all.sass";
// @import "bulma/sass/components/navbar.sass";
// @import "bulma/sass/layout/hero.sass";
// @import "bulma/sass/layout/section.sass";

@import '../../../node_modules/bulma/bulma.sass';
@import 'actiontext.css';

@import "ribbon";
@import "header";
@import "footer";
@import "nav1";
@import "nav2";
@import "nav3";
@import "footer";
@import "variants";
@import "loader";
@import "form";
@import "box";
@import "slimselect";
2 changes: 1 addition & 1 deletion app/controllers/editor/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class Editor::ApplicationController < ApplicationController

# deny access unless current_user is an editor
def authenticate_editor!
access_denied! unless current_user.editor? || current_user.admin?
access_denied! unless user_signed_in? && (current_user.editor? || current_user.admin?)
end
end
18 changes: 9 additions & 9 deletions app/controllers/editor/tickets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ def create
@ticket = Ticket.new(ticket_params)
@ticket.by_editor = true
if @ticket.save
flash[:success] = 'Prenotazione salvata'
redirect_to tickets_editor_fact_happening_path(@ticket.happening.fact, @ticket.happening)
broadcast_action_to "editor:happening_#{@ticket.happening_id}", action: :prepend, target: 'editor_tickets', locals: { ticket: self}, partial: 'editor/tickets/ticket'
render turbo_stream: [
turbo_stream.replace("editor_ticket_#{@ticket.id}", partial: 'ticket', locals: {ticlet: @ticket}),
turbo_stream.replace('modal', partial: 'modal_empty')
]

render 'empty_modal'
else
@users = User.pluck :username, :id
@status = { error: 'Creatione prenotazione fallita' }
render action: 'new'
end
Expand All @@ -60,20 +64,16 @@ def create
# PATCH/PUT /editor/facts/:fact_id/happenings/:happening_id/tickets/:id
def update
if @ticket.update(ticket_params.merge(by_editor: true))
flash[:success] = 'Prenotazione salvata'
render partial: 'ticket', locals: { ticket: @ticket, happening: @happening, fact: @fact }
render partial: 'modal_empty'
else
@users = User.pluck :username, :id
@status = { error: 'Aggionramento prenotazione fallito' }
render partial: 'form', locals: { ticket: @ticket, happening: @happening, fact: @fact }
end
end

# DELETE /editor/facts/:fact_id/happenings/:happening_id/tickets/:id
def destroy
@ticket.destroy
flash[:success] = 'Prenotazione eliminata'
redirect_to editor_fact_happening_path(@fact, @happening)
render partial: 'modal_empty'
end

private
Expand Down
9 changes: 6 additions & 3 deletions app/controllers/facts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ class FactsController < ApplicationController
before_action :set_fact, only: %i[show]

# GET /facts
def index; end
def index
@groups = Group.all if ENV['RAILS_GROUP_MENU'] || Settings.group_menu
end

# GET /facts/:id
def show; end
Expand All @@ -15,7 +17,8 @@ def show; end
def list
type = filter_params[:type] == 'history' ? 'history' : 'future'
@text = ['title ilike :text', { text: "%#{filter_params[:text]}%" }] if filter_params[:text].present?
@pagy, @facts = pagy(Fact.send(type).where(@text))
@group = {group: filter_params[:group]} if filter_params[:group].present?
@pagy, @facts = pagy(Fact.send(type).where(@text).where(@group), items: 6)
end

private
Expand All @@ -27,6 +30,6 @@ def set_fact

# Filter params for facts search
def filter_params
params.fetch(:filter, {}).permit(:text, :type)
params.fetch(:filter, {}).permit(:text, :type, :group)
end
end
2 changes: 2 additions & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Entry point for the build script in your package.json
import Rails from "@rails/ujs"
Rails.start()
import "@hotwired/turbo-rails"
import "./controllers"
import "trix"
Expand Down
6 changes: 1 addition & 5 deletions app/javascript/controllers/slim_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class extends Controller {
}

ajax(element, url) {
const slim = new SlimSelect({
new SlimSelect({
select: element,
placeholder: 'Seleziona un utente',
searchingText: 'Sto cercando...',
Expand All @@ -57,10 +57,6 @@ export default class extends Controller {
for (let i = 0; i < json.users.length; i++) {
data.push({text: json.users[i].username, value: json.users[i].id})
}

// Upon successful fetch send data to callback function.
// Be sure to send data back in the proper format.
// Refer to the method setData for examples of proper format.
callback(data)
})
.catch(function(error) { callback(false) })
Expand Down
1 change: 0 additions & 1 deletion app/models/happening.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def update_seats_count!
self.seats_count = tickets.sum :seats
save touch: false
broadcast_replace_to 'facts', target: "counter_happening_#{id}", partial: 'happenings/counter', locals: { happening: self }
broadcast_replace_to 'facts', target: "nav_fact_#{fact_id}", partial: 'facts/nav', locals: { fact: fact }
end
end

Expand Down
Loading

0 comments on commit d5da8e7

Please sign in to comment.