Skip to content

Commit

Permalink
feat(demo/media-lib): add date creation (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei authored Sep 12, 2024
1 parent dd7d629 commit 52b48f8
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 4 deletions.
49 changes: 46 additions & 3 deletions configs/admin/content-type/media_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"protected": false
}
},
"orderKey": 2,
"orderKey": 1,
"children": []
},
"replaced": []
Expand Down Expand Up @@ -202,7 +202,7 @@
"protected": false
}
},
"orderKey": 3,
"orderKey": 2,
"children": []
},
"replaced": []
Expand Down Expand Up @@ -235,7 +235,7 @@
},
"raw_data": []
},
"orderKey": 5,
"orderKey": 3,
"children": [
{
"class": "EMS\\CoreBundle\\Entity\\FieldType",
Expand Down Expand Up @@ -501,6 +501,49 @@
},
"raw_data": []
},
"orderKey": 4,
"children": []
},
"replaced": []
},
{
"class": "EMS\\CoreBundle\\Entity\\FieldType",
"arguments": [],
"properties": {
"type": "EMS\\CoreBundle\\Form\\DataField\\DateTimeFieldType",
"name": "date_creation",
"contentType": null,
"deleted": false,
"description": null,
"options": {
"displayOptions": {
"label": "Date Creation",
"class": "col-md-12 hidden",
"lastOfRow": false,
"helptext": null,
"displayFormat": null,
"parseFormat": null,
"daysOfWeekDisabled": null,
"hoursDisabled": null
},
"mappingOptions": {
"index": null
},
"restrictionOptions": {
"mandatory": false,
"mandatory_if": null,
"minimum_role": null
},
"extraOptions": {
"extra": null,
"clear_on_copy": false,
"postProcessing": "{% if attribute(_source, 'date_creation') is not defined %}\r\n{{ 'now'|date(constant('\\DateTime::ATOM'))|json_encode|raw }}\r\n{% endif %}"
},
"raw_data": [],
"migrationOptions": {
"protected": false
}
},
"orderKey": 6,
"children": []
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"date_creation": "2024-09-12T16:35:28+02:00",
"media_file": {
"filename": "2022-11-19 User group EMS NL.pdf",
"filesize": 4744190,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"date_creation": "2024-09-12T16:35:28+02:00",
"media_folder": "/",
"media_path": "/Manuals"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"date_creation": "2024-09-12T16:35:28+02:00",
"media_file": {
"filename": "2022-11-19 usergroup_pv_FR.pdf",
"filesize": 1129515,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"date_creation": "2024-09-12T16:35:28+02:00",
"media_file": {
"filename": "Presentation Architecture elasticMS.pptx",
"filesize": 885794,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"date_creation": "2024-09-12T16:35:28+02:00",
"media_file": {
"filename": "2022-11-19 usergroup_pv_NL.pdf",
"filesize": 1127869,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"date_creation": "2024-09-12T16:35:28+02:00",
"media_folder": "/",
"media_path": "/share"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"date_creation": "2024-09-12T16:35:28+02:00",
"media_file": {
"filename": "2022-11-19 User group EMS FR.pdf",
"filesize": 4925429,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"date_creation": "2024-09-12T16:35:28+02:00",
"media_file": {
"filename": "202304_usergroup_pv_NL.pdf",
"filesize": 729767,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"date_creation": "2024-09-12T16:35:28+02:00",
"media_folder": "/",
"media_path": "/User groups"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"date_creation": "2024-09-12T16:35:28+02:00",
"media_file": {
"filename": "202304_usergroup_pv_FR.pdf",
"filesize": 650946,
Expand Down
10 changes: 9 additions & 1 deletion skeleton/template_ems/dashboard/media_library.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{% block body %}
{{ component('media_library', {
'id': 'examaple-media-lib',
'template': _self
'template': _self,
"sort": [
{ "id": "name", "field": "media_path.alpha_order", "defaultOrder": "asc" },
{ "id": "type", "field": "media_file.mimetype", "nested_path": "media_file" },
{ "id": "created", "field": "date_creation" },
{ "id": "size", "field": "media_file.filesize", "nested_path": "media_file" }
]
}) }}
{% endblock body %}

Expand All @@ -13,13 +19,15 @@
<div data-sort-id="name">Name</div>
<div data-sort-id="type">Type</div>
<div>Revision</div>
<div data-sort-id="created">Creation</div>
<div data-sort-id="size" class="text-right">Size</div>
{%- endblock media_lib_file_header -%}

{%- block media_lib_file -%}
<div><a href="{{- mediaFile.urlView -}}" download="{{- mediaFile.name -}}" data-ems-id="{{- mediaFile.emsId -}}">{{- mediaFile.name -}}</a></div>
<div>{{- mediaFile.file.mimetype|trans({}, 'emsco-mimetypes') -}}</div>
<div><a href="{{ path('emsco_view_revisions', { 'type': mediaFile.document.contentType, 'ouuid': mediaFile.id }) }}">show revision</a></div>
<div>{{ mediaFile.document.getValue('date_creation')|date(date_time_format) }}</div>
<div class="text-right">{{- mediaFile.file.filesize|default(0)|format_bytes -}}</div>
{%- endblock media_lib_file -%}

Expand Down

0 comments on commit 52b48f8

Please sign in to comment.