Skip to content

Commit

Permalink
support new select API in paginaiton table
Browse files Browse the repository at this point in the history
  • Loading branch information
penqe committed May 10, 2024
1 parent 87daf55 commit 7a165a7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 37 deletions.
7 changes: 2 additions & 5 deletions stanzas/barchart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,12 @@ export default class Barchart extends MetaStanza {
}

handleEvent(event) {
console.trace(event.detail);
console.log(this.params["event-incoming_change_selected_nodes"]);
console.log(event.detail === this.params["data-url"]);
const { dataUrl } = event.detail;
const { selectedIds, dataUrl } = event.detail;
if (
this.params["event-incoming_change_selected_nodes"] &&
dataUrl === this.params["data-url"]
) {
changeSelectedStyle.apply(this, [event.detail.selectedIds]);
changeSelectedStyle.apply(this, [selectedIds]);
}
}
}
Expand Down
28 changes: 16 additions & 12 deletions stanzas/pagination-table/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ export default defineComponent({
rowIndex;
const rowId = filteredRowIds[actualRowIndex];
// selected rows
let selectedRows = [...state.selectedRows];
let selectedIds = [...state.selectedRows];
// update selected rows
if (isShift && state.lastSelectedRow !== null) {
const lastSelectedRowIndex = filteredRowIds.indexOf(
Expand All @@ -667,30 +667,33 @@ export default defineComponent({
const start = Math.min(lastSelectedRowIndex, actualRowIndex);
const end = Math.max(lastSelectedRowIndex, actualRowIndex);
for (let i = start; i <= end; i++) {
if (!selectedRows.includes(filteredRowIds[i])) {
selectedRows.push(filteredRowIds[i]);
if (!selectedIds.includes(filteredRowIds[i])) {
selectedIds.push(filteredRowIds[i]);
}
}
} else if (isCmd) {
if (selectedRows.includes(rowId)) {
selectedRows.splice(selectedRows.indexOf(rowId), 1);
if (selectedIds.includes(rowId)) {
selectedIds.splice(selectedIds.indexOf(rowId), 1);
} else {
selectedRows.push(rowId);
selectedIds.push(rowId);
}
} else {
selectedRows = [rowId];
selectedIds = [rowId];
}

// dispatch event

const stanza = rootElement.value.parentNode.parentNode.parentNode.host;
stanza.dispatchEvent(
new CustomEvent("changeSelectedNodes", {
detail: selectedRows,
detail: {
selectedIds,
targetId: rowId,
dataUrl: params.dataUrl
},
})
);
state.lastSelectedRow = rowId;
state.selectedRows = [...selectedRows.map(row => row.toString())];
state.selectedRows = [...selectedIds.map(row => row.toString())];
};

const handleMouseDown = (event) => {
Expand All @@ -716,8 +719,9 @@ export default defineComponent({
return state.selectedRows.includes(rowID);
};

const updateSelectedRows = (rows) => {
state.selectedRows = [...rows.map(row => row.toString())];
const updateSelectedRows = (emitSelectedEventParams) => {
const {selectedIds} = emitSelectedEventParams
state.selectedRows = [...selectedIds.map(id => id.toString())];
};

return {
Expand Down
35 changes: 15 additions & 20 deletions stanzas/treemap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export default class TreeMapStanza extends MetaStanza {
}

handleEvent(event) {
console.log(event.detail);
const { selectedIds, dataUrl } = event.detail;

if (
Expand Down Expand Up @@ -253,11 +252,10 @@ function draw(el, dataset, opts, stanza) {
.text((d) =>
d === root
? ""
: `${name(d)}\n${
d?.children
? format(sum(d, (d) => d?.data?.data.value || 0))
: d.data.data.value
}`
: `${name(d)}\n${d?.children
? format(sum(d, (d) => d?.data?.data.value || 0))
: d.data.data.value
}`
);

node
Expand All @@ -266,11 +264,10 @@ function draw(el, dataset, opts, stanza) {
.classed("breadcrumb", (d) => d === root)
.attr("id", (d) => (d.leafUid = uid("leaf")).id)
.attr("style", (d) => {
return `fill: ${
d === root
return `fill: ${d === root
? "var(--togostanza-theme-background_color)"
: colorScale(d.data.data.label)
}`;
}`;
});

//Add inner nodes to show that it's a zoomable tile
Expand Down Expand Up @@ -408,13 +405,11 @@ function draw(el, dataset, opts, stanza) {
if (d === root) {
return `translate(0,0)`;
} else if (d.parent !== root) {
return `translate(${x(d.x0) - x(d.parent.x0)},${
y(d.y0) - y(d.parent.y0)
})`;
return `translate(${x(d.x0) - x(d.parent.x0)},${y(d.y0) - y(d.parent.y0)
})`;
} else {
return `translate(${x(d.x0) + gapWidth},${
y(d.y0) + rootHeight + gapWidth
})`;
return `translate(${x(d.x0) + gapWidth},${y(d.y0) + rootHeight + gapWidth
})`;
}
});

Expand Down Expand Up @@ -510,11 +505,11 @@ function getLineHeight(el) {
temp.setAttribute(
"style",
"margin:0; padding:0; " +
"font-family:" +
(el.style.fontFamily || "inherit") +
"; " +
"font-size:" +
(el.style.fontSize || "inherit")
"font-family:" +
(el.style.fontFamily || "inherit") +
"; " +
"font-size:" +
(el.style.fontSize || "inherit")
);
temp.innerHTML = "A";

Expand Down

0 comments on commit 7a165a7

Please sign in to comment.