You can now indicate that you have completed something and add evidence but the update doesn't yet work and it will need refatoring because we need to get back to the CAF or company.
This commit is contained in:
parent
8200b974c3
commit
6b0da161be
3
Gemfile
3
Gemfile
@ -18,7 +18,7 @@ gem "sprockets-rails"
|
|||||||
gem "mysql2", "~> 0.5"
|
gem "mysql2", "~> 0.5"
|
||||||
|
|
||||||
# Use the Puma web server [https://github.com/puma/puma]
|
# Use the Puma web server [https://github.com/puma/puma]
|
||||||
gem "puma", git: 'https://github.com/puma/puma', branch: 'master'
|
gem "puma", ">= 5.0"
|
||||||
|
|
||||||
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
|
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
|
||||||
gem "importmap-rails"
|
gem "importmap-rails"
|
||||||
@ -73,5 +73,4 @@ group :test do
|
|||||||
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
|
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
|
||||||
gem "capybara"
|
gem "capybara"
|
||||||
gem "selenium-webdriver"
|
gem "selenium-webdriver"
|
||||||
gem "webdrivers"
|
|
||||||
end
|
end
|
||||||
|
|||||||
17
Gemfile.lock
17
Gemfile.lock
@ -1,11 +1,3 @@
|
|||||||
GIT
|
|
||||||
remote: https://github.com/puma/puma
|
|
||||||
revision: 7a999de2f0da5648c30f62a6e11d74c7ddbe4e00
|
|
||||||
branch: master
|
|
||||||
specs:
|
|
||||||
puma (6.4.2)
|
|
||||||
nio4r (~> 2.0)
|
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
@ -170,6 +162,8 @@ GEM
|
|||||||
psych (5.1.2)
|
psych (5.1.2)
|
||||||
stringio
|
stringio
|
||||||
public_suffix (5.0.5)
|
public_suffix (5.0.5)
|
||||||
|
puma (6.4.2)
|
||||||
|
nio4r (~> 2.0)
|
||||||
racc (1.7.3)
|
racc (1.7.3)
|
||||||
rack (2.2.9)
|
rack (2.2.9)
|
||||||
rack-session (1.0.2)
|
rack-session (1.0.2)
|
||||||
@ -251,10 +245,6 @@ GEM
|
|||||||
activemodel (>= 6.0.0)
|
activemodel (>= 6.0.0)
|
||||||
bindex (>= 0.4.0)
|
bindex (>= 0.4.0)
|
||||||
railties (>= 6.0.0)
|
railties (>= 6.0.0)
|
||||||
webdrivers (5.3.1)
|
|
||||||
nokogiri (~> 1.6)
|
|
||||||
rubyzip (>= 1.3.0)
|
|
||||||
selenium-webdriver (~> 4.0, < 4.11)
|
|
||||||
webrick (1.8.1)
|
webrick (1.8.1)
|
||||||
websocket (1.2.10)
|
websocket (1.2.10)
|
||||||
websocket-driver (0.7.6)
|
websocket-driver (0.7.6)
|
||||||
@ -285,7 +275,7 @@ DEPENDENCIES
|
|||||||
jbuilder
|
jbuilder
|
||||||
mysql2 (~> 0.5)
|
mysql2 (~> 0.5)
|
||||||
nokogiri
|
nokogiri
|
||||||
puma!
|
puma (>= 5.0)
|
||||||
rails (~> 7.1.3.2)
|
rails (~> 7.1.3.2)
|
||||||
selenium-webdriver
|
selenium-webdriver
|
||||||
spring
|
spring
|
||||||
@ -294,7 +284,6 @@ DEPENDENCIES
|
|||||||
turbo-rails
|
turbo-rails
|
||||||
tzinfo-data
|
tzinfo-data
|
||||||
web-console
|
web-console
|
||||||
webdrivers
|
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 3.3.0p0
|
ruby 3.3.0p0
|
||||||
|
|||||||
28
app/controllers/subprincipleitems_controller.rb
Normal file
28
app/controllers/subprincipleitems_controller.rb
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
class SubprincipleitemsController < ApplicationController
|
||||||
|
before_action :set_subprincipleitem, only: %i[ edit update ]
|
||||||
|
|
||||||
|
def edit
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
respond_to do |format|
|
||||||
|
if @subprincipleitem.update(subprincipleitem_params)
|
||||||
|
format.html { redirect_to company_url(@company), notice: "Company was successfully updated." }
|
||||||
|
format.json { render :show, status: :ok, location: @company }
|
||||||
|
else
|
||||||
|
format.html { render :edit, status: :unprocessable_entity }
|
||||||
|
format.json { render json: @company.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def set_subprincipleitem
|
||||||
|
@subprincipleitem = Subprincipleitem.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# Only allow a list of trusted parameters through.
|
||||||
|
def subprincipleitem_params
|
||||||
|
params.require(:subprincipleitem).permit(:affirmative)
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -1,12 +1,6 @@
|
|||||||
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
|
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
|
||||||
import "jquery";
|
|
||||||
import "@hotwired/turbo-rails";
|
import "@hotwired/turbo-rails";
|
||||||
//import "controllers";
|
import "controllers";
|
||||||
import Trix from "trix";
|
|
||||||
import "@rails/actiontext";
|
|
||||||
|
|
||||||
window.importmapScriptsLoaded = true;
|
|
||||||
|
|
||||||
|
|
||||||
import "trix"
|
import "trix"
|
||||||
import "@rails/actiontext"
|
import "@rails/actiontext"
|
||||||
|
|||||||
9
app/javascript/controllers/application.js
Normal file
9
app/javascript/controllers/application.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Application } from "@hotwired/stimulus"
|
||||||
|
|
||||||
|
const application = Application.start()
|
||||||
|
|
||||||
|
// Configure Stimulus development experience
|
||||||
|
application.debug = false
|
||||||
|
window.Stimulus = application
|
||||||
|
|
||||||
|
export { application }
|
||||||
7
app/javascript/controllers/hello_controller.js
Normal file
7
app/javascript/controllers/hello_controller.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { Controller } from "@hotwired/stimulus"
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
connect() {
|
||||||
|
this.element.textContent = "Hello World!"
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/javascript/controllers/index.js
Normal file
11
app/javascript/controllers/index.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Import and register all your controllers from the importmap under controllers/*
|
||||||
|
|
||||||
|
import { application } from "controllers/application"
|
||||||
|
|
||||||
|
// Eager load all controllers defined in the import map under controllers/**/*_controller
|
||||||
|
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
||||||
|
eagerLoadControllersFrom("controllers", application)
|
||||||
|
|
||||||
|
// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
|
||||||
|
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
|
||||||
|
// lazyLoadControllersFrom("controllers", application)
|
||||||
@ -27,7 +27,9 @@
|
|||||||
<% subprinciple.subprincipleitemgroups.each do |subprincipleitemgroup| %>
|
<% subprinciple.subprincipleitemgroups.each do |subprincipleitemgroup| %>
|
||||||
<td>
|
<td>
|
||||||
<% subprincipleitemgroup.subprincipleitems.each do |subprincipleitem| %>
|
<% subprincipleitemgroup.subprincipleitems.each do |subprincipleitem| %>
|
||||||
<div id="<%= "subprincipleitemid_#{subprincipleitem.id}" %>" class="subprincipleitem"><%= subprincipleitem.description %></div>
|
<div style="background-color:<%= subprincipleitem.affirmative ? '#05aa05' : '#aa3030' %>;" id="<%= "subprincipleitemid_#{subprincipleitem.id}" %>" class="subprincipleitem"><%= subprincipleitem.description %><%= link_to "Change", edit_subprincipleitem_path(subprincipleitem) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -40,31 +42,4 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
// Guard against double DOM loads
|
|
||||||
// https://stackoverflow.com/questions/71876873/rails-7-7-0-2-3-importmap-jquery-is-not-defined-in-view
|
|
||||||
var codeExecuted = false;
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function(e) {
|
|
||||||
|
|
||||||
// Check if importmap stuff exisits without throwing an error.
|
|
||||||
// Then run main code w/ guard against multiple executions.
|
|
||||||
if ("importmapScriptsLoaded" in window) {
|
|
||||||
|
|
||||||
if (!codeExecuted) {
|
|
||||||
// Main code here
|
|
||||||
console.log($('#hello'));
|
|
||||||
|
|
||||||
$(".subprincipleitem").click(function(event) {
|
|
||||||
alert(event.target.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Don't forget to bump guard for one-time only JS execution !!
|
|
||||||
codeExecuted = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|||||||
17
app/views/subprincipleitems/edit.html.erb
Normal file
17
app/views/subprincipleitems/edit.html.erb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<h1><%= @subprincipleitem.subprincipleitemgroup.subprinciple.name%></h1>
|
||||||
|
<p><%= @subprincipleitem.subprincipleitemgroup.subprinciple.description%></p>
|
||||||
|
|
||||||
|
<p><%= @subprincipleitem.description %><p>
|
||||||
|
|
||||||
|
<%= form_with(model: @subprincipleitem) do |form| %>
|
||||||
|
<div>
|
||||||
|
<%= form.label :affirmative %> <%= form.check_box :affirmative, {}, true, false %>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<%= form.label :evidence %>
|
||||||
|
<%= form.rich_text_area :evidence %>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<%= form.submit %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
@ -9,7 +9,7 @@ Bundler.require(*Rails.groups)
|
|||||||
module CafHiddenagendaLtdUk
|
module CafHiddenagendaLtdUk
|
||||||
class Application < Rails::Application
|
class Application < Rails::Application
|
||||||
# Initialize configuration defaults for originally generated Rails version.
|
# Initialize configuration defaults for originally generated Rails version.
|
||||||
config.load_defaults 7.0
|
config.load_defaults 7.1
|
||||||
|
|
||||||
# Configuration for the application, engines, and railties goes here.
|
# Configuration for the application, engines, and railties goes here.
|
||||||
#
|
#
|
||||||
|
|||||||
@ -6,7 +6,7 @@ Rails.application.configure do
|
|||||||
# In the development environment your application's code is reloaded any time
|
# In the development environment your application's code is reloaded any time
|
||||||
# it changes. This slows down response time but is perfect for development
|
# it changes. This slows down response time but is perfect for development
|
||||||
# since you don't have to restart the web server when you make code changes.
|
# since you don't have to restart the web server when you make code changes.
|
||||||
config.cache_classes = false
|
config.enable_reloading = true
|
||||||
|
|
||||||
# Do not eager load code on boot.
|
# Do not eager load code on boot.
|
||||||
config.eager_load = false
|
config.eager_load = false
|
||||||
@ -68,5 +68,7 @@ Rails.application.configure do
|
|||||||
# Uncomment if you wish to allow Action Cable access from any origin.
|
# Uncomment if you wish to allow Action Cable access from any origin.
|
||||||
# config.action_cable.disable_request_forgery_protection = true
|
# config.action_cable.disable_request_forgery_protection = true
|
||||||
|
|
||||||
|
config.action_controller.raise_on_missing_callback_actions = true
|
||||||
|
|
||||||
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,7 +4,7 @@ Rails.application.configure do
|
|||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
||||||
# Code is not reloaded between requests.
|
# Code is not reloaded between requests.
|
||||||
config.cache_classes = true
|
config.enable_reloading = false
|
||||||
|
|
||||||
# Eager load code on boot. This eager loads most of Rails and
|
# Eager load code on boot. This eager loads most of Rails and
|
||||||
# your application in memory, allowing both threaded web servers
|
# your application in memory, allowing both threaded web servers
|
||||||
@ -16,13 +16,12 @@ Rails.application.configure do
|
|||||||
config.consider_all_requests_local = false
|
config.consider_all_requests_local = false
|
||||||
config.action_controller.perform_caching = true
|
config.action_controller.perform_caching = true
|
||||||
|
|
||||||
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
|
||||||
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
# key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
|
||||||
# config.require_master_key = true
|
# config.require_master_key = true
|
||||||
|
|
||||||
# Disable serving static files from the `/public` folder by default since
|
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
|
||||||
# Apache or NGINX already handles this.
|
# config.public_file_server.enabled = false
|
||||||
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
|
|
||||||
|
|
||||||
# Compress CSS using a preprocessor.
|
# Compress CSS using a preprocessor.
|
||||||
# config.assets.css_compressor = :sass
|
# config.assets.css_compressor = :sass
|
||||||
@ -46,21 +45,27 @@ Rails.application.configure do
|
|||||||
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
|
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
|
||||||
|
|
||||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||||
# config.force_ssl = true
|
config.force_ssl = true
|
||||||
|
|
||||||
# Include generic and useful information about system operation, but avoid logging too much
|
# Log to STDOUT by default
|
||||||
# information to avoid inadvertent exposure of personally identifiable information (PII).
|
config.logger = ActiveSupport::Logger.new(STDOUT)
|
||||||
config.log_level = :info
|
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
|
||||||
|
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
|
||||||
|
|
||||||
# Prepend all log lines with the following tags.
|
# Prepend all log lines with the following tags.
|
||||||
config.log_tags = [ :request_id ]
|
config.log_tags = [ :request_id ]
|
||||||
|
|
||||||
|
# "info" includes generic and useful information about system operation, but avoids logging too much
|
||||||
|
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
|
||||||
|
# want to log everything, set the level to "debug".
|
||||||
|
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
|
||||||
|
|
||||||
# Use a different cache store in production.
|
# Use a different cache store in production.
|
||||||
# config.cache_store = :mem_cache_store
|
# config.cache_store = :mem_cache_store
|
||||||
|
|
||||||
# Use a real queuing backend for Active Job (and separate queues per environment).
|
# Use a real queuing backend for Active Job (and separate queues per environment).
|
||||||
# config.active_job.queue_adapter = :resque
|
# config.active_job.queue_adapter = :resque
|
||||||
# config.active_job.queue_name_prefix = "caf_hiddenagenda_ltd_uk_production"
|
# config.active_job.queue_name_prefix = "seven132_production"
|
||||||
|
|
||||||
config.action_mailer.perform_caching = false
|
config.action_mailer.perform_caching = false
|
||||||
|
|
||||||
@ -75,19 +80,14 @@ Rails.application.configure do
|
|||||||
# Don't log any deprecations.
|
# Don't log any deprecations.
|
||||||
config.active_support.report_deprecations = false
|
config.active_support.report_deprecations = false
|
||||||
|
|
||||||
# Use default logging formatter so that PID and timestamp are not suppressed.
|
|
||||||
config.log_formatter = ::Logger::Formatter.new
|
|
||||||
|
|
||||||
# Use a different logger for distributed setups.
|
|
||||||
# require "syslog/logger"
|
|
||||||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
|
|
||||||
|
|
||||||
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
|
||||||
logger = ActiveSupport::Logger.new(STDOUT)
|
|
||||||
logger.formatter = config.log_formatter
|
|
||||||
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Do not dump schema after migrations.
|
# Do not dump schema after migrations.
|
||||||
config.active_record.dump_schema_after_migration = false
|
config.active_record.dump_schema_after_migration = false
|
||||||
|
|
||||||
|
# Enable DNS rebinding protection and other `Host` header attacks.
|
||||||
|
# config.hosts = [
|
||||||
|
# "example.com", # Allow requests from example.com
|
||||||
|
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
|
||||||
|
# ]
|
||||||
|
# Skip DNS rebinding protection for the default health check endpoint.
|
||||||
|
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
|
||||||
end
|
end
|
||||||
|
|||||||
@ -8,8 +8,8 @@ require "active_support/core_ext/integer/time"
|
|||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
||||||
# Turn false under Spring and add config.action_view.cache_template_loading = true.
|
# While tests run files are not watched, reloading is not necessary.
|
||||||
config.cache_classes = true
|
config.enable_reloading = false
|
||||||
|
|
||||||
# Eager loading loads your whole application. When running a single test locally,
|
# Eager loading loads your whole application. When running a single test locally,
|
||||||
# this probably isn't necessary. It's a good idea to do in a continuous integration
|
# this probably isn't necessary. It's a good idea to do in a continuous integration
|
||||||
@ -28,7 +28,7 @@ Rails.application.configure do
|
|||||||
config.cache_store = :null_store
|
config.cache_store = :null_store
|
||||||
|
|
||||||
# Raise exceptions instead of rendering exception templates.
|
# Raise exceptions instead of rendering exception templates.
|
||||||
config.action_dispatch.show_exceptions = false
|
config.action_dispatch.show_exceptions = :rescuable
|
||||||
|
|
||||||
# Disable request forgery protection in test environment.
|
# Disable request forgery protection in test environment.
|
||||||
config.action_controller.allow_forgery_protection = false
|
config.action_controller.allow_forgery_protection = false
|
||||||
@ -57,5 +57,8 @@ Rails.application.configure do
|
|||||||
|
|
||||||
# Annotate rendered view with file names.
|
# Annotate rendered view with file names.
|
||||||
# config.action_view.annotate_rendered_view_with_filenames = true
|
# config.action_view.annotate_rendered_view_with_filenames = true
|
||||||
|
|
||||||
|
config.action_controller.raise_on_missing_callback_actions = true
|
||||||
|
|
||||||
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
# Pin npm packages by running ./bin/importmap
|
# Pin npm packages by running ./bin/importmap
|
||||||
pin "jquery", to: "https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.js"
|
|
||||||
pin "application", preload: true
|
pin "application"
|
||||||
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
|
pin "@hotwired/turbo-rails", to: "turbo.min.js"
|
||||||
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
|
pin "@hotwired/stimulus", to: "stimulus.min.js"
|
||||||
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
|
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
|
||||||
pin_all_from "app/javascript/controllers", under: "controllers"
|
pin_all_from "app/javascript/controllers", under: "controllers"
|
||||||
pin "script"
|
|
||||||
pin "trix"
|
pin "trix"
|
||||||
pin "@rails/actiontext", to: "actiontext.esm.js"
|
pin "@rails/actiontext", to: "actiontext.esm.js"
|
||||||
|
|||||||
@ -6,6 +6,8 @@ Rails.application.routes.draw do
|
|||||||
resources :cafs
|
resources :cafs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :subprincipleitems, only: [:edit, :update]
|
||||||
|
|
||||||
authenticated :user do
|
authenticated :user do
|
||||||
root to: 'home#index', as: :authenticated_root
|
root to: 'home#index', as: :authenticated_root
|
||||||
end
|
end
|
||||||
|
|||||||
55
vendor/javascript/jquery.js
vendored
Normal file
55
vendor/javascript/jquery.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user