You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2019/04/26 17:39:10 UTC
[sling-org-apache-sling-app-cms] branch master updated: Adding
support for selecting a resource via query string
This is an automated email from the ASF dual-hosted git repository.
dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git
The following commit(s) were added to refs/heads/master by this push:
new 4ceab5b Adding support for selecting a resource via query string
4ceab5b is described below
commit 4ceab5bec885d2bf777d3880535ee8498f97fa40
Author: Dan Klco <dk...@apache.org>
AuthorDate: Fri Apr 26 13:39:02 2019 -0400
Adding support for selecting a resource via query string
---
ui/src/main/frontend/src/js/cms.table.js | 57 +++++++++++++---------
.../components/cms/references/references.jsp | 2 +-
2 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/ui/src/main/frontend/src/js/cms.table.js b/ui/src/main/frontend/src/js/cms.table.js
index dc6e71a..156f24a 100644
--- a/ui/src/main/frontend/src/js/cms.table.js
+++ b/ui/src/main/frontend/src/js/cms.table.js
@@ -21,9 +21,22 @@
(function (rava) {
'use strict';
- var table = null,
- urlParams = new URLSearchParams(window.location.search),
- resourceParam = urlParams.get('resource');
+ var urlParams = new URLSearchParams(window.location.search),
+ resourceParam = urlParams.get('resource'),
+ searchParam = urlParams.get('search');
+
+ rava.bind(".table tbody tr", {
+ events: {
+ click: function () {
+ this.closest('.table').querySelectorAll('tr.is-selected').forEach(function (tr) {
+ tr.classList.remove('is-selected');
+ });
+ this.classList.add('is-selected');
+ document.querySelector('.actions-target').innerHTML = this.querySelector('.cell-actions').innerHTML;
+ }
+ }
+ });
+
rava.bind(".table", {
callbacks : {
created: function () {
@@ -33,9 +46,9 @@
filter = function (event) {
event.stopPropagation();
event.preventDefault();
- var value = this.value;
+ var value = this.value.toLowerCase();
table.querySelectorAll('tbody tr').forEach(function (row) {
- if (row.innerText.indexOf(value) === -1) {
+ if (row.innerText.toLowerCase().indexOf(value) === -1 && !row.querySelector('td[data-value="' + resourceParam + '"]')) {
row.classList.add('is-hidden');
} else {
row.classList.remove('is-hidden');
@@ -44,28 +57,24 @@
};
search.addEventListener('keyup', filter);
search.addEventListener('change', filter);
+
+ if (resourceParam) {
+ table.querySelectorAll('tbody tr').forEach(function (row) {
+ if (row.querySelector('td[data-value="' + resourceParam + '"]')) {
+ row.classList.remove('is-hidden');
+ row.click();
+ } else {
+ row.classList.add('is-hidden');
+ }
+ });
+ table.closest('.table__wrapper').querySelector('input[name=search]').value = resourceParam;
+ } else if (searchParam) {
+ table.closest('.table__wrapper').querySelector('input[name=search]').value = searchParam;
+ filter(new Event('fake'));
+ }
}
}
}
});
- rava.bind(".table tbody tr", {
- events: {
- click: function () {
- this.closest('.table').querySelectorAll('tr.is-selected').forEach(function (tr) {
- tr.classList.remove('is-selected');
- });
- this.classList.add('is-selected');
- document.querySelector('.actions-target').innerHTML = this.querySelector('.cell-actions').innerHTML;
- }
- }
- });
-
- if (table && resourceParam) {
- table.search(resourceParam.split(/\//).slice(-1)).draw();
- if (document.querySelector('.table tr[data-resource=\'' + resourceParam + '\']')) {
- document.querySelector('.table tr[data-resource=\'' + resourceParam + '\']').click();
- }
- }
-
}(window.rava = window.rava || {}));
\ No newline at end of file
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/references/references.jsp b/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/references/references.jsp
index 404e500..a4f8f54 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/references/references.jsp
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/references/references.jsp
@@ -37,7 +37,7 @@
</span>
</td>
<td title="${ref.containingPage.path}">
- <a href="/cms/site/content.html${ref.containingPage.parent.path}" target="_blank">
+ <a href="/cms/site/content.html${ref.containingPage.parent.path}?resource=${ref.containingPage.path}" target="_blank">
${sling:encode(ref.containingPage.title,'HTML')}
</a>
</td>