Kompanije rade

This commit is contained in:
2024-08-04 07:06:03 +02:00
commit 8d5a410c60
115 changed files with 2534 additions and 0 deletions

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

View File

@@ -0,0 +1,5 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js
//= link_tree ../builds

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

View File

@@ -0,0 +1 @@
//require 'toastui-calendar.min.js'

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/

View File

@@ -0,0 +1,13 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
/*
@layer components {
.btn-primary {
@apply py-2 px-4 bg-blue-200;
}
}
*/

File diff suppressed because one or more lines are too long

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

@@ -0,0 +1,70 @@
class CompaniesController < ApplicationController
before_action :set_company, only: %i[ show edit update destroy ]
# GET /companies or /companies.json
def index
@companies = Company.all
end
# GET /companies/1 or /companies/1.json
def show
end
# GET /companies/new
def new
@company = Company.new
end
# GET /companies/1/edit
def edit
end
# POST /companies or /companies.json
def create
@company = Company.new(company_params)
respond_to do |format|
if @company.save
format.html { redirect_to company_url(@company), notice: "Company was successfully created." }
format.json { render :show, status: :created, location: @company }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @company.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /companies/1 or /companies/1.json
def update
respond_to do |format|
if @company.update(company_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
# DELETE /companies/1 or /companies/1.json
def destroy
@company.destroy!
respond_to do |format|
format.html { redirect_to companies_url, notice: "Company was successfully destroyed." }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_company
@company = Company.find(params[:id])
end
# Only allow a list of trusted parameters through.
def company_params
params.require(:company).permit(:name, :id_number, :vat_number, :address_line_one, :address_line_two, :postal_code, :city, :entity, :country)
end
end

View File

View File

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

View File

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

View File

@@ -0,0 +1,3 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
import "controllers"

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,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)

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

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

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

View File

View File

@@ -0,0 +1,47 @@
<div id="<%= dom_id company %>">
<p class="my-5">
<strong class="block font-medium mb-1">Name:</strong>
<%= company.name %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Id number:</strong>
<%= company.id_number %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Vat number:</strong>
<%= company.vat_number %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Address line one:</strong>
<%= company.address_line_one %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Address line two:</strong>
<%= company.address_line_two %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Postal code:</strong>
<%= company.postal_code %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">City:</strong>
<%= company.city %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Entity:</strong>
<%= company.entity %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Country:</strong>
<%= company.country %>
</p>
</div>

View File

@@ -0,0 +1,2 @@
json.extract! company, :id, :name, :id_number, :vat_number, :address_line_one, :address_line_two, :postal_code, :city, :entity, :country, :created_at, :updated_at
json.url company_url(company, format: :json)

View File

@@ -0,0 +1,62 @@
<%= form_with(model: company, class: "contents") do |form| %>
<% if company.errors.any? %>
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3">
<h2><%= pluralize(company.errors.count, "error") %> prohibited this company from being saved:</h2>
<ul>
<% company.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="my-5">
<%= form.label :name %>
<%= form.text_field :name, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
</div>
<div class="my-5">
<%= form.label :id_number %>
<%= form.text_field :id_number, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
</div>
<div class="my-5">
<%= form.label :vat_number %>
<%= form.text_field :vat_number, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
</div>
<div class="my-5">
<%= form.label :address_line_one %>
<%= form.text_field :address_line_one, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
</div>
<div class="my-5">
<%= form.label :address_line_two %>
<%= form.text_field :address_line_two, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
</div>
<div class="my-5">
<%= form.label :postal_code %>
<%= form.text_field :postal_code, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
</div>
<div class="my-5">
<%= form.label :city %>
<%= form.text_field :city, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
</div>
<div class="my-5">
<%= form.label :entity %>
<%= form.text_field :entity, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
</div>
<div class="my-5">
<%= form.label :country %>
<%= form.text_field :country, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
</div>
<div class="inline">
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
</div>
<% end %>

View File

@@ -0,0 +1,8 @@
<div class="mx-auto md:w-2/3 w-full">
<h1 class="font-bold text-4xl">Editing company</h1>
<%= render "form", company: @company %>
<%= link_to "Show this company", @company, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<%= link_to "Back to companies", companies_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
</div>

View File

@@ -0,0 +1,21 @@
<div class="w-full">
<% if notice.present? %>
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
<% end %>
<% content_for :title, "Companies" %>
<div class="flex justify-between items-center">
<h1 class="font-bold text-4xl">Companies</h1>
<%= link_to "New company", new_company_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
</div>
<div id="companies" class="min-w-full">
<% @companies.each do |company| %>
<%= render company %>
<p>
<%= link_to "Show this company", company, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
</p>
<% end %>
</div>
</div>

View File

@@ -0,0 +1 @@
json.array! @companies, partial: "companies/company", as: :company

View File

@@ -0,0 +1,7 @@
<div class="mx-auto md:w-2/3 w-full">
<h1 class="font-bold text-4xl">New company</h1>
<%= render "form", company: @company %>
<%= link_to "Back to companies", companies_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
</div>

View File

@@ -0,0 +1,15 @@
<div class="mx-auto md:w-2/3 w-full flex">
<div class="mx-auto">
<% if notice.present? %>
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
<% end %>
<%= render @company %>
<%= link_to "Edit this company", edit_company_path(@company), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<%= link_to "Back to companies", companies_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<div class="inline-block ml-2">
<%= button_to "Destroy this company", @company, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
</div>
</div>
</div>

View File

@@ -0,0 +1 @@
json.partial! "companies/company", company: @company

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Terminator</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
</head>
<body>
<main class="container mx-auto mt-28 px-5 flex">
<%= yield %>
</main>
</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 %>