Skip to content

Commit

Permalink
allow setting an initial query
Browse files Browse the repository at this point in the history
  • Loading branch information
dabernathy89 committed Oct 18, 2016
1 parent b00a879 commit 91516f3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
20 changes: 20 additions & 0 deletions dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:rules="rules"
:maxDepth="3"
:labels="labels"
:initialQuery="initialQuery"
@queryUpdated="queryUpdated"
></vue-query-builder>

Expand All @@ -36,6 +37,20 @@
data () {
return {
initialQuery: {
"logicalOperator": "Any",
"children": [
{
"type": "query-builder-rule",
"query": {
"rule": "first-name",
"selectedOperator": "equals",
"selectedOperand": "First Name",
"value": "John"
}
},
]
},
query: null,
labels: {
removeRule: "<span class='glyphicon glyphicon-remove'></span>",
Expand All @@ -47,6 +62,11 @@
id: "a-text-field",
label: "A Text Field",
},
{
type: "text",
id: "first-name",
label: "First Name",
},
{
type: "numeric",
id: "a-numeric-field",
Expand Down
8 changes: 4 additions & 4 deletions dev/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev/bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vue-query-builder.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/VueQueryBuilder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export default {
validator: function (value) {
return value >= 1
}
}
},
initialQuery: Object
},
data () {
Expand Down Expand Up @@ -126,6 +127,10 @@ export default {
}, {
deep: true
});
if ( typeof this.$options.propsData.initialQuery !== "undefined" ) {
this.query = deepClone(this.$options.propsData.initialQuery);
}
}
}
</script>
Expand Down

0 comments on commit 91516f3

Please sign in to comment.