NIHVIVO-2343 Continuing implementation.
This commit is contained in:
parent
2e31f6fb5e
commit
cabc944481
3 changed files with 19 additions and 32 deletions
|
@ -15,9 +15,8 @@
|
|||
* profile associated with that individual.
|
||||
* ----------------------------------------------------------------------------
|
||||
* The template must inlude
|
||||
* 1) a link with attribute templatePart="remove"
|
||||
* 2) a link with attribute templatePart="restore"
|
||||
* 3) a hidden field with attribute templatePart="uriField" and value="%uri%" see below
|
||||
* 1) a link with attribute templatePart="remove" and restoreText="[something]"
|
||||
* 2) a hidden field with attribute templatePart="uriField" and value="%uri%" see below
|
||||
*
|
||||
* The template may include tokens to be replaced, from the following:
|
||||
* %uri% -- the URI of the individual being displayed
|
||||
|
@ -45,45 +44,31 @@ function proxyInfoElement(template, uri, label, classLabel, imageUrl, existing)
|
|||
this.element = function() {
|
||||
var element = $("<div name='proxyInfoElement'>" + content + "</div>");
|
||||
var removeLink = $("[templatePart='remove']", element).first();
|
||||
var restoreLink = $("[templatePart='restore']", element).first();
|
||||
var removeText = removeLink.text();
|
||||
var restoreText = removeLink.attr('restoreText');
|
||||
var proxyUriField = $("[templatePart='uriField']", element);
|
||||
|
||||
var setClass = function(r) {
|
||||
if (r) {
|
||||
element.removeClass('new existing').addClass('removed')
|
||||
} else if (existed) {
|
||||
element.removeClass('new removed').addClass('existing')
|
||||
} else {
|
||||
element.removeClass('removed existing').addClass('new')
|
||||
}
|
||||
}
|
||||
|
||||
var setRemoved = function(r) {
|
||||
removed = r;
|
||||
if (r) {
|
||||
removeLink.hide();
|
||||
restoreLink.show();
|
||||
var showRemoved = function() {
|
||||
if (removed) {
|
||||
removeLink.text(restoreText);
|
||||
proxyUriField.attr('disabled', 'disabled');
|
||||
setClass(r);
|
||||
element.addClass('removed');
|
||||
} else {
|
||||
removeLink.show();
|
||||
restoreLink.hide();
|
||||
removeLink.text(removeText);
|
||||
proxyUriField.attr('disabled', '');
|
||||
setClass(r);
|
||||
element.removeClass('removed');
|
||||
}
|
||||
}
|
||||
|
||||
removeLink.click(function(event) {
|
||||
setRemoved(true);
|
||||
removed = !removed;
|
||||
showRemoved();
|
||||
return false;
|
||||
});
|
||||
|
||||
restoreLink.click(function(event) {
|
||||
setRemoved(false);
|
||||
return false;
|
||||
});
|
||||
|
||||
setRemoved(removed);
|
||||
element.removeClass('new existing removed');
|
||||
element.addClass(existed ? 'existing' : 'new')
|
||||
showRemoved()
|
||||
|
||||
return element;
|
||||
}
|
||||
|
|
|
@ -126,7 +126,10 @@ function proxyAutocomplete(parent) {
|
|||
this.select = function(event, ui) {
|
||||
parent.proxyData.unshift(new proxyInfoElement(parent.templateHtml, ui.item.uri, ui.item.label, "", "", false));
|
||||
parent.displayProxyData();
|
||||
event.preventDefault();
|
||||
event.target.value = '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
|
|
@ -44,8 +44,7 @@ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/account/proxy.c
|
|||
%label% | %classLabel%
|
||||
</div>
|
||||
<div>
|
||||
<a href="." templatePart="remove">remove</a>
|
||||
<a href="." templatePart="restore">restore</a>
|
||||
<a href="." templatePart="remove" restoreText="restore">remove</a>
|
||||
<input type="hidden" name="proxyUri" templatePart="uriField" value="%uri%" >
|
||||
</div>
|
||||
</td>
|
||||
|
|
Loading…
Add table
Reference in a new issue