Skip to content

Commit

Permalink
try many rows + fix add button
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Sep 8, 2024
1 parent 6515937 commit 9d0c305
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 27 deletions.
18 changes: 14 additions & 4 deletions apps/hello/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,22 @@ def _get_main_df():
main_df = pd.read_csv("assets/main_df.csv")
return main_df


def _get_editable_df():
def repeat(arr, count):
res = []
for x in range(count):
for item in arr:
res.append(item)
return res

repeat_count = 1000

df = pd.DataFrame({
'number': [1, 2, 3],
'boolean': [True, False, True],
'object': [{"one": 1, "n": [{"one": 1}, {"two": 2}, {"three": 3}]}, {"two": 2}, {"three": 3}],
'text': ['one', 'two', 'three'],
'number': repeat([1, 2, 3], repeat_count),
'boolean': repeat([True, False, True], repeat_count),
'object': repeat([{"one": 1, "n": [{"one": 1}, {"two": 2}, {"three": 3}]}, {"two": 2}, {"three": 3}], repeat_count),
'text': repeat(['one', 'two', 'three'], repeat_count),
})
return wf.EditableDataframe(df)

Expand Down
52 changes: 31 additions & 21 deletions apps/hello/ui.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"metadata": {
"writer_version": "0.7.0"
"writer_version": "0.7.4"
},
"components": {
"root": {
Expand Down Expand Up @@ -1201,49 +1201,59 @@
"enableRecordAdd": "yes",
"enableRecordUpdate": "yes",
"enableSearch": "",
"showIndex": "yes"
"showIndex": "yes",
"actions": "{\n \"remove\": \"Remove\",\n \"open\": \"Open\"\n}"
},
"isCodeManaged": false,
"position": 0,
"position": 1,
"parentId": "c11snjfr0ma2btks",
"handlers": {
"wf-dataframe-add": "on_editable_df_record_add",
"wf-dataframe-update": "on_editable_df_record_change",
"wf-dataframe-action": "on_editable_df_record_action"
}
},
"ow629tw0fgphdpwv": {
"id": "ow629tw0fgphdpwv",
"type": "dataframe",
"7kdfu2nzs3t36i7u": {
"id": "7kdfu2nzs3t36i7u",
"type": "columns",
"content": {},
"isCodeManaged": false,
"position": 0,
"parentId": "c11snjfr0ma2btks",
"handlers": {}
},
"47jzvee6zle18zr8": {
"id": "47jzvee6zle18zr8",
"type": "column",
"content": {
"dataframe": "@{editable_df}",
"actions": "{}"
"width": "1"
},
"isCodeManaged": false,
"position": 0,
"parentId": "est4u3nlqyfuhicd",
"parentId": "7kdfu2nzs3t36i7u",
"handlers": {}
},
"est4u3nlqyfuhicd": {
"id": "est4u3nlqyfuhicd",
"type": "section",
"ltg4cp2oefv8dig9": {
"id": "ltg4cp2oefv8dig9",
"type": "text",
"content": {
"title": "Status of the dataframe"
"text": "Open row text: @{editable_df_open_text}"
},
"isCodeManaged": false,
"position": 1,
"parentId": "c11snjfr0ma2btks",
"position": 0,
"parentId": "47jzvee6zle18zr8",
"handlers": {}
},
"48566l2vkdvk8k1x": {
"id": "48566l2vkdvk8k1x",
"type": "text",
"jkfycjb324n84t7k": {
"id": "jkfycjb324n84t7k",
"type": "dataframe",
"content": {
"text": "Item selected: @{editable_df_open_text}"
"dataframe": "@{editable_df}",
"actions": "{}"
},
"isCodeManaged": false,
"position": 1,
"parentId": "est4u3nlqyfuhicd",
"position": 2,
"parentId": "c11snjfr0ma2btks",
"handlers": {}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/src/components/core/content/CoreDataframe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ const gridStyle = computed(() => {
const fontStyle = fields.fontStyle.value;
return {
"min-height": `${ROW_HEIGHT_PX * (1 + fields.displayRowCount.value)}px`,
"max-height": `${(displayRowCount.value + 1) * ROW_HEIGHT_PX}px`,
"min-height": `${(1 + fields.displayRowCount.value + Number(enableRecordAdd.value ?? false)) * ROW_HEIGHT_PX}px`,
"max-height": `${(displayRowCount.value + 1 + Number(enableRecordAdd.value ?? false)) * ROW_HEIGHT_PX}px`,
"font-family": fontStyle == "monospace" ? "monospace" : undefined,
"grid-template-rows": `${ROW_HEIGHT_PX}px repeat(${displayRowCount.value}, min-content) ${ROW_HEIGHT_PX}px`,
};
Expand Down

0 comments on commit 9d0c305

Please sign in to comment.