ckanext-privatedatasets/ckanext/privatedatasets/fanstatic/allowed_users.js

32 lines
1.1 KiB
JavaScript
Raw Normal View History

2014-06-30 13:31:11 +02:00
/* Dataset allowed_users and adquire_url toggler
* allowd_users and adquire_url can only be active when a user attempts to create
* a private dataset outside an organization
2014-06-23 17:25:37 +02:00
*/
this.ckan.module('allowed-users', function ($, _) {
return {
initialize: function() {
$('#field-private').on('change', this._onChange);
$('#field-organizations').on('change', this._onChange);
this._onChange();
},
_onChange: function() {
var ds_private = $('#field-private').val();
var organization = $('#field-organizations').val();
if (ds_private == "True" && !organization) {
$('#field-allowed_users').prop('disabled', false); //Enable
$('#field-adquire_url').prop('disabled', false); //Enable
2014-06-23 17:25:37 +02:00
} else {
$('#field-allowed_users').prop('disabled', true); //Disable
$('#field-adquire_url').prop('disabled', true); //Disable
2014-06-23 17:25:37 +02:00
//Remove previous values
$('#s2id_field-allowed_users .select2-search-choice').remove();
$('#field-allowed_users').val('');
$('#field-adquire_url').val('');
2014-06-23 17:25:37 +02:00
}
}
};
});