Skip to content

Commit

Permalink
#988, #1003: Set custom for column properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattRedBox committed Jun 15, 2020
1 parent 1064382 commit 9c819c7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
22 changes: 21 additions & 1 deletion src/renderer/partials/ColumnProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@
class="form-control label-sm col-sm-9"
@input="setProperty(formprop.key, $event.target.value)"
/>
<component
:is="formprop.key"
v-else-if="isSharedComponent(formprop.key)"
:currentHotId="currentHotId"
:getProperty="getProperty"
:isLocked="isLocked"
:setProperty="setProperty"
/>
<input
v-else-if="formprop.key === 'name'"
:id="formprop.key"
Expand Down Expand Up @@ -295,18 +303,23 @@ import {
} from '../rxSubject.js'
import ColumnTooltip from '../mixins/ColumnTooltip'
import ValidationRules from '../mixins/ValidationRules'
import customs from '@/partials/Customs'
import { isValidPatternForType } from '../dateFormats.js'
import { castBoolean, castNumber, castInteger } from 'tableschema/lib/types'
import { ERROR as tableSchemaError } from 'tableschema/lib/config'
import { LockProperties } from '../lockProperties'
import PreferenceProperty from '../mixins/PreferenceProperty'
Vue.use(VueRx, {
Subscription
})
Vue.use(AsyncComputed)
export default {
name: 'Column',
components: {
customs
},
extends: SideNav,
mixins: [ValidationRules, ColumnTooltip],
mixins: [ValidationRules, ColumnTooltip, PreferenceProperty],
props: {
cIndex: {
type: Number,
Expand Down Expand Up @@ -397,6 +410,10 @@ export default {
tooltipId: 'tooltip-column-rdfType',
tooltipView: 'tooltipColumnRdfType',
type: 'url'
},
{
label: 'Custom Properties',
key: 'customs'
}
],
formats: {
Expand Down Expand Up @@ -600,6 +617,9 @@ export default {
let hotId = this.activeCurrentHotId
let getter = this.getter(hotId, key)
let property = this.getHotColumnProperty(getter)
if (typeof property === 'undefined') {
property = this.setPreferencesAsDefault(key, this.setProperty)
}
return property
},
setProperty: function (key, value) {
Expand Down
28 changes: 13 additions & 15 deletions src/renderer/partials/Customs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import {ipcRenderer as ipc} from "electron"
:key="customType + gindex"
class="checkbox-inline form-control input-sm"
><input
:id="prop + customType + gindex"
:id="prop + gindex + customType"
:name="prop + gindex + customType"
type="checkbox"
:checked="includesCustomProp(custom[prop], customType)"
@click="setCustomPropChecked(gindex, prop, customType, $event.target.checked)"
Expand Down Expand Up @@ -107,6 +108,7 @@ import AsyncComputed from 'vue-async-computed'
import ValidationRules from '../mixins/ValidationRules'
import Vue from 'vue'
import { preferenceUpdate$ } from '../rxSubject'
import { filter } from 'rxjs/operators'
import { ipcRenderer as ipc } from 'electron'
Vue.use(AsyncComputed)
export default {
Expand Down Expand Up @@ -145,21 +147,9 @@ export default {
created: function () {
const self = this
if (!this.isChildOfPreferences) {
this.$subscribeTo(preferenceUpdate$, function (key) {
console.log(`inside for ${key}`)
if (key === 'customs') {
console.log(`updated customs property in rx for ${key}`)
self.mergeDefaultPreferencesIntoStore()
}
preferenceUpdate$.pipe(filter(key => key === 'customs')).subscribe(function (key) {
const temp = self.mergeDefaultPreferencesIntoStore()
})
// preferenceUpdate$.pipe(filter(key => key === 'customs')).subscribe(function (key) {
// if (key === 'customs') {
// console.log(`updated customs property in rx for ${key}`)
// const temp = self.mergePreferencesAsDefault(key, self.setProperty)
// } else {
// console.log('no custom key')
// }
// })
}
this.$validator.extend('unique_name', {
getMessage: function (field) {
Expand Down Expand Up @@ -267,6 +257,14 @@ export default {
this.setProperty(`customs[${index}][${prop}]`, value)
}
this.customs = this.getProperty('customs') || []
},
errorsHasType: function (prop, gindex) {
const self = this
return _.find(this.customTypes, function (customType) { return self.errors.has(prop + customType + gindex) })
},
errorsFirst: function (prop, gindex) {
const self = this
return _.find(this.customTypes, function (customType) { return self.errors.first(prop + customType + gindex) })
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/renderer/partials/PackageProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
</form>
</template>
<script>
import Vue from 'vue'
import VueRx from 'vue-rx'
import SideNav from '@/partials/SideNav'
import licenses from '@/partials/Licenses'
import sources from '@/partials/Sources'
Expand All @@ -67,11 +65,6 @@ import ValidationRules from '@/mixins/ValidationRules'
import { mapGetters, mapMutations } from 'vuex'
import autosize from 'autosize'
import PreferenceProperty from '../mixins/PreferenceProperty'
import { Subscription } from 'rxjs'
Vue.use(VueRx, {
Subscription
})
export default {
name: 'Packager',
components: {
Expand Down
1 change: 0 additions & 1 deletion src/renderer/partials/TableProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ export default {
const propertyArg = this.propertyGetObject(key)
let tableProperty = this.getTableProperty(propertyArg)
if (typeof tableProperty === 'undefined') {
console.log(`checking table property get for ${key}`)
tableProperty = this.setPreferencesAsDefault(key, this.setProperty)
}
return tableProperty
Expand Down

0 comments on commit 9c819c7

Please sign in to comment.