Skip to content

Commit

Permalink
Fix copy paste when clicking on row
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Dec 17, 2024
1 parent 92ed5a9 commit 3afd7a2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
28 changes: 17 additions & 11 deletions app/assets/javascripts/components/input_table.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { customElement, property } from "lit/decorators.js";
import { html, PropertyValues, render, TemplateResult } from "lit";
import jspreadsheet, { CellValue, Column, CustomEditor, JspreadsheetInstance } from "jspreadsheet-ce";
import jspreadsheet, {
CellValue,
Column,
CustomEditor,
JspreadsheetInstance,
JspreadsheetInstanceElement
} from "jspreadsheet-ce";
import { createRef, ref, Ref } from "lit/directives/ref.js";
import { DodonaElement } from "components/meta/dodona_element";
import { fetch, ready } from "utilities";
Expand Down Expand Up @@ -78,13 +84,13 @@ export class ScoreItemInputTable extends watchMixin(DodonaElement) {
get data(): CellData[][] {
return [
...this.scoreItems.map(item => [
item.id,
item.name,
item.description,
item.maximum,
item.visible
item.visible,
item.id,
]),
["", "", "", "", false]
["", "", "", false, ""]
];
}

Expand All @@ -93,11 +99,11 @@ export class ScoreItemInputTable extends watchMixin(DodonaElement) {

const scoreItems = tableData.map((row: CellData[], index: number) => {
return {
id: row[0] as number | null,
name: row[1] as string,
description: row[2] as string,
maximum: (row[3] as string).replace(",", "."), // replace comma with dot for float representation
visible: toBoolean(row[4]),
name: row[0] as string,
description: row[1] as string,
maximum: (row[2] as string).replace(",", "."), // replace comma with dot for float representation
visible: toBoolean(row[3]),
id: row[4] as number | null,
order: index,
};
});
Expand Down Expand Up @@ -155,11 +161,11 @@ export class ScoreItemInputTable extends watchMixin(DodonaElement) {

get columnConfig(): ColumnWithTooltip[] {
return [
{ type: "hidden", title: "id" },
{ type: "text", title: i18n.t("js.score_items.name"), width: 200, align: "left" },
{ type: "text", title: i18n.t("js.score_items.description"), width: this.descriptionColWidth, align: "left", tooltip: i18n.t("js.score_items.description_help") },
{ type: "numeric", title: i18n.t("js.score_items.maximum"), width: 75, align: "left", tooltip: i18n.t("js.score_items.maximum_help") },
{ type: "html", title: i18n.t("js.score_items.visible"), width: 75, align: "left", tooltip: i18n.t("js.score_items.visible_help"), editor: this.customCheckboxEditor() },
{ type: "hidden", title: "id" },
{ type: "html", title: " ", width: 30, align: "center", readOnly: true, editor: {
createCell: (cell: HTMLTableCellElement) => this.createDeleteButton(cell),
} },
Expand Down Expand Up @@ -215,7 +221,7 @@ export class ScoreItemInputTable extends watchMixin(DodonaElement) {

// update description column width when the window is resized
new ResizeObserver(() => {
this.table.setWidth(2, this.descriptionColWidth);
this.table.setWidth(1, this.descriptionColWidth);
}).observe(this.tableRef.value);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"flatpickr": "^4.6.13",
"fscreen": "^1.2.0",
"glightbox": "^3.2.0",
"jspreadsheet-ce": "^4.2.1",
"jspreadsheet-ce": "^4.15.0",
"lit": "^3.2.1",
"node-polyglot": "^2.6.0",
"sass": "^1.83.0",
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6059,18 +6059,18 @@ [email protected], json5@^2.1.2, json5@^2.2.3:
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

jspreadsheet-ce@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/jspreadsheet-ce/-/jspreadsheet-ce-4.2.1.tgz#66cba61fb28d65d6cf89e6aa495aecd89f63a710"
integrity sha512-kQ+bUwH0MEeyr3Ojdd+tB0BJik3NsnQlhC1E52uwrURvqBu3GnrDtRZZS3cAwtL0FzHBZDsJJB9afTdReBm6Hg==
jspreadsheet-ce@^4.15.0:
version "4.15.0"
resolved "https://registry.yarnpkg.com/jspreadsheet-ce/-/jspreadsheet-ce-4.15.0.tgz#9f857fa088691b124677d8c33fdfe1963d80eea7"
integrity sha512-1A1q7uxICxzXRiql3ZhXldFPjdt5VcFcoHSEvfvBFw9DcU7bq/gAEaqyKMJPeG+6zibpO4r+b8Dk88nIR7NKng==
dependencies:
"@jspreadsheet/formula" "^2.0.2"
jsuites "^5.3.0"
jsuites "^5.6.5"

jsuites@^5.3.0:
version "5.4.6"
resolved "https://registry.yarnpkg.com/jsuites/-/jsuites-5.4.6.tgz#0d8dc2aa3cdffda4ce0f07df8aa3a2177b3a3cec"
integrity sha512-/Do37lqZ+EhBKvWi3L1r7wHjP9PHAtjDPLNepp84Pqi4pWrH6ZisTuJZyI6SRHYqshsfMr+cg5CkPbPC6J6o4Q==
jsuites@^5.6.5:
version "5.8.2"
resolved "https://registry.yarnpkg.com/jsuites/-/jsuites-5.8.2.tgz#65c0518a4cbd562bcec757c6d940d84bd7ee77c5"
integrity sha512-HvVFuOWc5C5ASwddh7FwUS645cRVC0Yvt89uWAtaSCA0NNAh1TdL5LoK0TFbB2NlNEMO31pjvCv94tCcCuwysw==

keyv@^4.5.3, keyv@^4.5.4:
version "4.5.4"
Expand Down

0 comments on commit 3afd7a2

Please sign in to comment.