Skip to content

Commit

Permalink
add form to manipulate object properties
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jun 20, 2013
1 parent cfe5a0a commit f1013f2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
15 changes: 15 additions & 0 deletions fcrepo-http-api/src/main/resources/views/common-node-actions.vsl
Expand Up @@ -15,7 +15,22 @@
</label>
<button type="submit" class="btn btn-primary">Add</button>
</form>

<hr />

<form id="action_sparql_update">
<h3>Update Properties</h3>
<textarea class="span3" rows="5" id="sparql_update_query" name="query">
DELETE { }
INSERT { }
WHERE { }
</textarea>
<button type="submit" class="btn btn-primary">Update</button>
</form>

<hr />

<form id="action_delete" action="javascript:deleteItem()">
<h3>Delete Object</h3>
<button type="submit" class="btn btn-danger">Delete</button>
</form>
30 changes: 20 additions & 10 deletions fcrepo-http-api/src/main/resources/views/common.js
Expand Up @@ -25,26 +25,36 @@ function addChild()
}

$(function() {
$('#action_create').submit(addChild);
$('#action_create').submit(addChild);
$('#action_sparql_update').submit(sendSparqlUpdate);
$('#action_delete').submit(deleteItem);

});

function sendSparqlUpdate() {
var postURI = $('#main').attr('resource');


$.ajax({url: postURI, type: "POST", contentType: "application/sparql-update", data: $("#sparql_update_query").val(), success: function(data, textStatus, request) {
window.location.reload(true);
}});

return false;
}

function deleteItem()
{
var uri = window.location;
var uri = $('#main').attr('resource');
var arr = uri.toString().split("/");
arr.pop();
var newURI = arr.join("/");

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
window.location = newURI;
}
}
xhr.open('DELETE',uri,true);
xhr.send(null);
$.ajax({url: uri, type: "DELETE", success: function() {
window.location = request.getResponseHeader(newURI);
}});
return false;
}

function updateFile()
{
var update_file = document.getElementById("update_file").files[0];
Expand Down
2 changes: 1 addition & 1 deletion fcrepo-http-api/src/main/resources/views/common.vsl
Expand Up @@ -5,7 +5,7 @@
<dl>
#foreach($quad in $helpers.getSortedTriples($model, $rdf.find($nodeany, $sub, $nodeany, $nodeany)))
<dt>
<span class="namespace muted">$helpers.getNamespacePrefix($model, $quad.getPredicate().getNameSpace())</span><span class="localName">$quad.getPredicate().getLocalName()</span>
<span class="namespace muted" title="$quad.getPredicate().getNameSpace()">$helpers.getNamespacePrefix($model, $quad.getPredicate().getNameSpace())</span><span class="localName">$quad.getPredicate().getLocalName()</span>

</dt>
<dd>
Expand Down

0 comments on commit f1013f2

Please sign in to comment.