diff --git a/src/renderer/partials/ColumnProperties.vue b/src/renderer/partials/ColumnProperties.vue
index d9e514f23..4cfcef26b 100644
--- a/src/renderer/partials/ColumnProperties.vue
+++ b/src/renderer/partials/ColumnProperties.vue
@@ -50,11 +50,13 @@
-
+
+
-
+
+
@@ -194,7 +196,9 @@ export default {
'geojson': ['required', 'unique', 'minLength', 'maxLength', 'enum'],
'any': ['required', 'unique', 'enum']
},
- constraintBooleanBindings: ['required', 'unique']
+ constraintBooleanBindings: ['required', 'unique'],
+ trueValues: ['true', 'True', 'TRUE', '1'],
+ falseValues: ['false', 'False', 'FALSE', '0']
}
},
subscriptions() {
@@ -247,26 +251,12 @@ export default {
// ensure format also updates after setting type
let temp3 = this.typeProperty
}
- },
- getBooleanTypes: {
- async get() {
-
- },
- watch() {
-
- }
}
},
methods: {
...mapMutations([
- 'pushColumnProperty', 'pushTrueValues', 'pushFalseValues'
+ 'pushColumnProperty'
]),
- setTrueValues: function(values) {
-
- },
- setFalseValues: function(values) {
-
- },
isBooleanConstraint: function(option) {
return this.constraintBooleanBindings.indexOf(option) > -1
},
@@ -400,9 +390,85 @@ export default {
formatPropertyValueWrapper: function() {
return this.formatPropertyValue
},
+ setTrueValues: function(values) {
+ console.log('setting true values')
+ let withoutEmpties = this.removeStringEmpties(values)
+ let array = this.getNoDuplicatesArrayFromString(withoutEmpties)
+ this.setProperty('trueValues', values)
+ },
+ setFalseValues: function(values) {
+ console.log('setting true values')
+ let withoutEmpties = this.removeStringEmpties(values)
+ let array = this.getNoDuplicatesArrayFromString(withoutEmpties)
+ this.setProperty('falseValues', values)
+ },
+ // setTrueRawValues: function(values) {
+ // // let withoutEmpties = this.removeStringEmpties(values)
+ // // let array = this.getNoDuplicatesArrayFromString(withoutEmpties)
+ // this.setProperty('trueRawValues', values)
+ // },
+ // setFalseRawValues: function(values) {
+ // // let withoutEmpties = this.removeStringEmpties(values)
+ // // let array = this.getNoDuplicatesArrayFromString(withoutEmpties)
+ // this.setProperty('falseRawValues', values)
+ // },
+ getNoDuplicatesArrayFromString: function(values) {
+ return Array.from(new Set(values.split(',')))
+ },
+ getTrueValues: function() {
+ return this.getBooleanValuesOrDefaultAsString('trueValues')
+ },
+ getFalseValues: function() {
+ return this.getBooleanValuesOrDefaultAsString('falseValues')
+ },
+ getBooleanValuesOrDefaultAsString: function(booleanType) {
+ let values = this.getBooleanValuesOrDefault(booleanType)
+ console.log(values instanceof Array)
+ if (values instanceof Array) {
+ return values.join()
+ }
+ return values
+ },
+ getBooleanValuesOrDefault: function(booleanType) {
+ let values
+ if (booleanType === 'trueValues') {
+ values = this.getProperty('trueValues')
+ if (!values) {
+ // values = this.getProperty('trueRawValues')
+ // if (!values) {
+ values = this.setAndGetDefaultTrueValues()
+ // }
+ }
+ } else {
+ values = this.getProperty('falseValues')
+ if (!values) {
+ // values = this.getProperty('falseRawValues')
+ // if (!values) {
+ values = this.setAndGetDefaultFalseValues()
+ // }
+ }
+ }
+ return values
+ },
+ setAndGetDefaultTrueValues: function() {
+ let values = [...this.trueValues]
+ this.setProperty('trueValues', values)
+ return values
+ },
+ setAndGetDefaultFalseValues: function() {
+ let values = [...this.falseValues]
+ this.setProperty('falseValues', values)
+ return values
+ },
+ removeStringEmpties: function(string) {
+ let withoutInternalEmpties = string.replace(/[,]+/g, ',')
+ // also remove 'empty' if at start or end
+ let trimmed = _.trim(withoutInternalEmpties, ',')
+ return trimmed
+ },
// we cannot access frictionless' boolean types directly, so at least offer error message if not correct
validateBooleans: function() {
- for (const booleanValues of [this.getTrueValues, this.getFalseValues]) {
+ for (const booleanValues of [this.trueValues, this.falseValues]) {
for (const value of booleanValues) {
const result = castBoolean('default', value)
if (typeof result !== 'boolean') {
@@ -414,7 +480,7 @@ export default {
},
computed: {
...mapGetters([
- 'getActiveTab', 'getHotColumnProperty', 'getConstraint', 'getAllHotTablesColumnNames', 'getTrueValues', 'getFalseValues'
+ 'getActiveTab', 'getHotColumnProperty', 'getConstraint', 'getAllHotTablesColumnNames'
]),
getNameProperty() {
let allColumns = this.allTablesAllColumnsNames[this.activeCurrentHotId] || []
diff --git a/src/renderer/store/modules/hots.js b/src/renderer/store/modules/hots.js
index a2c8976fd..0fde569b1 100644
--- a/src/renderer/store/modules/hots.js
+++ b/src/renderer/store/modules/hots.js
@@ -4,9 +4,7 @@ const state = {
hotTabs: {},
packageProperties: {},
provenanceProperties: { markdown: '', errors: [] },
- fkPackageComponents: {},
- trueValues: ['true', 'True', 'TRUE', '1'],
- falseValues: ['false', 'False', 'FALSE', '0']
+ fkPackageComponents: {}
}
export function getHotColumnPropertiesFromPropertyObject(property) {
@@ -28,12 +26,6 @@ export function getHotIdFromTabIdFunction() {
}
const getters = {
- getTrueValues: state => {
- return state.trueValues
- },
- getFalseValues: state => {
- return state.falseValues
- },
getFkPackageComponents: (state, getters) => (url) => {
return state.fkPackageComponents[url]
},
@@ -150,14 +142,6 @@ const getters = {
}
const mutations = {
- pushTrueValues(state, values) {
- state.trueValues.length = 0
- state.trueValues.push(...values)
- },
- pushFalseValues(state, values) {
- state.falseValues.length = 0
- state.falseValues.push(...values)
- },
pushFkPackageComponents(state, property) {
_.set(state.fkPackageComponents[property.url], property.tableName, property.fields)
},