Minor fix in CRUDKit build_href: We don't necessarily only want to link to CRUDKit blueprints.
This commit is contained in:
parent
d8e8790987
commit
15d0de44fe
4 changed files with 11 additions and 11 deletions
|
|
@ -677,8 +677,9 @@ def _build_href(spec: Dict[str, Any], row: Dict[str, Any], obj) -> Optional[str]
|
||||||
if any(v is None for v in params.values()):
|
if any(v is None for v in params.values()):
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
return url_for('crudkit.' + spec["endpoint"], **params)
|
return url_for(spec["endpoint"], **params)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(f"Cannot create endpoint for {spec['endpoint']}: {str(e)}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _humanize(field: str) -> str:
|
def _humanize(field: str) -> str:
|
||||||
|
|
@ -725,7 +726,6 @@ def get_crudkit_template(env, name):
|
||||||
|
|
||||||
def render_field(field, value):
|
def render_field(field, value):
|
||||||
env = get_env()
|
env = get_env()
|
||||||
print(field)
|
|
||||||
|
|
||||||
# 1) custom template field
|
# 1) custom template field
|
||||||
field_type = field.get('type', 'text')
|
field_type = field.get('type', 'text')
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ def init_listing_routes(app):
|
||||||
{"field": "model"},
|
{"field": "model"},
|
||||||
{"field": "device_type.description", "label": "Device Type"},
|
{"field": "device_type.description", "label": "Device Type"},
|
||||||
{"field": "condition"},
|
{"field": "condition"},
|
||||||
{"field": "owner.label", "label": "Contact", "link": {"endpoint": "user.get_item", "params": {"id": "{owner.id}"}}},
|
{"field": "owner.label", "label": "Contact", "link": {"endpoint": "entry.entry", "params": {"id": "{owner.id}", "model": "user"}}},
|
||||||
{"field": "location.label", "label": "Room"},
|
{"field": "location.label", "label": "Room"},
|
||||||
]
|
]
|
||||||
elif model.lower() == 'user':
|
elif model.lower() == 'user':
|
||||||
|
|
@ -60,7 +60,7 @@ def init_listing_routes(app):
|
||||||
{"field": "label", "label": "Full Name"},
|
{"field": "label", "label": "Full Name"},
|
||||||
{"field": "last_name"},
|
{"field": "last_name"},
|
||||||
{"field": "first_name"},
|
{"field": "first_name"},
|
||||||
{"field": "supervisor.label", "label": "Supervisor", "link": {"endpoint": "user.get_item", "params": {"id": "{supervisor.id}"}}},
|
{"field": "supervisor.label", "label": "Supervisor", "link": {"endpoint": "entry.entry", "params": {"id": "{supervisor.id}", "model": "user"}}},
|
||||||
{"field": "staff", "format": "yesno"},
|
{"field": "staff", "format": "yesno"},
|
||||||
{"field": "active", "format": "yesno"},
|
{"field": "active", "format": "yesno"},
|
||||||
]
|
]
|
||||||
|
|
@ -80,8 +80,8 @@ def init_listing_routes(app):
|
||||||
"complete",
|
"complete",
|
||||||
]}
|
]}
|
||||||
columns = [
|
columns = [
|
||||||
{"field": "work_item.label", "label": "Work Item", "link": {"endpoint": "inventory.get_item", "params": {"id": "{work_item.id}"}}},
|
{"field": "work_item.label", "label": "Work Item", "link": {"endpoint": "entry.entry", "params": {"id": "{work_item.id}", "model": "inventory"}}},
|
||||||
{"field": "contact.label", "label": "Contact", "link": {"endpoint": "user.get_item", "params": {"id": "{contact.id}"}}},
|
{"field": "contact.label", "label": "Contact", "link": {"endpoint": "entry.entry", "params": {"id": "{contact.id}", "model": "user"}}},
|
||||||
{"field": "start_time", "format": "datetime"},
|
{"field": "start_time", "format": "datetime"},
|
||||||
{"field": "end_time", "format": "datetime"},
|
{"field": "end_time", "format": "datetime"},
|
||||||
{"field": "complete", "format": "yesno"},
|
{"field": "complete", "format": "yesno"},
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% if rows %}
|
{% if rows %}
|
||||||
{% for row in rows %}
|
{% for row in rows %}
|
||||||
<tr onclick="location.href='{{ url_for( 'crudkit.' + kwargs['object_class'] + '.get_item', id=row.id) }}'" style="cursor: pointer;" class="{{ row.class or '' }}">
|
<tr onclick="location.href='{{ url_for( 'entry.entry', model=kwargs['object_class'], id=row.id) }}'" style="cursor: pointer;" class="{{ row.class or '' }}">
|
||||||
{% for cell in row.cells %}
|
{% for cell in row.cells %}
|
||||||
{% if cell.href %}
|
{% if cell.href %}
|
||||||
<td class="{{ cell.class or '' }}"><a href="{{ cell.href }}" class="link-success link-underline link-underline-opacity-0 fw-semibold">{{ cell.text if cell.text is not none else '-' }}</a></td>
|
<td class="{{ cell.class or '' }}"><a href="{{ cell.href }}" class="link-success link-underline link-underline-opacity-0 fw-semibold">{{ cell.text if cell.text is not none else '-' }}</a></td>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<img src="{{ url_for('static', filename=field['value_label']) }}" alt="{{ value }}"
|
{% if value %}
|
||||||
{% if field['attrs'] %}{% for k,v in field['attrs'].items() %}
|
<img src="{{ url_for('static', filename=field['value_label']) }}" alt="{{ value }}" {% if field['attrs'] %}{% for k,v in
|
||||||
{{k}}{% if v is not sameas true %}="{{ v }}"{% endif %}
|
field['attrs'].items() %} {{k}}{% if v is not sameas true %}="{{ v }}" {% endif %} {% endfor %}{% endif %}>
|
||||||
{% endfor %}{% endif %}>
|
{% endif %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue