first commit

This commit is contained in:
Kris
2024-02-03 08:34:36 -05:00
commit 2f398caa90
102 changed files with 2717 additions and 0 deletions

0
app/assets/builds/.keep Normal file
View File

View File

@@ -0,0 +1,2 @@
//= link_tree ../images
//= link_tree ../builds

0
app/assets/images/.keep Normal file
View File

View File

@@ -0,0 +1,2 @@
@import 'bootstrap/scss/bootstrap';
@import 'bootstrap-icons/font/bootstrap-icons';

View File

@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end

View File

@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end

View File

@@ -0,0 +1,2 @@
class ApplicationController < ActionController::Base
end

View File

View File

@@ -0,0 +1,70 @@
class SuggestionsController < ApplicationController
before_action :set_suggestion, only: %i[ show edit update destroy ]
# GET /suggestions or /suggestions.json
def index
@suggestions = Suggestion.all
end
# GET /suggestions/1 or /suggestions/1.json
def show
end
# GET /suggestions/new
def new
@suggestion = Suggestion.new
end
# GET /suggestions/1/edit
def edit
end
# POST /suggestions or /suggestions.json
def create
@suggestion = Suggestion.new(suggestion_params)
respond_to do |format|
if @suggestion.save
format.html { redirect_to suggestion_url(@suggestion), notice: "Suggestion was successfully created." }
format.json { render :show, status: :created, location: @suggestion }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @suggestion.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /suggestions/1 or /suggestions/1.json
def update
respond_to do |format|
if @suggestion.update(suggestion_params)
format.html { redirect_to suggestion_url(@suggestion), notice: "Suggestion was successfully updated." }
format.json { render :show, status: :ok, location: @suggestion }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @suggestion.errors, status: :unprocessable_entity }
end
end
end
# DELETE /suggestions/1 or /suggestions/1.json
def destroy
@suggestion.destroy!
respond_to do |format|
format.html { redirect_to suggestions_url, notice: "Suggestion was successfully destroyed." }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_suggestion
@suggestion = Suggestion.find(params[:id])
end
# Only allow a list of trusted parameters through.
def suggestion_params
params.require(:suggestion).permit(:subject, :body, :sent)
end
end

View File

@@ -0,0 +1,2 @@
module ApplicationHelper
end

View File

@@ -0,0 +1,2 @@
module SuggestionsHelper
end

View File

@@ -0,0 +1,4 @@
// Entry point for the build script in your package.json
import "@hotwired/turbo-rails"
import "./controllers"
import * as bootstrap from "bootstrap"

View 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 }

View File

@@ -0,0 +1,7 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
this.element.textContent = "Hello World!"
}
}

View File

@@ -0,0 +1,8 @@
// This file is auto-generated by ./bin/rails stimulus:manifest:update
// Run that command whenever you add a new controller or create them with
// ./bin/rails generate stimulus controllerName
import { application } from "./application"
import HelloController from "./hello_controller"
application.register("hello", HelloController)

View File

@@ -0,0 +1,7 @@
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end

View File

@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
layout "mailer"
end

View File

@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end

View File

2
app/models/suggestion.rb Normal file
View File

@@ -0,0 +1,2 @@
class Suggestion < ApplicationRecord
end

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Suggest</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>
</head>
<body>
<%= yield %>
</body>
</html>

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
/* Email styles need to be inline */
</style>
</head>
<body>
<%= yield %>
</body>
</html>

View File

@@ -0,0 +1 @@
<%= yield %>

View File

@@ -0,0 +1,32 @@
<%= form_with(model: suggestion) do |form| %>
<% if suggestion.errors.any? %>
<div style="color: red">
<h2><%= pluralize(suggestion.errors.count, "error") %> prohibited this suggestion from being saved:</h2>
<ul>
<% suggestion.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
<div>
<%= form.label :subject, style: "display: block" %>
<%= form.text_field :subject %>
</div>
<div>
<%= form.label :body, style: "display: block" %>
<%= form.text_area :body %>
</div>
<div>
<%= form.label :sent, style: "display: block" %>
<%= form.check_box :sent %>
</div>
<div>
<%= form.submit %>
</div>
<% end %>

View File

@@ -0,0 +1,17 @@
<div id="<%= dom_id suggestion %>">
<p>
<strong>Subject:</strong>
<%= suggestion.subject %>
</p>
<p>
<strong>Body:</strong>
<%= suggestion.body %>
</p>
<p>
<strong>Sent:</strong>
<%= suggestion.sent %>
</p>
</div>

View File

@@ -0,0 +1,2 @@
json.extract! suggestion, :id, :subject, :body, :sent, :created_at, :updated_at
json.url suggestion_url(suggestion, format: :json)

View File

@@ -0,0 +1,10 @@
<h1>Editing suggestion</h1>
<%= render "form", suggestion: @suggestion %>
<br>
<div>
<%= link_to "Show this suggestion", @suggestion %> |
<%= link_to "Back to suggestions", suggestions_path %>
</div>

View File

@@ -0,0 +1,14 @@
<p style="color: green"><%= notice %></p>
<h1>Suggestions</h1>
<div id="suggestions">
<% @suggestions.each do |suggestion| %>
<%= render suggestion %>
<p>
<%= link_to "Show this suggestion", suggestion %>
</p>
<% end %>
</div>
<%= link_to "New suggestion", new_suggestion_path %>

View File

@@ -0,0 +1 @@
json.array! @suggestions, partial: "suggestions/suggestion", as: :suggestion

View File

@@ -0,0 +1,9 @@
<h1>New suggestion</h1>
<%= render "form", suggestion: @suggestion %>
<br>
<div>
<%= link_to "Back to suggestions", suggestions_path %>
</div>

View File

@@ -0,0 +1,10 @@
<p style="color: green"><%= notice %></p>
<%= render @suggestion %>
<div>
<%= link_to "Edit this suggestion", edit_suggestion_path(@suggestion) %> |
<%= link_to "Back to suggestions", suggestions_path %>
<%= button_to "Destroy this suggestion", @suggestion, method: :delete %>
</div>

View File

@@ -0,0 +1 @@
json.partial! "suggestions/suggestion", suggestion: @suggestion