summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/project_new.js
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2016-09-16 16:15:39 -0300
committerFelipe Artur <felipefac@gmail.com>2016-10-17 18:12:18 -0200
commitda07c2e4d3d382c05ec287ee60f639b870074fe7 (patch)
treef6ffa7fd29fe177d4d78c0e043a1fdcff5b6eba4 /app/assets/javascripts/project_new.js
parentc49e152605ad1fe77bea6414c383cf70669ca110 (diff)
downloadgitlab-ce-da07c2e4d3d382c05ec287ee60f639b870074fe7.tar.gz
Add visibility level to project repositoryissue_19734_2
Diffstat (limited to 'app/assets/javascripts/project_new.js')
-rw-r--r--app/assets/javascripts/project_new.js38
1 files changed, 35 insertions, 3 deletions
diff --git a/app/assets/javascripts/project_new.js b/app/assets/javascripts/project_new.js
index 3cf41505814..478e82aa14d 100644
--- a/app/assets/javascripts/project_new.js
+++ b/app/assets/javascripts/project_new.js
@@ -4,9 +4,8 @@
this.ProjectNew = (function() {
function ProjectNew() {
this.toggleSettings = bind(this.toggleSettings, this);
- this.$selects = $('.features select').filter(function () {
- return $(this).data('field');
- });
+ this.$selects = $('.features select');
+ this.$repoSelects = this.$selects.filter('.js-repo-select');
$('.project-edit-container').on('ajax:before', (function(_this) {
return function() {
@@ -16,6 +15,7 @@
})(this));
this.toggleSettings();
this.toggleSettingsOnclick();
+ this.toggleRepoVisibility();
}
ProjectNew.prototype.toggleSettings = function() {
@@ -43,6 +43,38 @@
}
};
+ ProjectNew.prototype.toggleRepoVisibility = function () {
+ var $repoAccessLevel = $('.js-repo-access-level select');
+
+ this.$repoSelects.find("option[value='" + $repoAccessLevel.val() + "']")
+ .nextAll()
+ .hide();
+
+ $repoAccessLevel.off('change')
+ .on('change', function () {
+ var selectedVal = parseInt($repoAccessLevel.val());
+
+ this.$repoSelects.each(function () {
+ var $this = $(this),
+ repoSelectVal = parseInt($this.val());
+
+ $this.find('option').show();
+
+ if (selectedVal < repoSelectVal) {
+ $this.val(selectedVal);
+ }
+
+ $this.find("option[value='" + selectedVal + "']").nextAll().hide();
+ });
+
+ if (selectedVal) {
+ this.$repoSelects.removeClass('disabled');
+ } else {
+ this.$repoSelects.addClass('disabled');
+ }
+ }.bind(this));
+ };
+
return ProjectNew;
})();