Permalink
Browse files

Adding refresh vocabulary option (related to issues 22 and 49)

  • Loading branch information...
1 parent 4427047 commit 602b377d5ad5539f14dc1609b04526a9540e2b0f Fadi committed Apr 22, 2012
@@ -131,6 +131,7 @@ function init() {
RefineServlet.registerCommand(module, "get-default-prefixes", new GetDefaultPrefixesCommand(ctxt));
RefineServlet.registerCommand(module, "add-prefix", new AddPrefixCommand(ctxt));
RefineServlet.registerCommand(module, "remove-prefix", new RemovePrefixCommand(ctxt));
+ RefineServlet.registerCommand(module, "refresh-prefix", new RefreshPrefixCommand(ctxt));
RefineServlet.registerCommand(module, "suggest-term", new SuggestTermCommand(ctxt));
RefineServlet.registerCommand(module, "get-prefix-cc-uri", new SuggestPrefixUriCommand(ctxt));
RefineServlet.registerCommand(module, "upload-file-add-prefix", new AddPrefixFromFileCommand(ctxt));
@@ -28,7 +28,8 @@ ManageVocabsWidget.prototype.renderBody = function(){
self._prefixesManager._addPrefix(false,false,function(){self.renderBody();});
}));
var table = $('<table></table>').addClass('rdf-prefixes-table');
- table.append($('<tr>').addClass('rdf-table-even').append($('<th/>').text('Prefix')).append($('<th/>').text('URI')).append($('<th/>').text('Delete')));
+ table.append($('<tr>').addClass('rdf-table-even').append($('<th/>').text('Prefix')).append($('<th/>').text('URI')).append($('<th/>').text('Delete'))
+ .append($('<th/>').text('Refresh')));
var getDeleteHandler = function(name){
return function(e){
e.preventDefault();
@@ -43,14 +44,31 @@ ManageVocabsWidget.prototype.renderBody = function(){
}
});
}
+ };
+ var getRefreshHandler = function(name,uri){
+ return function(e){
+ e.preventDefault();
+ if (window.confirm("This will re-fetch the vocabulary from \"" + uri + "\" If you added it by uploading a file you need to delete it and add it again to refresh the index. Continue?")) {
+ dismissBusy = DialogSystem.showBusy('Refreshing prefix ' + name);
+ $.post('/command/rdf-extension/refresh-prefix',{'name':name,'uri':uri,'project':theProject.id},function(data){
+ dismissBusy();
+ if(data.code==='error'){
+ alert('something went wrong: ' + data.messge);
+ }
+ });
+ }
+ }
};
for(var i=0;i<self._prefixesManager._prefixes.length;i++){
var name =self._prefixesManager._prefixes[i].name;
+ var uri =self._prefixesManager._prefixes[i].uri;
var delete_handle = $('<a/>').text('delete').attr('href','#').click(getDeleteHandler(name));
+ var refresh_handle = $('<a/>').text('refresh').attr('href','#').click(getRefreshHandler(name,uri));
var tr = $('<tr/>').addClass(i%2==1?'rdf-table-even':'rdf-table-odd')
.append($('<td>').text(self._prefixesManager._prefixes[i].name))
.append($('<td>').text(self._prefixesManager._prefixes[i].uri))
- .append($('<td>').html(delete_handle));
+ .append($('<td>').html(delete_handle))
+ .append($('<td>').html(refresh_handle));
table.append(tr);
}
self._body.empty().append(addPrefixSpan).append(table);
Oops, something went wrong.

0 comments on commit 602b377

Please sign in to comment.