Vue component for editing application member environment role
This commit is contained in:
parent
d38c4df878
commit
39cc200bf2
36
js/components/environment_role.js
Normal file
36
js/components/environment_role.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import optionsinput from './options_input'
|
||||||
|
import { emitEvent } from '../lib/emitters'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'environment-role',
|
||||||
|
|
||||||
|
components: {
|
||||||
|
optionsinput,
|
||||||
|
},
|
||||||
|
|
||||||
|
props: {
|
||||||
|
initialRole: String,
|
||||||
|
},
|
||||||
|
|
||||||
|
data: function() {
|
||||||
|
return {
|
||||||
|
role: this.initialRole,
|
||||||
|
expanded: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
toggle: function() {
|
||||||
|
this.expanded = !this.expanded
|
||||||
|
},
|
||||||
|
radioChange: function(e) {
|
||||||
|
this.role = e.target.value
|
||||||
|
emitEvent('field-change', this, {
|
||||||
|
value: e.target.value,
|
||||||
|
valid: true,
|
||||||
|
name: this.name,
|
||||||
|
watch: true,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
@ -2,6 +2,7 @@ import editEnvironmentRole from './forms/edit_environment_role'
|
|||||||
import FormMixin from '../mixins/form'
|
import FormMixin from '../mixins/form'
|
||||||
import optionsinput from './options_input'
|
import optionsinput from './options_input'
|
||||||
import textinput from './text_input'
|
import textinput from './text_input'
|
||||||
|
import EnvironmentRole from './environment_role'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'toggler',
|
name: 'toggler',
|
||||||
@ -20,6 +21,7 @@ export default {
|
|||||||
optionsinput,
|
optionsinput,
|
||||||
textinput,
|
textinput,
|
||||||
optionsinput,
|
optionsinput,
|
||||||
|
EnvironmentRole,
|
||||||
toggler: this,
|
toggler: this,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ import KoReview from './components/forms/ko_review'
|
|||||||
import BaseForm from './components/forms/base_form'
|
import BaseForm from './components/forms/base_form'
|
||||||
import DeleteConfirmation from './components/delete_confirmation'
|
import DeleteConfirmation from './components/delete_confirmation'
|
||||||
import NewEnvironment from './components/forms/new_environment'
|
import NewEnvironment from './components/forms/new_environment'
|
||||||
|
import EnvironmentRole from './components/environment_role'
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ const app = new Vue({
|
|||||||
DeleteConfirmation,
|
DeleteConfirmation,
|
||||||
nestedcheckboxinput,
|
nestedcheckboxinput,
|
||||||
NewEnvironment,
|
NewEnvironment,
|
||||||
|
EnvironmentRole,
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
{% for environment_form in environment_roles_form %}
|
{% for environment_form in environment_roles_form %}
|
||||||
<li class="accordion-table__item__expanded">
|
<li class="accordion-table__item__expanded">
|
||||||
<toggler inline-template>
|
<environment-role inline-template v-bind:initial-role="'{{ environment_form.role.data }}'">
|
||||||
<div>
|
<div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col--grow">
|
<div class="col col--grow">
|
||||||
@ -48,28 +48,27 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="accordion-table__item__expanded-role col col--grow">
|
<div class="accordion-table__item__expanded-role col col--grow">
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<span>
|
<span v-html="role">
|
||||||
{{ environment_form.role.data }}
|
|
||||||
</span>
|
</span>
|
||||||
<div class="icon-link" v-on:click="toggleSection('edit-env-role')">
|
<div class="icon-link" v-on:click="toggle">
|
||||||
{{ Icon("edit") }}
|
{{ Icon("edit") }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="member-list__role-select" v-show="selectedSection === 'edit-env-role'">
|
<div class="member-list__role-select" v-show="expanded">
|
||||||
{{ environment_form.role.label }}
|
{{ environment_form.role.label }}
|
||||||
{{ environment_form.role(class="member-list____role-select__radio") }}
|
{{ environment_form.role(**{"v-on:change": "radioChange", "class": "member-list____role-select__radio"}) }}
|
||||||
<button
|
<button
|
||||||
class="usa-button"
|
class="usa-button"
|
||||||
type="button"
|
type="button"
|
||||||
v-on:click="toggleSection('edit-env-role')"
|
v-on:click="toggle"
|
||||||
>
|
>
|
||||||
{{ "common.close" | translate }}
|
{{ "common.close" | translate }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</toggler>
|
</environment-role>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user