mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 21:21:50 +08:00
Fix advanced filters for ID and Name columns [SCI-6496] (#3865)
This commit is contained in:
parent
c92dc1fd81
commit
dd5939e89d
5 changed files with 63 additions and 8 deletions
|
@ -21,7 +21,7 @@ const DEFAULT_FILTERS = [
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
column: {
|
column: {
|
||||||
data_type: 'RepositoryTextValue',
|
data_type: 'RepositoryNonEmptyTextValue',
|
||||||
id: 'row_id',
|
id: 'row_id',
|
||||||
name: I18n.t('repositories.table.id')
|
name: I18n.t('repositories.table.id')
|
||||||
},
|
},
|
||||||
|
@ -31,7 +31,7 @@ const DEFAULT_FILTERS = [
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
column: {
|
column: {
|
||||||
data_type: 'RepositoryTextValue',
|
data_type: 'RepositoryNonEmptyTextValue',
|
||||||
id: 'row_name',
|
id: 'row_name',
|
||||||
name: I18n.t('repositories.table.row_name')
|
name: I18n.t('repositories.table.row_name')
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// filter types
|
// filter types
|
||||||
|
import RepositoryNonEmptyTextValue from 'vue/repository_filter/filters/repositoryNonEmptyTextValue.vue'
|
||||||
import RepositoryAssetValue from 'vue/repository_filter/filters/repositoryAssetValue.vue'
|
import RepositoryAssetValue from 'vue/repository_filter/filters/repositoryAssetValue.vue'
|
||||||
import RepositoryTextValue from 'vue/repository_filter/filters/repositoryTextValue.vue'
|
import RepositoryTextValue from 'vue/repository_filter/filters/repositoryTextValue.vue'
|
||||||
import RepositoryNumberValue from 'vue/repository_filter/filters/repositoryNumberValue.vue'
|
import RepositoryNumberValue from 'vue/repository_filter/filters/repositoryNumberValue.vue'
|
||||||
|
@ -45,6 +46,7 @@
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
DropdownSelector,
|
DropdownSelector,
|
||||||
|
RepositoryNonEmptyTextValue,
|
||||||
RepositoryAssetValue,
|
RepositoryAssetValue,
|
||||||
RepositoryTextValue,
|
RepositoryTextValue,
|
||||||
RepositoryNumberValue,
|
RepositoryNumberValue,
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
<template>
|
||||||
|
<div class="filter-attributes">
|
||||||
|
<div class="operator-selector">
|
||||||
|
<DropdownSelector
|
||||||
|
:disableSearch="true"
|
||||||
|
:options="this.operators"
|
||||||
|
:selectedValue="this.operator"
|
||||||
|
:selectorId="`OperatorSelector${this.filter.id}`"
|
||||||
|
@dropdown:changed="updateOperator"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="sci-input-container">
|
||||||
|
<input
|
||||||
|
class="sci-input-field"
|
||||||
|
type="text"
|
||||||
|
name="value"
|
||||||
|
v-model="value"
|
||||||
|
:placeholder= "this.i18n.t('repositories.show.repository_filter.filters.types.RepositoryNonEmptyTextValue.input_placeholder', {name: this.filter.column.name})"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import FilterMixin from 'vue/repository_filter/mixins/filter.js'
|
||||||
|
import DropdownSelector from 'vue/shared/dropdown_selector.vue'
|
||||||
|
export default {
|
||||||
|
name: 'RepositoryNonEmptyTextValue',
|
||||||
|
mixins: [FilterMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
operators: [
|
||||||
|
{ value: 'contains', label: this.i18n.t('repositories.show.repository_filter.filters.operators.contains') },
|
||||||
|
{ value: 'doesnt_contain', label: this.i18n.t('repositories.show.repository_filter.filters.operators.does_not_contain') }
|
||||||
|
],
|
||||||
|
operator: 'contains',
|
||||||
|
value: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
DropdownSelector
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
value() {
|
||||||
|
this.parameters = { text: this.value };
|
||||||
|
this.updateFilter();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
isBlank(){
|
||||||
|
return this.operator == 'contains' && !this.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -160,8 +160,6 @@ class RepositoryDatatableService
|
||||||
repository_rows
|
repository_rows
|
||||||
.where.not("(#{RepositoryRow::PREFIXED_ID_SQL})::text ILIKE ?",
|
.where.not("(#{RepositoryRow::PREFIXED_ID_SQL})::text ILIKE ?",
|
||||||
"%#{ActiveRecord::Base.sanitize_sql_like(filter_element_params.dig(:parameters, :text))}%")
|
"%#{ActiveRecord::Base.sanitize_sql_like(filter_element_params.dig(:parameters, :text))}%")
|
||||||
when 'empty'
|
|
||||||
repository_rows.where(id: nil)
|
|
||||||
else
|
else
|
||||||
raise ArgumentError, 'Wrong operator for RepositoryRow ID!'
|
raise ArgumentError, 'Wrong operator for RepositoryRow ID!'
|
||||||
end
|
end
|
||||||
|
@ -176,8 +174,6 @@ class RepositoryDatatableService
|
||||||
repository_rows
|
repository_rows
|
||||||
.where.not('repository_rows.name ILIKE ?',
|
.where.not('repository_rows.name ILIKE ?',
|
||||||
"%#{ActiveRecord::Base.sanitize_sql_like(filter_element_params.dig(:parameters, :text))}%")
|
"%#{ActiveRecord::Base.sanitize_sql_like(filter_element_params.dig(:parameters, :text))}%")
|
||||||
when 'empty'
|
|
||||||
repository_rows.where(name: nil)
|
|
||||||
else
|
else
|
||||||
raise ArgumentError, 'Wrong operator for RepositoryRow Name!'
|
raise ArgumentError, 'Wrong operator for RepositoryRow Name!'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1418,7 +1418,7 @@ en:
|
||||||
filters:
|
filters:
|
||||||
operators:
|
operators:
|
||||||
contains: "Contains"
|
contains: "Contains"
|
||||||
does_not_contain: "Does not contain"
|
does_not_contain: "Doesn’t contain"
|
||||||
equal_to: "Equal to"
|
equal_to: "Equal to"
|
||||||
unequal_to: "Not equal to"
|
unequal_to: "Not equal to"
|
||||||
greater_than: "Greater than"
|
greater_than: "Greater than"
|
||||||
|
@ -1452,6 +1452,8 @@ en:
|
||||||
this_year: "The current calendar year from beginning of 1st January to the end of 31st December"
|
this_year: "The current calendar year from beginning of 1st January to the end of 31st December"
|
||||||
last_year: "The last calendar year from beginning of 1st January to the end of 31st December"
|
last_year: "The last calendar year from beginning of 1st January to the end of 31st December"
|
||||||
types:
|
types:
|
||||||
|
RepositoryNonEmptyTextValue:
|
||||||
|
input_placeholder: "Enter %{name}"
|
||||||
RepositoryAssetValue:
|
RepositoryAssetValue:
|
||||||
input_placeholder: "Enter text"
|
input_placeholder: "Enter text"
|
||||||
RepositoryTextValue:
|
RepositoryTextValue:
|
||||||
|
@ -1523,7 +1525,7 @@ en:
|
||||||
name: "Cid"
|
name: "Cid"
|
||||||
placeholder: "Enter Cid"
|
placeholder: "Enter Cid"
|
||||||
table:
|
table:
|
||||||
id: 'ID'
|
id: 'Item ID'
|
||||||
external_id: 'External ID'
|
external_id: 'External ID'
|
||||||
assigned: "Assigned"
|
assigned: "Assigned"
|
||||||
assigned_tasks: "Assigned to task"
|
assigned_tasks: "Assigned to task"
|
||||||
|
|
Loading…
Reference in a new issue