|
@@ -47,11 +47,18 @@ def _preseed_package_filter(session: BomSession, row_id: str) -> None:
|
|
|
apply_filter(session, row_id, "Package", match)
|
|
apply_filter(session, row_id, "Package", match)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def _preseed_value_filter(row: BomRow) -> None:
|
|
|
|
|
+ value_str = row.normalized_params.value_str
|
|
|
|
|
+ if value_str:
|
|
|
|
|
+ row.applied_filters["keyword"] = value_str
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def confirm_category(session: BomSession, row_id: str, category_id: int, category_name: str) -> BomRow:
|
|
def confirm_category(session: BomSession, row_id: str, category_id: int, category_name: str) -> BomRow:
|
|
|
row = get_row(session, row_id)
|
|
row = get_row(session, row_id)
|
|
|
row.resolved_category_id = category_id
|
|
row.resolved_category_id = category_id
|
|
|
row.resolved_category_name = category_name
|
|
row.resolved_category_name = category_name
|
|
|
row.applied_filters = {}
|
|
row.applied_filters = {}
|
|
|
|
|
+ _preseed_value_filter(row)
|
|
|
row.confirmed_pick = None
|
|
row.confirmed_pick = None
|
|
|
row.state = RowState.filtering
|
|
row.state = RowState.filtering
|
|
|
_refresh_filtering(row)
|
|
_refresh_filtering(row)
|
|
@@ -64,11 +71,17 @@ def apply_filter(session: BomSession, row_id: str, group: str, value: str) -> Bo
|
|
|
if row.resolved_category_id is None:
|
|
if row.resolved_category_id is None:
|
|
|
raise ScoutingValidationError("row has no confirmed category yet")
|
|
raise ScoutingValidationError("row has no confirmed category yet")
|
|
|
key = _GROUP_FILTER_KEYS.get(group)
|
|
key = _GROUP_FILTER_KEYS.get(group)
|
|
|
- if key is None:
|
|
|
|
|
|
|
+ if key is not None:
|
|
|
|
|
+ row.applied_filters.setdefault(key, [])
|
|
|
|
|
+ if value not in row.applied_filters[key]:
|
|
|
|
|
+ row.applied_filters[key].append(value)
|
|
|
|
|
+ elif group in row.facet_groups.get("paramNameValueMap", {}):
|
|
|
|
|
+ param_map = row.applied_filters.setdefault("paramNameValueMap", {})
|
|
|
|
|
+ param_map.setdefault(group, [])
|
|
|
|
|
+ if value not in param_map[group]:
|
|
|
|
|
+ param_map[group].append(value)
|
|
|
|
|
+ else:
|
|
|
raise ScoutingValidationError(f"unsupported filter group: {group}")
|
|
raise ScoutingValidationError(f"unsupported filter group: {group}")
|
|
|
- row.applied_filters.setdefault(key, [])
|
|
|
|
|
- if value not in row.applied_filters[key]:
|
|
|
|
|
- row.applied_filters[key].append(value)
|
|
|
|
|
_refresh_filtering(row)
|
|
_refresh_filtering(row)
|
|
|
return row
|
|
return row
|
|
|
|
|
|