Continue separation of state and value

This commit is contained in:
Gregoo 2025-02-04 12:34:19 +01:00
parent 584389e205
commit 16e4c28516
4 changed files with 14 additions and 5 deletions

View File

@ -28,8 +28,9 @@ class BrickMetadataList(BrickRecordList[T]):
# Queries # Queries
select_query: str select_query: str
# Set state endpoint # Set endpoints
set_state_endpoint: str set_state_endpoint: str
set_value_endpoint: str
def __init__( def __init__(
self, self,
@ -149,3 +150,11 @@ class BrickMetadataList(BrickRecordList[T]):
cls.set_state_endpoint, cls.set_state_endpoint,
id=id, id=id,
) )
# URL to change the selected value of this metadata item for a set
@classmethod
def url_for_set_value(cls, id: str, /) -> str:
return url_for(
cls.set_value_endpoint,
id=id,
)

View File

@ -17,8 +17,8 @@ class BrickSetStorageList(BrickMetadataList[BrickSetStorage]):
select_query = 'set/metadata/storage/list' select_query = 'set/metadata/storage/list'
all_query = 'set/metadata/storage/all' all_query = 'set/metadata/storage/all'
# Set state endpoint # Set value endpoint
set_state_endpoint: str = 'set.update_storage' set_value_endpoint: str = 'set.update_storage'
# Load all storages # Load all storages
@classmethod @classmethod

View File

@ -66,7 +66,7 @@ def update_status(*, id: str, metadata_id: str) -> Response:
return jsonify({'value': state}) return jsonify({'value': state})
# Change the state of a storage # Change the value of storage
@set_page.route('/<id>/storage', methods=['POST']) @set_page.route('/<id>/storage', methods=['POST'])
@login_required @login_required
@exception_handler(__file__, json=True) @exception_handler(__file__, json=True)

View File

@ -48,7 +48,7 @@
{% if icon %}<span class="input-group-text"><i class="ri-{{ icon }}"></i></span>{% endif %} {% if icon %}<span class="input-group-text"><i class="ri-{{ icon }}"></i></span>{% endif %}
<select id="{{ prefix }}-{{ item.fields.id }}" class="form-select" <select id="{{ prefix }}-{{ item.fields.id }}" class="form-select"
{% if not delete %} {% if not delete %}
data-changer-id="{{ item.fields.id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ metadata_list.url_for_set_state(item.fields.id) }}" data-changer-id="{{ item.fields.id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ metadata_list.url_for_set_value(item.fields.id) }}"
{% else %} {% else %}
disabled disabled
{% endif %} {% endif %}