|
1 |
| -import { ActionContainer, classesToSelector, ComputedUpdater, DragOrClickHelper, IAction, PageModel, property, QuestionRowModel, settings as SurveySettings } from "survey-core"; |
| 1 | +import { ActionContainer, classesToSelector, ComputedUpdater, CssClassBuilder, DragOrClickHelper, IAction, PageModel, property, QuestionRowModel, settings as SurveySettings } from "survey-core"; |
2 | 2 | import { SurveyCreatorModel } from "../creator-base";
|
3 | 3 | import { IPortableMouseEvent } from "../utils/events";
|
4 | 4 | import { SurveyElementActionContainer, SurveyElementAdornerBase } from "./action-container-view-model";
|
5 | 5 | import { getLocString } from "../editorLocalization";
|
6 | 6 | import { SurveyHelper } from "../survey-helper";
|
7 | 7 | import { settings } from "../creator-settings";
|
8 |
| -import { DragDropSurveyElements, DropTo } from "../dragdrop-survey-elements"; |
| 8 | +import { DragDropSurveyElements, DropIndicatorPosition } from "../dragdrop-survey-elements"; |
9 | 9 |
|
10 | 10 | import "./page.scss";
|
11 | 11 |
|
@@ -48,7 +48,7 @@ export class PageAdorner extends SurveyElementAdornerBase<PageModel> {
|
48 | 48 | }
|
49 | 49 | protected attachElement(surveyElement: PageModel): void {
|
50 | 50 | super.attachElement(surveyElement);
|
51 |
| - this.dragTypeOverMe = null; |
| 51 | + this.dropIndicatorPosition = null; |
52 | 52 |
|
53 | 53 | if (!!surveyElement) {
|
54 | 54 | surveyElement["surveyChangedCallback"] = () => {
|
@@ -83,7 +83,7 @@ export class PageAdorner extends SurveyElementAdornerBase<PageModel> {
|
83 | 83 | }
|
84 | 84 | super.detachElement(surveyElement);
|
85 | 85 | if (!this.isDisposed) {
|
86 |
| - this.dragTypeOverMe = null; |
| 86 | + this.dropIndicatorPosition = null; |
87 | 87 | }
|
88 | 88 | }
|
89 | 89 |
|
@@ -226,49 +226,40 @@ export class PageAdorner extends SurveyElementAdornerBase<PageModel> {
|
226 | 226 | }
|
227 | 227 |
|
228 | 228 | get css(): string {
|
229 |
| - let result = super.getCss(); |
230 |
| - if (this.dragDropHelper.draggedElement && this.dragDropHelper.draggedElement.isPage) { |
231 |
| - if (this.dragTypeOverMe === DropTo.Top) { |
232 |
| - result += " svc-question__content--drag-over-top"; |
233 |
| - } |
234 |
| - if (this.dragTypeOverMe === DropTo.Bottom) { |
235 |
| - result += " svc-question__content--drag-over-bottom"; |
236 |
| - } |
237 |
| - } else { |
238 |
| - if (!!this.dragTypeOverMe && this.showPlaceholder) { |
239 |
| - result = "svc-question__content--drag-over-inside"; |
240 |
| - } else if (!!this.dragTypeOverMe && this.page.elements.length === 0 && this.creator.survey.pages.length > 0) { |
241 |
| - result = "svc-page--drag-over-empty"; |
242 |
| - if (!!this.creator && !this.creator.showAddQuestionButton) { |
243 |
| - result += " svc-page--drag-over-empty-no-add-button"; |
244 |
| - } |
245 |
| - } |
246 |
| - if (!!this.dragTypeOverMe && this.collapsed) { |
| 229 | + const isDraggedElementPage = this.dragDropHelper.draggedElement && this.dragDropHelper.draggedElement.isPage; |
| 230 | + const isDragOverInside = !!this.dropIndicatorPosition && this.showPlaceholder; |
| 231 | + const isDragOverEmpty = !!this.dropIndicatorPosition && this.page.elements.length === 0 && this.creator.survey.pages.length > 0; |
| 232 | + const isShowAddQuestionButton = !!this.creator && !this.creator.showAddQuestionButton; |
| 233 | + const isDragOverCollapsedInside = !!this.dropIndicatorPosition && this.collapsed; |
| 234 | + |
| 235 | + let result: string = new CssClassBuilder() |
| 236 | + .append(super.getCss()) |
| 237 | + .append("svc-question__content--drag-over-top", isDraggedElementPage && this.dropIndicatorPosition === DropIndicatorPosition.Top) |
| 238 | + .append("svc-question__content--drag-over-bottom", isDraggedElementPage && this.dropIndicatorPosition === DropIndicatorPosition.Bottom) |
| 239 | + .append("svc-question__content--drag-over-inside", !isDraggedElementPage && isDragOverInside) |
| 240 | + .append("svc-page--drag-over-empty", !isDraggedElementPage && !isDragOverInside && isDragOverEmpty) |
| 241 | + .append("svc-page--drag-over-empty-no-add-button", !isDraggedElementPage && !isDragOverInside && isDragOverEmpty && isShowAddQuestionButton) |
| 242 | + .append("svc-page__content--collapsed-drag-over-inside", !isDraggedElementPage && isDragOverCollapsedInside) |
| 243 | + .append("svc-page__content--dragged", this.isBeingDragged) |
| 244 | + .append("svc-page__content--collapse-" + this.creator.expandCollapseButtonVisibility, this.allowExpandCollapse || !!this.page["isGhost"]) |
| 245 | + .append("svc-page__content--collapsed", (this.allowExpandCollapse || !!this.page["isGhost"]) && (this.renderedCollapsed || !!this.page["isGhost"])) |
| 246 | + .append("svc-page__content--animation-running", (this.allowExpandCollapse || !!this.page["isGhost"]) && (this.expandCollapseAnimationRunning)) |
| 247 | + .append("svc-page__content--new", !!this.isGhost) |
| 248 | + .append("svc-page__content--selected", !this.isGhost && !!this.creator.isElementSelected(this.page)) |
| 249 | + .append("svc-page__content--no-header", !this.isGhost && SurveySettings.designMode.showEmptyTitles === false) |
| 250 | + .toString(); |
| 251 | + |
| 252 | + if (!isDraggedElementPage) { |
| 253 | + if (isDragOverCollapsedInside) { |
247 | 254 | this.dragIn();
|
248 |
| - result += " svc-page__content--collapsed-drag-over-inside"; |
249 | 255 | } else {
|
250 | 256 | this.dragOut();
|
251 | 257 | }
|
252 | 258 | }
|
253 |
| - if (this.allowExpandCollapse || this.page["isGhost"]) { |
254 |
| - result += (" svc-page__content--collapse-" + this.creator.expandCollapseButtonVisibility); |
255 |
| - if (this.renderedCollapsed || this.page["isGhost"]) result += (" svc-page__content--collapsed"); |
256 |
| - if (this.expandCollapseAnimationRunning) result += (" svc-page__content--animation-running"); |
257 |
| - } |
258 |
| - if (this.isDragMe) { |
259 |
| - result += " svc-page__content--dragged"; |
260 |
| - } |
261 |
| - if (this.isGhost) { |
262 |
| - return result + " svc-page__content--new"; |
263 |
| - } |
264 |
| - if (this.creator.isElementSelected(this.page)) { |
265 |
| - result += " svc-page__content--selected"; |
266 |
| - } |
267 |
| - if (SurveySettings.designMode.showEmptyTitles === false) { |
268 |
| - result += " svc-page__content--no-header"; |
269 |
| - } |
270 |
| - return result.trim(); |
| 259 | + |
| 260 | + return result; |
271 | 261 | }
|
| 262 | + |
272 | 263 | private creatorPropertyChanged = (sender, options) => {
|
273 | 264 | if (options.name === "isMobileView" && this.isActionContainerCreated) {
|
274 | 265 | this.actionContainer.alwaysShrink = options.newValue;
|
|
0 commit comments