Skip to content

Commit

Permalink
Merge pull request #1996 from noirbizarre/harvest-edit-preview
Browse files Browse the repository at this point in the history
Fix harvest preview in edit form not taking configuration (features and filters)
  • Loading branch information
noirbizarre committed Jan 25, 2019
2 parents dc8c37d + 2e869aa commit 2fba14d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@
- Added the missing `number` input field widget [#1993](https://github.com/opendatateam/udata/pull/1993)
- Fix the organization private datasets and reuses counters [#1994](https://github.com/opendatateam/udata/pull/1994)
- Disable autocorrect, spellcheck... on search and completion fields [#1995](https://github.com/opendatateam/udata/pull/1995)
- Fix harvest preview in edit form not taking configuration (features and filters) [#1996](https://github.com/opendatateam/udata/pull/1996)

## 1.6.2 (2018-11-05)

Expand Down
16 changes: 16 additions & 0 deletions js/components/harvest/config-form.vue
Expand Up @@ -38,6 +38,7 @@ import FeatureField from './feature-field.vue';
import FilterField from './filter-field.vue';
export default {
name: 'config-form',
components: {FeatureField, FilterField},
data() {
return {
Expand All @@ -48,6 +49,17 @@ export default {
events: {
'filter:delete': function(index) {
this.config.filters.splice(index, 1);
this.$nextTick(() => {
this.$dispatch('form:change', this)
})
},
'field:change': function(field, value) {
this.$dispatch('form:change', this, field, value);
return true; // Let the event continue its bubbling
},
// Custom fields are not wrapped into a FormField
'field:value-change': function(value) {
this.$dispatch('form:change', this);
}
},
props: {
Expand All @@ -71,6 +83,7 @@ export default {
this.$set('config.filters', []);
}
this.config.filters.push({key: undefined, value: undefined});
this.$dispatch('form:change', this)
},
serialize() {
const config = {};
Expand All @@ -86,6 +99,9 @@ export default {
}));
}
return config;
},
validate() {
return true; // Always valid
}
}
}
Expand Down
13 changes: 11 additions & 2 deletions js/components/harvest/feature-field.vue
Expand Up @@ -3,6 +3,7 @@
<label :for="id">
<input v-el:checkbox type="checkbox"
:id="id" :name="key" :checked="checked"
@input="onChange"
/>
{{ feature.label }}
</label>
Expand Down Expand Up @@ -31,8 +32,16 @@ export default {
key() {
return this.feature.key;
},
value() {
return this.$els.checkbox.checked;
value: {
cache: false,
get() {
return this.$els.checkbox.checked;
}
}
},
methods: {
onChange(evt) {
this.$dispatch('field:value-change', evt.target.checked);
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions js/components/harvest/filter-field.vue
@@ -1,13 +1,13 @@
<template>
<div class="input-group filter-group">
<select class="form-control filter-group__type" v-model="type">
<select class="form-control filter-group__type" v-model="type" @change="onChange">
<option v-for="t in TYPES" :value="t.value" :key="t.value">{{ t.label }}</option>
</select>
<select class="form-control filter-group__key" v-model="key">
<select class="form-control filter-group__key" v-model="key" @change="onChange">
<option v-for="c in choices" :value="c.key" :key="c.key">{{ c.label }}</option>
</select>
<input type="text" class="form-control filter-group__value" v-model="value"
:placeholder="placeholder"></input>
:placeholder="placeholder" @change="onChange"></input>
<span class="input-group-btn">
<button class="btn btn-danger" type="button" @click.prevent="onDelete">
<span class="fa fa-remove">
Expand Down Expand Up @@ -52,6 +52,9 @@ export default {
}
},
methods: {
onChange(evt) {
this.$dispatch('field:value-change', evt.target.value);
},
onDelete() {
this.$dispatch('filter:delete', this.index);
}
Expand Down
7 changes: 7 additions & 0 deletions js/views/harvester-edit.vue
Expand Up @@ -48,6 +48,13 @@ export default {
}
}
},
ready() {
this.source.$on('updated', () => {
this.$nextTick(() => {
this.previewSource = Object.assign(new HarvestSource(), this.$refs.form.serialize());
});
});
},
methods: {
save() {
const form = this.$refs.form;
Expand Down

0 comments on commit 2fba14d

Please sign in to comment.