-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1812 from noirbizarre/harvest-config-admin
Harvest config admin
- Loading branch information
Showing
13 changed files
with
256 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<template> | ||
<form class="config-form" role="form" v-el:form> | ||
<!-- Filters --> | ||
<div v-if="hasFilters" class="vertical-field form-group"> | ||
<span class="form-help" | ||
v-popover="description" popover-trigger="hover" popover-placement="left"> | ||
</span> | ||
<label class="filter-label">{{ _('Filters') }}</label> | ||
<filter-field v-for="(idx,filter) in config.filters" | ||
:choices="backend.filters" :key="filter.key" :value="filter.value" | ||
:index="idx" :type="filter.type" | ||
v-ref:filters | ||
> | ||
</filter-field> | ||
<label :for="field.id" class="help-block" :key="error" | ||
v-for="error in errors">{{error}}</label> | ||
<button class="btn btn-success" @click.prevent="addFilter"> | ||
<span class="fa fa-fw fa-plus"></span> | ||
{{ _('Add a filter') }} | ||
</button> | ||
</div> | ||
</form> | ||
</template> | ||
|
||
<script> | ||
import FilterField from './filter-field.vue'; | ||
export default { | ||
components: {FilterField}, | ||
data() { | ||
return { | ||
description: this._('A set of filters to apply'), | ||
}; | ||
}, | ||
events: { | ||
'filter:delete': function(index) { | ||
this.config.filters.splice(index, 1); | ||
} | ||
}, | ||
props: { | ||
config: { | ||
type: Object, | ||
default: () => {}, | ||
}, | ||
backend: Object, | ||
}, | ||
computed: { | ||
hasFilters() { | ||
return this.backend && this.backend.filters.length; | ||
} | ||
}, | ||
methods: { | ||
addFilter() { | ||
if (!this.config.filters) { | ||
this.$set('config.filters', []); | ||
} | ||
this.config.filters.push({key: undefined, value: undefined}); | ||
}, | ||
serialize() { | ||
const config = {}; | ||
if (this.hasFilters) { | ||
config.filters = this.$refs.filters.map(vm => ({ | ||
key: vm.key, value: vm.value, type: vm.type | ||
})); | ||
} | ||
return config; | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="less"> | ||
.config-form { | ||
.filter-label { | ||
display: block; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<template> | ||
<div class="input-group filter-group"> | ||
<select class="form-control filter-group__type" v-model="type"> | ||
<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"> | ||
<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> | ||
<span class="input-group-btn"> | ||
<button class="btn btn-danger" type="button" @click.prevent="onDelete"> | ||
<span class="fa fa-remove"> | ||
</button> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import {_} from 'i18n'; | ||
const TYPES = [ | ||
{value: 'include', label: _('Include')}, | ||
{value: 'exclude', label: _('Exclude')}, | ||
]; | ||
export default { | ||
data() { | ||
return {TYPES}; | ||
}, | ||
props: { | ||
choices: Array, | ||
type: { | ||
type: String, | ||
validator: value => TYPES.map(t => t.value).includes(value), | ||
default: 'include', | ||
}, | ||
key: [String, null], | ||
value: undefined, | ||
index: Number, | ||
}, | ||
computed: { | ||
hasData() { | ||
return this.key || this.value; | ||
}, | ||
isDefined() { | ||
return this.key && this.value; | ||
}, | ||
placeholder() { | ||
if (!this.key || !this.choices) return; | ||
return this.choices.find(c => c.key == this.key).description; | ||
} | ||
}, | ||
methods: { | ||
onDelete() { | ||
this.$dispatch('filter:delete', this.index); | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="less"> | ||
.filter-group { | ||
display: flex; | ||
margin-bottom: 5px; | ||
.form-control { | ||
border-right: none; | ||
} | ||
.filter-group__type { | ||
flex: 0 1 auto; | ||
width: auto; | ||
} | ||
.filter-group__key { | ||
flex: 0 1 auto; | ||
width: auto; | ||
} | ||
.filter-group__value { | ||
flex: 1 0 auto; | ||
width: auto; | ||
} | ||
.input-group-btn { | ||
flex: 0 0; | ||
width: auto; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.