-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds the service logo to column header and while schema building #6156
base: master
Are you sure you want to change the base?
Changes from all commits
3b343c4
a5d76ce
c0637ed
2fbd210
79c556a
b22ddbf
a0a754b
28e7772
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,27 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
*/ | ||
|
||
function serviceLogoFromReconConfig(reconConfig){ | ||
var serviceUrl = null; | ||
var service = null; | ||
var serviceLogo=null; | ||
if (reconConfig) { | ||
serviceUrl =reconConfig.service; | ||
} | ||
if (serviceUrl) { | ||
service = ReconciliationManager.getServiceFromUrl(serviceUrl); | ||
} | ||
if (service) { | ||
serviceLogo=service.logo; | ||
} | ||
try { | ||
return new URL(serviceLogo); | ||
} | ||
catch { | ||
console.warn("Invalid logo URL supplied by service "+serviceUrl) | ||
} | ||
|
||
}; | ||
var SchemaAlignment = { | ||
_isSetUp: false | ||
}; | ||
|
@@ -246,7 +266,7 @@ SchemaAlignment.updateColumns = function() { | |
// TODO we could potentially ignore any reconciliation to a siteIRI not | ||
// mentioned in the manifest… | ||
var cell = SchemaAlignment._createDraggableColumn(column.name, | ||
reconConfig && column.reconStats ? reconConfig.identifierSpace : null); | ||
reconConfig && column.reconStats ? reconConfig.identifierSpace : null, reconConfig); | ||
this._columnArea.append(cell); | ||
} | ||
|
||
|
@@ -433,8 +453,19 @@ SchemaAlignment._changesCleared = function() { | |
.addClass('disabled'); | ||
}; | ||
|
||
SchemaAlignment._createDraggableColumn = function(name, reconciledSiteIRI) { | ||
SchemaAlignment._createDraggableColumn = function(name, reconciledSiteIRI, reconConfig) { | ||
var logo=serviceLogoFromReconConfig(reconConfig); | ||
var cell = $("<div></div>").addClass('wbs-draggable-column').text(name); | ||
if(logo) { | ||
var img =$("<img>"); | ||
if(serviceLogo) { | ||
var imageUrl = serviceLogo; | ||
img.attr("src", imageUrl); | ||
img.attr("title", service.name); | ||
img.addClass("serviceLogo-for-schema") | ||
} | ||
cell.append(img); | ||
} | ||
cell.data({ | ||
'columnName': name, | ||
'reconciledSiteIRI': reconciledSiteIRI | ||
|
@@ -1467,13 +1498,26 @@ SchemaAlignment._initField = function(inputContainer, mode, initialValue, change | |
} | ||
|
||
var acceptDraggableColumn = function(column) { | ||
var Logo=serviceLogoFromReconConfig(reconConfig); | ||
var img =$("<img>"); | ||
if(Logo ){ | ||
var imageUrl = serviceLogo; | ||
img.attr("src", imageUrl); | ||
img.attr("title", service.name); | ||
img.addClass("serviceLogo-for-schema") | ||
|
||
}; | ||
|
||
input.hide(); | ||
input.val(""); | ||
var columnDiv = $('<div></div>').appendTo(inputContainer); | ||
column.appendTo(columnDiv); | ||
//columnDiv.append(img); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This commented out code can probably be removed, no? |
||
|
||
var origText = column.text(); | ||
column.text(""); | ||
column.append($('<div></div>').addClass('wbs-restricted-column-name').text(origText)); | ||
column.append($('<div></div>').addClass('wbs-restricted-column-name').text(origText).append(img)); | ||
|
||
var deleteButton = SchemaAlignment._makeDeleteButton(true).appendTo(column); | ||
deleteButton.attr('alt', $.i18n('wikibase-schema/remove-column')); | ||
deleteButton.on('click',function (e) { | ||
|
@@ -1538,13 +1582,20 @@ SchemaAlignment._initField = function(inputContainer, mode, initialValue, change | |
|
||
// Init with the provided initial value. | ||
if (initialValue) { | ||
var columns = theProject.columnModel.columns; | ||
var reconConfig=null; | ||
for (var i = 0; i < columns.length; i++) { | ||
if(columns[i].name===initialValue.columnName){ | ||
reconConfig = columns[i].reconConfig; | ||
} | ||
} | ||
if (initialValue.type === "wbentityidvalueconstant" || | ||
/* item for backwards-compatibility purposes */ | ||
initialValue.type === "wbitemconstant" || initialValue.type === "wbpropconstant") { | ||
input.val(initialValue.label); | ||
input.addClass("wbs-validated-input"); | ||
} else if (initialValue.type == "wbentityvariable") { | ||
var cell = SchemaAlignment._createDraggableColumn(initialValue.columnName, true); | ||
var cell = SchemaAlignment._createDraggableColumn(initialValue.columnName, true, reconConfig); | ||
acceptDraggableColumn(cell); | ||
} else if (initialValue.type === "wbstringconstant" || | ||
initialValue.type === "wbdateconstant" || | ||
|
@@ -1557,7 +1608,7 @@ SchemaAlignment._initField = function(inputContainer, mode, initialValue, change | |
initialValue.type === "wbdatevariable" || | ||
initialValue.type === "wblocationvariable" || | ||
initialValue.type === "wblanguagevariable") { | ||
var cell = SchemaAlignment._createDraggableColumn(initialValue.columnName, false); | ||
var cell = SchemaAlignment._createDraggableColumn(initialValue.columnName, false, reconConfig ); | ||
acceptDraggableColumn(cell); | ||
} | ||
inputContainer.data("jsonValue", initialValue); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,35 @@ DataTableColumnHeaderUI.prototype._render = function() { | |
elmts.dropdownMenu.on('click',function() { | ||
self._createMenuForColumnHeader(this); | ||
}); | ||
|
||
|
||
var serviceUrl = null; | ||
var service = null; | ||
var serviceLogo=null; | ||
if (this._column.reconConfig) { | ||
serviceUrl =this._column.reconConfig.service; | ||
} | ||
try { | ||
|
||
if (new URL(serviceUrl)) { | ||
service = ReconciliationManager.getServiceFromUrl(serviceUrl); | ||
ayushrai206 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
if(service) { | ||
serviceLogo=service.logo; | ||
} | ||
|
||
var img =$("<img>"); | ||
if(serviceLogo) { | ||
var imageUrl = serviceLogo; | ||
img.attr("src", imageUrl); | ||
img.attr("title", service.name); | ||
img.addClass("serviceLogo") | ||
img.appendTo(elmts.serviceLogoContainer.show()); | ||
} | ||
} | ||
catch { | ||
console.log("The URL is not valid"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those logging statements could be more useful with a more explicit error message. When you are looking at the code here, it is clear that this logging statement refers to a recon service URL, but imagine what happens when just seeing this message in the console, in the middle of other unrelated statements: the current error message does not give a lot of information, as we have no idea which URL is referred to. Once the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like this problem is still there, no? Or do you see it resolved in another way? |
||
} | ||
|
||
if ("reconStats" in this._column) { | ||
var stats = this._column.reconStats; | ||
if (stats.nonBlanks > 0) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
<div class="column-header-title"><button class="column-header-menu" bind="dropdownMenu"></button><span class="column-header-name" bind="nameContainer"></span></div> | ||
<div style="display:none;" bind="reconStatsContainer"></div> | ||
<div class="container-of-logo-and-statsbar"> | ||
<div style="display: none; grid-column:1" bind="serviceLogoContainer" ></div> | ||
<div style="display: none; grid-column:2" bind="reconStatsContainer"></div> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
if
block is probably redundant with the outer one, and seems to refer to an undeclared variable.