Skip to content
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

Add Keyword edit capability to Individual gallery images in encounte… #588

Merged
merged 2 commits into from
Jun 10, 2024
Merged
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
53 changes: 32 additions & 21 deletions src/main/webapp/encounters/encounterMediaGallery.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ String langCode=ServletUtilities.getLanguageCode(request);
Properties encprops = ShepherdProperties.getProperties("encounter.properties", langCode,context);
String encNum="";
boolean isOwner=false;
JSONObject MediaAssetOwner = new JSONObject();



Expand Down Expand Up @@ -120,6 +121,7 @@ function forceLink(el) {
<%
List<String> maAcms = new ArrayList<String>();
List<String> maIds = new ArrayList<String>();
boolean isEncounterOwner=isOwner;

for(int f=0;f<numEncs;f++){

Expand All @@ -134,7 +136,9 @@ function forceLink(el) {
//System.out.println(" EMG: hiding enc "+enc.getCatalogNumber()+" for security reasons.");
continue;
}

if(!isOwner){
isEncounterOwner = ServletUtilities.isUserAuthorizedForEncounter(enc, request,imageShepherd);
}
ArrayList<Annotation> anns = enc.getAnnotations();
JSONObject iaTasks = new JSONObject();

Expand All @@ -155,6 +159,7 @@ function forceLink(el) {
if (ma == null) continue;
if ((ma.getAcmId() != null) && !maAcms.contains(ma.getAcmId())) maAcms.add(ma.getAcmId());
maIds.add(Integer.toString(ma.getId()));
MediaAssetOwner.put(Integer.toString(ma.getId()),isEncounterOwner);



Expand Down Expand Up @@ -288,6 +293,7 @@ System.out.println("\n\n==== got detected frame! " + ma + " -> " + ann.getFeatur

}
out.println("<script> var iaTasks = " + iaTasks.toString() + ";</script>");
out.println("<script> var MediaAssetOwner = " + MediaAssetOwner.toString() + ";</script>");
}

JSONObject dups = new JSONObject();
Expand Down Expand Up @@ -1415,26 +1421,26 @@ console.info("############## mid=%s -> %o", mid, ma);
console.info("Have labeled keyword %o", kw);
h += '<div class="image-enhancer-keyword labeled-keyword" id="keyword-' + kw.indexname + '"><span class="keyword-label">' + kw.label+'</span>: <span class="keyword-value">'+kw.readableName+'</span>';

<%
if(isOwner){
%>

if(MediaAssetOwner[mid]){

h+='<span class="iek-remove" onclick="addOrRemoveNewKeyword(this)" title="remove keyword">X</span>';
<%

}
%>


h+='</div>';
}
else {

h+= '<div class="image-enhancer-keyword" id="keyword-' + ma.keywords[i].indexname + '">' + ma.keywords[i].readableName;
<%
if(isOwner){
%>

if(MediaAssetOwner[mid]){

h+=' <span class="iek-remove" onclick="addOrRemoveNewKeyword(this)" title="remove keyword">X</span>';
<%

}
%>

h+='</div>';

}
Expand All @@ -1448,9 +1454,9 @@ console.info("############## mid=%s -> %o", mid, ma);
console.log("Labeled keywords %o", labelsToValues);
let labeledAvailable = (labelsToValues.length>0);

<%
if(isOwner){
%>



h +='<div class="labeled iek-new-wrapper' + ( !labeledAvailable ? ' iek-autohide' : '') + '">add new <span class="keyword-label">labeled</span> keyword<div class="iek-new-labeled-form">';

if (!$.isEmptyObject(labelsToValues)) {
Expand Down Expand Up @@ -1481,11 +1487,11 @@ console.info("############## mid=%s -> %o", mid, ma);
}
h += '</div></div>';

<%
}



if(isOwner){
%>



h += '<div class="iek-new-wrapper' + (ma.keywords.length ? ' iek-autohide' : '') + '">add new keyword<div class="iek-new-form">';
if (wildbookGlobals.keywords) {
Expand All @@ -1501,9 +1507,9 @@ console.info("############## mid=%s -> %o", mid, ma);
}
h += '<br /><input placeholder="or enter new" id="keyword-new" type="text" style="" onChange="return addOrRemoveNewKeyword(this);" />';
h += '</div></div>';
<%
}
%>




// we need to attach this to the outer container now
if (!hasWrapper) {
Expand Down Expand Up @@ -1536,6 +1542,11 @@ function showKeywordList(el) {
$(el).parent().attr('class').split(' ').map(function(className){
if (className.startsWith('image-enhancer-wrapper-mid-')) {
let mid = className.replace('image-enhancer-wrapper-mid-', '');
if(!MediaAssetOwner[mid]){
$('.image-enhancer-keyword-wrapper-hover > .iek-new-wrapper:not(.labeled)').hide();
} else {
$('.image-enhancer-keyword-wrapper-hover > .iek-new-wrapper:not(.labeled)').show();
}
$('.pswp__button--arrow--right').click(function(ev) {
nextImageArrow(ev,mid);
});
Expand Down