-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work for #3390: started svc-question
- Loading branch information
T_S_V
committed
Sep 7, 2022
1 parent
7c55cdd
commit c1f7606
Showing
3 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
packages/survey-creator-angular/src/question.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<ng-template #template> | ||
<div *ngIf="model && adorner" class="svc-question__adorner" [class]="adorner.rootCss()" | ||
data-bind="css: rootCss(), attr: { 'data-sv-drop-target-survey-element': element.name || null }, event: { mouseover: function(m, e) { hover(e, $element); }, mouseleave: function(m, e) { hover(e, $element); } }"> | ||
|
||
<div *ngIf="adorner.element.isInteractiveDesignElement" class="svc-question__content" [class]="adorner.css()" | ||
data-bind="click: koSelect, key2click, clickBubble: false, css: css()"> | ||
<div *ngIf="adorner.allowDragging" class="svc-question__drag-area" | ||
data-bind="event: {pointerdown: (model, event)=>{onPointerDown(event)}}"> | ||
<!-- ko component: { name: 'sv-svg-icon', params: { css: 'svc-question__drag-element', iconName: 'icon-drag-area-indicator_24x16', size: 24 } } --> | ||
<!-- /ko --> | ||
<svg class="svc-question__drag-element" [iconName]="'icon-drag-area-indicator_24x16'" [size]="24" | ||
sv-ng-svg-icon></svg> | ||
</div> | ||
|
||
<!-- ko component: { name: 'sv-template-renderer', params: { componentData: null, templateData: templateData } } --> | ||
<!-- /ko --> | ||
<ng-template [component]="{ name: 'sv-template-renderer', data: { model: model } }"></ng-template> | ||
|
||
<div *ngIf="adorner.isEmptyElement" class="svc-panel__placeholder_frame"> | ||
<div class="svc-panel__placeholder" data-bind="text: placeholderText"></div> | ||
<!-- ko if: element.isPanel && showAddQuestionButton --> | ||
<div class="svc-panel__add-new-question svc-action-button" | ||
data-bind="click: addNewQuestion, key2click, clickBubble: false"> | ||
<span class="svc-text svc-text--normal svc-text--bold" data-bind="text: $data.addNewQuestionText"> | ||
</span> | ||
</div> | ||
<!-- /ko --> | ||
</div> | ||
|
||
<!-- ko if: adornerComponent --> | ||
<!-- ko component: { name: adornerComponent, params: { model: $data } } --> | ||
<!-- /ko --> | ||
<!-- /ko --> | ||
|
||
<div *ngIf="!adorner.isEmptyElement && model.isPanel && adorner.showAddQuestionButton" | ||
class="svc-panel__add-new-question-container"> | ||
<div class="svc-panel__add-new-question svc-action-button" | ||
data-bind="click: addNewQuestion, key2click, clickBubble: false"> | ||
<span class="svc-text svc-text--normal svc-text--bold" data-bind="text: $data.addNewQuestionText"> | ||
</span> | ||
</div> | ||
<!-- ko with: questionTypeSelectorModel --> | ||
<button type="button" | ||
data-bind="click: action, key2click, clickBubble: false, attr: { title: $data.addNewQuestionText }" | ||
class="svc-panel__question-type-selector"> | ||
<!-- <sv-svg-icon class="svc-panel__question-type-selector-icon" params="iconName: iconName, size: 24"></sv-svg-icon> --> | ||
<!-- <sv-popup params="model: popupModel"></sv-popup> --> | ||
</button> | ||
<!-- /ko --> | ||
</div> | ||
|
||
<div class="svc-question__content-actions"> | ||
<!-- ko component: { name: 'sv-action-bar', params: { model: actionContainer, handleClick: false } } --> | ||
<!-- /ko --> | ||
<sv-action-bar [model]="adorner.actionContainer"></sv-action-bar> | ||
</div> | ||
</div> | ||
|
||
<ng-container *ngIf="!adorner.element.isInteractiveDesignElement"> | ||
<!-- ko component: { name: 'sv-template-renderer', params: { componentData: null, templateData: templateData } } --> | ||
<!-- /ko --> | ||
<ng-template [component]="{ name: 'sv-template-renderer', data: { model: model } }"></ng-template> | ||
|
||
<div *ngIf="adorner.isEmptyElement" class="svc-panel__placeholder_frame"> | ||
<div class="svc-panel__placeholder" data-bind="text: placeholderText"></div> | ||
<!-- ko if: showAddQuestionButton --> | ||
<div class="svc-panel__add-new-question svc-action-button" | ||
data-bind="click: addNewQuestion, key2click, clickBubble: false"> | ||
<span class="svc-text svc-text--normal svc-text--bold" data-bind="text: $data.addNewQuestionText"> | ||
</span> | ||
</div> | ||
<!-- /ko --> | ||
</div> | ||
|
||
<div *ngIf="!adorner.isEmptyElement" class="svc-panel__add-new-question-container"> | ||
<div class="svc-panel__add-new-question svc-action-button" | ||
data-bind="click: addNewQuestion, key2click, clickBubble: false"> | ||
<span class="svc-text svc-text--normal svc-text--bold" data-bind="text: $data.addNewQuestionText"> | ||
</span> | ||
</div> | ||
<!-- ko with: questionTypeSelectorModel --> | ||
<button type="button" | ||
data-bind="click: action, key2click, clickBubble: false, attr: { title: $data.addNewQuestionText }" | ||
class="svc-panel__question-type-selector"> | ||
<!-- <sv-svg-icon class="svc-panel__question-type-selector-icon" params="iconName: iconName, size: 24"></sv-svg-icon> --> | ||
<!-- <sv-popup params="model: popupModel"></sv-popup> --> | ||
</button> | ||
<!-- /ko --> | ||
</div> | ||
|
||
</ng-container> | ||
</div> | ||
</ng-template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ChangeDetectorRef, Component, Input, ViewContainerRef } from "@angular/core"; | ||
import { AngularComponentFactory, BaseAngular, EmbeddedViewContentComponent } from "survey-angular-ui"; | ||
import { PageModel, Question, SurveyModel } from "survey-core"; | ||
import { CreatorBase, QuestionAdornerViewModel } from "survey-creator-core"; | ||
|
||
@Component({ | ||
selector: "svc-question", | ||
templateUrl: "./question.component.html", | ||
styles: [":host { display: none; }"] | ||
}) | ||
export class QuestionDesignerComponent extends BaseAngular<Question> { | ||
@Input() model!: any; | ||
@Input() componentData!: CreatorBase; | ||
public adorner?: QuestionAdornerViewModel; | ||
private get creator() { | ||
return this.componentData; | ||
} | ||
constructor(changeDetectorRef: ChangeDetectorRef, viewContainerRef?: ViewContainerRef) { | ||
super(changeDetectorRef, viewContainerRef); | ||
if(this.model) { | ||
this.adorner = new QuestionAdornerViewModel(this.creator, this.model, <any>null); | ||
} | ||
} | ||
protected override onModelChanged(): void { | ||
super.onModelChanged(); | ||
this.adorner = new QuestionAdornerViewModel(this.creator, this.model, <any>null); | ||
} | ||
protected getModel(): Question { | ||
return this.model; | ||
} | ||
} | ||
|
||
AngularComponentFactory.Instance.registerComponent("svc-question", QuestionDesignerComponent); | ||
|