Skip to content

Commit

Permalink
recon: Add back missing 'search for match' button (#6600)
Browse files Browse the repository at this point in the history
Closes #6599.
  • Loading branch information
wetneb committed May 15, 2024
1 parent 9687267 commit 269051e
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 73 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
describe('Show more or less reconciliation candidates', () => {
describe('In-cell reconciliation buttons', () => {
afterEach(() => {
cy.addProjectForDeletion();
});

it('Show "Search for match" even if there are no candidates', () => {
cy.visitOpenRefine();
cy.navigateTo('Import project');
cy.get('.grid-layout').should('to.contain', 'Locate an existing Refine project file');

//we're using here the "no automatch" project, so rows are reconciled and we have more than 3 matched candidates
cy.get('#project-tar-file-input').attachFile('reconciled-project-no-match.zip')
cy.get('#import-project-button').click();

cy.getCell(0, 'entity').find('.data-table-recon-visibility').should('not.contain', 'See more');
cy.getCell(0, 'entity').find('.data-table-recon-visibility').should('to.contain', 'Search for match');
});

it('Testing see more / see less', () => {
it('Display see more / see less when there are candidates', () => {
cy.visitOpenRefine();
cy.navigateTo('Import project');
cy.get('.grid-layout').should('to.contain', 'Locate an existing Refine project file');
Expand Down Expand Up @@ -37,10 +50,6 @@ describe('Show more or less reconciliation candidates', () => {

//confirming the no. of candidates after we click on see less
cy.getCell(0, 'species').find('.data-table-recon-candidate:visible').should('have.length', 4);




});
});

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -88,77 +88,75 @@ class ReconCellRenderer {
$('<span>').text(cell.v).appendTo(divContentRecon);
if (cellUI._dataTableView._showRecon) {
var ul = $('<div></div>').addClass("data-table-recon-candidates").appendTo(divContentRecon);
if ("c" in r && r.c.length > 0) {
var candidates = r.c;
var visibleCandidates = 3;
var renderCandidate = function(candidate, index) {
var li = $('<div></div>').addClass("data-table-recon-candidate").appendTo(ul);

if (index >= visibleCandidates) {
li.hide();
}
var liSpan = $('<span></span>').appendTo(li);

$('<a href="javascript:{}">&nbsp;</a>')
.addClass("data-table-recon-match")
.attr("title", $.i18n('core-views/match-this-cell') )
.appendTo(liSpan).on('click',function(evt) {
self.doMatchTopicToOneCell(candidate, rowIndex, cellIndex, cell, cellUI);
});

$('<a href="javascript:{}">&nbsp;</a>')
.addClass("data-table-recon-match-similar")
.attr("title", $.i18n('core-views/match-all-cells'))
.appendTo(liSpan).on('click',function(evt) {
self.doMatchTopicToSimilarCells(candidate, cellIndex, cell);
});

var a = $('<a></a>')
.addClass("data-table-recon-topic")
.attr("target", "_blank")
.text(_.unescape(candidate.name)) // TODO: only use of _.unescape - consolidate
.appendTo(liSpan);

if ((service) && (service.view) && (service.view.url)) {
a.attr("href", encodeURI(service.view.url.replace("{{id}}", candidate.id)));
}
var candidates = r.c || [];
var visibleCandidates = 3;
var renderCandidate = function(candidate, index) {
var li = $('<div></div>').addClass("data-table-recon-candidate").appendTo(ul);

if (index >= visibleCandidates) {
li.hide();
}
var liSpan = $('<span></span>').appendTo(li);

$('<a href="javascript:{}">&nbsp;</a>')
.addClass("data-table-recon-match")
.attr("title", $.i18n('core-views/match-this-cell') )
.appendTo(liSpan).on('click',function(evt) {
self.doMatchTopicToOneCell(candidate, rowIndex, cellIndex, cell, cellUI);
});

$('<a href="javascript:{}">&nbsp;</a>')
.addClass("data-table-recon-match-similar")
.attr("title", $.i18n('core-views/match-all-cells'))
.appendTo(liSpan).on('click',function(evt) {
self.doMatchTopicToSimilarCells(candidate, cellIndex, cell);
});

var a = $('<a></a>')
.addClass("data-table-recon-topic")
.attr("target", "_blank")
.text(_.unescape(candidate.name)) // TODO: only use of _.unescape - consolidate
.appendTo(liSpan);

if ((service) && (service.view) && (service.view.url)) {
a.attr("href", encodeURI(service.view.url.replace("{{id}}", candidate.id)));
}

self.previewOnHover(service, candidate, liSpan.parent(), liSpan, true, rowIndex, cellIndex, cell);
self.previewOnHover(service, candidate, liSpan.parent(), liSpan, true, rowIndex, cellIndex, cell);

var score;
if (candidate.score < 1) {
score = Math.round(candidate.score * 1000) / 1000;
} else {
score = Math.round(candidate.score);
var score;
if (candidate.score < 1) {
score = Math.round(candidate.score * 1000) / 1000;
} else {
score = Math.round(candidate.score);
}
$('<span></span>').addClass("data-table-recon-score").text("(" + score + ")").appendTo(liSpan);
};
var visibilityChoices = $('<div>').addClass("data-table-recon-visibility").appendTo(divContentRecon);
if (candidates.length > visibleCandidates) {
var isExpanded = false; // Variable to track visibility state
var seeMoreLink = $('<a href="javascript:{}"></a>')
.on('click', function(evt) {
var link = $(this);
isExpanded = !isExpanded; // Toggle visibility state
if (isExpanded) {
ul.find('.data-table-recon-candidate').show(); // Show all candidates
seeMoreLink.text($.i18n('core-views/see-less')); // Change link text to "See Less"

}
else {
ul.find('.data-table-recon-candidate:not(:lt(' + visibleCandidates + '))').hide();
ul.find('.data-table-recon-candidate:last').show();
seeMoreLink.text($.i18n('core-views/see-more')); // Change link text to "See More"
}
$('<span></span>').addClass("data-table-recon-score").text("(" + score + ")").appendTo(liSpan);
};
var visibilityChoices = $('<div>').addClass("data-table-recon-visibility").appendTo(divContentRecon);
if (candidates.length > visibleCandidates) {
var isExpanded = false; // Variable to track visibility state
var seeMoreLink = $('<a href="javascript:{}"></a>')
.on('click', function(evt) {
var link = $(this);
isExpanded = !isExpanded; // Toggle visibility state
if (isExpanded) {
ul.find('.data-table-recon-candidate').show(); // Show all candidates
seeMoreLink.text($.i18n('core-views/see-less')); // Change link text to "See Less"

}
else {
ul.find('.data-table-recon-candidate:not(:lt(' + visibleCandidates + '))').hide();
ul.find('.data-table-recon-candidate:last').show();
seeMoreLink.text($.i18n('core-views/see-more')); // Change link text to "See More"
}
return false;
})
.text($.i18n('core-views/see-more'))
.appendTo(visibilityChoices);
seeMoreLink.after(" | ");
return false;
})
.text($.i18n('core-views/see-more'))
.appendTo(visibilityChoices);
seeMoreLink.after(" | ");
}
for (var i = 0; i < candidates.length; i++) {
renderCandidate(candidates[i], i);
}
for (var i = 0; i < candidates.length; i++) {
renderCandidate(candidates[i], i);
}

var liNew = $('<div></div>').addClass("data-table-recon-candidate").appendTo(ul);
Expand Down

0 comments on commit 269051e

Please sign in to comment.