jobshop 0.0.167 → 0.0.179

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -2
  3. data/Rakefile +2 -1
  4. data/app/assets/javascripts/application.js +1 -0
  5. data/app/controllers/jobshop/application_controller.rb +3 -1
  6. data/app/controllers/jobshop/dashboards_controller.rb +11 -0
  7. data/app/controllers/jobshop/departments_controller.rb +52 -0
  8. data/app/controllers/jobshop/employees_controller.rb +77 -0
  9. data/app/controllers/jobshop/organizations_controller.rb +29 -0
  10. data/app/controllers/jobshop/rfqs_controller.rb +49 -0
  11. data/app/controllers/jobshop/roles_controller.rb +52 -0
  12. data/app/helpers/jobshop/application_helper.rb +10 -0
  13. data/app/listeners/jobshop/assignment_listener.rb +13 -0
  14. data/app/mailers/jobshop/rfq_responder_mailer.rb +1 -1
  15. data/app/models/jobshop/auditing.rb +20 -0
  16. data/app/models/jobshop/collection.rb +2 -7
  17. data/app/models/jobshop/customer.rb +6 -17
  18. data/app/models/jobshop/customer/category.rb +2 -8
  19. data/app/models/jobshop/customer/contact.rb +3 -8
  20. data/app/models/jobshop/department.rb +10 -0
  21. data/app/models/jobshop/department/assignment.rb +15 -0
  22. data/app/models/jobshop/employee.rb +13 -6
  23. data/app/models/jobshop/employment.rb +8 -8
  24. data/app/models/jobshop/inspection.rb +1 -1
  25. data/app/models/jobshop/inspection/boolean_criterion.rb +13 -17
  26. data/app/models/jobshop/inspection/criterion.rb +9 -10
  27. data/app/models/jobshop/inspection/deviation_criterion.rb +10 -12
  28. data/app/models/jobshop/inspection/limit_criterion.rb +12 -10
  29. data/app/models/jobshop/inspection/report.rb +22 -34
  30. data/app/models/jobshop/mailman.rb +2 -4
  31. data/app/models/jobshop/order.rb +3 -27
  32. data/app/models/jobshop/order_line.rb +4 -10
  33. data/app/models/jobshop/organization.rb +8 -15
  34. data/app/models/jobshop/organization_state.rb +10 -0
  35. data/app/models/jobshop/place.rb +3 -8
  36. data/app/models/jobshop/product.rb +4 -7
  37. data/app/models/jobshop/rfq.rb +32 -14
  38. data/app/models/jobshop/rfq/line.rb +28 -0
  39. data/app/models/jobshop/rfq/line/assignment.rb +25 -0
  40. data/app/models/jobshop/rfq/line/quantity.rb +23 -0
  41. data/app/models/jobshop/role.rb +3 -9
  42. data/app/models/jobshop/role_assignment.rb +10 -4
  43. data/app/models/jobshop/routing_process.rb +4 -10
  44. data/app/models/jobshop/routing_step.rb +3 -5
  45. data/app/models/jobshop/thing.rb +3 -8
  46. data/app/models/jobshop/user.rb +24 -11
  47. data/app/views/jobshop/dashboards/show.html.haml +35 -0
  48. data/app/views/jobshop/departments/_form.html.haml +12 -0
  49. data/app/views/jobshop/departments/edit.html.haml +7 -0
  50. data/app/views/jobshop/departments/index.html.haml +17 -0
  51. data/app/views/jobshop/departments/new.html.haml +5 -0
  52. data/app/views/jobshop/departments/show.html.haml +15 -0
  53. data/app/views/jobshop/employees/_form.html.haml +46 -0
  54. data/app/views/jobshop/employees/edit.html.haml +1 -0
  55. data/app/views/jobshop/employees/index.html.haml +12 -0
  56. data/app/views/jobshop/employees/new.html.haml +1 -0
  57. data/app/views/jobshop/employees/show.html.haml +16 -0
  58. data/app/views/jobshop/organizations/_form.html.haml +10 -0
  59. data/app/views/jobshop/organizations/edit.html.haml +7 -0
  60. data/app/views/jobshop/organizations/index.html.haml +19 -0
  61. data/app/views/jobshop/organizations/new.html.haml +5 -0
  62. data/app/views/jobshop/organizations/show.html.haml +16 -0
  63. data/app/views/jobshop/rfqs/_form.html.haml +60 -0
  64. data/app/views/jobshop/rfqs/edit.html.haml +4 -0
  65. data/app/views/jobshop/rfqs/index.html.haml +2 -0
  66. data/app/views/jobshop/roles/_form.html.haml +11 -0
  67. data/app/views/jobshop/roles/edit.html.haml +7 -0
  68. data/app/views/jobshop/roles/index.html.haml +21 -0
  69. data/app/views/jobshop/roles/new.html.haml +5 -0
  70. data/app/views/jobshop/roles/show.html.haml +3 -0
  71. data/app/views/layouts/jobshop/application.html.haml +50 -2
  72. data/config/initializers/devise.rb +2 -2
  73. data/config/routes.rb +18 -0
  74. data/db/migrate/20170311194758_initialize_jobshop.rb +4 -39
  75. data/db/migrate/20171216021339_create_organizations.rb +3 -8
  76. data/db/migrate/20171216021350_create_users.rb +28 -0
  77. data/db/migrate/20171216021400_create_employees.rb +27 -9
  78. data/db/migrate/20171216021853_create_customers.rb +29 -14
  79. data/db/migrate/20171216022020_create_places.rb +3 -4
  80. data/db/migrate/20171216022135_create_products.rb +4 -4
  81. data/db/migrate/20171216022605_create_orders.rb +27 -13
  82. data/db/migrate/20171216023018_create_roles.rb +30 -27
  83. data/db/migrate/20171216035357_create_things.rb +26 -23
  84. data/db/migrate/20171219022118_create_routing_processes.rb +28 -33
  85. data/db/migrate/20180107203241_create_inspections.rb +48 -115
  86. data/db/migrate/20181117023949_create_rfqs.rb +74 -15
  87. data/db/migrate/20181118014603_create_mailmen.rb +5 -6
  88. data/db/migrate/20190309163306_create_departments.rb +38 -0
  89. data/db/migrate/support/temporal_tables.sql +210 -0
  90. data/db/seeds.rb +92 -64
  91. data/exe/jobshop +1 -0
  92. data/lib/generators/jobshop/app/app_generator.rb +13 -3
  93. data/lib/generators/jobshop/app/templates/Procfile.tt +1 -1
  94. data/lib/generators/jobshop/app/templates/config/databases/postgresql.yml.tt +24 -0
  95. data/lib/generators/jobshop/app/templates/config/puma.rb.tt +44 -0
  96. data/lib/generators/jobshop/canary/canary_generator.rb +21 -9
  97. data/lib/generators/jobshop/dev_cert/dev_cert_generator.rb +124 -0
  98. data/lib/jobshop.rb +1 -1
  99. data/lib/jobshop/cli.rb +3 -3
  100. data/lib/jobshop/cli/app_generator.rb +15 -10
  101. data/lib/jobshop/cli/application.rb +7 -7
  102. data/lib/jobshop/cli/base.rb +65 -0
  103. data/lib/jobshop/cli/canary.rb +120 -22
  104. data/lib/jobshop/configuration.rb +1 -1
  105. data/lib/jobshop/engine.rb +8 -4
  106. data/lib/jobshop/helpers/migration.rb +27 -66
  107. data/lib/jobshop/mailroom/base_handler.rb +1 -1
  108. data/lib/jobshop/mailroom/null_handler.rb +1 -1
  109. data/lib/jobshop/mailroom/postmaster.rb +1 -1
  110. data/lib/jobshop/mailroom/rfq_handler.rb +1 -1
  111. data/lib/jobshop/version.rb +2 -2
  112. data/lib/tasks/jobshop_tasks.rake +15 -1
  113. metadata +114 -61
  114. data/app/controllers/jobshop/organizations/lookups_controller.rb +0 -18
  115. data/app/models/jobshop/employment_version.rb +0 -10
  116. data/app/models/jobshop/inspection/result.rb +0 -46
  117. data/app/models/jobshop/inspection/tuple.rb +0 -17
  118. data/app/models/jobshop/rfq_line.rb +0 -12
  119. data/db/migrate/20171216021554_create_people.rb +0 -43
  120. data/lib/generators/jobshop/app/templates/config/database.yml.tt +0 -19
@@ -0,0 +1,46 @@
1
+ - if employee.errors.present?
2
+ %ul
3
+ - employee.errors.full_messages.each do |message|
4
+ %li= message
5
+
6
+ = form_with(model: employee) do |employee_f|
7
+ %ul
8
+ %li= employee_f.text_field :forename, placeholder: "First Name"
9
+ %li= employee_f.text_field :surname, placeholder: "Last Name"
10
+ %li= employee_f.text_field :email, placeholder: "Email Address"
11
+ %li
12
+ Departments
13
+ %ul
14
+ = employee_f.collection_check_boxes(:department_ids,
15
+ current_organization.departments.all, :id, :name) do |department|
16
+ %li
17
+ = department.label do
18
+ = department.check_box
19
+ = department.object.name
20
+
21
+ %table
22
+ = employee_f.fields_for :employments do |employment_f|
23
+ %tr
24
+ %td
25
+ = employment_f.label :started_on
26
+ %br
27
+ = employment_f.date_select :started_on, include_blank: true
28
+ %td
29
+ = employment_f.label :ended_on
30
+ %br
31
+ = employment_f.date_select :ended_on, include_blank: true
32
+
33
+ -if employee.employments.empty? || employee.employments.last.ended_on != nil
34
+ %table
35
+ = employee_f.fields_for :employments, employee.employments.build do |employment_f|
36
+ %tr
37
+ %td
38
+ = employment_f.label :started_on
39
+ %br
40
+ = employment_f.date_select :started_on, include_blank: true
41
+ %td
42
+ = employment_f.label :ended_on
43
+ %br
44
+ = employment_f.date_select :ended_on, include_blank: true
45
+
46
+ = employee_f.submit
@@ -0,0 +1 @@
1
+ = render("form", employee: employee)
@@ -0,0 +1,12 @@
1
+ #active-employees
2
+ %nav
3
+ %ul
4
+ %li= link_to "Add Employee", new_employee_path
5
+
6
+ %h3 Active Employees
7
+
8
+ %table
9
+ - @active_employees.each do |employee|
10
+ %tr
11
+ %td= link_to employee.name, employee
12
+ %td= employee.departments.map(&:name).join(", ")
@@ -0,0 +1 @@
1
+ = render("form", employee: employee)
@@ -0,0 +1,16 @@
1
+ %h3
2
+ = employee.name
3
+ %small (#{link_to "edit", edit_employee_path})
4
+
5
+ #employment-history
6
+ %h4 Employment History
7
+ %table
8
+ %thead
9
+ %tr
10
+ %th Start Date
11
+ %th End Date
12
+ %tbody
13
+ - employee.employments.each do |employment|
14
+ %tr
15
+ %td= employment.started_on
16
+ %td= employment.ended_on || "Present"
@@ -0,0 +1,10 @@
1
+ = form_for @organization do |f|
2
+ - if @organization.errors.any?
3
+ #error_explanation
4
+ %h2= "#{pluralize(@organization.errors.count, "error")} prohibited this organization from being saved:"
5
+ %ul
6
+ - @organization.errors.full_messages.each do |message|
7
+ %li= message
8
+
9
+ .actions
10
+ = f.submit
@@ -0,0 +1,7 @@
1
+ %h1 Editing organization
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Show', @organization
6
+ \|
7
+ = link_to 'Back', organization_path
@@ -0,0 +1,19 @@
1
+ %h1 Listing organizations
2
+
3
+ %table
4
+ %thead
5
+ %tr
6
+ %th
7
+ %th
8
+ %th
9
+
10
+ %tbody
11
+ - @organizations.each do |organization|
12
+ %tr
13
+ %td= link_to 'Show', organization
14
+ %td= link_to 'Edit', edit_organization_path(organization)
15
+ %td= link_to 'Destroy', organization, method: :delete, data: { confirm: 'Are you sure?' }
16
+
17
+ %br
18
+
19
+ = link_to 'New Organization', new_organization_path
@@ -0,0 +1,5 @@
1
+ %h1 New organization
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Back', organizations_path
@@ -0,0 +1,16 @@
1
+ %h2= current_organization.name
2
+
3
+ %table
4
+ %tr
5
+ %td Employees:
6
+ %td= current_organization.employees.count
7
+ %tr
8
+ %td Departments:
9
+ %td= current_organization.departments.count
10
+ %tr
11
+ %td RFQs:
12
+ %td= current_organization.rfqs.count
13
+
14
+ = link_to "Edit", edit_organization_path
15
+ \|
16
+ = link_to "Back", organization_path
@@ -0,0 +1,60 @@
1
+ :css
2
+ thead, tbody, tfoot, tr {
3
+ display: block;
4
+ border-top: 1px solid grey;
5
+ border-bottom: 1px solid grey;
6
+ }
7
+
8
+ td {
9
+ vertical-align: top;
10
+ }
11
+
12
+ - if rfq.errors.present?
13
+ %ul
14
+ %li Unable to save RFQ
15
+ - rfq.errors.full_messages.each do |message|
16
+ %li= message
17
+
18
+ = form_with(model: rfq) do |rfq_f|
19
+ %table
20
+ %thead
21
+ %tr
22
+ %th Quantities
23
+ %th Identifier
24
+ %th Description
25
+ %th Assigned To
26
+ %th
27
+ %tbody
28
+ = rfq_f.fields_for :lines do |line_f|
29
+ %tr{ id: line_f.object.cache_key_with_version }
30
+ %td
31
+ = line_f.fields_for :quantities do |quantity_f|
32
+ = quantity_f.text_field :quantity, placeholder: "Quantity"
33
+ %br
34
+ - if line_f.object.persisted?
35
+ = line_f.fields_for :quantities, line_f.object.quantities.build do |quantity_f|
36
+ = quantity_f.text_field :quantity, placeholder: "Quantity",
37
+ data: { new_quantity_for: line_f.object.id }
38
+ %td= line_f.text_field :identifier, placeholder: "Identifier"
39
+ %td= line_f.text_area :description, placeholder: "Description"
40
+ %td= line_f.collection_select :assignee_ids,
41
+ current_organization.employees, :id, :name, {},
42
+ { multiple: true, include_blank: true }
43
+ %td
44
+ = line_f.check_box :_destroy
45
+ = line_f.label "Delete"
46
+ %tfoot#new-rfq-line-item
47
+ = rfq_f.fields_for :lines, rfq.lines.build do |line_f|
48
+ %tr
49
+ %td
50
+ = line_f.fields_for :quantities, line_f.object.quantities.build do |quantity_f|
51
+ = quantity_f.text_field :quantity, placeholder: "Quantity",
52
+ data: { new_line_quantity: DateTime.now.strftime("%Q") }
53
+ %td= line_f.text_field :identifier, placeholder: "Identifier",
54
+ data: { new_line_identifier: DateTime.now.strftime("%Q") }
55
+ %td= line_f.text_area :description, placeholder: "Description"
56
+ %td= line_f.collection_select :assignee_ids,
57
+ current_organization.employees, :id, :name, { },
58
+ { multiple: true, include_blank: true }
59
+ %td
60
+ = rfq_f.submit
@@ -0,0 +1,4 @@
1
+ = render("form", rfq: rfq)
2
+ %h1= rfq.subject
3
+ %p From: #{rfq.from}
4
+ %p Content: #{rfq.content}
@@ -0,0 +1,2 @@
1
+ %h1 RFQs#index
2
+ %p Find me in app/views/jobshop/rfqs/index.html.haml
@@ -0,0 +1,11 @@
1
+ = form_for @role do |f|
2
+ - if @role.errors.any?
3
+ #error_explanation
4
+ %h2= "#{pluralize(@role.errors.count, "error")} prohibited this role from being saved:"
5
+ %ul
6
+ - @role.errors.full_messages.each do |message|
7
+ %li= message
8
+
9
+ = f.text_field :name, placeholder: "Name"
10
+ .actions
11
+ = f.submit
@@ -0,0 +1,7 @@
1
+ %h1 Editing role
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Show', @role
6
+ \|
7
+ = link_to 'Back', roles_path
@@ -0,0 +1,21 @@
1
+ %h1 Listing roles
2
+
3
+ %table
4
+ %thead
5
+ %tr
6
+ %th Name
7
+ %th
8
+ %th
9
+ %th
10
+
11
+ %tbody
12
+ - @roles.each do |role|
13
+ %tr
14
+ %td= role.name
15
+ %td= link_to 'Show', role
16
+ %td= link_to 'Edit', edit_role_path(role)
17
+ %td= link_to 'Destroy', role, method: :delete, data: { confirm: 'Are you sure?' }
18
+
19
+ %br
20
+
21
+ = link_to 'New Role', new_role_path
@@ -0,0 +1,5 @@
1
+ %h1 New role
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Back', roles_path
@@ -0,0 +1,3 @@
1
+ = link_to 'Edit', edit_role_path(@role)
2
+ \|
3
+ = link_to 'Back', roles_path
@@ -7,9 +7,57 @@
7
7
 
8
8
  %title Jobshop
9
9
 
10
- =# stylesheet_link_tag "jobshop/application", media: "all", "data-turbolinks-track": "reload"
11
- =# javascript_include_tag "jobshop/application", "data-turbolinks-track": "reload"
10
+ //= stylesheet_link_tag "jobshop/application", media: "all", "data-turbolinks-track": "reload"
11
+ //= javascript_include_tag webpack_asset_url("application.js"), "data-turbolinks-track": "reload"
12
12
  = csrf_meta_tags
13
13
 
14
14
  %body{ class: :body_class }
15
+ :scss
16
+ nav {
17
+ ul {
18
+ margin: 0;
19
+ padding: 0;
20
+ list-style: none;
21
+ }
22
+
23
+ li {
24
+ display: inline-block;
25
+ }
26
+
27
+ a {
28
+ display: block;
29
+ padding: 6px 12px;
30
+ text-decoration: none;
31
+ }
32
+ }
33
+
34
+ thead, tbody, tfoot, tr {
35
+ display: block;
36
+ border-top: 1px solid grey;
37
+ border-bottom: 1px solid grey;
38
+ }
39
+
40
+ td {
41
+ vertical-align: top;
42
+ }
43
+
44
+ - if user_signed_in?
45
+ %p
46
+ #{current_organization.name} - Hello, #{current_user.name} (#{current_user.email})
47
+ %span= link_to("Sign Out", destroy_user_session_path)
48
+ %nav
49
+ %ul
50
+ %li= link_to "Home", root_path
51
+ %li= link_to "HR", employees_path
52
+ %li
53
+ %ul
54
+ %li Administration
55
+ %li= link_to "Organization", organization_path
56
+ %li= link_to "Departments", departments_path
57
+ %li= link_to "Roles", roles_path
58
+ %hr
59
+ - flash.each do |key, value|
60
+ = content_tag :div, value, class: "flash #{key}"
61
+ %hr
62
+
15
63
  = content_for?(:body) ? yield(:body) : yield
@@ -8,7 +8,7 @@ Devise.setup do |config|
8
8
  # confirmation, reset password and unlock tokens in the database.
9
9
  # Devise will use the `secret_key_base` as its `secret_key`
10
10
  # by default. You can change it below and use your own secret key.
11
- config.secret_key = SecureRandom.hex(64)
11
+ config.secret_key = Rails.application.credentials.secret_key_base
12
12
 
13
13
  # ==> Controller configuration
14
14
  # Configure the parent class to the devise controllers.
@@ -251,7 +251,7 @@ Devise.setup do |config|
251
251
  # config.navigational_formats = ['*/*', :html]
252
252
 
253
253
  # The default HTTP method used to sign out a resource. Default is :delete.
254
- config.sign_out_via = :delete
254
+ config.sign_out_via = :get
255
255
 
256
256
  # ==> OmniAuth
257
257
  # Add a new OmniAuth provider. Check the wiki for more information on setting
@@ -1,3 +1,21 @@
1
1
  Jobshop::Engine.routes.draw do
2
+ default_url_options = { protocol: :https, host: "jobshop.test" }
3
+
2
4
  devise_for :users, class_name: "Jobshop::User", module: :devise
5
+
6
+ scope "/sales" do
7
+ resources :rfqs
8
+ end
9
+
10
+ scope "/hr" do
11
+ resources :employees
12
+ end
13
+
14
+ scope "/admin" do
15
+ resources :departments
16
+ resources :roles
17
+ resource :organization
18
+ end
19
+
20
+ root to: "dashboards#show"
3
21
  end
@@ -1,4 +1,4 @@
1
- # frozen_string_literals: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  class InitializeJobshop < ActiveRecord::Migration[5.2]
4
4
  def change
@@ -6,43 +6,8 @@ class InitializeJobshop < ActiveRecord::Migration[5.2]
6
6
  enable_extension "citext" unless extension_enabled? "citext"
7
7
  enable_extension "btree_gist" unless extension_enabled? "btree_gist"
8
8
 
9
- execute <<~SQL
10
- -- prepare_auditable()
11
- CREATE OR REPLACE FUNCTION prepare_auditable() RETURNS TRIGGER AS $$
12
- BEGIN
13
- IF (TG_OP = 'UPDATE') THEN
14
- NEW.version = OLD.version + 1;
15
- RETURN NEW;
16
- ELSIF (TG_OP = 'INSERT') THEN
17
- NEW.version = 0;
18
- RETURN NEW;
19
- END IF;
20
- END;
21
- $$ LANGUAGE plpgsql;
22
-
23
- -- process_auditable(audit_table_name)
24
- CREATE OR REPLACE FUNCTION process_auditable() RETURNS TRIGGER AS $$
25
- DECLARE
26
- audit_table_name text := TG_ARGV[0];
27
-
28
- BEGIN
29
- IF (TG_OP = 'UPDATE') THEN
30
- EXECUTE
31
- FORMAT(
32
- 'INSERT INTO %1$I SELECT gen_random_uuid(), now(), ($1).*',
33
- audit_table_name)
34
- USING OLD;
35
- RETURN NEW;
36
- ELSIF (TG_OP = 'INSERT') THEN
37
- EXECUTE
38
- FORMAT(
39
- 'INSERT INTO %1$I SELECT gen_random_uuid(), now(), ($1).*',
40
- audit_table_name)
41
- USING NEW;
42
- RETURN NEW;
43
- END IF;
44
- END;
45
- $$ LANGUAGE plpgsql;
46
- SQL
9
+ execute File.read(
10
+ File.join(Jobshop::Engine.config.paths["db/migrate"].first,
11
+ "support/temporal_tables.sql"))
47
12
  end
48
13
  end
@@ -1,4 +1,4 @@
1
- # frozen_string_literals: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  require "jobshop/helpers/migration.rb"
4
4
 
@@ -6,14 +6,9 @@ class CreateOrganizations < ActiveRecord::Migration[5.2]
6
6
  include Jobshop::Helpers::Migration
7
7
 
8
8
  def change
9
- create_table :jobshop_organizations, id: false do |t|
10
- t.uuid :organization_id, null: false, default: "gen_random_uuid()"
11
- t.index :organization_id, unique: true,
12
- name: :idx_jobshop_organizations_pkey
13
-
9
+ create_table_with_auditing :jobshop_organizations, primary_key: :id do |t|
10
+ t.citext :name, null: false, index: true
14
11
  t.timestamps
15
12
  end
16
-
17
- idx_table_name_pkey :jobshop_organizations
18
13
  end
19
14
  end