diff --git a/tailbone/templates/generate_feature.mako b/tailbone/templates/generate_feature.mako index 658aab12..acd1db2f 100644 --- a/tailbone/templates/generate_feature.mako +++ b/tailbone/templates/generate_feature.mako @@ -47,6 +47,7 @@ ${h.hidden('feature_type', value='new-table')} ${h.hidden('app_prefix', **{'v-model': 'app.app_prefix'})} ${h.hidden('app_cap_prefix', **{'v-model': 'app.app_cap_prefix'})} + ${h.hidden('columns', **{':value': 'JSON.stringify(new_table.columns)'})}
@@ -93,6 +94,118 @@ + +
+ +
+
+
+ + New Column + +
+
+
+
+ + Delete All + +
+
+
+ + + + + + + + + +
+
+
@@ -207,8 +320,53 @@ this.new_table.description = `Represents a ${'$'}{this.new_table.model_title}.` } + ThisPageData.showingEditColumn = false + ThisPageData.editingColumn = null + ThisPageData.editingColumnName = null + ThisPageData.editingColumnDataType = null + ThisPageData.editingColumnNullable = null + ThisPageData.editingColumnDescription = null + + ThisPage.methods.addColumn = function(column) { + this.editingColumn = null + this.editingColumnName = null + this.editingColumnDataType = null + this.editingColumnNullable = true + this.editingColumnDescription = null + this.showingEditColumn = true + } + + ThisPage.methods.editColumnRow = function(column) { + this.editingColumn = column + this.editingColumnName = column.name + this.editingColumnDataType = column.data_type + this.editingColumnNullable = column.nullable + this.editingColumnDescription = column.description + this.showingEditColumn = true + } + + ThisPage.methods.saveColumn = function() { + if (this.editingColumn) { + column = this.editingColumn + } else { + column = {} + this.new_table.columns.push(column) + } + column.name = this.editingColumnName + column.data_type = this.editingColumnDataType + column.nullable = this.editingColumnNullable + column.description = this.editingColumnDescription + this.showingEditColumn = false + } + + ThisPage.methods.deleteColumn = function(index) { + this.new_table.columns.splice(index, 1) + } + ThisPage.methods.submitFeatureForm = function() { let form = this.$refs[this.featureType + '-form'] + // TODO: why do we have to set this? hidden field value is blank?! + form['feature_type'].value = this.featureType form.submit() }