Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions assets/src/legacy/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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('/'));
Expand All @@ -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('/');

Expand All @@ -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) {
Expand Down
8 changes: 0 additions & 8 deletions lizmap/modules/view/templates/view.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@
data-lizmap-proj="{$p->proj}">
<a class="liz-project-view" href="{$p->url}{if $hide_header}&h=0{/if}">
<img width="250" height="250" loading="lazy" src="{$p->img}" alt="project image" class="_liz-project-img img-fluid">
<p class="liz-project-desc" >
<!-- This block is deprecated, use dataset attributes -->
<b class="title">{$p->title}</b>
<br/>
<br/><b>{@default.project.abstract.label@}</b>&nbsp;: <span class="abstract">{$p->abstract|strip_tags|truncate:100}</span>
<br/>
<br/><b>{@default.project.keywordList.label@}</b>&nbsp;: <span class="keywordList">{$p->keywordList}</span>
</p>
</a>
</div>
<h5 class="liz-project-title">{$p->title}</h5>
Expand Down
4 changes: 0 additions & 4 deletions lizmap/www/assets/css/view.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
max-width:100%;
}

.liz-project-desc {
display: none;
}

.liz-project:hover {
background-color: #f8faff;
}
Expand Down
4 changes: 0 additions & 4 deletions lizmap/www/themes/default/css/view.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
background-color: white;
}

.liz-project-desc {
display: none;
}

.liz-project:hover {
background-color: #f8faff;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
62 changes: 1 addition & 61 deletions tests/end2end/playwright/project-homepage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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();

});
});
Loading