Skip to content

Commit

Permalink
[master][js] Re-instated the client-side resource-validation integrat…
Browse files Browse the repository at this point in the history
…ion.

 - Lost in the large merge of UX changes.
 - Original integration: 81e5fe7
 - Haven't re-integrated the highlighting of url errors though; just the auto-population of some resource fields.
  • Loading branch information
Ian Murray committed Mar 12, 2012
1 parent f2cd051 commit 1f6c72d
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions ckan/public/scripts/application.js
Expand Up @@ -767,8 +767,37 @@ CKAN.View.ResourceAddLink = Backbone.View.extend({

setResourceInfo: function(e) {
e.preventDefault();
var urlVal=this.el.find('input[name=url]').val();
this.model.set({url: urlVal, resource_type: this.mode})

this.el.find('input[name=save]').addClass("disabled");
this.el.find('input[name=reset]').addClass("disabled");
var urlVal=this.el.find('input[name=url]').val();
var qaEnabled = $.inArray('qa',CKAN.plugins)>=0;

if(qaEnabled && this.mode=='file') {
$.ajax({
url: CKAN.SITE_URL + '/qa/link_checker',
context: this.model,
data: {url: urlVal},
dataType: 'json',
error: function(){
this.set({url: urlVal, resource_type: 'file'});
},
success: function(data){
data = data[0];
this.set({
url: urlVal,
resource_type: 'file',
format: data.format,
size: data.size,
mimetype: data.mimetype,
last_modified: data.last_modified,
url_error: (data.url_errors || [""])[0]
});
}
});
} else {
this.model.set({url: urlVal, resource_type: this.mode});
}
}
});

Expand Down

0 comments on commit 1f6c72d

Please sign in to comment.