mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-31 07:09:45 +02:00
Show the creating or last editing user in part or structure info.
This commit is contained in:
parent
8a7b90d0ea
commit
73c2aa232d
7 changed files with 152 additions and 8 deletions
|
@ -1,3 +1,5 @@
|
|||
{% import "helper.twig" as helper %}
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-3">{% trans %}id.label{% endtrans %}</label>
|
||||
<div class="col-md-9">
|
||||
|
@ -10,8 +12,8 @@
|
|||
<div class="col-md-9">
|
||||
<p class="form-control-plaintext">
|
||||
|
||||
{% if date(entity.addedDate) > date('1900/01/01') %}
|
||||
{{ entity.addedDate | format_datetime("long") }}
|
||||
{% if entity.id is not null and date(entity.addedDate) > date('1900/01/01') %}
|
||||
{{ helper.date_user_combination(entity, false, "long") }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
|
@ -23,8 +25,8 @@
|
|||
<label class="col-form-label col-md-3">{% trans %}lastModified{% endtrans %}</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-plaintext">
|
||||
{% if date(entity.lastModified) > date('1900/01/01') %}
|
||||
{{ entity.lastModified | format_datetime("long") }}
|
||||
{% if entity.id is not null and date(entity.lastModified) > date('1900/01/01') %}
|
||||
{{ helper.date_user_combination(entity, true, "long") }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
|
|
|
@ -7,11 +7,31 @@
|
|||
<td>{{ part.addedDate | format_datetime("long")}}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>{% trans %}user.creating_user{% endtrans %}</td>
|
||||
<td>{% if is_granted('show_users', part) %}
|
||||
{{ getCreatingUser(part).fullName(true) ?? 'Unknown'|trans }}
|
||||
{% else %}
|
||||
{% trans %}accessDenied{% endtrans %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr> {# Last modified date #}
|
||||
<td>{% trans %}lastModified{% endtrans %}</td>
|
||||
<td>{{ part.lastModified | format_datetime("long")}}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>{% trans %}user.last_editing_user{% endtrans %}</td>
|
||||
<td>{% if is_granted('show_users', part) %}
|
||||
{{ getLastEditingUser(part).fullName(true) ?? 'Unknown'|trans }}
|
||||
{% else %}
|
||||
{% trans %}accessDenied{% endtrans %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr> {# ID #}
|
||||
<td>{% trans %}id.label{% endtrans %}</td>
|
||||
<td>{{ part.iD }} ({{ part.iDString}})</td>
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
<div class="mb-3">
|
||||
<span class="text-muted" title="{% trans %}lastModified{% endtrans %}">
|
||||
<i class="fas fa-history fa-fw"></i> {{ part.lastModified | format_datetime("short") }}
|
||||
<i class="fas fa-history fa-fw"></i> {{ helper.date_user_combination(part, true) }}
|
||||
</span>
|
||||
<br>
|
||||
<span class="text-muted mt-1" title="{% trans %}createdAt{% endtrans %}">
|
||||
<i class="fas fa-calendar-plus fa-fw"></i> {{ part.addedDate | format_datetime("short") }}
|
||||
<i class="fas fa-calendar-plus fa-fw"></i> {{ helper.date_user_combination(part, false) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -88,4 +88,27 @@
|
|||
{% else %}
|
||||
<i class="fas fa-times-circle fa-fw" title="{% trans %}No{% endtrans %}"></i>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro date_user_combination(entity, lastModified, datetime_format = "short") %}
|
||||
{% if lastModified == true %}
|
||||
{{ entity.lastModified | format_datetime(datetime_format) }}
|
||||
{% else %}
|
||||
{{ entity.addedDate | format_datetime(datetime_format) }}
|
||||
{% endif %}
|
||||
{% if is_granted('show_users', entity) %}
|
||||
{% if lastModified == true %}
|
||||
{% set user = getLastEditingUser(entity) %}
|
||||
{% else %}
|
||||
{% set user = getCreatingUser(entity) %}
|
||||
{% endif %}
|
||||
|
||||
{% if user is not null %}
|
||||
{% if user.fullName is not empty %}
|
||||
<a href="{{ url('user_info', {"id": user.id}) }}" title="@{{ user.name }}"><i>({{ user.fullName }})</i></a>
|
||||
{% else %}
|
||||
<a href="{{ url('user_info', {"id": user.id}) }}" title="@{{ user.name }}"><i>(@{{ user.name }})</i></a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
Loading…
Add table
Add a link
Reference in a new issue