Skip to content

Commit d476fe7

Browse files
committed
Models client employee project quote
1 parent 295a0c3 commit d476fe7

File tree

93 files changed

+2329
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2329
-30
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ gem "thruster", require: false
4343
gem "bootstrap", "~> 5.2"
4444
gem "devise"
4545
gem "autoprefixer-rails"
46-
gem "font-awesome-sass", "~> 6.1"
46+
#gem "font-awesome-sass", "~> 6.1"
4747
gem "simple_form", github: "heartcombo/simple_form"
4848
gem "sassc-rails"
4949

Gemfile.lock

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ GEM
159159
ffi (1.17.1-x86_64-darwin)
160160
ffi (1.17.1-x86_64-linux-gnu)
161161
ffi (1.17.1-x86_64-linux-musl)
162-
font-awesome-sass (6.7.2)
163-
sassc (~> 2.0)
164162
fugit (1.11.1)
165163
et-orbi (~> 1, >= 1.2.11)
166164
raabro (~> 1.4)
@@ -452,7 +450,6 @@ DEPENDENCIES
452450
debug
453451
devise
454452
dotenv-rails
455-
font-awesome-sass (~> 6.1)
456453
importmap-rails
457454
jbuilder
458455
kamal

app/assets/config/manifest.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//= link rails-ujs.js
2+
//= link_tree ../../javascript .js
3+
//= link_tree ../../../vendor/javascript .js
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Rails from "@rails/ujs";
2+
Rails.start();
3+
4+
import "@hotwired/turbo-rails"; // Si vous utilisez Turbo

app/assets/stylesheets/application.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
// External libraries
77
@import "bootstrap";
8-
@import "font-awesome";
8+
//@import "font-awesome";
99

1010
// Your CSS partials
1111
@import "components/index";
1212
@import "pages/index";
13+
@import "pages/project";
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ul.employee-list {
2+
list-style: none;
3+
padding: 0;
4+
}
5+
6+
ul.employee-list li {
7+
margin-bottom: 10px;
8+
}
9+
10+
ul.employee-list li input[type="checkbox"] {
11+
margin-right: 10px;
12+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
class ClientsController < ApplicationController
2+
before_action :set_client, only: [:show, :edit, :update, :destroy]
3+
4+
def index
5+
@clients = Client.all
6+
end
7+
8+
def show; end
9+
10+
def new
11+
@client = Client.new
12+
end
13+
14+
def create
15+
@client = Client.new(client_params)
16+
if @client.save
17+
redirect_to @client, notice: "Client créé avec succès."
18+
else
19+
render :new
20+
end
21+
end
22+
23+
def edit; end
24+
25+
def update
26+
if @client.update(client_params)
27+
redirect_to @client, notice: "Client mis à jour avec succès."
28+
else
29+
render :edit
30+
end
31+
end
32+
33+
def destroy
34+
@client.destroy
35+
redirect_to clients_path, notice: "Client supprimé avec succès."
36+
end
37+
38+
private
39+
40+
def set_client
41+
@client = Client.find(params[:id])
42+
end
43+
44+
def client_params
45+
params.require(:client).permit(:firstname, :lastname, :address, :phone, :email, :rib)
46+
end
47+
end
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
class EmployeesController < ApplicationController
2+
before_action :authenticate_user!
3+
before_action :set_employee, only: [:show, :edit, :update, :destroy]
4+
5+
def index
6+
@employees = Employee.all
7+
end
8+
9+
def show; end
10+
11+
def new
12+
@employee = Employee.new
13+
end
14+
15+
def create
16+
@employee = Employee.new(employee_params)
17+
if @employee.save
18+
redirect_to @employee, notice: "Employé créé avec succès."
19+
else
20+
render :new
21+
end
22+
end
23+
24+
def edit; end
25+
26+
def update
27+
if @employee.update(employee_params)
28+
redirect_to @employee, notice: "Employé mis à jour avec succès."
29+
else
30+
render :edit
31+
end
32+
end
33+
34+
def destroy
35+
@employee = Employee.find(params[:id])
36+
@employee.destroy
37+
redirect_to employees_path, notice: "Employé supprimé avec succès."
38+
end
39+
40+
private
41+
42+
def set_employee
43+
@employee = Employee.find(params[:id])
44+
end
45+
46+
def employee_params
47+
params.require(:employee).permit(:firstname, :lastname, :address, :phone, :email, :group, :position, :hoursalary, :user_id)
48+
end
49+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class PagesController < ApplicationController
2+
before_action :authenticate_user!, except: [:home]
3+
4+
def home
5+
# Page accessible sans authentification
6+
end
7+
8+
def about
9+
# Nécessite une authentification
10+
end
11+
end
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
class ProjectsController < ApplicationController
2+
before_action :set_project, only: [:show, :edit, :update, :destroy]
3+
before_action :set_clients, only: [:new, :edit]
4+
before_action :set_employees, only: [:new, :edit]
5+
6+
def index
7+
@projects = Project.all
8+
end
9+
10+
def show
11+
@employees = Employee.all
12+
end
13+
14+
def new
15+
@project = Project.new
16+
set_clients
17+
set_employees
18+
end
19+
20+
def create
21+
@project = Project.new(project_params)
22+
if @project.save
23+
redirect_to @project, notice: "Projet créé avec succès."
24+
else
25+
set_clients
26+
set_employees
27+
render :new
28+
end
29+
end
30+
31+
def edit
32+
set_clients
33+
set_employees
34+
end
35+
36+
def update
37+
if @project.update(project_params)
38+
redirect_to @project, notice: "Projet mis à jour avec succès."
39+
else
40+
set_clients
41+
set_employees
42+
render :edit
43+
end
44+
end
45+
46+
def destroy
47+
@project.destroy
48+
redirect_to projects_path, notice: "Projet supprimé avec succès."
49+
end
50+
51+
def assign_employees
52+
@project = Project.find(params[:id])
53+
54+
# Mettre à jour les employés assignés
55+
@project.employees = Employee.where(id: params[:employee_ids])
56+
57+
if @project.save
58+
redirect_to @project, notice: "Les employés ont été mis à jour avec succès."
59+
else
60+
redirect_to @project, alert: "Une erreur s'est produite lors de la mise à jour des employés."
61+
end
62+
end
63+
64+
private
65+
66+
def set_project
67+
@project = Project.find(params[:id])
68+
end
69+
70+
def set_clients
71+
@clients = Client.all
72+
end
73+
74+
def set_employees
75+
@employees = Employee.all
76+
end
77+
78+
def project_params
79+
params.require(:project).permit(
80+
:name, :description, :address, :latitude, :longitude, :start_at, :end_at,
81+
:initial_start_at, :initial_end_at, :totalbudget, :progression,
82+
:human_cost, :material_cost, :customer_budget, :total_expenses, :client_id,
83+
employee_ids: []
84+
)
85+
end
86+
end

0 commit comments

Comments
 (0)