Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
clive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
clive
Commits
181991e2
Commit
181991e2
authored
8 months ago
by
Mateusz Kudela
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
5d0cfa2c
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request
!388
. Comments created here will be created in the context of that merge request.
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
clive/__private/ui/widgets/clive_checkerboard_table.py
+29
-23
29 additions, 23 deletions
clive/__private/ui/widgets/clive_checkerboard_table.py
with
29 additions
and
23 deletions
clive/__private/ui/widgets/clive_checkerboard_table.py
+
29
−
23
Edit
View file @
181991e2
...
...
@@ -196,10 +196,34 @@ class CliveCheckerboardTable(CliveWidget):
self
.
update_previous_state
(
content
)
await
self
.
rebuild
(
content
)
async
def
_rebuild_header
(
self
)
->
None
:
await
self
.
query
(
"
*
"
)[
1
].
remove
()
await
self
.
mount
(
self
.
_header
,
after
=
self
.
_title
)
async
def
_rebuild_rows
(
self
,
row_type
:
Any
,
# noqa: ANN401
start_index
:
int
=
0
,
end_index
:
int
|
None
=
None
,
)
->
None
:
rows
=
self
.
query
(
row_type
)
assert
start_index
<
len
(
rows
),
"
Starting_from_element parameter has higher value than number of elements in the table
"
if
end_index
:
assert
(
start_index
<
end_index
),
"
Starting_from_element parameter has higher value than ending_with_element argument
"
for
index
in
range
(
start_index
,
end_index
+
1
if
end_index
else
len
(
rows
)):
await
rows
[
index
].
remove
()
self
.
_mount_static_rows
(
start_index
,
end_index
)
async
def
rebuild
(
self
,
content
:
Content
|
None
=
None
,
row_type
:
Any
=
None
,
# noqa: ANN401
rebuild_header
:
bool
=
False
,
starting_from_element
:
int
=
0
,
ending_with_element
:
int
|
None
=
None
,
)
->
None
:
...
...
@@ -213,31 +237,13 @@ class CliveCheckerboardTable(CliveWidget):
if
not
self
.
should_be_dynamic
and
content
is
not
None
:
# content is given, but table is static
raise
RebuildStaticTableWithContentError
with
self
.
app
.
batch_update
():
if
starting_from_element
==
0
and
ending_with_element
is
None
:
await
self
.
query
(
"
*
"
).
remove
()
await
self
.
mount_all
(
self
.
_create_table_content
(
content
))
if
rebuild_header
:
await
self
.
_rebuild_header
()
if
self
.
should_be_dynamic
:
self
.
_create_table_content
(
content
)
else
:
rows
=
self
.
query
(
row_type
)
assert
row_type
,
"
You have to set row_type.
"
assert
starting_from_element
<
len
(
rows
),
"
Starting_from_element parameter has higher value than number of elements in the table
"
if
ending_with_element
:
assert
(
starting_from_element
<
ending_with_element
),
"
Starting_from_element parameter has higher value than ending_with_element argument
"
# remove elements
for
index
in
range
(
starting_from_element
,
ending_with_element
+
1
if
ending_with_element
else
len
(
rows
)
):
await
rows
[
index
].
remove
()
# mount again - rebuild only rows after index
(
self
.
_mount_static_rows
(
starting_from_element
,
ending_with_element
)
if
not
self
.
should_be_dynamic
else
self
.
_create_table_content
(
content
)
)
await
self
.
_rebuild_rows
(
row_type
,
starting_from_element
,
ending_with_element
)
def
_create_table_content
(
self
,
content
:
Content
|
None
=
None
,
rows_from_index
:
int
=
0
,
rows_to_index
:
int
|
None
=
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment