Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#953] Adds JS module for disabling visibility field on dataset creation
Essentially we get the current value of the visibility dropdown and then if no org is selected then we disable the visibilty dropdown and set it to be public.
- Loading branch information
1 parent
f83b0c7
commit 972b1c8
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* Dataset visibility toggler | ||
* When no organization is selected in the org dropdown then set visibility to | ||
* public always and disable dropdown | ||
*/ | ||
this.ckan.module('dataset-visibility', function ($, _) { | ||
return { | ||
currentValue: false, | ||
options: { | ||
organizations: $('#field-organizations'), | ||
visibility: $('#field-private'), | ||
currentValue: null | ||
}, | ||
initialize: function() { | ||
$.proxyAll(this, /_on/); | ||
this.options.currentValue = this.options.visibility.val(); | ||
this.options.organizations.on('change', this._onOrganizationChange); | ||
this._onOrganizationChange(); | ||
}, | ||
_onOrganizationChange: function() { | ||
var value = this.options.organizations.val(); | ||
if (value) { | ||
this.options.visibility | ||
.prop('disabled', false) | ||
.val(this.options.currentValue); | ||
} else { | ||
this.options.visibility | ||
.prop('disabled', true) | ||
.val('False'); | ||
} | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters