Skip to content

Commit

Permalink
Merge pull request #1711 from ProcessMaker/FOUR-13442
Browse files Browse the repository at this point in the history
FOUR-13442 Implement Clear clipboard
  • Loading branch information
devmiguelangel authored Sep 20, 2024
2 parents cc2529b + d5cbe8d commit 7c903b0
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/components/TabsBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
</div>
</template>
</b-tab>
<b-tab
class="h-100 w-100"
@click="clipboard"
>
<template #title>
{{ $t('Clear Clipboard') }}
</template>
</b-tab>
<template #tabs-end>
<div
v-if="tabsListOverflow"
Expand Down Expand Up @@ -170,6 +178,9 @@ export default {
this.checkTabsOverflow();
},
methods: {
clipboard() {
this.$emit('clearClipboard');
},
tabOpened() {
const pageIndex = this.localOpenedPages[this.activeTab];
this.$emit("tab-opened", pageIndex);
Expand Down
22 changes: 20 additions & 2 deletions src/components/editor/pagesDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,27 @@
<!-- Option to add a new page -->
<b-dropdown-item data-test="add-page" @click="onAddPage">
<!-- Icon for adding a new page -->
<i class="fa fa-plus platform-dropdown-item-icon"></i>
<i class="fas fa-plus platform-dropdown-item-icon text-dark w-icon text-center"></i>
<!-- Text for adding a new page -->
{{ $t("Create Page") }}
</b-dropdown-item>

<!-- Option to see all pages -->
<b-dropdown-item data-test="see-all-pages" @click="onSeeAllPages">
<!-- Icon for seeing all pages -->
<i class="fa fa-eye platform-dropdown-item-icon"></i>
<i class="far fa-eye platform-dropdown-item-icon text-dark w-icon text-center"></i>
<!-- Text for seeing all pages -->
{{ $t("See all pages") }}
</b-dropdown-item>

<!-- Option to open Clipboard page -->
<b-dropdown-item data-test="clipboard" @click="onClipboard" class="d-flex">
<!-- Icon for clipboard -->
<i class="far fa-clipboard platform-dropdown-item-icon text-dark w-icon text-center"></i>
<!-- Text for clipboard -->
{{ $t("Clipboard") }}
</b-dropdown-item>

<!-- Divider between adding and viewing options -->
<b-dropdown-divider></b-dropdown-divider>

Expand Down Expand Up @@ -100,6 +108,13 @@ export default {
this.$emit("seeAllPages");
},
/**
* Handle when user clicks on "Clipboard
*/
onClipboard() {
this.$emit("clipboard");
},
/**
* Handler for when a specific page is clicked.
* Emits the "clickPage" event with the selected page.
Expand All @@ -122,4 +137,7 @@ export default {
// Style for the icons in dropdown items.
color: #1572c2;
}
.w-icon {
width: 1.25rem;
}
</style>
8 changes: 8 additions & 0 deletions src/components/vue-form-builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
:pages="config"
:is-multi-page="showToolbar"
@tab-opened="currentPage = $event"
@clearClipboard="clearClipboard"
>
<template #tabs-start>
<pages-dropdown
Expand All @@ -115,6 +116,7 @@
@addPage="$bvModal.show('addPageModal')"
@clickPage="onClick"
@seeAllPages="$bvModal.show('openSortable')"
@clipboard="openClipboard"
/>
</template>
<template #default="{ currentPage: tabPage }">
Expand Down Expand Up @@ -656,6 +658,9 @@ export default {
};
},
computed: {
pagesAndClipboard() {
return [...this.config, [{name:"Clipboard", items: []}]];
},
// Get clipboard items from Vuex store
clipboardItems() {
return this.$store.getters["clipboardModule/clipboardItems"];
Expand Down Expand Up @@ -810,6 +815,9 @@ export default {
this.setGroupOrder(defaultGroupOrder);
},
methods: {
openClipboard() {
this.$refs.tabsBar.openPageByIndex(-1);
},
isCurrentPageEmpty(currentPage) {
return this.config[currentPage]?.items?.length === 0;
},
Expand Down
8 changes: 8 additions & 0 deletions src/mixins/Clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,13 @@ export default {
}
screenConfig.forEach((item) => replaceInPage(item));
},

/**
* Clear the clipboard
*/
clearClipboard() {
this.$store.dispatch("clipboardModule/clearClipboard"); // Dispatch action to clear clipboard from the Vuex store
this.$root.$emit('update-clipboard');
},
},
};
19 changes: 11 additions & 8 deletions src/stories/PagesDropdown.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default {
@addPage="onAddPage"
@clickPage="onClick"
@seeAllPages="onSeeAllPages"
@clipboard="onClipboard"
/>
`,
data() {
Expand All @@ -31,7 +32,10 @@ export default {
},
onClick(index) {
console.log("Click page item:", index);
}
},
onClipboard() {
console.log("Open clipboard");
},
}
})
};
Expand Down Expand Up @@ -104,8 +108,8 @@ export const ClickInCreatePage = {
await selectorAddPage.click(selectorAddPage);
}
};
// Open the See all Pages
export const ClickInSeeAllPages = {
// Open the Clipboard
export const ClickInClipboard = {
args: {
data: [{ name: "Page 1" }]
},
Expand All @@ -114,19 +118,18 @@ export const ClickInSeeAllPages = {
const selector = canvasElement.querySelector(
"[data-test=page-dropdown] button"
);
const selectorAddPage = canvasElement.querySelector(
"[data-test=see-all-pages]"
const clipboardOption = canvasElement.querySelector(
"[data-test=clipboard]"
);
console.log(selectorAddPage);
await selector.click(selector);
await waitFor(
() => {
expect(canvas.getByTestId("page-dropdown")).toContainHTML(
"See all pages"
"Clipboard"
);
},
{ timeout: 1000 }
);
await selectorAddPage.click(selectorAddPage);
await clipboardOption.click(clipboardOption);
}
};

0 comments on commit 7c903b0

Please sign in to comment.