initial commit

This commit is contained in:
Stefan Tollkühn
2025-07-21 12:14:42 +02:00
parent a77fc87832
commit 3735122750
156 changed files with 3862 additions and 1 deletions

View File

@@ -0,0 +1,4 @@
class ApplicationController < ActionController::Base
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern
end

View File

@@ -0,0 +1,70 @@
class ClientsController < ApplicationController
before_action :set_client, only: %i[ show edit update destroy ]
# GET /clients or /clients.json
def index
@clients = Client.all
end
# GET /clients/1 or /clients/1.json
def show
end
# GET /clients/new
def new
@client = Client.new
end
# GET /clients/1/edit
def edit
end
# POST /clients or /clients.json
def create
@client = Client.new(client_params)
respond_to do |format|
if @client.save
format.html { redirect_to @client, notice: "Client was successfully created." }
format.json { render :show, status: :created, location: @client }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @client.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /clients/1 or /clients/1.json
def update
respond_to do |format|
if @client.update(client_params)
format.html { redirect_to @client, notice: "Client was successfully updated." }
format.json { render :show, status: :ok, location: @client }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @client.errors, status: :unprocessable_entity }
end
end
end
# DELETE /clients/1 or /clients/1.json
def destroy
@client.destroy!
respond_to do |format|
format.html { redirect_to clients_path, status: :see_other, notice: "Client was successfully destroyed." }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_client
@client = Client.find(params.expect(:id))
end
# Only allow a list of trusted parameters through.
def client_params
params.expect(client: [ :company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone ])
end
end

View File

View File

@@ -0,0 +1,84 @@
class ProjectsController < ApplicationController
before_action :set_project, only: %i[ show edit update destroy ]
# GET /projects or /projects.json
def index
@projects = Project.all
end
# GET /projects/1 or /projects/1.json
def show
end
# GET /projects/new
def new
@project = Project.new
@project.subprojects.build # initialize one subproject
@project.subprojects.each do |subproject|
subproject.build_client
subproject.build_owner
subproject.build_builder
end
end
# GET /projects/1/edit
def edit
end
# POST /projects or /projects.json
def create
@project = Project.new(project_params)
respond_to do |format|
if @project.save
format.html { redirect_to @project, notice: "Project was successfully created." }
format.json { render :show, status: :created, location: @project }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @project.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /projects/1 or /projects/1.json
def update
respond_to do |format|
if @project.update(project_params)
format.html { redirect_to @project, notice: "Project was successfully updated." }
format.json { render :show, status: :ok, location: @project }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @project.errors, status: :unprocessable_entity }
end
end
end
# DELETE /projects/1 or /projects/1.json
def destroy
@project.destroy!
respond_to do |format|
format.html { redirect_to projects_path, status: :see_other, notice: "Project was successfully destroyed." }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_project
@project = Project.find(params.expect(:id))
end
# Only allow a list of trusted parameters through.
def project_params
params.require(:project).permit(
:name,
subprojects_attributes: [
:id, :subproject_name, :client_id, :owner_id, :builder_id, :_destroy,
client_attributes: [:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone],
owner_attributes: [:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone],
builder_attributes: [:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone]
]
)
end
end

View File

@@ -0,0 +1,70 @@
class SubprojectsController < ApplicationController
before_action :set_subproject, only: %i[ show edit update destroy ]
# GET /subprojects or /subprojects.json
def index
@subprojects = Subproject.all
end
# GET /subprojects/1 or /subprojects/1.json
def show
end
# GET /subprojects/new
def new
@subproject = Subproject.new
end
# GET /subprojects/1/edit
def edit
end
# POST /subprojects or /subprojects.json
def create
@subproject = Subproject.new(subproject_params)
respond_to do |format|
if @subproject.save
format.html { redirect_to @subproject, notice: "Subproject was successfully created." }
format.json { render :show, status: :created, location: @subproject }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @subproject.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /subprojects/1 or /subprojects/1.json
def update
respond_to do |format|
if @subproject.update(subproject_params)
format.html { redirect_to @subproject, notice: "Subproject was successfully updated." }
format.json { render :show, status: :ok, location: @subproject }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @subproject.errors, status: :unprocessable_entity }
end
end
end
# DELETE /subprojects/1 or /subprojects/1.json
def destroy
@subproject.destroy!
respond_to do |format|
format.html { redirect_to subprojects_path, status: :see_other, notice: "Subproject was successfully destroyed." }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_subproject
@subproject = Subproject.find(params.expect(:id))
end
# Only allow a list of trusted parameters through.
def subproject_params
params.expect(subproject: [ :subproject_name, :project_id, :client_id, :owner_id, :builder_id ])
end
end