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

Resolved #5747 - We should use AddQuestionButtonComponent in panel adorner #5814

Merged
merged 32 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
461798f
Resolved #5747 - We should use AddQuestionButtonComponent in panel ad…
Aug 22, 2024
8bbdce7
Merge branch 'master' into feature/5747-use-add-question-component
Aug 22, 2024
1505a19
Merge branch 'master' into feature/5747-use-add-question-component
Aug 23, 2024
9a26cfb
Angular add button component refactoring
Aug 23, 2024
187ac5a
Fixed execution context
Aug 23, 2024
a64bd27
Knockout add button component refactoring
Aug 23, 2024
3a0a11e
Vue3 add button component refactoring
Aug 23, 2024
65e3836
Merge branch 'master' into feature/5747-use-add-question-component
Aug 26, 2024
2b3e475
Merge branch 'master' into feature/5747-use-add-question-component
Aug 27, 2024
6aa7912
Try to fix f-tests
Aug 28, 2024
bfa9c83
Removed unused css and fixed vr-test
Aug 28, 2024
841e831
Fixed lint
Aug 28, 2024
26359b2
Try to fix tests
Aug 30, 2024
e9bc03f
Fixed lint
Aug 30, 2024
376c10f
Merge branch 'master' into feature/5747-use-add-question-component
Sep 3, 2024
a0affcf
Merge branch 'master' into feature/5747-use-add-question-component
Sep 5, 2024
bb47321
Merge branch 'master' into feature/5747-use-add-question-component
Sep 9, 2024
32e346a
Merge branch 'master' into feature/5747-use-add-question-component
Sep 11, 2024
69db9e7
Try to fix v-tests
Sep 11, 2024
08b5d32
Updated etalons
Sep 11, 2024
b4f205f
Fixed f-test
Sep 11, 2024
91bcb70
Merge branch 'master' into feature/5747-use-add-question-component
tsv2013 Sep 11, 2024
a9cefe9
Merge branch 'master' into feature/5747-use-add-question-component
Sep 12, 2024
499ada8
Merge branch 'feature/5747-use-add-question-component' of https://git…
Sep 12, 2024
8b59043
Fixed AddQuestion vue component
Sep 12, 2024
26ba28f
Fixed SCSS file
Sep 12, 2024
9f7a434
Merge branch 'master' into feature/5747-use-add-question-component
Sep 12, 2024
ef7e7d3
Try to fix eslint
Sep 12, 2024
97b1031
Try to fix vue creator components
Sep 12, 2024
ae64ac6
Merge branch 'master' into feature/5747-use-add-question-component
Sep 13, 2024
e37193b
Merge branch 'master' into feature/5747-use-add-question-component
Sep 16, 2024
703152a
Fixed vr-tests
Sep 16, 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
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
"linebreak-style": [
"off",
"windows"
]
],
"react/no-is-mounted": "off"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ng-template #template>
<button type="button" [key2click] (click)="selectQuestionType($event)" [attr.title]="questionTypeSelectorModel.title"
[attr.aria-label]="questionTypeSelectorModel.title" class="svc-element__question-type-selector">
<svg class="svc-element__question-type-selector-icon" [iconName]="questionTypeSelectorModel.iconName" [size]="24"
sv-ng-svg-icon></svg>
<sv-ng-popup *ngIf="renderPopup" [popupModel]="questionTypeSelectorModel.popupModel"></sv-ng-popup>
</button>
</ng-template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Component, Input } from "@angular/core";
import { ActionBarItemComponent, AngularComponentFactory } from "survey-angular-ui";
import { CreatorModelComponent } from "./creator-model.component";
import { Base } from "survey-core";

@Component(
{
selector: "svc-add-question-type-selector",
templateUrl: "./add-question-type-selector.component.html",
styles: [":host { display: none; }"]
}
)
export class AddQuestionTypeSelectorComponent extends CreatorModelComponent<Base> {
protected override getPropertiesToTrack(): string[] {
return [];
}
protected override createModel(): void {
}
protected override getModel(): Base {
return this.questionTypeSelectorModel;
}
@Input() questionTypeSelectorModel!: any;
@Input() renderPopup?: boolean = true;
public selectQuestionType(event: any) {
event.stopPropagation();
this.questionTypeSelectorModel.action();
}
}
AngularComponentFactory.Instance.registerComponent("svc-add-question-type-selector", AddQuestionTypeSelectorComponent);
16 changes: 16 additions & 0 deletions packages/survey-creator-angular/src/add-question.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<ng-template #template>
<div *ngIf="adorner.showAddQuestionButton" [class]="'svc-element__add-new-question ' + buttonClass" [key2click]
(click)="addNewQuestion($event)"
(mouseover)="adorner.hoverStopper && adorner.hoverStopper($event, $event.currentTarget)"
data-bind="clickBubble: false">
<span class="svc-text svc-text--normal svc-text--bold">
{{ adorner.addNewQuestionText }}
</span>
<ng-template *ngIf="renderPopup"
[component]="{ name: 'svc-add-question-type-selector', data: { questionTypeSelectorModel: adorner.questionTypeSelectorModel, renderPopup: renderPopup } }">
</ng-template>
</div>
<ng-template *ngIf="!renderPopup"
[component]="{ name: 'svc-add-question-type-selector', data: { questionTypeSelectorModel: adorner.questionTypeSelectorModel, renderPopup: renderPopup } }">
</ng-template>
</ng-template>
33 changes: 33 additions & 0 deletions packages/survey-creator-angular/src/add-question.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Component, Input } from "@angular/core";
import { ActionBarItemComponent, AngularComponentFactory } from "survey-angular-ui";
import { CreatorModelComponent } from "./creator-model.component";
import { Base } from "survey-core";

@Component(
{
selector: "svc-add-new-question-btn",
templateUrl: "./add-question.component.html",
styles: [":host { display: none; }"]
}
)
export class AddQuestionButtonComponent extends CreatorModelComponent<Base> {
protected override getPropertiesToTrack(): string[] {
return [];
}
protected override createModel(): void {
}
protected override getModel(): Base {
return this.model.data;
}
@Input() model!: any;
@Input() buttonClass?: string = "svc-btn";
@Input() renderPopup?: boolean = true;
public get adorner() {
return this.model.data;
}
public addNewQuestion(event: any) {
event.stopPropagation();
this.adorner.addNewQuestion(this.adorner, event);
}
}
AngularComponentFactory.Instance.registerComponent("svc-add-new-question-btn", AddQuestionButtonComponent);
7 changes: 4 additions & 3 deletions packages/survey-creator-angular/src/angular-ui.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import { SurveyResultsTableRowComponent } from "./tabs/preview/survey-results-ro
import { TestTabComponent } from "./tabs/preview/test.component";
import { ThemeTabComponent } from "./tabs/theme/theme.component";
import { PageDesignerComponent } from "./page.component";
import { AddQuestionButtonComponent } from "./page-add-question.component";
import { AddQuestionButtonComponent } from "./add-question.component";
import { AddQuestionTypeSelectorComponent } from "./add-question-type-selector.component";
import { QuestionDesignerComponent } from "./question.component";
import { ItemValueDesignerComponent } from "./adorners/item-value.component";
import { ImageItemValueDesignerComponent } from "./adorners/image-item-value.component";
Expand Down Expand Up @@ -81,7 +82,7 @@ import { TranslateFromAction } from "./tabs/translation/translate-from-action.co
AdaptiveToolboxComponent, ToolboxToolComponent, ToolboxItemComponent, ToolboxItemGroupComponent, ToolboxListComponent, ToolboxCategoryComponent, StringEditorComponent, PageNavigatorComponent, PageNavigatorItemComponent,
QuestionDropdownDesignerComponent, QuestionDropdownAdornerDesignerComponent, QuestionImageDesignerComponent, QuestionImageAdornerDesignerComponent,
ItemValueDesignerComponent, ImageItemValueDesignerComponent, LogicOperatorComponent, MatrixCellComponent, QuestionEditorComponent, CellQuestionDropdownComponent, CreatorRowComponent, DesignerPagesComponent, DesignerSurveyComponent, CellQuestionComponent, QuestionWidgetDesignerComponent, ToolboxComponent, CreatorLogoImageComponent,
QuestionRatingAdornerDesignerComponent, QuestionRatingDesignerComponent, QuestionSpinEditorComponent, ColorItemComponent, QuestionColorComponent, QuestionFileEditorComponent, AddQuestionButtonComponent, QuestionBannerComponent, JsonErrorItemComponent, QuestionTextWithResetComponent, TranslateFromAction],
QuestionRatingAdornerDesignerComponent, QuestionRatingDesignerComponent, QuestionSpinEditorComponent, ColorItemComponent, QuestionColorComponent, QuestionFileEditorComponent, AddQuestionButtonComponent, AddQuestionTypeSelectorComponent, QuestionBannerComponent, JsonErrorItemComponent, QuestionTextWithResetComponent, TranslateFromAction],

imports: [
CommonModule, FormsModule, SurveyModule
Expand All @@ -91,7 +92,7 @@ import { TranslateFromAction } from "./tabs/translation/translate-from-action.co
AdaptiveToolboxComponent, ToolboxToolComponent, ToolboxItemComponent, ToolboxItemGroupComponent, ToolboxListComponent, ToolboxCategoryComponent, StringEditorComponent, PageNavigatorComponent, PageNavigatorItemComponent,
QuestionDropdownDesignerComponent, QuestionDropdownAdornerDesignerComponent, QuestionImageDesignerComponent, QuestionImageAdornerDesignerComponent,
ItemValueDesignerComponent, ImageItemValueDesignerComponent, LogicOperatorComponent, MatrixCellComponent, QuestionEditorComponent, CellQuestionDropdownComponent, CreatorRowComponent, DesignerPagesComponent, DesignerSurveyComponent, CellQuestionComponent, QuestionWidgetDesignerComponent, ToolboxComponent, CreatorLogoImageComponent,
QuestionRatingAdornerDesignerComponent, QuestionRatingDesignerComponent, QuestionSpinEditorComponent, ColorItemComponent, QuestionColorComponent, QuestionFileEditorComponent, AddQuestionButtonComponent, QuestionBannerComponent, JsonErrorItemComponent, QuestionTextWithResetComponent, TranslateFromAction],
QuestionRatingAdornerDesignerComponent, QuestionRatingDesignerComponent, QuestionSpinEditorComponent, ColorItemComponent, QuestionColorComponent, QuestionFileEditorComponent, AddQuestionButtonComponent, AddQuestionTypeSelectorComponent, QuestionBannerComponent, JsonErrorItemComponent, QuestionTextWithResetComponent, TranslateFromAction],
providers: [],
})
export class SurveyCreatorModule { }
3 changes: 2 additions & 1 deletion packages/survey-creator-angular/src/angular-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export * from "./tabs/preview/survey-results-row.component";
export * from "./tabs/preview/test.component";
export * from "./tabs/theme/theme.component";
export * from "./page.component";
export * from "./page-add-question.component";
export * from "./add-question.component";
export * from "./add-question-type-selector.component";
export * from "./question.component";
export * from "./adorners/item-value.component";
export * from "./adorners/image-item-value.component";
Expand Down

This file was deleted.

24 changes: 0 additions & 24 deletions packages/survey-creator-angular/src/page-add-question.component.ts

This file was deleted.

29 changes: 10 additions & 19 deletions packages/survey-creator-angular/src/panel.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<ng-template #template>
<div *ngIf="adorner" class="svc-question__adorner" [class]="adorner.rootCss()"
(dblclick)="adorner.dblclick($event)"
<div *ngIf="adorner" class="svc-question__adorner" [class]="adorner.rootCss()" (dblclick)="adorner.dblclick($event)"
(mouseover)="adorner.hover($event, $event.currentTarget)" (mouseleave)="adorner.hover($event, $event.currentTarget)"
[attr.data-sv-drop-target-survey-element]="adorner.element.name || null" #container>

Expand All @@ -14,9 +13,9 @@
(pointerdown)="adorner.onPointerDown($event)">
<svg class="svc-question__drag-element" [iconName]="'icon-drag-area-indicator_24x16'" [size]="24"
sv-ng-svg-icon></svg>
<div class="svc-question__top-actions">
<sv-action-bar [model]="adorner.topActionContainer" [handleClick]="false"></sv-action-bar>
</div>
<div class="svc-question__top-actions">
<sv-action-bar [model]="adorner.topActionContainer" [handleClick]="false"></sv-action-bar>
</div>
</div>

<ng-template [component]="{ name: componentName, data: componentData }"></ng-template>
Expand All @@ -26,8 +25,6 @@
<div class="svc-panel__placeholder">{{ adorner.placeholderText }}</div>
<div *ngIf="adorner.showAddQuestionButton" class="svc-panel__add-new-question svc-action-button" [key2click]
(click)="addNewQuestion($event)">
<svg class="svc-panel__add-new-question-icon" [iconName]="('icon-add_24x24')"
[size]="24" sv-ng-svg-icon></svg>
<span class="svc-text svc-text--normal svc-text--bold">
{{ adorner.addNewQuestionText }}
</span>
Expand All @@ -44,22 +41,16 @@
<div class="svc-panel__question-type-selector-popup"> <sv-ng-popup
[popupModel]="adorner.questionTypeSelectorModel.popupModel"></sv-ng-popup>
</div>

<div class="svc-panel__add-new-question-wrapper">
<div class="svc-panel__add-new-question svc-action-button" [key2click] (click)="addNewQuestion($event)">
<svg class="svc-panel__add-new-question-icon" [iconName]="('icon-add_24x24')" [size]="24" sv-ng-svg-icon></svg>
<span class="svc-text svc-text--normal svc-text--bold">
{{ adorner.addNewQuestionText }}
</span>
</div>
<button type="button" [attr.title]="adorner.addNewQuestionText" [key2click] (click)="selectQuestionType($event)"
class="svc-panel__question-type-selector">
<svg class="svc-panel__question-type-selector-icon" [iconName]="adorner.questionTypeSelectorModel.iconName"
[size]="24" sv-ng-svg-icon></svg>
</button>
<ng-template
[component]="{ name: 'svc-add-new-question-btn', data: { model: { data: adorner }, buttonClass: 'svc-action-button', renderPopup: false } }">
</ng-template>
</div>
</div>

<div *ngIf="adorner.element.isInteractiveDesignElement" class="svc-question__content-actions" (focusin)="adorner.select(adorner, $event)">
<div *ngIf="adorner.element.isInteractiveDesignElement" class="svc-question__content-actions"
(focusin)="adorner.select(adorner, $event)">
<sv-action-bar [model]="adorner.actionContainer" [handleClick]="false"></sv-action-bar>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions packages/survey-creator-core/src/components/page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,17 @@ svc-page {
}
}

.svc-page__add-new-question {
.svc-element__add-new-question {
.svc-text {
margin-left: calcSize(6);
}
}

.svc-page__add-new-question {
.svc-element__add-new-question {
-webkit-tap-highlight-color: transparent;
}

.svc-page__question-type-selector {
.svc-element__question-type-selector {
appearance: none;
display: flex;
height: calcSize(5);
Expand Down Expand Up @@ -281,7 +281,7 @@ svc-page {
}
}

.svc-page__add-new-question,
.svc-element__add-new-question,
.svc-question__adorner {
.sv-list__item.sv-list__item--disabled {
opacity: 0.25;
Expand Down
2 changes: 1 addition & 1 deletion packages/survey-creator-core/src/components/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class PageAdorner extends SurveyElementAdornerBase<PageModel> {
}
}

addNewQuestion(model: PageAdorner, event: IPortableMouseEvent, type?: string) {
addNewQuestion = (model: PageAdorner, event: IPortableMouseEvent, type?: string) => {
this.creator.addNewQuestionInPage((type) => {
this.addGhostPage(false);
this.creator.survey.currentPage = this.page;
Expand Down
Loading
Loading