Skip to content

Commit

Permalink
#988, #1003: Added logic to persist custom names and types in and out…
Browse files Browse the repository at this point in the history
…side of app life. Corrected ids so unique.
  • Loading branch information
mattRedBox committed Jun 3, 2020
1 parent cedad98 commit 7092e15
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 60 deletions.
6 changes: 3 additions & 3 deletions src/renderer/partials/Contributors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<div class="inputs-container">
<div
v-for="prop in Object.keys(contributor)"
:id="prop + gindex"
:key="prop + gindex"
:id="'contributor' + prop + gindex"
:key="'contributor' + prop + gindex"
class="input-group"
>
<span class="input-group-addon input-sm">{{ prop }}</span>
<select
v-if="prop === 'role'"
:id="prop"
:id="prop + gindex"
:value="contributor[prop]"
class="form-control input-sm"
@input="setContributorProp(gindex, prop, $event.target.value)"
Expand Down
50 changes: 18 additions & 32 deletions src/renderer/partials/Customs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
>
<div
v-for="prop in Object.keys(custom)"
:id="prop + gindex"
:key="prop + gindex"
:id="'custom' + prop + gindex"
:key="'custom' + prop + gindex"
class="inputs-container"
>
<div
Expand All @@ -26,32 +26,23 @@
@input="setCustomProp(gindex, prop, $event.target.value)"
>
</div>
<div class="input-group type">
<div
v-else
class="input-group type"
>
<span class="input-group-addon input-sm">type</span>
<div class="custom-types">
<label
v-for="customType of customTypes"
:key="customType"
:key="customType + gindex"
class="checkbox-inline form-control input-sm"
><input
:id="prop + customType + gindex"
type="checkbox"
value=""
:checked="includesCustomProp(custom[prop], customType)"
@click="setCustomPropChecked(gindex, prop, customType, $event.target.checked)"
><span>{{ customType }}</span></label>
</div>
<!-- <select-->
<!-- :id="prop + gindex"-->
<!-- v-model="selectedCustomTypes"-->
<!-- class="form-control custom-types input-sm"-->
<!-- multiple-->
<!-- >-->
<!-- <option-->
<!-- v-for="customType of customTypes"-->
<!-- :key="customType"-->
<!-- :value="customType"-->
<!-- >-->
<!-- {{ customType }}-->
<!-- </option>-->
<!-- </select>-->
</div>
<div
v-show="errors.has(prop + gindex)"
Expand Down Expand Up @@ -127,11 +118,6 @@ export default {
}
}
},
watch: {
selectedCustomTypes: function (selected) {
this.setProperty('customTableProperties', this.customsObject(selected))
}
},
mounted: function () {
this.initCustoms()
},
Expand All @@ -149,15 +135,18 @@ export default {
this.customs = customs
},
emptyCustom: function () {
return { 'name': '' }
return { 'name': '', type: [] }
},
initCustoms: function () {
this.customs = this.getProperty('customs')
this.selectedCustomTypes = this.getCustomTypes()
},
getCustomTypes: function () {
console.log('in get custom types')
return []
includesCustomProp: function (current, customType) {
return _.includes(current, customType)
},
setCustomPropChecked: function (index, prop, value, isChecked) {
const existingCustom = _.get(this.customs, `[${index}][${prop}]`)
const updatedCustom = isChecked ? _.union(existingCustom, [value]) : _.without(existingCustom, value)
this.setCustomProp(index, prop, updatedCustom)
},
setCustomProp: function (index, prop, value) {
if (typeof this.defaultSetter !== 'undefined') {
Expand All @@ -167,9 +156,6 @@ export default {
}
let customs = this.getProperty('customs') || []
this.customs = customs
},
customsObject: function (ids) {
return []
}
}
}
Expand Down
25 changes: 0 additions & 25 deletions src/renderer/store/modules/custom.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@

const state = {
customProperties: {}
// customColumnProperties: [],
// customTableProperties: [],
// customPackageProperties: []
}

const getters = {
// getCustomColumnProperties: state => {
// return state.customColumnProperties
// },
// getCustomTableProperties: state => {
// return state.customTableProperties
// },
// getCustomPackageProperties: state => {
// return state.customPackageProperties
// },
getCustomProperty: (state, getters) => (property) => {
return _.get(state.customProperties, property.key)
},
Expand All @@ -27,25 +15,12 @@ const getters = {
const mutations = {
pushCustomProperty (state, property) {
_.set(state.customProperties, property.key, property.value)
const customTypes = _.get(property, 'types')
// if (_.includes(customTypes, 'column') && _.indexOf(state.customColumnProperties, property.key) === -1) {
// state.customColumnProperties.push(property.key)
// }
// if (_.includes(customTypes, 'table') && _.indexOf(state.customColumnProperties, property.key) === -1) {
// state.customTableProperties.push(property.key)
// }
// if (_.includes(customTypes, 'package') && _.indexOf(state.customColumnProperties, property.key) === -1) {
// state.customPackageProperties.push(property.key)
// }
},
removeCustomProperty (state, propertyKey) {
_.unset(state, 'customProperties', propertyKey)
},
resetCustomProperties (state) {
state.customProperties = {}
// state.customColumnProperties = []
// state.customTableProperties = []
// state.customPackageProperties = []
}
}

Expand Down

0 comments on commit 7092e15

Please sign in to comment.