Skip to content

Commit

Permalink
use jquery; use a common set of node actions
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jun 20, 2013
1 parent 27e992c commit ad7c0c3
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 73 deletions.
9 changes: 0 additions & 9 deletions fcrepo-http-api/src/main/resources/views/bootstrap.min.css

This file was deleted.

6 changes: 0 additions & 6 deletions fcrepo-http-api/src/main/resources/views/bootstrap.min.js

This file was deleted.

Expand Up @@ -4,10 +4,10 @@
<ul class="breadcrumb">
<li><a href="$uriInfo.getBaseUri()">Home</a> <span class="divider">/</span></li>
#foreach($entry in $breadcrumbs.entrySet())
#if ($entry.getValue() == $uriInfo.getAbsolutePath().toString())
<li class="active">$entry.getKey()</li>
#if ($entry.getKey() == $uriInfo.getAbsolutePath().toString())
<li class="active">$entry.getValue()</li>
#else
<li ><a href="$entry.getValue()">$entry.getKey()</a> <span class="divider">/</span></li>
<li ><a href="$entry.getKey()">$entry.getValue()</a> <span class="divider">/</span></li>
#end
#end
</ul>
10 changes: 4 additions & 6 deletions fcrepo-http-api/src/main/resources/views/common-head.vsl
@@ -1,9 +1,7 @@
<script type="text/javascript">
#include("views/bootstrap.min.js")
</script>
<style type="text/css">
#include("views/bootstrap.min.css")
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>

<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<script type="text/javascript">
#include("views/common.js")
</script>
Expand Down
21 changes: 21 additions & 0 deletions fcrepo-http-api/src/main/resources/views/common-node-actions.vsl
@@ -0,0 +1,21 @@

<form id="action_create">
<h3>Create New Node</h3>
<label>
Type
<select id="new_mixin">
<option value="">folder</option>
<option value="fedora:object">object</option>
<option value="fedora:datastream">datastream</option>
</select>
</label>
<label>
Identifier
<input type="text" id="new_id" placeholder="identifier"/>
</label>
<button type="submit" class="btn btn-primary">Add</button>
</form>
<hr />
<form id="action_delete" action="javascript:deleteItem()">
<button type="submit" class="btn btn-danger">Delete</button>
</form>
9 changes: 9 additions & 0 deletions fcrepo-http-api/src/main/resources/views/common.css
@@ -1 +1,10 @@
body { padding-top: 40px; }

.mode_root #action_delete {
display: none;
}


.nt_file #action_create, .nt_resource #action_create {
display: none;
}
32 changes: 21 additions & 11 deletions fcrepo-http-api/src/main/resources/views/common.js
@@ -1,24 +1,34 @@

function addChild()
{
var id = document.getElementById("new_id").value;
var mixin = document.getElementById("new_mixin").value;
var newURI = window.location + "/" + id;
var id = $("#new_id").val().trim();

if ( id == "") {
id = "fcr:new";
}

var mixin = $("#new_mixin").val();

var newURI = $('#main').attr('resource') + "/" + id;

if ( mixin != '' ) {
var postURI = newURI + "?mixin=" + mixin;
} else {
var postURI = newURI;
}

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
window.location = newURI;
}
}
xhr.open('POST',postURI,true);
xhr.send(null);
$.post(postURI, function(data, textStatus, request) {
window.location = request.getResponseHeader('Location');
});

return false;
}

$(function() {
$('#action_create').submit(addChild);

});

function deleteItem()
{
var uri = window.location;
Expand Down
19 changes: 4 additions & 15 deletions fcrepo-http-api/src/main/resources/views/mode-root.vsl
Expand Up @@ -7,8 +7,8 @@
</head>


<body>
<div class="container" resource="$topic.getURI()">
<body class="mode_root">
<div id="main" class="container" resource="$topic.getURI()">

#parse("views/common-node-header.vsl")

Expand Down Expand Up @@ -41,19 +41,8 @@
<div class="span3">
## output actions
<div class="actions">
<form action="javascript:addChild()">
<select id="new_mixin">
<option value="">folder</option>
<option value="fedora:object">object</option>
<option value="fedora:datastream">datastream</option>
</select>
<input type="text" id="new_id" value="new_id"/>
<input type="submit" value="add">
</form>
<form action="javascript:deleteItem()">
<input type="submit" value="delete this folder"/>

</form>
#parse("views/common-node-actions.vsl")

</div>

</div>
Expand Down
8 changes: 3 additions & 5 deletions fcrepo-http-api/src/main/resources/views/nt-file.vsl
Expand Up @@ -7,8 +7,8 @@
</head>


<body>
<div class="container" resource="$topic.getURI()">
<body class="nt_file">
<div id="main" class="container" resource="$topic.getURI()">
#parse("views/common-node-header.vsl")

<div class="row">
Expand Down Expand Up @@ -40,13 +40,11 @@
## output actions
## output actions
<div class="actions">
#parse("views/common-node-actions.vsl")
<form action="javascript:updateFile()">
<input type="file" id="update_file"/>
<input type="submit" value="update content">
</form>
<form action="javascript:deleteItem()">
<input type="submit" value="delete this datastream"/>
</form>
</div>
</div>

Expand Down
18 changes: 3 additions & 15 deletions fcrepo-http-api/src/main/resources/views/nt-folder.vsl
Expand Up @@ -7,8 +7,8 @@
</head>


<body>
<div class="container" resource="$topic.getURI()">
<body class="nt_folder">
<div id="main" class="container" resource="$topic.getURI()">
#parse("views/common-node-header.vsl")


Expand Down Expand Up @@ -42,19 +42,7 @@
<div class="span3">
## output actions
<div class="actions">
<form action="javascript:addChild()">
<select id="new_mixin">
<option value="">folder</option>
<option value="fedora:object">object</option>
<option value="fedora:datastream">datastream</option>
</select>
<input type="text" id="new_id" value="new_id"/>
<input type="submit" value="add">
</form>
<form action="javascript:deleteItem()">
<input type="submit" value="delete this folder"/>

</form>
#parse("views/common-node-actions.vsl")
</div>
</div>

Expand Down
5 changes: 3 additions & 2 deletions fcrepo-http-api/src/main/resources/views/nt-resource.vsl
Expand Up @@ -7,8 +7,8 @@
</head>


<body>
<div class="container" resource="$topic.getURI()">
<body class="nt_resource">
<div id="main" class="container" resource="$topic.getURI()">
#parse("views/common-node-header.vsl")


Expand Down Expand Up @@ -40,6 +40,7 @@

<div class="span3">
## output actions
#parse("views/common-node-actions.vsl")
</div>

</div>
Expand Down
Expand Up @@ -106,7 +106,7 @@ public Map<String, String> getNodeBreadcrumbs(final UriInfo uriInfo, final Node
LOGGER.trace("Adding breadcrumb for path segment {} => {}", path, uri);


builder.put(path, uri);
builder.put(uri, path);

cumulativePath.append("/");

Expand Down

0 comments on commit ad7c0c3

Please sign in to comment.