Skip to content

Commit

Permalink
ref: get_revision_id filter is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 committed Jan 6, 2024
1 parent bdbb37d commit 72c5dd9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion EMS/core-bundle/src/Twig/AppExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public function getFunctions(): array
new TwigFunction('emsco_get_form', [FormRuntime::class, 'getFormByName']),
new TwigFunction('emsco_form', [FormRuntime::class, 'handleForm']),
new TwigFunction('emsco_get_data_field', [FormRuntime::class, 'getDataField']),
new TwigFunction('emsco_get_revision_id', [RevisionRuntime::class, 'getRevisionId']),
// deprecated
new TwigFunction('cant_be_finalized', $this->cantBeFinalized(...), ['deprecated' => true, 'alternative' => 'emsco_cant_be_finalized']),
new TwigFunction('get_default_environments', [EnvironmentRuntime::class, 'getDefaultEnvironmentNames'], ['deprecated' => true, 'alternative' => 'emsco_get_default_environment_names']),
Expand Down Expand Up @@ -170,7 +171,6 @@ public function getFilters(): array
new TwigFilter('emsco_call_user_func', $this->callUserFunc(...)),
new TwigFilter('emsco_get_string', $this->getString(...)),
new TwigFilter('emsco_get_field_by_path', $this->getFieldByPath(...)),
new TwigFilter('get_revision_id', [RevisionRuntime::class, 'getRevisionId']),
new TwigFilter('emsco_document_info', [RevisionRuntime::class, 'getDocumentInfo']),
new TwigFilter('emsco_documents_info', [RevisionRuntime::class, 'getDocumentsInfo']),
new TwigFilter('emsco_display', [RevisionRuntime::class, 'display']),
Expand Down Expand Up @@ -215,6 +215,7 @@ public function getFilters(): array
new TwigFilter('get_string', $this->getString(...), ['deprecated' => true, 'alternative' => 'emsco_get_string']),
new TwigFilter('get_file', $this->getFile(...), ['deprecated' => true]),
new TwigFilter('get_field_by_path', $this->getFieldByPath(...), ['deprecated' => true, 'alternative' => 'emsco_get_field_by_path']),
new TwigFilter('get_revision_id', [RevisionRuntime::class, 'getRevisionId'], ['deprecated' => true, 'alternative' => 'emsco_get_revision_id']),
];
}

Expand Down
2 changes: 1 addition & 1 deletion demo/configs/admin/content-type/route.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
"options": {
"body": "{}",
"size": 0,
"template": "{% set columns = [] %}\r\n{% set columns = columns|merge([\r\n {\r\n \"label\": \"#\",\r\n \"template\": \"{{ data.source.order|default(999) }}\",\r\n \"orderField\": \"order\"\r\n },{\r\n \"label\": \"Name\",\r\n \"template\": '<a href=\"' ~ \"{{path('data.revisions', {ouuid: data.id, type: data.contentType} ) }}\"~'\">' ~\"{{ data.source.name }}</a>\",\r\n \"orderField\": \"name\"\r\n },{\r\n \"label\": \"Path\",\r\n \"template\": \"\r\n {% set path = attribute(data.source.config|default({})|ems_json_decode, 'path')|default('N/A') %}\r\n {% if path is iterable %}\r\n <ul>\r\n {% for l, item in path %}\r\n <li>{{ l }} : {{ item }}</li>\r\n {% endfor %}\r\n </ul>\r\n {% else %}\r\n <span class=\"~'\"'~\"{% if attribute(data.source.config|default({})|ems_json_decode, 'path') is not defined %}text-gray{% endif %}\"~'\"'~\">{{ path }}</span>\r\n {% endif %}\r\n \"\r\n },{\r\n \"label\": \"Template\",\r\n \"template\": \"<span class=\"~'\"'~\"{% if data.source.template_static is not defined %}text-gray{% endif %}\"~'\"'~\">{{ data.source.template_static|default('N/A')|emsco_data_link }}</span>\"\r\n },{\r\n \"label\": \"Query\",\r\n \"template\": \"{{ data.source.query is defined ? 'Yes' : 'No' }}\"\r\n }\r\n]) %}\r\n\r\n{% set columnLive %}{% verbatim %}\r\n <i style=\"color: {{ docInfo.published('live') and docInfo.aligned('live') ? 'green' : 'red' }}\" \r\n class=\"{{ docInfo.published('live') and docInfo.aligned('live') ? 'fa fa-check' : 'fa fa-eye-slash' }}\"></i>\r\n{% endverbatim %}{% endset %}\r\n\r\n{% set columns = columns|merge([\r\n {\r\n \"label\": \"Last Update\", \r\n \"template\": '\r\n <div style=\"width: 130px;\" data-toggle=\"tooltip\" data-placement=\"top\" aria-hidden=\"true\" title=\"By {{ data.source._finalized_by }}\" >\r\n {{ data.source._finalization_datetime|default ? data.source._finalization_datetime|date(\"d/m/Y (H:i)\") : \"N.A.\" }}\r\n </div>\r\n ', \r\n \"orderField\": \"_finalization_datetime\"\r\n },\r\n { \"label\": \"Live\", \"template\": columnLive|format },\r\n {\r\n \"label\": \"Action\",\r\n \"template\": '\r\n <div class=\"btn-group btn-group-sm\" style=\"width: 130px;\">\r\n <a href=\"{{ docInfo.draft ? path(\"ems_revision_edit\", {revisionId: revisionId}) : docInfo.aligned(\"live\") ? path(\"revision.new-draft\", {type: data.contentType, ouuid: data.id }) : path(\"revision.publish_to\", {revisionId: revisionId, envId: liveId, redirectToUrl: path(\"data.customindexview\", {viewId: '~view.id~'})}) }}\" class=\"btn btn-default\" style=\"width: 100px;\">\r\n {{ docInfo.draft ? \"Edit draft\" : docInfo.aligned(\"live\") ? \"Edit\" : \"Publish in live\" }}\r\n </a>\r\n <button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\" aria-expanded=\"false\">\r\n <span class=\"caret\">\r\n </span>\r\n <span class=\"sr-only\">Toggle Dropdown\r\n </span>\r\n </button>\r\n <ul class=\"dropdown-menu\" role=\"menu\">\r\n <li>\r\n <a href=\"{{ path(\"data.revisions\", {ouuid: data.id, type: data.contentType} ) }}\">Revision</a>\r\n </li>\r\n {% if docInfo.draft %}\r\n <li><a href=\"{{ path(\"revision.publish_to\", {revisionId: revisionId, envId: previewId}) }}\">Publish in preview</a></li>\r\n {% elseif not docInfo.aligned(\\'live\\') %}\r\n <li><a href=\"{{ path(\"revision.new-draft\", {type: data.contentType, ouuid: data.id }) }}\">Edit</a></li>\r\n {% endif %}\r\n </ul>\r\n </div>\r\n ',\r\n \"orderField\": \"_finalization_datetime\" \r\n }\r\n]) %}\r\n\r\n{% set must = {} %}\r\n{% set filterQuery = [ {\r\n \"multi_match\": {\r\n \"fields\": [\r\n \"live_search\",\r\n \"live_search._2gram\",\r\n \"live_search._3gram\"\r\n ],\r\n \"query\": \"%query%\",\r\n \"operator\": \"and\", \r\n \"type\": \"bool_prefix\"\r\n \r\n } } ] %}\r\n\r\n{{ emsco_datatable(['preview'],[contentType.name], {\r\n \"frontendOptions\": { \"pageLength\": 100, \"order\": [[(columns|length - 3), 'desc']] },\r\n \"default_sort\": { \"_finalization_datetime\": \"desc\", \"_score\": \"asc\" },\r\n \"empty_query\": must,\r\n \"query\": { \"bool\": { \"must\": must|merge(filterQuery) } },\r\n \"row_context\": \"{% set docInfo = [line.data.contentType, line.data.id]|join(':')|emsco_document_info %}{% set revisionId = line.data.id|get_revision_id(line.data.contentType) %}{% set liveId = 3 %}{% set previewId = 2 %}\",\r\n \"columns\": columns\r\n}) }}",
"template": "{% set columns = [] %}\r\n{% set columns = columns|merge([\r\n {\r\n \"label\": \"#\",\r\n \"template\": \"{{ data.source.order|default(999) }}\",\r\n \"orderField\": \"order\"\r\n },{\r\n \"label\": \"Name\",\r\n \"template\": '<a href=\"' ~ \"{{path('data.revisions', {ouuid: data.id, type: data.contentType} ) }}\"~'\">' ~\"{{ data.source.name }}</a>\",\r\n \"orderField\": \"name\"\r\n },{\r\n \"label\": \"Path\",\r\n \"template\": \"\r\n {% set path = attribute(data.source.config|default({})|ems_json_decode, 'path')|default('N/A') %}\r\n {% if path is iterable %}\r\n <ul>\r\n {% for l, item in path %}\r\n <li>{{ l }} : {{ item }}</li>\r\n {% endfor %}\r\n </ul>\r\n {% else %}\r\n <span class=\"~'\"'~\"{% if attribute(data.source.config|default({})|ems_json_decode, 'path') is not defined %}text-gray{% endif %}\"~'\"'~\">{{ path }}</span>\r\n {% endif %}\r\n \"\r\n },{\r\n \"label\": \"Template\",\r\n \"template\": \"<span class=\"~'\"'~\"{% if data.source.template_static is not defined %}text-gray{% endif %}\"~'\"'~\">{{ data.source.template_static|default('N/A')|emsco_data_link }}</span>\"\r\n },{\r\n \"label\": \"Query\",\r\n \"template\": \"{{ data.source.query is defined ? 'Yes' : 'No' }}\"\r\n }\r\n]) %}\r\n\r\n{% set columnLive %}{% verbatim %}\r\n <i style=\"color: {{ docInfo.published('live') and docInfo.aligned('live') ? 'green' : 'red' }}\" \r\n class=\"{{ docInfo.published('live') and docInfo.aligned('live') ? 'fa fa-check' : 'fa fa-eye-slash' }}\"></i>\r\n{% endverbatim %}{% endset %}\r\n\r\n{% set columns = columns|merge([\r\n {\r\n \"label\": \"Last Update\", \r\n \"template\": '\r\n <div style=\"width: 130px;\" data-toggle=\"tooltip\" data-placement=\"top\" aria-hidden=\"true\" title=\"By {{ data.source._finalized_by }}\" >\r\n {{ data.source._finalization_datetime|default ? data.source._finalization_datetime|date(\"d/m/Y (H:i)\") : \"N.A.\" }}\r\n </div>\r\n ', \r\n \"orderField\": \"_finalization_datetime\"\r\n },\r\n { \"label\": \"Live\", \"template\": columnLive|format },\r\n {\r\n \"label\": \"Action\",\r\n \"template\": '\r\n <div class=\"btn-group btn-group-sm\" style=\"width: 130px;\">\r\n <a href=\"{{ docInfo.draft ? path(\"ems_revision_edit\", {revisionId: revisionId}) : docInfo.aligned(\"live\") ? path(\"revision.new-draft\", {type: data.contentType, ouuid: data.id }) : path(\"revision.publish_to\", {revisionId: revisionId, envId: liveId, redirectToUrl: path(\"data.customindexview\", {viewId: '~view.id~'})}) }}\" class=\"btn btn-default\" style=\"width: 100px;\">\r\n {{ docInfo.draft ? \"Edit draft\" : docInfo.aligned(\"live\") ? \"Edit\" : \"Publish in live\" }}\r\n </a>\r\n <button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\" aria-expanded=\"false\">\r\n <span class=\"caret\">\r\n </span>\r\n <span class=\"sr-only\">Toggle Dropdown\r\n </span>\r\n </button>\r\n <ul class=\"dropdown-menu\" role=\"menu\">\r\n <li>\r\n <a href=\"{{ path(\"data.revisions\", {ouuid: data.id, type: data.contentType} ) }}\">Revision</a>\r\n </li>\r\n {% if docInfo.draft %}\r\n <li><a href=\"{{ path(\"revision.publish_to\", {revisionId: revisionId, envId: previewId}) }}\">Publish in preview</a></li>\r\n {% elseif not docInfo.aligned(\\'live\\') %}\r\n <li><a href=\"{{ path(\"revision.new-draft\", {type: data.contentType, ouuid: data.id }) }}\">Edit</a></li>\r\n {% endif %}\r\n </ul>\r\n </div>\r\n ',\r\n \"orderField\": \"_finalization_datetime\" \r\n }\r\n]) %}\r\n\r\n{% set must = {} %}\r\n{% set filterQuery = [ {\r\n \"multi_match\": {\r\n \"fields\": [\r\n \"live_search\",\r\n \"live_search._2gram\",\r\n \"live_search._3gram\"\r\n ],\r\n \"query\": \"%query%\",\r\n \"operator\": \"and\", \r\n \"type\": \"bool_prefix\"\r\n \r\n } } ] %}\r\n\r\n{{ emsco_datatable(['preview'],[contentType.name], {\r\n \"frontendOptions\": { \"pageLength\": 100, \"order\": [[(columns|length - 3), 'desc']] },\r\n \"default_sort\": { \"_finalization_datetime\": \"desc\", \"_score\": \"asc\" },\r\n \"empty_query\": must,\r\n \"query\": { \"bool\": { \"must\": must|merge(filterQuery) } },\r\n \"row_context\": \"{% set docInfo = [line.data.contentType, line.data.id]|join(':')|emsco_document_info %}{% set revisionId = emsco_get_revision_id(line.data.id, line.data.contentType) %}{% set liveId = 3 %}{% set previewId = 2 %}\",\r\n \"columns\": columns\r\n}) }}",
"header": null,
"javascript": "<script>\r\n $('#DataTables_Table_0').on( 'draw.dt', function () {\r\n $('[data-toggle=\"tooltip\"]').tooltip();\r\n });\r\n</script>"
},
Expand Down
Loading

0 comments on commit 72c5dd9

Please sign in to comment.