diff --git a/app/javascript/packs/vue/repository_filter.js b/app/javascript/packs/vue/repository_filter.js index 055dec525..16d589d4a 100644 --- a/app/javascript/packs/vue/repository_filter.js +++ b/app/javascript/packs/vue/repository_filter.js @@ -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 } }); } diff --git a/app/javascript/vue/repository_filter/filters/repositoryAssetValue.vue b/app/javascript/vue/repository_filter/filters/repositoryAssetValue.vue index a4526a62e..3192069f8 100644 --- a/app/javascript/vue/repository_filter/filters/repositoryAssetValue.vue +++ b/app/javascript/vue/repository_filter/filters/repositoryAssetValue.vue @@ -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')" /> @@ -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: { diff --git a/app/javascript/vue/repository_filter/filters/repositoryChecklistValue.vue b/app/javascript/vue/repository_filter/filters/repositoryChecklistValue.vue index 37511da81..088ace6ff 100644 --- a/app/javascript/vue/repository_filter/filters/repositoryChecklistValue.vue +++ b/app/javascript/vue/repository_filter/filters/repositoryChecklistValue.vue @@ -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: { diff --git a/app/javascript/vue/repository_filter/filters/repositoryDateTimeValue.vue b/app/javascript/vue/repository_filter/filters/repositoryDateTimeValue.vue index 7dc60b37d..73bf5d7eb 100644 --- a/app/javascript/vue/repository_filter/filters/repositoryDateTimeValue.vue +++ b/app/javascript/vue/repository_filter/filters/repositoryDateTimeValue.vue @@ -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()}` diff --git a/app/javascript/vue/repository_filter/filters/repositoryDateValue.vue b/app/javascript/vue/repository_filter/filters/repositoryDateValue.vue index ba826ff12..df625eab7 100644 --- a/app/javascript/vue/repository_filter/filters/repositoryDateValue.vue +++ b/app/javascript/vue/repository_filter/filters/repositoryDateValue.vue @@ -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()}` diff --git a/app/javascript/vue/repository_filter/filters/repositoryListValue.vue b/app/javascript/vue/repository_filter/filters/repositoryListValue.vue index e6982f995..a6c71d04c 100644 --- a/app/javascript/vue/repository_filter/filters/repositoryListValue.vue +++ b/app/javascript/vue/repository_filter/filters/repositoryListValue.vue @@ -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: { diff --git a/app/javascript/vue/repository_filter/filters/repositoryMyModuleValue.vue b/app/javascript/vue/repository_filter/filters/repositoryMyModuleValue.vue index 8c2ce4ac6..30adb3a89 100644 --- a/app/javascript/vue/repository_filter/filters/repositoryMyModuleValue.vue +++ b/app/javascript/vue/repository_filter/filters/repositoryMyModuleValue.vue @@ -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: { diff --git a/app/javascript/vue/repository_filter/filters/repositoryNumberValue.vue b/app/javascript/vue/repository_filter/filters/repositoryNumberValue.vue index 41fdfd519..e4517cce0 100644 --- a/app/javascript/vue/repository_filter/filters/repositoryNumberValue.vue +++ b/app/javascript/vue/repository_filter/filters/repositoryNumberValue.vue @@ -8,7 +8,6 @@ />
@@ -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; diff --git a/app/javascript/vue/repository_filter/filters/repositoryTimeValue.vue b/app/javascript/vue/repository_filter/filters/repositoryTimeValue.vue index 2caa53172..b9d05ca81 100644 --- a/app/javascript/vue/repository_filter/filters/repositoryTimeValue.vue +++ b/app/javascript/vue/repository_filter/filters/repositoryTimeValue.vue @@ -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()}` } } } diff --git a/app/javascript/vue/repository_filter/filters/repositoryUserValue.vue b/app/javascript/vue/repository_filter/filters/repositoryUserValue.vue index dd0930838..966777e40 100644 --- a/app/javascript/vue/repository_filter/filters/repositoryUserValue.vue +++ b/app/javascript/vue/repository_filter/filters/repositoryUserValue.vue @@ -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 ` diff --git a/app/javascript/vue/repository_filter/mixins/filter.js b/app/javascript/vue/repository_filter/mixins/filter.js index e46c80f32..00f00b27a 100644 --- a/app/javascript/vue/repository_filter/mixins/filter.js +++ b/app/javascript/vue/repository_filter/mixins/filter.js @@ -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 } } ); diff --git a/app/javascript/vue/repository_filter/mixins/filters/date_time_filter.js b/app/javascript/vue/repository_filter/mixins/filters/date_time_filter.js index 7cc789535..e7e081b4f 100644 --- a/app/javascript/vue/repository_filter/mixins/filters/date_time_filter.js +++ b/app/javascript/vue/repository_filter/mixins/filters/date_time_filter.js @@ -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); } } } diff --git a/config/locales/en.yml b/config/locales/en.yml index 4594f554c..639f549d3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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: