UI - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: трехсекционная шкала прогресса чекеров
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# See the LICENSE file for details.
|
||||
|
||||
STRUCTURED_BLOCKS_KEY = "nodedc_structured_blocks"
|
||||
|
||||
|
||||
def build_issue_checker_progress(detail_layout):
|
||||
blocks = detail_layout.get(STRUCTURED_BLOCKS_KEY) if isinstance(detail_layout, dict) else []
|
||||
|
||||
checker_blocks_count = 0
|
||||
checker_items_count = 0
|
||||
checker_items_completed_count = 0
|
||||
|
||||
if not isinstance(blocks, list):
|
||||
blocks = []
|
||||
|
||||
for block in blocks:
|
||||
if not isinstance(block, dict) or block.get("type") != "checker":
|
||||
continue
|
||||
|
||||
checker_blocks_count += 1
|
||||
items = block.get("items")
|
||||
|
||||
if not isinstance(items, list):
|
||||
continue
|
||||
|
||||
for item in items:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
|
||||
checker_items_count += 1
|
||||
if item.get("checked"):
|
||||
checker_items_completed_count += 1
|
||||
|
||||
return {
|
||||
"checker_blocks_count": checker_blocks_count,
|
||||
"checker_items_count": checker_items_count,
|
||||
"checker_items_completed_count": checker_items_completed_count,
|
||||
}
|
||||
|
||||
|
||||
def attach_issue_checker_progress(items):
|
||||
prepared_items = list(items)
|
||||
|
||||
for item in prepared_items:
|
||||
detail_layout = item.pop("detail_layout", None)
|
||||
item.update(build_issue_checker_progress(detail_layout))
|
||||
|
||||
return prepared_items
|
||||
Reference in New Issue
Block a user