Skip to content

Commit

Permalink
beginn with implementation of edit skillset
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcEgliP committed Feb 16, 2024
1 parent c73e391 commit 95372b9
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/assets/images/floppy2-fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

.modal-dialog {
max-width: 60%;
}

.pointer {
cursor: pointer;
}
33 changes: 32 additions & 1 deletion app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
import "@hotwired/turbo-rails"
import "./controllers"
import "@puzzleitc/puzzle-shell";
import "@puzzleitc/puzzle-shell/style.css";
import "@puzzleitc/puzzle-shell/style.css";

let toggleEditModeButton = document.querySelectorAll('.edit-button');
let saveButton = document.querySelectorAll('.save-button');
let cancelButton = document.querySelectorAll('.cancel-button');

document.addEventListener('turbo:load', () => {
toggleEditModeButton.forEach((img, index) => {
img.addEventListener("click", () => {
let row = document.getElementById('table-row-' + index);
row.contentEditable = "true";
row.focus();
toggleActionButtonDisplay(index, "block");
img.style.display = "none";
});
});

cancelButton.forEach((cancel, index) => {
cancel.addEventListener("click", () => {
let row = document.getElementById("table-row-" + index);
row.contentEditable = "false";
toggleActionButtonDisplay(index, "none");
document.getElementById("edit-button-" + index).style.display = "block";
});
toggleActionButtonDisplay(index, "none");
});
});

function toggleActionButtonDisplay(id, display) {
document.getElementById("cancel-button-" + id).style.display = display;
document.getElementById("save-button-" + id).style.display = display;
}
10 changes: 6 additions & 4 deletions app/views/skills/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
%th.table-secondary{scope: "col"}= t "skills.table.radar"
%th{scope: "col"}= t "skills.table.modify"
%tbody
- @skills.each_with_index do |skill|
%tr
- @skills.each_with_index do |skill, index|
%tr{:contenteditable => "false", :id => "table-row-#{index}"}
%td= skill.title
%td.table-light= skill.people.count
%td= skill.category.title
%td.table-light= skill.category.parent.title
%td= skill.default_set.nil? ? "Neu" : (skill.default_set? ? "Ja" : "Nein")
%td.table-light= skill.radar
%td
%img{:src=> "/assets/pencil-square.svg",:height=>"16"}
%td{:contenteditable => "false"}
%img.pointer.edit-button{:src=> "/assets/pencil-square.svg",:height=>"16", :id=>"edit-button-#{index}"}
=link_to image_tag("/assets/floppy2-fill.svg", class: "text-primary", id: "save-button-#{index}"), "#{skill_path(skill)}", class: "btn text-primary", method: :put
%img.pointer.cancel-button{:src=> "/assets/x.svg",:height=>"16", :id=>"cancel-button-#{index}"}

0 comments on commit 95372b9

Please sign in to comment.