diff --git a/assets/src/legacy/view.js b/assets/src/legacy/view.js index 4aa0e0a276..779956e85e 100644 --- a/assets/src/legacy/view.js +++ b/assets/src/legacy/view.js @@ -5,6 +5,15 @@ * @license MPL-2.0 */ +/** + * Split and clean a keyword string and return an array of keywords. + * @param {string} keywords A string having keywords separated by commas. + * @returns {string[]} + */ +function cleanKeywords(keywords) { + return keywords.split(",").map(item => item.trim()); +} + var searchProjects = function(){ // Hide search if there are no projects if ($("#content.container li .liz-project-title").length === 0) { @@ -44,11 +53,11 @@ var searchProjects = function(){ // Get unique keywords for visible projects var getVisibleProjectsKeywords = function() { var keywordList = []; - var selector = '.liz-repository-project-item :visible .keywordList'; + var selector = '.liz-repository-project-item :visible .liz-project'; $(selector).each(function () { - if ($(this).text() !== '') { - var keywordsSplitByComma = $(this).text().toUpperCase().split(', '); + const keywordsSplitByComma = cleanKeywords($(this).attr('data-lizmap-keywords')); + if (keywordsSplitByComma.length > 0) { if (isGraph) { for (var index = 0; index < keywordsSplitByComma.length; index++) { keywordList = keywordList.concat(keywordsSplitByComma[index].split('/')); @@ -66,9 +75,10 @@ var searchProjects = function(){ var getEdges = function () { var edgeList = []; - $('.liz-repository-project-item :visible .keywordList').each(function () { - if ($(this).text() !== '') { - var keywordsSplitByComma = $(this).text().toUpperCase().split(', '); + $('.liz-repository-project-item :visible .liz-project').each(function () { + const keywordsSplitByComma = cleanKeywords($(this).attr('data-lizmap-keywords')); + + if (keywordsSplitByComma.length > 0) { for (var index = 0; index < keywordsSplitByComma.length; index++) { var keywordsInGraph = keywordsSplitByComma[index].split('/'); @@ -95,9 +105,9 @@ var searchProjects = function(){ $("#content.container .liz-repository-title").hide(); // Show project when its keywords match all keywords in selectedKeywords - $('.keywordList').each(function () { + $('.liz-project').each(function () { var showProject = false; - var keywordListSplitByComma = $(this).text().toUpperCase().split(', '); + const keywordListSplitByComma = cleanKeywords($(this).attr('data-lizmap-keywords')); // Graph if (isGraph) { diff --git a/lizmap/modules/view/templates/view.tpl b/lizmap/modules/view/templates/view.tpl index e92b246311..f62c30dc2a 100644 --- a/lizmap/modules/view/templates/view.tpl +++ b/lizmap/modules/view/templates/view.tpl @@ -23,14 +23,6 @@ data-lizmap-proj="{$p->proj}"> project image -

- - {$p->title} -
-
{@default.project.abstract.label@} : {$p->abstract|strip_tags|truncate:100} -
-
{@default.project.keywordList.label@} : {$p->keywordList} -

{$p->title}
diff --git a/lizmap/www/assets/css/view.css b/lizmap/www/assets/css/view.css index 3bb8481dc4..3743e921e4 100644 --- a/lizmap/www/assets/css/view.css +++ b/lizmap/www/assets/css/view.css @@ -20,10 +20,6 @@ max-width:100%; } -.liz-project-desc { - display: none; -} - .liz-project:hover { background-color: #f8faff; } diff --git a/lizmap/www/themes/default/css/view.css b/lizmap/www/themes/default/css/view.css index fd139548d7..74ce95d730 100644 --- a/lizmap/www/themes/default/css/view.css +++ b/lizmap/www/themes/default/css/view.css @@ -2,10 +2,6 @@ background-color: white; } -.liz-project-desc { - display: none; -} - .liz-project:hover { background-color: #f8faff; } diff --git a/tests/end2end/cypress/integration/projects_homepage-ghaction.js b/tests/end2end/cypress/integration/projects_homepage-ghaction.js index 823eb0d2c6..72dccb476b 100644 --- a/tests/end2end/cypress/integration/projects_homepage-ghaction.js +++ b/tests/end2end/cypress/integration/projects_homepage-ghaction.js @@ -13,7 +13,7 @@ describe('Projects homepage', function () { cy.get('.liz-repository-project-item:visible').its('length').as('totalProjects') // Insert value in search input cy.get('#search-project').type('nature') - // CHeck the number of title projects that contains the serach value + // Check the number of title projects that contains the search value cy.get('.liz-repository-project-item:visible').should('length', 2) // Clear the search input cy.get('#search-project').clear() diff --git a/tests/end2end/playwright/project-homepage.spec.js b/tests/end2end/playwright/project-homepage.spec.js index d02e0d0421..1347e03386 100644 --- a/tests/end2end/playwright/project-homepage.spec.js +++ b/tests/end2end/playwright/project-homepage.spec.js @@ -8,7 +8,7 @@ test.describe('Projects homepage @readonly', function () { await page.goto(url, { waitUntil: 'networkidle' }); }); - test('should display project metadata (cold cache)', async function ({ page }) { + test('should have project metadata', async function ({ page }) { let project = page.locator( '.liz-repository-project-item' @@ -27,19 +27,6 @@ test.describe('Projects homepage @readonly', function () { await expect(project).toHaveAttribute( "data-lizmap-abstract", 'This is an abstract'); - const allMetadata = await project.locator('.liz-project-desc'); - await expect(allMetadata).not.toBeVisible(); - - await project.hover(); - // await expect(allMetadata).toBeVisible(); - await expect(allMetadata.locator('.title')).toContainText('Test tags: nature, flower'); - await expect(allMetadata.locator('.abstract')).toContainText('This is an abstract'); - await expect(allMetadata.locator('.keywordList')).toContainText('nature, flower'); - - // hover on header - await page.locator('#headermenu').hover(); - await expect(allMetadata).not.toBeVisible(); - // another project project = page.locator( '.liz-repository-project-item' @@ -57,52 +44,5 @@ test.describe('Projects homepage @readonly', function () { "data-lizmap-title", 'Tests tags: nature, tree'); await expect(project).toHaveAttribute( "data-lizmap-abstract", 'Tags: nature, tree'); - - const allMetadataTree = project.locator('.liz-project-desc'); - await expect(allMetadataTree).not.toBeVisible(); - - await project.hover(); - // await expect(allMetadataTree).toBeVisible(); - await expect(allMetadataTree.locator('.title')).toContainText('Tests tags: nature, tree'); - await expect(allMetadataTree.locator('.abstract')).toContainText('Tags: nature, tree'); - await expect(allMetadataTree.locator('.keywordList')).toContainText('nature, tree'); - - // hover on header - await page.locator('#headermenu').hover(); - await expect(allMetadataTree).not.toBeVisible(); - - }); - - test('should display project metadata (hot cache)', async function ({ page }) { - - const project = page.locator( - '.liz-repository-project-item' - ).filter( - { hasText: 'Test tags: nature, flower' } - ).locator('.liz-project'); - - await expect(project).toHaveAttribute( - "data-lizmap-proj",'EPSG:4326'); - await expect(project).toHaveAttribute( - "data-lizmap-bbox", '-1.2459627329192546, -1.0, 1.2459627329192546, 1.0'); - await expect(project).toHaveAttribute( - "data-lizmap-keywords", 'nature, flower'); - await expect(project).toHaveAttribute( - "data-lizmap-title", 'Test tags: nature, flower'); - await expect(project).toHaveAttribute( - "data-lizmap-abstract", 'This is an abstract'); - const allMetadata = project.locator('.liz-project-desc'); - await expect(allMetadata).not.toBeVisible(); - - await project.hover(); - // await expect(allMetadata).toBeVisible(); - await expect(allMetadata.locator('.title')).toContainText('Test tags: nature, flower'); - await expect(allMetadata.locator('.abstract')).toContainText('This is an abstract'); - await expect(allMetadata.locator('.keywordList')).toContainText('nature, flower'); - - // hover on header - await page.locator('#headermenu').hover(); - await expect(allMetadata).not.toBeVisible(); - }); });