Skip to content

Commit

Permalink
Merge pull request #3178 from csordasmarton/close_filter_settings_on_…
Browse files Browse the repository at this point in the history
…apply

[gui] Close filter settings on apply
  • Loading branch information
bruntib authored Feb 15, 2021
2 parents 1e06ffa + b6008c8 commit f30b58e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 28 deletions.
9 changes: 0 additions & 9 deletions web/server/vue-cli/e2e/pages/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ const filterCommands = {
return this;
},

closeFilterSettings() {
this.click("@settings");

const reportPage = this.api.page.report();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

return this;
},

selectedItemClick(index) {
return this.click({ selector: "@selectedItems", index: index});
}
Expand Down
24 changes: 12 additions & 12 deletions web/server/vue-cli/e2e/specs/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module.exports = {
.click("@item")
.applyFilter();

section.closeFilterSettings(section);
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({result}) => {
browser.assert.ok(result.value.length === 2);
Expand Down Expand Up @@ -162,7 +162,7 @@ module.exports = {
// Apply the filter.
runMenu.applyFilter();

section.closeFilterSettings();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({ result }) => {
browser.assert.ok(result.value.length === 1);
Expand Down Expand Up @@ -244,7 +244,7 @@ module.exports = {
// Apply the filter.
runMenu.applyFilter();

section.closeFilterSettings();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({ result }) => {
browser.assert.ok(result.value.length === 1);
Expand Down Expand Up @@ -302,7 +302,7 @@ module.exports = {
.toggleMenuItem(2)
.applyFilter();

section.closeFilterSettings();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({result}) => {
browser.assert.ok(result.value.length === 1);
Expand All @@ -320,7 +320,7 @@ module.exports = {
.click("@regexItem")
.applyFilter();

section.closeFilterSettings();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({result}) => {
browser.assert.ok(result.value.length === 1);
Expand All @@ -338,7 +338,7 @@ module.exports = {
.click("@regexItem")
.applyFilter();

section.closeFilterSettings();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({result}) => {
browser.assert.ok(result.value.length === 1);
Expand All @@ -357,7 +357,7 @@ module.exports = {
.toggleMenuItem(5)
.applyFilter();

section.closeFilterSettings();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({result}) => {
browser.assert.ok(result.value.length === 3);
Expand All @@ -377,7 +377,7 @@ module.exports = {
.toggleMenuItem(3)
.applyFilter();

section.closeFilterSettings();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({result}) => {
browser.assert.ok(result.value.length === 4);
Expand All @@ -394,7 +394,7 @@ module.exports = {
.toggleMenuItem(0)
.applyFilter();

section.closeFilterSettings();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({result}) => {
browser.assert.ok(result.value.length === 1);
Expand All @@ -413,7 +413,7 @@ module.exports = {
.toggleMenuItem(2)
.applyFilter();

section.closeFilterSettings();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({result}) => {
browser.assert.ok(result.value.length === 3);
Expand Down Expand Up @@ -473,7 +473,7 @@ module.exports = {
.toggleMenuItem(0)
.applyFilter();

section.closeFilterSettings();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({result}) => {
browser.assert.ok(result.value.length === 1);
Expand Down Expand Up @@ -515,7 +515,7 @@ module.exports = {
.click("@regexItem")
.applyFilter();

section.closeFilterSettings();
reportPage.expect.section("@settingsMenu").to.not.be.present.before(5000);

section.api.elements("@selectedItems", ({result}) => {
browser.assert.ok(result.value.length === 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
items,
prevSelectedItems,
cancel: cancelItemSelection,
select
select,
onApplyFinished
}"
>
<v-menu
Expand All @@ -45,6 +46,7 @@
:limit="defaultLimit"
:format="formatRunTitle"
@apply="apply"
@apply:finished="onApplyFinished"
@cancel="cancelItemSelection"
@select="select"
@update:items="items.splice(0, items.length, ...$event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
text
class="apply-btn"
color="primary"
@click="$emit('apply', selectedItems)"
@click="apply"
>
<v-icon left>
mdi-check-circle-outline
Expand Down Expand Up @@ -232,7 +232,12 @@ export default {
filter: _.debounce(async function (value) {
const items = await this.search.filterItems(value);
this.$emit("update:items", items);
}, 500)
}, 500),
apply() {
this.$emit("apply", this.selectedItems);
this.$emit("apply:finished");
}
}
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
:items="items"
:prevSelectedItems="prevSelectedItems"
:apply="applyFilters"
:onApplyFinished="onApplyFinished"
:cancel="cancel"
:select="select"
>
Expand All @@ -62,6 +63,7 @@
:multiple="multiple"
:limit="limit"
@apply="applyFilters"
@apply:finished="onApplyFinished"
@cancel="cancel"
@select="select"
>
Expand Down Expand Up @@ -140,7 +142,7 @@ export default {
reloadItems: true,
menu: false,
prevSelectedItems: [],
cancelled: false
preventApply: false
};
},
Expand All @@ -158,15 +160,15 @@ export default {
if (show) {
this.$emit("on-menu-show");
this.cancelled = false;
this.preventApply = false;
if (this.reloadItems) {
this.items = await this.fetchItems();
this.reloadItems = false;
}
this.select(JSON.parse(JSON.stringify(this.selectedItems)));
} else if (!this.cancelled) {
} else if (!this.preventApply) {
this.applyFilters(this.prevSelectedItems);
}
}
Expand All @@ -187,6 +189,11 @@ export default {
},
methods: {
onApplyFinished() {
this.preventApply = true;
this.menu = false;
},
/**
* Returns true if the filter is changed, else false.
*/
Expand All @@ -206,7 +213,7 @@ export default {
},
cancel() {
this.cancelled = true;
this.preventApply = true;
this.menu = false;
this.$emit("cancel");
},
Expand Down

0 comments on commit f30b58e

Please sign in to comment.