mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-06 15:40:31 +08:00
Merge pull request #3745 from artoscinote/ma_SCI_6229
Added filter parameter formatting [SCI-6229]
This commit is contained in:
commit
7981bbf92c
15 changed files with 111 additions and 41 deletions
|
@ -32,11 +32,11 @@ window.initRepositoryFilter = () => {
|
|||
},
|
||||
computed: {
|
||||
filtersJSON() {
|
||||
return this.filters.map((f) => {
|
||||
return this.filters.filter((f) => !f.isBlank).map((f) => {
|
||||
return {
|
||||
repository_column_id: f.column.id,
|
||||
operator: f.operator,
|
||||
parameters: { ...f.data, isBlank: f.isBlank }
|
||||
operator: f.data.operator,
|
||||
parameters: f.data.parameters
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
type="text"
|
||||
name="value"
|
||||
v-model="value"
|
||||
:placeholder="i18n.t('repositories.show.repository_filter.enter_text')"
|
||||
@input="updateFilter"
|
||||
:placeholder="i18n.t('repositories.show.repository_filter.filters.types.RepositoryAssetValue.input_placeholder')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -43,6 +42,10 @@
|
|||
watch: {
|
||||
operator() {
|
||||
if(this.operator !== 'file_contains') this.value = '';
|
||||
},
|
||||
value() {
|
||||
this.parameters = this.operator === 'file_contains' ? { text: this.value } : {}
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -43,10 +43,15 @@
|
|||
components: {
|
||||
DropdownSelector
|
||||
},
|
||||
watch: {
|
||||
value() {
|
||||
this.parameters = { item_ids: this.value };
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateValue(value) {
|
||||
this.value = value
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
mixins: [FilterMixin, DateTimeFilterMixin],
|
||||
data() {
|
||||
return {
|
||||
timeType: 'datetime',
|
||||
operators: [
|
||||
{ value: 'today', label: this.i18n.t('repositories.show.repository_filter.filters.operators.today') },
|
||||
{ value: 'yesterday', label: this.i18n.t('repositories.show.repository_filter.filters.operators.yesterday') },
|
||||
|
@ -55,6 +56,12 @@
|
|||
DropdownSelector,
|
||||
DateTimePicker
|
||||
},
|
||||
watch: {
|
||||
value() {
|
||||
this.parameters = this.value;
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formattedDate(date) {
|
||||
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}`
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
mixins: [FilterMixin, DateTimeFilterMixin],
|
||||
data() {
|
||||
return {
|
||||
timeType: 'date',
|
||||
operators: [
|
||||
{ value: 'today', label: this.i18n.t('repositories.show.repository_filter.filters.operators.today') },
|
||||
{ value: 'yesterday', label: this.i18n.t('repositories.show.repository_filter.filters.operators.yesterday') },
|
||||
|
@ -55,6 +56,12 @@
|
|||
DropdownSelector,
|
||||
DateTimePicker
|
||||
},
|
||||
watch: {
|
||||
value() {
|
||||
this.parameters = this.value;
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formattedDate(date) {
|
||||
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
|
||||
|
|
|
@ -42,10 +42,15 @@
|
|||
components: {
|
||||
DropdownSelector
|
||||
},
|
||||
watch: {
|
||||
value() {
|
||||
this.parameters = { item_ids: this.value };
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateValue(value) {
|
||||
this.value = value
|
||||
this.updateFilter();
|
||||
this.value = value;
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
@ -42,10 +42,15 @@
|
|||
components: {
|
||||
DropdownSelector
|
||||
},
|
||||
watch: {
|
||||
value() {
|
||||
this.parameters = { my_module_ids: this.value };
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateValue(value) {
|
||||
this.value = value
|
||||
this.updateFilter();
|
||||
this.value = value;
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
/>
|
||||
<div v-if="operator !== 'between'" class="sci-input-container">
|
||||
<input
|
||||
@input="updateFilter"
|
||||
class="sci-input-field"
|
||||
type="number"
|
||||
name="value"
|
||||
|
@ -68,12 +67,11 @@
|
|||
DropdownSelector
|
||||
},
|
||||
methods: {
|
||||
updateRange(value) {
|
||||
updateRange() {
|
||||
this.value = {
|
||||
from: this.from,
|
||||
to: this.to
|
||||
}
|
||||
this.updateFilter();
|
||||
};
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -81,6 +79,14 @@
|
|||
if(this.operator !== 'between' && !(typeof this.value === 'string')) this.value = '';
|
||||
if(this.operator === 'between') this.value = {to: '', from: ''};
|
||||
|
||||
},
|
||||
value() {
|
||||
if (this.operator === 'between') {
|
||||
this.parameters = this.value;
|
||||
} else {
|
||||
this.parameters = { number: this.value }
|
||||
}
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
@ -42,10 +42,15 @@
|
|||
components: {
|
||||
DropdownSelector
|
||||
},
|
||||
watch: {
|
||||
value() {
|
||||
this.parameters = { status_ids: this.value };
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateValue(value) {
|
||||
this.value = value
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
/>
|
||||
<div class="sci-input-container">
|
||||
<input
|
||||
@input="updateFilter"
|
||||
class="sci-input-field"
|
||||
type="text"
|
||||
name="value"
|
||||
v-model="value"
|
||||
:placeholder= "this.i18n.t('repositories.show.repository_filter.filters.types.RepositoryNumberValue.input_placeholder',{name: this.filter.column.name})"
|
||||
:placeholder= "this.i18n.t('repositories.show.repository_filter.filters.types.RepositoryTextValue.input_placeholder',{name: this.filter.column.name})"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -28,8 +27,8 @@
|
|||
data() {
|
||||
return {
|
||||
operators: [
|
||||
{ value: 'contains', label: this.i18n.t('repositories.show.repository_filter.filters.operators.contain') },
|
||||
{ value: 'doesnt_contain', label: this.i18n.t('repositories.show.repository_filter.filters.operators.not_contain') },
|
||||
{ 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') },
|
||||
{ value: 'empty', label: this.i18n.t('repositories.show.repository_filter.filters.operators.empty') }
|
||||
],
|
||||
operator: 'contains',
|
||||
|
@ -39,6 +38,12 @@
|
|||
components: {
|
||||
DropdownSelector
|
||||
},
|
||||
watch: {
|
||||
value() {
|
||||
this.parameters = { text: this.value };
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isBlank(){
|
||||
return this.operator == 'contains' && !this.value;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
mixins: [FilterMixin, DateTimeFilterMixin],
|
||||
data() {
|
||||
return {
|
||||
timeType: 'time',
|
||||
operators: [
|
||||
{ value: 'equal_to', label: this.i18n.t('repositories.show.repository_filter.filters.operators.equal_to')},
|
||||
{ value: 'unequal_to', label: this.i18n.t('repositories.show.repository_filter.filters.operators.unequal_to') },
|
||||
|
@ -49,9 +50,15 @@
|
|||
DropdownSelector,
|
||||
DateTimePicker
|
||||
},
|
||||
watch: {
|
||||
value() {
|
||||
this.parameters = this.value;
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formattedDate(date) {
|
||||
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}`
|
||||
return `${date.getHours()}:${date.getMinutes()}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
{ value: 'none_of', label: this.i18n.t('repositories.show.repository_filter.filters.operators.none_of') }
|
||||
],
|
||||
operator: 'any_of',
|
||||
value: '',
|
||||
value: [],
|
||||
users: []
|
||||
}
|
||||
},
|
||||
|
@ -52,10 +52,15 @@
|
|||
this.users = data.users;
|
||||
});
|
||||
},
|
||||
watch: {
|
||||
value() {
|
||||
this.parameters = { user_ids: this.value };
|
||||
this.updateFilter();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateValue(value) {
|
||||
this.value = value
|
||||
this.updateFilter();
|
||||
},
|
||||
renderOption(data) {
|
||||
return `<span class="user-filter-option" title="${data.label.trim()} | ${data.params.email}">
|
||||
|
|
|
@ -3,9 +3,18 @@ export default {
|
|||
filter: Object,
|
||||
my_modules: Array
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
parameters: {}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.operator = this.operator || this.filter.data.operator;
|
||||
this.value = this.value || this.filter.data.value;
|
||||
this.parameters = this.parameters || this.filter.data.parameters;
|
||||
|
||||
// load value from parameters
|
||||
const keys = Object.keys(this.parameters);
|
||||
this.value = keys.length <= 1 ? this.parameters[keys[0]] : { ...this.parameters };
|
||||
},
|
||||
methods: {
|
||||
updateOperator(operator) {
|
||||
|
@ -20,7 +29,7 @@ export default {
|
|||
isBlank: this.isBlank,
|
||||
data: {
|
||||
operator: this.operator,
|
||||
value: this.value
|
||||
parameters: this.parameters
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -66,29 +66,30 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
rangeObject(start, end) {
|
||||
let range = {};
|
||||
|
||||
range['start_' + this.timeType] = start;
|
||||
range['end_' + this.timeType] = end;
|
||||
|
||||
return range;
|
||||
},
|
||||
updateDate(date) {
|
||||
date = date && this.formattedDate(date);
|
||||
this.date = date;
|
||||
if (this.dateTo) {
|
||||
this.value = {
|
||||
from_date: date,
|
||||
to_date: this.dateTo
|
||||
};
|
||||
this.value = this.rangeObject(date, this.dateTo);
|
||||
} else {
|
||||
this.value = date;
|
||||
}
|
||||
let valueObject = {};
|
||||
valueObject[this.timeType] = date;
|
||||
|
||||
this.updateFilter();
|
||||
this.value = valueObject;
|
||||
}
|
||||
},
|
||||
updateDateTo(date) {
|
||||
date = date && this.formattedDate(date);
|
||||
this.dateTo = date;
|
||||
this.value = {
|
||||
from_date: this.date,
|
||||
to_date: date
|
||||
};
|
||||
|
||||
this.updateFilter();
|
||||
this.value = this.rangeObject(this.date, date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1418,12 +1418,12 @@ en:
|
|||
any_of: "Any of"
|
||||
all_of: "All of"
|
||||
none_of: "None of"
|
||||
file_contains: "File contains"
|
||||
file_attached: "File is attached"
|
||||
file_not_attached: "File is not attached"
|
||||
types:
|
||||
RepositoryAssetValue:
|
||||
operators:
|
||||
file_contains: "File contains"
|
||||
file_attached: "File is attached"
|
||||
file_not_attached: "File is not attached"
|
||||
input_placeholder: "Enter text"
|
||||
RepositoryTextValue:
|
||||
input_placeholder: "Enter %{name}"
|
||||
RepositoryNumberValue:
|
||||
|
|
Loading…
Reference in a new issue