Update record field query fields selection to limit filter out unqueryable fields, and replace it with c-input-select
This commit is contained in:
@@ -57,9 +57,12 @@
|
||||
:label="$t('kind.record.queryFieldsLabel')"
|
||||
label-class="text-primary"
|
||||
>
|
||||
<b-form-select
|
||||
<c-input-select
|
||||
v-model="f.options.queryFields"
|
||||
:options="queryFieldOptions"
|
||||
label="text"
|
||||
:reduce="field => field.value"
|
||||
:placeholder="$t('kind.record.queryFieldsPlaceholder')"
|
||||
multiple
|
||||
/>
|
||||
</b-form-group>
|
||||
@@ -116,6 +119,7 @@
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import { NoID } from '@cortezaproject/corteza-js'
|
||||
import { nonQueryableFieldKinds } from 'corteza-webapp-compose/src/lib/record-filter'
|
||||
import base from './base'
|
||||
|
||||
export default {
|
||||
@@ -167,7 +171,9 @@ export default {
|
||||
fieldOptions () {
|
||||
const fields = this.selectedModule
|
||||
? this.selectedModule.fields
|
||||
.map(({ label, name }) => { return { value: name, text: label || name } })
|
||||
.map(({ label, name, kind }) => {
|
||||
return { value: name, text: label || name, kind }
|
||||
})
|
||||
: []
|
||||
return [
|
||||
...fields.sort((a, b) => a.text.localeCompare(b.text)),
|
||||
@@ -175,7 +181,7 @@ export default {
|
||||
},
|
||||
|
||||
queryFieldOptions () {
|
||||
return this.fieldOptions.slice(1)
|
||||
return this.fieldOptions.filter(({ kind }) => !nonQueryableFieldKinds.includes(kind))
|
||||
},
|
||||
|
||||
labelField () {
|
||||
|
||||
@@ -167,7 +167,7 @@ import base from './base'
|
||||
import { debounce } from 'lodash'
|
||||
import { compose, NoID } from '@cortezaproject/corteza-js'
|
||||
import { mapActions, mapGetters } from 'vuex'
|
||||
import { evaluatePrefilter, isFieldInFilter } from 'corteza-webapp-compose/src/lib/record-filter'
|
||||
import { queryToFilter, evaluatePrefilter, isFieldInFilter } from 'corteza-webapp-compose/src/lib/record-filter'
|
||||
import Pagination from '../Common/Pagination.vue'
|
||||
|
||||
export default {
|
||||
@@ -371,10 +371,8 @@ export default {
|
||||
}
|
||||
|
||||
if (query.length > 0) {
|
||||
// Construct query
|
||||
query = qf.map(qf => {
|
||||
return `${qf} LIKE '%${query}%'`
|
||||
}).join(' OR ')
|
||||
const fields = qf.map(f => this.module.fields.find(({ name }) => name === f))
|
||||
query = queryToFilter(query, '', fields)
|
||||
}
|
||||
|
||||
this.fetchPrefiltered({ namespaceID, moduleID, query, sort: this.sortString(), limit, pageCursor })
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import moment from 'moment'
|
||||
|
||||
const noneQueryableFieldNames = ['recordID']
|
||||
const noneQueryableFieldKinds = ['Number', 'Record', 'User', 'Bool', 'DateTime', 'File', 'Geometry']
|
||||
export const nonQueryableFieldNames = ['recordID']
|
||||
export const nonQueryableFieldKinds = ['Number', 'Record', 'User', 'Bool', 'DateTime', 'File', 'Geometry']
|
||||
|
||||
// Generate record list sql query string based on filter object input
|
||||
|
||||
@@ -171,7 +171,7 @@ export function queryToFilter (searchQuery = '', prefilter = '', fields = [], re
|
||||
// Create query for search string
|
||||
if (searchQuery || searchQuery === 0) {
|
||||
searchQuery = fields
|
||||
.filter(f => !noneQueryableFieldNames.includes(f.name) && !noneQueryableFieldKinds.includes(f.kind))
|
||||
.filter(f => !nonQueryableFieldNames.includes(f.name) && !nonQueryableFieldKinds.includes(f.kind))
|
||||
.map(f => getFieldFilter(f.name, f.kind, searchQuery, 'LIKE'))
|
||||
.filter(q => !!q)
|
||||
.join(' OR ')
|
||||
|
||||
@@ -118,6 +118,7 @@ kind:
|
||||
moduleLabel: Module
|
||||
modulePlaceholder: Pick module
|
||||
queryFieldsLabel: Query fields on search
|
||||
queryFieldsPlaceholder: If no fields are picked the Label field will be used
|
||||
moduleField: Label field
|
||||
variantField: Variant field
|
||||
fieldFromModuleField: Label field from related module field
|
||||
|
||||
Reference in New Issue
Block a user