2020-09-26 21:02:37 +00:00
|
|
|
<template>
|
|
|
|
<div class="modal-mask keyboard-shortcuts-modal">
|
|
|
|
<div @click.self="$router.back()" class="modal-container">
|
|
|
|
<div class="modal-content">
|
2021-01-17 17:57:57 +00:00
|
|
|
<card class="has-background-white has-no-shadow" title="Create A Saved Filter">
|
|
|
|
<p>
|
|
|
|
A saved filter is a virtual list which is computed from a set of filters each time it is
|
|
|
|
accessed. Once created, it will appear in a special namespace.
|
|
|
|
</p>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="title">Title</label>
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
v-model="savedFilter.title"
|
|
|
|
:class="{ 'disabled': savedFilterService.loading}"
|
|
|
|
:disabled="savedFilterService.loading"
|
|
|
|
class="input"
|
|
|
|
id="Title"
|
|
|
|
placeholder="The saved filter title goes here..."
|
|
|
|
type="text"
|
|
|
|
v-focus
|
|
|
|
/>
|
2020-09-26 21:02:37 +00:00
|
|
|
</div>
|
2021-01-17 17:57:57 +00:00
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="description">Description</label>
|
|
|
|
<div class="control">
|
|
|
|
<editor
|
|
|
|
v-model="savedFilter.description"
|
|
|
|
:class="{ 'disabled': savedFilterService.loading}"
|
|
|
|
:disabled="savedFilterService.loading"
|
|
|
|
:preview-is-default="false"
|
|
|
|
id="description"
|
|
|
|
placeholder="The description goes here..."
|
|
|
|
v-if="editorActive"
|
|
|
|
/>
|
2020-09-26 21:02:37 +00:00
|
|
|
</div>
|
2021-01-17 17:57:57 +00:00
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="filters">Filters</label>
|
|
|
|
<div class="control">
|
|
|
|
<filters
|
|
|
|
:class="{ 'disabled': savedFilterService.loading}"
|
|
|
|
:disabled="savedFilterService.loading"
|
|
|
|
class="has-no-shadow has-no-border"
|
|
|
|
v-model="filters"
|
|
|
|
/>
|
2020-09-26 21:02:37 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-17 17:57:57 +00:00
|
|
|
<x-button
|
|
|
|
:loading="savedFilterService.loading"
|
|
|
|
:disabled="savedFilterService.loading"
|
|
|
|
@click="create()"
|
|
|
|
class="is-fullwidth"
|
|
|
|
>
|
|
|
|
Create new saved filter
|
|
|
|
</x-button>
|
|
|
|
</card>
|
2020-09-26 21:02:37 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import LoadingComponent from '@/components/misc/loading'
|
|
|
|
import ErrorComponent from '@/components/misc/error'
|
|
|
|
import Filters from '@/components/list/partials/filters'
|
|
|
|
import SavedFilterService from '@/services/savedFilter'
|
|
|
|
import SavedFilterModel from '@/models/savedFilter'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'CreateSavedFilter',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
editorActive: false,
|
|
|
|
filters: {
|
|
|
|
sort_by: ['done', 'id'],
|
|
|
|
order_by: ['asc', 'desc'],
|
|
|
|
filter_by: ['done'],
|
|
|
|
filter_value: ['false'],
|
|
|
|
filter_comparator: ['equals'],
|
|
|
|
filter_concat: 'and',
|
|
|
|
filter_include_nulls: true,
|
|
|
|
},
|
|
|
|
savedFilterService: SavedFilterService,
|
|
|
|
savedFilter: SavedFilterModel,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
Filters,
|
|
|
|
editor: () => ({
|
2020-11-02 20:47:31 +00:00
|
|
|
component: import(/* webpackChunkName: "editor" */ '../../components/input/editor'),
|
2020-09-26 21:02:37 +00:00
|
|
|
loading: LoadingComponent,
|
|
|
|
error: ErrorComponent,
|
|
|
|
timeout: 60000,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.editorActive = false
|
|
|
|
this.$nextTick(() => this.editorActive = true)
|
|
|
|
|
|
|
|
this.savedFilterService = new SavedFilterService()
|
|
|
|
this.savedFilter = new SavedFilterModel()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
create() {
|
|
|
|
this.savedFilter.filters = this.filters
|
|
|
|
this.savedFilterService.create(this.savedFilter)
|
|
|
|
.then(r => {
|
|
|
|
this.$store.dispatch('namespaces/loadNamespaces')
|
|
|
|
this.$router.push({name: 'list.index', params: {listId: r.getListId()}})
|
|
|
|
})
|
|
|
|
.catch(e => this.error(e, this))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|