Allow user to create new fields for environment names
Currently only one of them is being created.
This commit is contained in:
parent
67700e13ba
commit
020e1b9cb0
@ -1,5 +1,5 @@
|
|||||||
from flask_wtf import Form
|
from flask_wtf import Form
|
||||||
from wtforms.fields import StringField, TextAreaField
|
from wtforms.fields import StringField, TextAreaField, FieldList
|
||||||
|
|
||||||
|
|
||||||
class NewProjectForm(Form):
|
class NewProjectForm(Form):
|
||||||
|
46
js/components/forms/new_project.js
Normal file
46
js/components/forms/new_project.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import textinput from '../text_input'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'new-project',
|
||||||
|
|
||||||
|
components: {
|
||||||
|
textinput
|
||||||
|
},
|
||||||
|
|
||||||
|
props: {
|
||||||
|
initialData: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
data: function () {
|
||||||
|
const {
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
environments = ['']
|
||||||
|
} = this.initialData
|
||||||
|
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
environments,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted: function () {
|
||||||
|
this.$root.$on('onEnvironmentAdded', this.addEnvironment)
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
addEnvironment: function (event) {
|
||||||
|
this.environments.push('')
|
||||||
|
},
|
||||||
|
|
||||||
|
removeEnvironment: function (index) {
|
||||||
|
if (this.environments.length > 1) {
|
||||||
|
this.environments.splice(index, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ import checkboxinput from './components/checkbox_input'
|
|||||||
import DetailsOfUse from './components/forms/details_of_use'
|
import DetailsOfUse from './components/forms/details_of_use'
|
||||||
import poc from './components/forms/poc'
|
import poc from './components/forms/poc'
|
||||||
import financial from './components/forms/financial'
|
import financial from './components/forms/financial'
|
||||||
|
import NewProject from './components/forms/new_project'
|
||||||
|
|
||||||
Vue.use(VTooltip)
|
Vue.use(VTooltip)
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ const app = new Vue({
|
|||||||
DetailsOfUse,
|
DetailsOfUse,
|
||||||
poc,
|
poc,
|
||||||
financial,
|
financial,
|
||||||
|
NewProject
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
closeModal: function(name) {
|
closeModal: function(name) {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
{% extends "base_workspace.html" %}
|
{% extends "base_workspace.html" %}
|
||||||
|
|
||||||
{% block workspace_content %}
|
{% block workspace_content %}
|
||||||
|
<new-project inline-template v-bind:initial-data='{{ form.data|tojson }}'>
|
||||||
<form method="POST" action="{{ url_for('workspaces.update_project', workspace_id=workspace.id) }}" >
|
<form method="POST" action="{{ url_for('workspaces.update_project', workspace_id=workspace.id) }}" >
|
||||||
{{ form.csrf_token }}
|
{{ form.csrf_token }}
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
@ -24,19 +25,21 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li class="block-list__item">
|
<li v-for="(_, i) in environments" class="block-list__item">
|
||||||
<span class="project-list-item__environment">
|
<span class="project-list-item__environment">
|
||||||
{{ TextInput(form.environment_name) }}
|
{{ TextInput(form.environment_name) }}
|
||||||
|
<span v-on:click="removeEnvironment(i)">{{ Icon('x') }}</span>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<a v-on:click="addEnvironment">Add another environment</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="action-group">
|
<div class="action-group">
|
||||||
<input type="submit" value="Create Project" class="action-group__action usa-button usa-button-big">
|
<input type="submit" value="Create Project" class="action-group__action usa-button usa-button-big">
|
||||||
<!-- <a href="/styleguide" class="action-group__action">Cancel</a> -->
|
<a href="{{ url_for('workspaces.workspace_projects', workspace_id=workspace.id) }}" class="action-group__action">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
</new-project>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user