Allow roles to be revoked many times

This commit is contained in:
richard-dds 2018-10-23 16:55:56 -04:00
parent 783b47b2f7
commit cd9ae2c928
3 changed files with 23 additions and 7 deletions

View File

@ -31,14 +31,21 @@ export default {
methods: { methods: {
change: function (e) { change: function (e) {
e.preventDefault() this.new_role = e.target.value
this.new_role = this.revoke ? "" : e.target.value
}, },
cancel: function () { cancel: function () {
this.new_role = this.initialData this.new_role = this.initialData
}, },
}, },
watch: {
revoke: function (val) {
if (val) {
this.new_role = ""
}
}
},
computed: { computed: {
displayName: function () { displayName: function () {
const newRole = this.newRole const newRole = this.newRole
@ -53,7 +60,7 @@ export default {
"label" : "label label--success" "label" : "label label--success"
}, },
newRole: function () { newRole: function () {
return this.revoke ? "" : this.new_role return this.new_role
} }
}, },
} }

View File

@ -19,5 +19,14 @@ export default {
data: function() { data: function() {
return { revoke: false } return { revoke: false }
},
methods: {
doRevoke: function () {
// This is being used to send an event to the edit-environment-role child component.
// We'll toggle this back on the next line so that it can be used again.
this.revoke = true
setTimeout(() => { this.revoke = false }, 25)
}
} }
} }

View File

@ -70,7 +70,7 @@
Confirming will revoke access for {{ member.user.full_name }} to any environments associated with {{ project.name }}. Confirming will revoke access for {{ member.user.full_name }} to any environments associated with {{ project.name }}.
</p> </p>
<div class='action-group'> <div class='action-group'>
<a v-on:click="revoke = true; closeModal('{{ revoke_modal_name }}')" class='action-group__action usa-button'>Confirm</a> <a v-on:click="doRevoke(); closeModal('{{ revoke_modal_name }}')" class='action-group__action usa-button'>Confirm</a>
<a class='action-group__action icon-link icon-link--danger' v-on:click="closeModal('{{ revoke_modal_name }}'); cancel();">Cancel</a> <a class='action-group__action icon-link icon-link--danger' v-on:click="closeModal('{{ revoke_modal_name }}'); cancel();">Cancel</a>
</div> </div>
</div> </div>
@ -106,11 +106,11 @@
<input <input
name='radio_input_{{ env.id }}' name='radio_input_{{ env.id }}'
v-on:change='change' v-on:change.prevent='change'
type='radio' type='radio'
id="env_{{ env.id }}_{{ choice[0] }}" id="env_{{ env.id }}_{{ choice[0] }}"
value='{{ choice[0] }}' value='{{ choice[0] }}'
{% if role == choice[0] %} {% if "!{new_role}" == choice[0] %}
checked='checked' checked='checked'
{% endif %} {% endif %}
/> />