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