Skip to content

Commit

Permalink
Update (#108)
Browse files Browse the repository at this point in the history
* 103 aggiungere tipi di domande integer e data (#107)

* aggiunte tipologie di domande per allegati, date, numeri

* Aggiunti devcontainer

* navbar title configuration with RAILS_TITLE and RAILS_ICON (#106)
  • Loading branch information
MdreW authored Dec 18, 2024
1 parent 276eb3a commit 163a7f6
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=3.3.5
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION
36 changes: 36 additions & 0 deletions .devcontainer/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "rails_app"

services:
rails-app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Uncomment the next line to use a non-root user for all processes.
# user: vscode

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
depends_on:
- selenium
- redis

selenium:
image: selenium/standalone-chromium
restart: unless-stopped

redis:
image: redis:7.2
restart: unless-stopped
volumes:
- redis-data:/data


volumes:
redis-data:
36 changes: 36 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// For format details, see https://containers.dev/implementors/json_reference/.
// For config options, see the README at: https://github.com/devcontainers/templates/tree/main/src/ruby
{
"name": "rails_app",
"dockerComposeFile": "compose.yaml",
"service": "rails-app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/rails/devcontainer/features/activestorage": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/rails/devcontainer/features/sqlite3": {}
},

"containerEnv": {
"CAPYBARA_SERVER_PORT": "45678",
"SELENIUM_HOST": "selenium",
"REDIS_URL": "redis://redis:6379/1",
"KAMAL_REGISTRY_PASSWORD": "$KAMAL_REGISTRY_PASSWORD"
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [3000, 6379],

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://containers.dev/implementors/json_reference/#remoteUser.
// "remoteUser": "root",


// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bin/setup --skip-server"
}
6 changes: 6 additions & 0 deletions app/components/answers/sub_form_component.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
= @form.text_area :value, class: 'textarea', required: @form.object.question_mandatory?
- when 'select'
.select.is-fullwidth= @form.select :value, @form.object.question.options.map(&:title), {}, required: @form.object.question_mandatory?
- when 'file'
= @form.file_field :file, class: 'input', required: @form.object.question_mandatory?
- when 'number'
= @form.number_field :value, class: 'input', required: @form.object.question_mandatory?
- when 'date'
= @form.date_field :value, class: 'input', required: @form.object.question_mandatory?

3 changes: 2 additions & 1 deletion app/components/layout/navbar_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def navbar

# Generate the navbar-title html block
def navbar_title
safe_join([ icon_text("fas fa-signature", "P"), "artecipo" ])
title = ENV.fetch("RAILS_TITLE", "Partecipo")
safe_join([ icon_text(ENV.fetch("RAILS_ICON", "fas fa-signature"), title.first), title[1..] ])
end

# Gerate the navbar-start html block
Expand Down
4 changes: 3 additions & 1 deletion app/components/tickets/ticket_component.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
- @ticket.answers.each do |answer|
%tr
%th.is-size-7.is-narrow= answer.question.title
%td.is-size-7= answer.value
%td.is-size-7
= answer.value
= link_to answer.file.filename, rails_blob_path(answer.file, disposition: "attachment") if answer.file.present?
.list-item-controls
.buttons.is-right
%button.button{data: {action: 'details#toggle', _to: dom_id(@ticket, 'detail')}}= icon "fas fa-maximize"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/tickets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ def filter_params

# filter params for {Happening}'s {Ticket}
def ticket_params
params.fetch(:ticket, {}).permit(:happening_id, answers_attributes: [ :question_id, :value ])
params.fetch(:ticket, {}).permit(:happening_id, answers_attributes: [ :question_id, :value, :file ])
end
end
2 changes: 1 addition & 1 deletion app/models/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Question < ApplicationRecord

accepts_nested_attributes_for :options, allow_destroy: true, reject_if: :all_blank

enum :category, %i[string text select file], prefix: true
enum :category, %i[string text select file number date], prefix: true

validates :title, presence: true
validates :weight, presence: true
Expand Down
10 changes: 7 additions & 3 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
{ title: 'Cognome', mandatory: true, weight: 2 }
]
t2 = Template.create title: 'Generalità con dettagli', data: [
{ title: 'Nome', mandatory: true, weight: 3 },
{ title: 'Cognome', mandatory: true, weight: 2 },
{ title: 'Ente o società', mandatory: false, weight: 1 },
{ title: 'Ente o società', mandatory: false, weight: 8 },
{ title: 'Nome', mandatory: true, weight: 7 },
{ title: 'Cognome', mandatory: true, weight: 6 },
{ title: 'Anni di esperienza', mandatory: true, weight: 5, category: :number},
{ title: 'Data di nascita', mandatory: true, weight: 4, category: :date},
{ title: 'Raccontaci di te', mandatory: true, weight: 3, category: :text},
{ title: 'Foto', mandatory: true, weight: 2, category: :file},
{ title: 'tipologia', category: :select, mandatory: true, weight: 1, options_attributes: [
{ title: 'Dirigente pubblico', acceptable: true, weight: 4 },
{ title: 'Dipendente pubblico', acceptable: true, weight: 3 },
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ x-rails_conf: &rails_conf
### RAILS_RESTRICTED, If true entire site require authentication
# RAILS_RESTRICTED: true
RAILS_MASTER_KEY: 5cdcc57160c136623510fa73c7a7587f
### RAILS_ICON, Used for navbar
RAILS_ICON: fas fa-signature
### RAILS_TITLE, used for html head title, email and navbar
RAILS_TITLE: Partecipo
RAILS_DESCRIPTION: Partecipo description
RAILS_HEAD_URL: /head.html
Expand Down
11 changes: 10 additions & 1 deletion test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@
require "test_helper"

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :chrome, screen_size: [ 1400, 1400 ]
if ENV["CAPYBARA_SERVER_PORT"]
served_by host: "rails-app", port: ENV["CAPYBARA_SERVER_PORT"]

driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ], options: {
browser: :remote,
url: "http://#{ENV["SELENIUM_HOST"]}:4444"
}
else
driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ]
end
end

0 comments on commit 163a7f6

Please sign in to comment.