Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/5680-Expand-panels-and-pages-on-dragged-in #5746

Merged
merged 53 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
72e023a
#5610 Add an option to expand and collapse pages on a design surface
novikov82 Jul 10, 2024
ef4e93f
#5610 - add option
novikov82 Jul 10, 2024
926fba9
#5610 - support doubleclick
novikov82 Jul 10, 2024
74d7752
#5610 add screenshots
novikov82 Jul 11, 2024
0aa48ce
#5610 - fix unit-tests
novikov82 Jul 11, 2024
a58e6be
#5610 fixed react event bubbling
novikov82 Jul 11, 2024
811fc54
#5610 - do not expand on doubleclick when setting is "never"
novikov82 Jul 11, 2024
c0a124b
#5610 - key for pages in vue
novikov82 Jul 11, 2024
d48527a
#5610 - move page collapse button to toolbar
novikov82 Jul 11, 2024
288bb17
#5610 broken double click
novikov82 Jul 12, 2024
572f440
#5610 fixed page styles
novikov82 Jul 12, 2024
780121a
#5610 - fix border radius for dashed page
novikov82 Jul 12, 2024
f5bd0d3
#5610 - updated screenshots
novikov82 Jul 12, 2024
5c4544c
#5610 - keep inner border for mobile pages
novikov82 Jul 12, 2024
5e0010a
#5610 - update screenshots and mask
novikov82 Jul 12, 2024
7f51c2e
#5610 - update screenshots
novikov82 Jul 12, 2024
26c9e39
#5610 - fixed tests
novikov82 Jul 12, 2024
33817e4
#5680 Expand panels and pages on dragged in
novikov82 Jul 12, 2024
6e78136
#5610 Add an option to expand and collapse pages on a design surface
novikov82 Jul 29, 2024
53c3baa
#5610 refresh screenshots
novikov82 Jul 30, 2024
c475b7f
#5680 merge
novikov82 Jul 30, 2024
eef1591
#5680 merge master
novikov82 Aug 1, 2024
74479c1
#5680 Expand panels and pages on dragged in Fixes #5680
novikov82 Aug 1, 2024
dbc868b
#5680 fixed collapsed page color priority on drag in
novikov82 Aug 6, 2024
59370c0
#5680 fix styles and add blinking
novikov82 Aug 7, 2024
a25ee29
#5680 Expand panels and pages on dragged in
novikov82 Aug 8, 2024
8a8e3c2
Merge branch 'master' into issue/5680-Expand-panels-and-pages-on-drag…
novikov82 Aug 8, 2024
182f431
Merge remote-tracking branch 'origin/HEAD' into issue/5680-Expand-pan…
novikov82 Aug 9, 2024
74a7132
#5680 Expand panels and pages on dragged in
novikov82 Aug 9, 2024
24c5063
#5680 - revert unnecessery changes
novikov82 Aug 9, 2024
e76b4d8
#5680 - revert broken merge
novikov82 Aug 9, 2024
346b9a4
#5680 - add tests
novikov82 Aug 9, 2024
4bab1d0
#5680 - removed calculatedCollapsed property
novikov82 Aug 9, 2024
030da15
#5680 - restore renderedCollapsed
novikov82 Aug 9, 2024
0c072a6
#5680 - switch off animation in tests
novikov82 Aug 9, 2024
e5a76b3
#5680 - update screenshot
Aug 11, 2024
c620fd9
#5680 fix dragging and timers
novikov82 Aug 13, 2024
f6eb6e7
#5680 blink for selected page
novikov82 Aug 14, 2024
71b1421
#5680 - supported dynamic panel
novikov82 Aug 14, 2024
73adf43
#5680 Expand panels and pages on dragged in
novikov82 Aug 14, 2024
d1974db
Revert "#5680 Expand panels and pages on dragged in"
Aug 14, 2024
e58d82e
#5680 Expand panels and pages on dragged in
Aug 14, 2024
25ea199
#5680 Expand panels and pages on dragged in - add test for dynamic panel
novikov82 Aug 15, 2024
9389cef
#5680 - fix styles
novikov82 Aug 15, 2024
17aa761
#5680 fixed drop to collapsed panel
novikov82 Aug 15, 2024
89e6987
#5680 transparent color for blinking
novikov82 Aug 16, 2024
a77f529
#5680 drop to collapse
novikov82 Aug 19, 2024
c79b51e
#5680 fix page adorner button position
novikov82 Aug 19, 2024
0664721
#5680 - fix drop to collapsed page and selected panel
novikov82 Aug 19, 2024
4f9c306
#5680 - fix unit test
novikov82 Aug 20, 2024
545dfc4
#5680 fix unit test
novikov82 Aug 20, 2024
110fc2f
#5680 - update screenshors
novikov82 Aug 20, 2024
8ad27ea
#5680 - fixed selection after drag
novikov82 Aug 20, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ export class SurveyElementAdornerBase<T extends SurveyElement = SurveyElement> e
protected expandCollapseAction: IAction;
protected designerStateManager: DesignerStateManager;
@property({ defaultValue: true }) allowDragging: boolean;

protected get dragInsideCollapsedContainer(): boolean {
return this.collapsed && this.creator.dragDropSurveyElements.insideContainer;
}

@property({ defaultValue: true }) allowExpandCollapse: boolean;
@property({
onSet: (val, target: SurveyElementAdornerBase<T>) => {
Expand All @@ -108,6 +113,23 @@ export class SurveyElementAdornerBase<T extends SurveyElement = SurveyElement> e
}) collapsed: boolean;
@property() renderedCollapsed: boolean;

private dragCollapsedTimer;

protected dragIn() {
if ((this.surveyElement.isPanel || this.surveyElement.isPage) && this.collapsed) {
this.dragCollapsedTimer = setTimeout(() => {
this.expandWithDragIn();
}, this.creator.expandOnDragTimeOut);
}
}
protected expandWithDragIn() {
this.collapsed = false;
}

protected dragOut() {
if (this.dragCollapsedTimer) clearTimeout(this.dragCollapsedTimer);
}

public dblclick(event) {
if (this.allowExpandCollapse) this.collapsed = !this.collapsed;
event.stopPropagation();
Expand All @@ -124,6 +146,9 @@ export class SurveyElementAdornerBase<T extends SurveyElement = SurveyElement> e
this.designerStateManager = (creator.getPlugin("designer") as TabDesignerPlugin)?.designerStateManager;
this.designerStateManager?.initForElement(surveyElement);
this.selectedPropPageFunc = (sender: Base, options: any) => {
if (options.name === "dragTypeOverMe") {
if (!!options.newValue && this.dragInsideCollapsedContainer) this.dragIn(); else this.dragOut();
}
if (options.name === "isSelectedInDesigner") {
this.onElementSelectedChanged(options.newValue);
}
Expand Down
28 changes: 26 additions & 2 deletions packages/survey-creator-core/src/components/page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,32 @@ svc-page {
visibility: visible;
}
}

.svc-creator .svc-page .svc-page__content--collapsed {
&::after {
content: "";
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
border: 2px $border dashed;
margin: -2px;
border-radius: calcSize(1.25);
box-sizing: content-box;
pointer-events: none;
}
&.svc-page__content--collapsed-drag-over-inside {
box-shadow: 0 0 0 2px $primary;
background: $primary-light;
&::after {
border: 2px $primary solid;
background: $primary-light;
animation: collapsed-drag-over-inside-blinking 1s infinite;
}
}
}

.svc-creator--mobile {
.svc-page .svc-page__content--collapsed {
&::after {
Expand All @@ -151,8 +177,6 @@ svc-page {
&.svc-creator .svc-page .svc-page__content--selected:focus,
.svc-hovered.svc-page__content {
&.svc-page__content--selected {
box-shadow: 0 0 0 2px inset $secondary;

box-shadow: 0 0 0 2px inset var(--ctr-survey-page-border-color-selected, $secondary);
background: var(--ctr-survey-page-background-color-selected, $secondary-backcolor-semi-light);

Expand Down
3 changes: 3 additions & 0 deletions packages/survey-creator-core/src/components/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ export class PageAdorner extends SurveyElementAdornerBase<PageModel> {
result += " svc-page--drag-over-empty-no-add-button";
}
}
if (!!this.dragTypeOverMe && this.collapsed) {
result += " svc-page__content--collapsed-drag-over-inside";
}
if (this.isGhost) {
return result + " svc-page__content--new";
}
Expand Down
19 changes: 18 additions & 1 deletion packages/survey-creator-core/src/components/question.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ svc-question {
display: flex;
flex-direction: column;
justify-content: stretch;

&.svc-question__adorner--collapsed {
height: fit-content;
}
.sv-action-bar {
overflow: visible;

Expand Down Expand Up @@ -270,6 +272,21 @@ svc-question {
.svc-question__content--selected:not(.svc-question__content--dragged) {
box-shadow: 0 0 0 2px $secondary;
}
.svc-question__content--collapsed-drag-over-inside:not(.svc-question__content--dragged) {
box-shadow: 0 0 0 2px $primary;
background: $primary-light;
animation: collapsed-drag-over-inside-blinking 1s;
}

@keyframes collapsed-drag-over-inside-blinking {
0%{ background: $primary-light }
40%{ background: $primary-light }
50%{ background: $background }
60%{ background: $primary-light }
75%{ background: $background }
85%{ background: $primary-light }
100%{ background: $primary-light }
}

.svc-question__content--selected:not(.svc-question__content--dragged),
.svc-creator:not(.svc-creator--mobile)
Expand Down
55 changes: 25 additions & 30 deletions packages/survey-creator-core/src/components/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,49 +130,44 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {

if (this.isDragMe) {
result += " svc-question__content--dragged";
} else {
result = result.replace(" svc-question__content--dragged", "");
}

if (this.dragTypeOverMe === DragTypeOverMeEnum.InsideEmptyPanel) {
result += " svc-question__content--drag-over-inside";
} else {
result = result.replace(" svc-question__content--drag-over-inside", "");
if (!!this.dragTypeOverMe && this.surveyElement.isPanel && this.dragInsideCollapsedContainer) {
result += " svc-question__content--collapsed-drag-over-inside";
}

if (this.dragTypeOverMe === DragTypeOverMeEnum.Left) {
result += " svc-question__content--drag-over-left";
} else {
result = result.replace(" svc-question__content--drag-over-left", "");
}

if (this.dragTypeOverMe === DragTypeOverMeEnum.Right) {
result += " svc-question__content--drag-over-right";
} else {
result = result.replace(" svc-question__content--drag-over-right", "");
if (this.dragTypeOverMe === DragTypeOverMeEnum.InsideEmptyPanel) {
result += " svc-question__content--drag-over-inside";
}
if (!this.dragInsideCollapsedContainer) {
if (this.dragTypeOverMe === DragTypeOverMeEnum.Left) {
result += " svc-question__content--drag-over-left";
}

if (this.dragTypeOverMe === DragTypeOverMeEnum.Top) {
result += " svc-question__content--drag-over-top";
} else {
result = result.replace(" svc-question__content--drag-over-top", "");
}
if (this.dragTypeOverMe === DragTypeOverMeEnum.Right) {
result += " svc-question__content--drag-over-right";
}

if (this.dragTypeOverMe === DragTypeOverMeEnum.Bottom) {
result += " svc-question__content--drag-over-bottom";
} else {
result = result.replace(" svc-question__content--drag-over-bottom", "");
}
if (this.creator) {
result = this.creator.getElementAddornerCssCallback(this.surveyElement, result);
if (this.dragTypeOverMe === DragTypeOverMeEnum.Top) {
result += " svc-question__content--drag-over-top";
}
if (this.dragTypeOverMe === DragTypeOverMeEnum.Bottom) {
result += " svc-question__content--drag-over-bottom";
}
if (this.creator) {
result = this.creator.getElementAddornerCssCallback(this.surveyElement, result);
}
}
return result;
}

protected expandWithDragIn() {
super.expandWithDragIn();
this.element.dragTypeOverMe = null;
this.creator.dragDropSurveyElements.dropTarget = null;
}
get isDragMe(): boolean {
return this.surveyElement.isDragMe;
}

get dragTypeOverMe() {
return this.element.dragTypeOverMe;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3801,6 +3801,8 @@ export class SurveyCreatorModel extends Base
*/
@property({ defaultValue: "never" }) expandCollapseButtonVisibility?: "never" | "onhover" | "always";

expandOnDragTimeOut: number = 1000;

selectFromStringEditor: boolean;

@property({
Expand Down
17 changes: 7 additions & 10 deletions packages/survey-creator-core/src/survey-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class DragDropSurveyElements extends DragDropCore<any> {
public static nestedPanelDepth: number = -1;
public static ghostSurveyElementName = "sv-drag-drop-ghost-survey-element-name"; // before renaming use globa search (we have also css selectors)

private insideEmptyContainer = null;
public insideContainer = null;
protected prevIsEdge: any = null;
// protected ghostSurveyElement: IElement = null;
protected dragOverIndicatorElement: any = null;
Expand Down Expand Up @@ -179,10 +179,6 @@ export class DragDropSurveyElements extends DragDropCore<any> {
// drop to page
let page: any = this.survey.getPageByName(dataAttributeValue);
if (page) {
if (page.elements.length !== 0) {
// TODO we can't drop on not empty page directly for now
return null;
}
return page;
}

Expand All @@ -199,12 +195,12 @@ export class DragDropSurveyElements extends DragDropCore<any> {
});

// drop to paneldynamic
if (dropTarget.getType() === "paneldynamic" && this.insideEmptyContainer) {
if (dropTarget.getType() === "paneldynamic" && this.insideContainer) {
dropTarget = (<any>dropTarget).template;
}

// drop to matrix detail panel
if ((dropTarget.getType() === "matrixdropdown" || dropTarget.getType() === "matrixdynamic") && (<any>dropTarget).detailPanelMode !== "none" && this.insideEmptyContainer) {
if ((dropTarget.getType() === "matrixdropdown" || dropTarget.getType() === "matrixdynamic") && (<any>dropTarget).detailPanelMode !== "none" && this.insideContainer) {
dropTarget = (<any>dropTarget).detailPanel;
}

Expand Down Expand Up @@ -365,12 +361,12 @@ export class DragDropSurveyElements extends DragDropCore<any> {
this.banDropHere();
return;
}
this.insideEmptyContainer = !calculateIsEdge(dropTargetNode, event.clientY) && !calculateIsSide(dropTargetNode, event.clientX);
this.insideContainer = !calculateIsEdge(dropTargetNode, event.clientY) && !calculateIsSide(dropTargetNode, event.clientX);
const dropTarget = this.getDropTargetByNode(dropTargetNode, event);

let dragOverLocation = calculateDragOverLocation(event.clientX, event.clientY, dropTargetNode);
if (dropTarget && (dropTarget.isPanel || dropTarget.isPage) && dropTarget.elements.length === 0) {
if (dropTarget.isPage || this.insideEmptyContainer) {
if (dropTarget.isPage || this.insideContainer) {
dragOverLocation = DragTypeOverMeEnum.InsideEmptyPanel;
}
}
Expand Down Expand Up @@ -428,6 +424,7 @@ export class DragDropSurveyElements extends DragDropCore<any> {
srcContainer.removeElement(src);
}
const dest = this.dragOverIndicatorElement?.isPanel ? this.dragOverIndicatorElement : this.dropTarget;
if (dest.isPage && dest.elements.length > 0) return;
const isTargetIsContainer = dest.isPanel || dest.isPage;
if (isTargetIsContainer && this.dragOverLocation == DragTypeOverMeEnum.InsideEmptyPanel) {
dest.insertElement(src);
Expand All @@ -449,7 +446,7 @@ export class DragDropSurveyElements extends DragDropCore<any> {
}

public clear(): void {
this.insideEmptyContainer = null;
this.insideContainer = null;
this.removeDragOverMarker(this.prevDropTarget);
this.removeDragOverMarker(this.dropTarget);
this.removeDragOverMarker(this.dragOverIndicatorElement);
Expand Down
85 changes: 85 additions & 0 deletions testCafe/designer/drag-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,91 @@ test("Drag Drop to Panel", async (t) => {
const resultJson = await getJSON();
await t.expect(resultJson).eql(expectedJson);
});

test("Drag Drop to collapsed panel", async (t) => {
await ClientFunction(() => { window["creator"].expandCollapseButtonVisibility = "always"; })();

await t.resizeWindow(1600, 1000);
const json = {
pages: [
{
name: "page1",
elements: [
{
type: "panel",
name: "panel1",
elements: [{
type: "text",
name: "q1"
}]
}
]
}
]
};
await setJSON(json);

const qCollapseButton = Selector(".svc-question__content #collapse");
await t.click(qCollapseButton.filterVisible());

const Panel = Selector("[data-sv-drop-target-survey-element=\"panel1\"]");
const toolboxToolAction = Selector(".svc-toolbox__tool > .sv-action__content");
await t
.hover(toolboxToolAction)
.dispatchEvent(toolboxToolAction, "pointerdown")
.hover(Panel, { offsetX: 5 })
.expect(Panel.find(".svc-question__content--drag-over-left").exists).ok()
.expect(Panel.find(".svc-question__content--collapsed-drag-over-inside").exists).notOk()
.wait(2000)
.hover(Panel, { offsetX: 100 })
.expect(Panel.find(".svc-question__content--collapsed").exists).ok()
.wait(2000)
.expect(Panel.find(".svc-question__content--collapsed").exists).notOk()
.expect(Panel.find(".svc-question__content--drag-over-left").exists).notOk()
.dispatchEvent(toolboxToolAction, "pointerup");

const resultJson = await getJSON();
await t.expect(resultJson).eql(json);
});

test("Drag Drop to collapsed page", async (t) => {
await ClientFunction(() => { window["creator"].expandCollapseButtonVisibility = "always"; })();

await t.resizeWindow(1600, 1000);
const json = {
pages: [
{
name: "page1",
elements: [
{
type: "panel",
name: "panel1",
elements: [{
type: "text",
name: "q1"
}]
}
]
}
]
};
await setJSON(json);

const qCollapseButton = Selector(".svc-page__content #collapse");
await t.click(qCollapseButton.filterVisible());

const Page = Selector(".svc-page");
const toolboxToolAction = Selector(".svc-toolbox__tool > .sv-action__content");
await t
.hover(toolboxToolAction)
.dispatchEvent(toolboxToolAction, "pointerdown")
.hover(Page)

.expect(Page.find(".svc-page__content--collapsed").exists).ok()
.wait(2000)
.expect(Page.find(".svc-page__content--collapsed").exists).notOk();
});

test("Drag Drop Question from a panel", async (t) => {
await t.resizeWindow(2560, 1440);
const json = {
Expand Down
Loading
Loading