repo-auth-tokens: UX, set and disable to VCS scope if selected an repo from select2

This commit is contained in:
Marcin Kuzminski 2017-09-21 20:12:13 +02:00
parent 79c8fadc26
commit a9fc01d079
4 changed files with 20 additions and 0 deletions

View file

@ -699,6 +699,7 @@ class UsersView(UserAppView):
c.role_options = [(c.role_values, _("Role"))]
c.user_auth_tokens = AuthTokenModel().get_auth_tokens(
c.user.user_id, show_expired=True)
c.role_vcs = AuthTokenModel.cls.ROLE_VCS
return self._get_template_context(c)
def maybe_attach_token_scope(self, token):

View file

@ -159,6 +159,7 @@ class MyAccountView(BaseAppView, DataGridAppView):
c.role_options = [(c.role_values, _("Role"))]
c.user_auth_tokens = AuthTokenModel().get_auth_tokens(
c.user.user_id, show_expired=True)
c.role_vcs = AuthTokenModel.cls.ROLE_VCS
return self._get_template_context(c)
def maybe_attach_token_scope(self, token):

View file

@ -141,6 +141,12 @@ var repoFilter = function(data) {
$("#scope_repo_id_disabled").select2(select2Options);
var selectVcsScope = function() {
// select vcs scope and disable input
$("#role").select2("val", "${c.role_vcs}").trigger('change');
$("#role").select2("readonly", true)
};
$("#scope_repo_id").select2({
cachedDataSource: {},
minimumInputLength: 2,
@ -174,6 +180,9 @@ $("#scope_repo_id").select2({
}
})
});
$("#scope_repo_id").on('select2-selecting', function(e){
selectVcsScope()
});
});
</script>

View file

@ -139,6 +139,12 @@ var repoFilter = function(data) {
$("#scope_repo_id_disabled").select2(select2Options);
var selectVcsScope = function() {
// select vcs scope and disable input
$("#role").select2("val", "${c.role_vcs}").trigger('change');
$("#role").select2("readonly", true)
};
$("#scope_repo_id").select2({
cachedDataSource: {},
minimumInputLength: 2,
@ -172,6 +178,9 @@ $("#scope_repo_id").select2({
}
})
});
$("#scope_repo_id").on('select2-selecting', function(e){
selectVcsScope()
});
});
</script>