Skip to content

Feature/884 Team Skill Tracking over time view #888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/controllers/department_skill_snapshots_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class DepartmentSkillSnapshotsController < CrudController
def index
@data = chart_data.to_json
super
end

private

def chart_data
{
labels: Date::MONTHNAMES.compact,
datasets: dataset_values.map { |value| build_dataset(value) }
}
end

def dataset_values
%w[Azubi Junior Senior Professional Expert]
end

def build_dataset(value)
{
label: value,
data: Array.new(12) { rand(10) },
fill: false,
tension: 0.1
}
end
end
3 changes: 2 additions & 1 deletion app/helpers/tab_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def global_tabs
{ title: ti('navbar.skill_search'), path: people_skills_path, admin_only: false },
{ title: ti('navbar.cv_search'), path: cv_search_index_path, admin_only: false },
{ title: ti('navbar.skillset'), path: skills_path, admin_only: false },
{ title: ti('navbar.certificates'), path: certificates_path, admin_only: true }
{ title: ti('navbar.certificates'), path: certificates_path, admin_only: true },
{ title: ti('navbar.skills_tracking'), path: department_skill_snapshots_path, admin_only: false }
]
end

Expand Down
35 changes: 35 additions & 0 deletions app/javascript/controllers/chart_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Controller } from "@hotwired/stimulus"
import Chart from "chart.js/auto"
import { Colors } from 'chart.js';

export default class extends Controller {
static targets = ["canvas"]
static values = {
dataset: String
}

connect() {
Chart.register(Colors);

const ctx = this.canvasTarget.getContext("2d")

const chartData = JSON.parse(this.datasetValue)

this.chart = new Chart(ctx, {
type: 'line',
data: chartData,
options: {
responsive: true,
scales: {
y: {
beginAtZero: true
}
}
}
})
}

disconnect() {
this.chart?.destroy()
}
}
5 changes: 5 additions & 0 deletions app/models/department_skill_snapshot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class DepartmentSkillSnapshot < ApplicationRecord
belongs_to :department

serialize :department_skill_levels, type: Hash, coder: JSON
end
18 changes: 18 additions & 0 deletions app/views/department_skill_snapshots/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
= form_with url: department_skill_snapshots_path, method: :get, data: { turbo_frame: "team-skill-chart" } do |f|
.d-flex.mt-4.mb-4.gap-4
%div
= f.label :department_id, t('activerecord.models.department.one'), class: "text-secondary"
= f.select :department_id,
options_from_collection_for_select(Department.all, :id, :name, params[:department_id]), {}, { onchange: "this.form.requestSubmit()", class: "form-select"}
%div
= f.label :skill_id, t('activerecord.models.skill.one'), class: "text-secondary"
= f.select :skill_id,
options_from_collection_for_select(Skill.all, :id, :title, params[:skill_id]), {}, { onchange: "this.form.requestSubmit()", class: "form-select" }
%div
= f.label :year, t('global.date.year'), class: "text-secondary"
= f.select :year,
options_for_select((2025..Date.today.year).to_a.reverse, params[:year]), {}, { onchange: "this.form.requestSubmit()", class: "form-select"}

%turbo-frame#team-skill-chart
%div.chart-container{data: {"chart-dataset-value": @data, controller: "chart" }}
%canvas{ "data-chart-target": "canvas", width: "3", height: "1" }
1 change: 1 addition & 0 deletions config/locales/de-CH.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ de-CH:
profile: Profiu
skill_search: Skill Suechi
skillset: Skillset
skills_tracking: Skills tracking
new: Neu
people_skills:
certificate: Zertifikat
Expand Down
1 change: 1 addition & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ de:
profile: Profil
skill_search: Skill Suche
skillset: Skillset
skills_tracking: Skills tracking
new: Neu
people_skills:
certificate: Zertifikat
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ en:
profile: Profile
skill_search: Skill search
skillset: Skillset
skills_tracking: Skills tracking
new: New
people_skills:
certificate: Certificate
Expand Down
1 change: 1 addition & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ fr:
profile: Profil
skill_search: Recherche de compétences
skillset: Kit de compétences
skills_tracking: Suivi des compétences
new: Nouveau
people_skills:
certificate: Certificat
Expand Down
1 change: 1 addition & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ it:
profile: Profilo
skill_search: Ricerca di competenze
skillset: Competenze
skills_tracking: Tracciamento delle competenze
new: Nuovo
people_skills:
certificate: Certificato
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
end

resources :certificates

resources :department_skill_snapshots, only: [:index]
end


Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"autoprefixer": "^10.4.17",
"bootstrap": "^5.3.2",
"bootstrap-icons": "^1.11.3",
"chart.js": "^4.4.9",
"esbuild": "^0.25.0",
"esbuild-rails": "^1.0.7",
"nodemon": "^3.0.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

describe DepartmentSkillSnapshotsController do

end
21 changes: 21 additions & 0 deletions spec/features/department_skill_snapshots_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'rails_helper'

describe 'Department Skill Snapshots', type: :feature, js: true do
before(:each) do
admin = auth_users(:admin)
login_as(admin, scope: :auth_user)
visit department_skill_snapshots_path
end

it 'Should display all selects with the corresponding labels and the the canvas chart' do
expect(page).to have_content('Organisationseinheit')
expect(page).to have_content('Skill')
expect(page).to have_content('Jahr')

expect(page).to have_select('department_id')
expect(page).to have_select('skill_id')
expect(page).to have_select('year')

expect(page).to have_selector("canvas")
end
end
5 changes: 3 additions & 2 deletions spec/features/tabbar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{ title: 'global.navbar.skill_search', path_helper: "people_skills_path", admin_only: false },
{ title: 'global.navbar.cv_search', path_helper: "cv_search_index_path", admin_only: false },
{ title: 'global.navbar.skillset', path_helper: "skills_path", admin_only: false },
{ title: 'global.navbar.certificates', path_helper: "certificates_path", admin_only: true }
{ title: 'global.navbar.certificates', path_helper: "certificates_path", admin_only: true },
{ title: 'global.navbar.skills_tracking', path_helper: "department_skill_snapshots_path", admin_only: false }
]

PERSON_TABS =
Expand All @@ -27,7 +28,7 @@
end

after(:each) do
expect(current_path.start_with?("/#{locale}")).to eq(I18n.locale != I18n.default_locale)
expect(current_path.start_with?("/#{locale}/")).to eq(I18n.locale != I18n.default_locale)
end

describe 'Global' do
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@
resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.12.tgz#50aa8345d7f62402680c6d2d9814660761837001"
integrity sha512-l3BiQRkD7qrnQv6ms6sqPLczvwbQpXt5iAVwjDvX0iumrz6yEonQkNAzNjeDX25/OJMFDTxpHjkJZHGpM9ikWw==

"@kurkle/color@^0.3.0":
version "0.3.4"
resolved "https://registry.yarnpkg.com/@kurkle/color/-/color-0.3.4.tgz#4d4ff677e1609214fc71c580125ddddd86abcabf"
integrity sha512-M5UknZPHRu3DEDWoipU6sE8PdkZ6Z/S+v4dD+Ke8IaNlpdSQah50lz1KtcFBa2vsdOnwbbnxJwVM4wty6udA5w==

"@nodelib/[email protected]":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
Expand Down Expand Up @@ -263,6 +268,13 @@ caniuse-lite@^1.0.30001646, caniuse-lite@^1.0.30001688:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001699.tgz#a102cf330d153bf8c92bfb5be3cd44c0a89c8c12"
integrity sha512-b+uH5BakXZ9Do9iK+CkDmctUSEqZl+SP056vc5usa0PL+ev5OHw003rZXcnjNDv3L8P5j6rwT6C0BPKSikW08w==

chart.js@^4.4.9:
version "4.4.9"
resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-4.4.9.tgz#602e2fc2462f0f7bb7b255eaa1b51f56a43a1362"
integrity sha512-EyZ9wWKgpAU0fLJ43YAEIF8sr5F2W3LqbS40ZJyHIner2lY14ufqv2VMp69MAiZ2rpwxEUxEhIH/0U3xyRynxg==
dependencies:
"@kurkle/color" "^0.3.0"

"chokidar@>=3.0.0 <4.0.0", chokidar@^3.3.0, chokidar@^3.5.2:
version "3.6.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b"
Expand Down