diff --git a/src/App.vue b/src/App.vue index a2ba161e2..eef62ff20 100644 --- a/src/App.vue +++ b/src/App.vue @@ -52,6 +52,7 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/components/ScreenTemplateCard.vue b/src/components/ScreenTemplateCard.vue new file mode 100644 index 000000000..323173bf5 --- /dev/null +++ b/src/components/ScreenTemplateCard.vue @@ -0,0 +1,257 @@ + + + + + \ No newline at end of file diff --git a/src/components/ScreenTemplates.vue b/src/components/ScreenTemplates.vue new file mode 100644 index 000000000..606f932dd --- /dev/null +++ b/src/components/ScreenTemplates.vue @@ -0,0 +1,205 @@ + + + + + diff --git a/src/components/ScreenToolbar.vue b/src/components/ScreenToolbar.vue index a1815d844..daf8a1eb9 100644 --- a/src/components/ScreenToolbar.vue +++ b/src/components/ScreenToolbar.vue @@ -21,6 +21,15 @@ {{ $t("Redo") }} + + + {{ $t("Templates") }} + - - + + @@ -488,6 +501,7 @@ import MultipleUploadsCheckbox from "./utils/multiple-uploads-checkbox"; import { formTypes } from "@/global-properties"; import TabsBar from "./TabsBar.vue"; import Sortable from './sortable/Sortable.vue'; +import ScreenTemplates from './ScreenTemplates.vue'; // To include another language in the Validator with variable processmaker const globalObject = typeof window === "undefined" ? global : window; @@ -555,6 +569,7 @@ export default { ...renderer, PagesDropdown, Sortable, + ScreenTemplates, }, mixins: [HasColorProperty, testing], props: { @@ -580,7 +595,10 @@ export default { }, processId: { default: 0 - } + }, + sharedTemplatesData: { + type: Array, + }, }, data() { const config = this.initialConfig || defaultConfig; @@ -631,6 +649,7 @@ export default { collapse: {}, groupOrder: {}, searchProperties: ['name'], + showTemplatesPanel: false, }; }, computed: { @@ -1105,6 +1124,12 @@ export default { this.$store.getters["undoRedoModule/currentState"].currentPage ); }, + openTemplatesPanel() { + this.showTemplatesPanel = true; + }, + closeTemplatesPanel() { + this.showTemplatesPanel = false; + }, updateConfig(items) { this.config[this.currentPage].items = items; this.updateState(); @@ -1265,6 +1290,7 @@ export default { }); }, inspect(element = {}) { + this.closeTemplatesPanel(); this.inspection = element; this.selected = element; const defaultAccordion = this.accordions.find( @@ -1398,7 +1424,6 @@ export default { this.updateState(); this.inspect(clone); }, - } }; @@ -1532,6 +1557,12 @@ $side-bar-font-size: 0.875rem; .inspector-column { max-width: 265px; font-size: $side-bar-font-size; + border-left: 1px solid rgba(0, 0, 0, 0.125); + height: 100%; +} + +.screen-templates-column { + overflow-y: auto; } .form-control-ghost { diff --git a/tests/e2e/specs/ScreenTemplateSection.spec.js b/tests/e2e/specs/ScreenTemplateSection.spec.js new file mode 100644 index 000000000..2fa212c2f --- /dev/null +++ b/tests/e2e/specs/ScreenTemplateSection.spec.js @@ -0,0 +1,131 @@ +describe('Screen Template Section', () => { + it('Opens the screen template panel when Templates button is clicked', () => { + cy.visit("/"); + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=screen-templates-section]").should( + "be.visible" + ); + }) +}); + +it("Closes the screen template panel when X button is clicked", () => { + cy.visit("/"); + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=screen-templates-section]").should( + "be.visible" + ); + cy.get("[data-cy=close-templates-section]").click(); + cy.get("[data-cy=screen-templates-section]").should( + "not.exist" + ); +}); + +it("Displays My Templates when My Templates button is clicked", () => { + cy.visit("/"); + + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=screen-templates-section]").should("be.visible"); + + cy.intercept( + "GET", + "/api/1.0/templates/screen?is_public=0", + { + statusCode: 200, + body: { + data: [{ + asset_type: null, + description: "This is a sample screen description for testing.", + editing_screen_uuid: null, + id: 1, + is_default_template: 0, + is_owner: true, + is_public: 0, + is_system: 0, + media: [], + name: "My Templates Test", + screen_custom_css: null, + screen_type: "EMAIL", + template_media: [], + updated_at: "2024-09-10T18:18:27+00:00", + user_id: 1, + version: "1" + }] + } + } + ).as("fetchMyTemplates"); + + cy.get("[data-cy=my-templates-tab]").click(); + + cy.wait("@fetchMyTemplates"); + + cy.get("[data-cy=my-templates-list]") + .should("be.visible") + .within(() => { + cy.contains("My Templates Test").should("exist"); + }); +}); + +it("Displays Shared Templates when Shared Templates button is clicked", () => { + cy.visit("/"); + + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=screen-templates-section]").should("be.visible"); + + cy.intercept( + "GET", + "/api/1.0/templates/screen?is_public=1", + { + statusCode: 200, + body: { + data: [{ + asset_type: null, + description: "This is a sample screen description for testing.", + editing_screen_uuid: null, + id: 2, + is_default_template: 0, + is_owner: true, + is_public: 1, + is_system: 0, + media: [], + name: "Shared Templates Test", + screen_custom_css: null, + screen_type: "FORM", + template_media: [], + updated_at: "2024-09-10T18:18:27+00:00", + user_id: 1, + version: "1" + }] + } + } + ).as("fetchSharedTemplates"); + + cy.get("[data-cy=shared-templates-tab]").click(); + + cy.wait("@fetchSharedTemplates"); + + cy.get("[data-cy=shared-templates-list]") + .should("be.visible") + .within(() => { + cy.contains("Shared Templates Test").should("exist"); + }); +}); + +it("Is hidden when an Inspector Panel should open", () => { + cy.visit("/"); + + cy.get("[data-cy=screen-templates]").click(); + cy.get("[data-cy=screen-templates-section]").should( + "be.visible" + ); + + cy.setPreviewDataInput({ name: "" }); + cy.openAcordeon("collapse-1"); + cy.get("[data-cy=controls-FormInput]").drag("[data-cy=screen-drop-zone]", { + position: "bottom" + }); + cy.get("[data-cy=screen-element-container]").click(); + + cy.get("[data-cy=screen-templates-section]").should( + "not.exist" + ); +}); \ No newline at end of file