Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<screen-toolbar
@undo="$refs.builder.undo()"
@redo="$refs.builder.redo()"
@open-templates="openTemplatesPanel"
@open-calc="openComputedProperties"
@open-customCss="openCustomCSS"
@open-watchers="openWatchersPopup"
Expand Down Expand Up @@ -111,6 +112,8 @@
:screen="screen"
title="Default"
:render-controls="displayBuilder"
:show-templates-panel="showTemplatesPanel"
:reshow-templates-panel="reshowTemplatesPanel"
@change="updateConfig"
>
<default-loading-spinner />
Expand Down Expand Up @@ -443,7 +446,11 @@ export default {
minimap: {
enabled: false
}
}
},
showTemplatesPanel: false,
reshowTemplatesPanel: false,
myTemplatesData: null,
sharedTemplatesData: null,
};
},
computed: {
Expand Down Expand Up @@ -696,6 +703,12 @@ export default {
openWatchersPopup() {
this.$refs.watchersPopup.show();
},
openTemplatesPanel() {
this.showTemplatesPanel = true;
this.reshowTemplatesPanel = true;
this.$emit('update-templates-panel', this.showTemplatesPanel);
window.ProcessMaker.EventBus.$emit("open-templates-panel");
},
openComputedProperties() {
this.$refs.computedProperties.show();
},
Expand Down
28 changes: 24 additions & 4 deletions src/components/ScreenTemplates.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
<template>
<div>
<div data-cy="screen-templates-section">
<div class="d-flex justify-content-between">
<h6 class="pt-2">Select a Template</h6>
<button class="panel-close-btn" @click="$emit('close-templates-panel')"><i class="fas fa-times"></i></button>
<button
class="panel-close-btn"
@click="$emit('close-templates-panel')"
data-cy="close-templates-section"
>
<i class="fas fa-times"></i>
</button>
</div>
<div class="d-flex m-2 template-tabs justify-content-center">
<b-button @click="showMyTemplates" class="d-inline default-template-btn px-1" :class="{ 'my-templates-selected': myTemplatesSelected }">My Templates</b-button>
<b-button @click="showSharedTemplates" class="d-inline default-template-btn" :class="{ 'shared-templates-selected': sharedTemplatesSelected }">Shared Templates</b-button>
<b-button
@click="showMyTemplates"
class="d-inline default-template-btn px-1"
:class="{ 'my-templates-selected': myTemplatesSelected }"
data-cy="my-templates-tab"
>
My Templates
</b-button>
<b-button
@click="showSharedTemplates"
class="d-inline default-template-btn"
:class="{ 'shared-templates-selected': sharedTemplatesSelected }"
data-cy="shared-templates-tab"
>
Shared Templates
</b-button>
</div>
<div class="d-flex justify-content-center">
<div v-if="myTemplatesSelected" class="d-flex justify-content-center p-0">
Expand Down
9 changes: 9 additions & 0 deletions src/components/ScreenToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
<i class="fas fa-redo" />
{{ $t("Redo") }}
</b-button>
<b-button
class="screen-toolbar-button"
variant="link"
data-cy="screen-templates"
@click="$emit('open-templates')"
>
<i class="fas fa-palette" />
{{ $t("Templates") }}
</b-button>
<b-button
type="button"
class="screen-toolbar-button"
Expand Down
19 changes: 14 additions & 5 deletions src/components/vue-form-builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,15 @@
no-body
class="p-0 h-100 border-top-0 border-bottom-0 border-right-0 rounded-0"
>
<div v-if="myTemplatesData && showTemplatesPanel">
<!--ADD NO TEMPLATES TO SHOW OPTION AND LOADING OPTION-->
<div v-if="showTemplatesPanel & !hideTemplatesPanel">
<!--{{ templatesPanelComp }}-->
<b-card-body class="p-2 h-100 overflow-auto">
<screen-templates
ref="screenTemplates"
v-model="templates"
:my-templates-data="myTemplatesData"
:shared-templates-data="sharedTemplatesData"
@close-templates-panel="$emit('close-templates-panel')"
@close-templates-panel="closeTemplatesPanel"
@show-shared-templates="$emit('show-shared-templates')"
/>
</b-card-body>
Expand Down Expand Up @@ -657,9 +658,14 @@ export default {
collapse: {},
groupOrder: {},
searchProperties: ['name'],
hideTemplatesPanel: false,
};
},
computed: {
// templatesPanelComp() {
// console.log('SHOWTEMPLATESPANEL =', this.showTemplatesPanel);
// console.log('HIDETEMPLATESPANEL =', this.hideTemplatesPanel);
// },
sortedPages() {
return [...this.config].sort((a, b) => a.order - b.order);
},
Expand Down Expand Up @@ -1291,7 +1297,7 @@ export default {
});
},
inspect(element = {}) {
this.$emit('close-templates-panel');
this.closeTemplatesPanel();
this.inspection = element;
this.selected = element;
const defaultAccordion = this.accordions.find(
Expand Down Expand Up @@ -1425,7 +1431,10 @@ export default {
this.updateState();
this.inspect(clone);
},

closeTemplatesPanel() {
this.hideTemplatesPanel = true;
window.ProcessMaker.EventBus.$emit("close-templates-panel");
},
}
};
</script>
Expand Down
84 changes: 84 additions & 0 deletions tests/e2e/specs/ScreenTemplateSection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
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.get("[data-cy=screen-templates]").click();
cy.get("[data-cy=my-templates-tab]").click();

// CHECK REQUEST DATA FOR is_public = 0

cy.intercept(
"POST",
"/api/1.0/scripts/execute/1",
JSON.stringify({
output: [
{
value: "Jobs",
content: "Steve Jobs"
},
{
value: "Musk",
content: "Elon Musk"
}
]
})
);

});

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.get("[data-cy=screen-templates]").click();
cy.get("[data-cy=shared-templates-tab]").click();

// CHECK REQUEST DATA FOR is_public = 1

});

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"
);
});