Skip to content

Commit

Permalink
Merge pull request #819 from LibCrowds/dev
Browse files Browse the repository at this point in the history
Update form init
  • Loading branch information
alexandermendes committed Jun 26, 2018
2 parents 3cbade3 + 66760c6 commit b973500
Showing 1 changed file with 33 additions and 40 deletions.
73 changes: 33 additions & 40 deletions pages/admin/project/new/_category_short_name.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,35 @@ export default {
const endpoint = `/lc/projects/${params.category_short_name}/new`
return app.$axios.$get(endpoint).then(data => {
return {
endpoint: endpoint,
formModel: data.form,
built_projects: data.built_projects
built_projects: data.built_projects,
form: {
endpoint: endpoint,
method: 'post',
model: data.form,
schema: {
fields: [
{
type: 'input',
inputType: 'text',
label: 'Name',
model: 'name',
placeholder: 'Your Project Name',
hint: 'The name of the project (generated according to the ' +
'chosen template and volume).'
},
{
type: 'input',
inputType: 'text',
label: 'Short name',
model: 'short_name',
placeholder: 'your_project_name',
hint: 'An identifier used, for example, in the names of any ' +
'downloadable files (generated according to the ' +
'chosen template and volume).'
}
]
}
}
}
}).catch(err => {
error(err)
Expand All @@ -142,39 +168,6 @@ export default {
return this.$store.state.currentCollection
},
form () {
return {
endpoint: this.endpoint,
method: 'post',
model: this.formModel,
schema: {
fields: [
{
type: 'input',
inputType: 'text',
label: 'Name',
model: 'name',
readonly: true,
placeholder: 'Your Project Name',
hint: 'The name of the project (generated according to the ' +
'chosen template and volume).'
},
{
type: 'input',
inputType: 'text',
label: 'Short name',
model: 'short_name',
readonly: true,
placeholder: 'your_project_name',
hint: 'An identifier used, for example, in the names of any ' +
'downloadable files (generated according to the ' +
'chosen template and volume).'
}
]
}
}
},
availableTemplates () {
return this.currentCollection.info.templates.filter(tmpl => {
// Check if project built with parent template is complete
Expand Down Expand Up @@ -233,7 +226,7 @@ export default {
* The template.
*/
selectTemplate (tmpl) {
this.formModel.template_id = tmpl.id
this.form.model.template_id = tmpl.id
this.setNameAndShortName()
},
Expand All @@ -243,7 +236,7 @@ export default {
* The volume.
*/
selectVolume (volume) {
this.formModel.volume_id = volume.id
this.form.model.volume_id = volume.id
this.setNameAndShortName()
},
Expand All @@ -254,8 +247,8 @@ export default {
const tmplName = this.selectedTemplate.name || ''
const volName = this.selectedVolume.name || ''
const name = `${tmplName}: ${volName}`
this.formModel.name = name
this.formModel.short_name = this.getShortname(name)
this.form.model.name = name
this.form.model.short_name = this.getShortname(name)
},
/**
Expand Down

0 comments on commit b973500

Please sign in to comment.