-
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: start work on toolbox
- Loading branch information
Showing
10 changed files
with
159 additions
and
2 deletions.
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
2 changes: 1 addition & 1 deletion
2
packages/survey-creator-angular/src/tabs/designer.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
14 changes: 14 additions & 0 deletions
14
packages/survey-creator-angular/src/toolbox/adaptive-toolbox.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,14 @@ | ||
<ng-template #template> | ||
<div class="svc-toolbox" [class.svc-toolbox--compact]="model.isCompact" #container> | ||
<div class="svc-toolbox__container"> | ||
<ng-container *ngIf="!(model.isCompact || model.categories.length == 1)"> | ||
<svc-toolbox-category *ngFor="let category of model.categories" [category]="category" [toolbox]="model"></svc-toolbox-category> | ||
</ng-container> | ||
<ng-container *ngIf="model.isCompact || model.categories.length == 1"> | ||
<div class="svc-toolbox__category"> | ||
<svc-toolbox-tool *ngFor="let item of model.renderedActions" [creator]="creator" [item]="item" [isCompact]="model.isCompact"></svc-toolbox-tool> | ||
</div> | ||
</ng-container> | ||
</div> | ||
</div> | ||
</ng-template> |
30 changes: 30 additions & 0 deletions
30
packages/survey-creator-angular/src/toolbox/adaptive-toolbox.component.ts
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,30 @@ | ||
import { AfterViewInit, Component, ElementRef, Input, ViewChild } from "@angular/core"; | ||
import { CreatorBase, QuestionToolbox } from "survey-creator-core"; | ||
import { VerticalResponsivityManager } from "survey-core"; | ||
import { BaseAngular } from "survey-angular-ui"; | ||
|
||
@Component({ | ||
selector: "svc-adaptive-toolbox", | ||
templateUrl: "./adaptive-toolbox.component.html", | ||
styles: [":host { display: none; }"] | ||
}) | ||
export class AdaptiveToolboxComponent extends BaseAngular<QuestionToolbox> implements AfterViewInit { | ||
@Input() creator!: CreatorBase; | ||
@ViewChild("container") container!: ElementRef<HTMLElement>; | ||
private responsivityManager: VerticalResponsivityManager | undefined; | ||
public get model() { | ||
return this.creator.toolbox; | ||
} | ||
ngAfterViewInit() { | ||
this.responsivityManager = | ||
new VerticalResponsivityManager(this.container.nativeElement, | ||
this.model, ".svc-toolbox__tool:not(.sv-dots)>.sv-action__content", 44, 44); | ||
} | ||
protected getModel(): QuestionToolbox { | ||
return this.model; | ||
} | ||
override ngOnDestroy(): void { | ||
this.responsivityManager?.dispose(); | ||
super.ngOnDestroy(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/survey-creator-angular/src/toolbox/toolbox-category.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,17 @@ | ||
<ng-template #template> | ||
<div class="svc-toolbox__category"> | ||
<div class="svc-toolbox__category-header" | ||
(click)="category.toggleState()" [key2click] [class.svc-toolbox__category-header--collapsed]="toolbox.canCollapseCategories"> | ||
<span class="svc-toolbox__category-title">{{category.name}}</span> | ||
<div *ngIf="toolbox.canCollapseCategories" class="svc-toolbox__category-header__controls"> | ||
<svg [iconName]="'icon-arrow-down'" class="svc-toolbox__category-header__button svc-string-editor__button--expand" [size]="24" sv-ng-svg-icon></svg> | ||
<svg [iconName]="'icon-arrow-up'" class="svc-toolbox__category-header__button svc-string-editor__button--collapse" [size]="24" sv-ng-svg-icon [visible]="category.collapsed"></svg> | ||
</div> | ||
</div> | ||
<ng-container *ngIf="!category.collapsed"> | ||
<ng-container *ngFor="let item of category.items"> | ||
<svc-toolbox-tool [item]="item" [creator]="toolbox.creator" [isCompact]="false" ></svc-toolbox-tool> | ||
</ng-container> | ||
</ng-container> | ||
</div> | ||
</ng-template> |
16 changes: 16 additions & 0 deletions
16
packages/survey-creator-angular/src/toolbox/toolbox-category.component.ts
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,16 @@ | ||
import { Component, Input } from "@angular/core"; | ||
import { BaseAngular } from "survey-angular-ui"; | ||
import { QuestionToolbox, QuestionToolboxCategory } from "survey-creator-core"; | ||
|
||
@Component({ | ||
selector: "svc-toolbox-category ", | ||
templateUrl: "./toolbox-category.component.html", | ||
styles: [":host { display: none; }"] | ||
}) | ||
export class ToolboxCategoryComponent extends BaseAngular<QuestionToolboxCategory> { | ||
@Input() category!: QuestionToolboxCategory; | ||
@Input() toolbox!: QuestionToolbox; | ||
getModel() { | ||
return this.category; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/survey-creator-angular/src/toolbox/toolbox-item.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,15 @@ | ||
<ng-template #template> | ||
<div class="svc-toolbox__item" role="button" [attr.ariaLabel]="ariaLabel" | ||
[class]="'svc-toolbox__item--' + item.iconName" (click)="viewModel.click($event)" [key2click]> | ||
<span class="svc-toolbox__item-container"> | ||
<svg [iconName]="item.iconName" [size]="24" [title]="ariaLabel" sv-ng-svg-icon></svg> | ||
</span> | ||
<span *ngIf="isCompact" class="svc-toolbox__item-banner svc-item__banner"> | ||
<svg [iconName]="item.iconName" [size]="24" [title]="ariaLabel" class="svc-toolbox__item-icon" sv-ng-svg-icon></svg> | ||
<span class="svc-toolbox__item-title">{{item.title}}</span> | ||
</span> | ||
<span *ngIf="!isCompact" class="svc-toolbox__item-title"> | ||
{{item.title}} | ||
</span> | ||
</div> | ||
</ng-template> |
26 changes: 26 additions & 0 deletions
26
packages/survey-creator-angular/src/toolbox/toolbox-item.component.ts
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,26 @@ | ||
import { Component, Input } from "@angular/core"; | ||
import { ToolboxToolViewModel, CreatorBase, IQuestionToolboxItem, editorLocalization } from "survey-creator-core"; | ||
import { BaseAngular, AngularComponentFactory } from "survey-angular-ui"; | ||
import { Action } from "survey-core"; | ||
|
||
@Component({ | ||
selector: "svc-toolbox-item", | ||
templateUrl: "./toolbox-item.component.html", | ||
styles: [":host { display: none; }"] | ||
}) | ||
export class ToolboxItemComponent extends BaseAngular<ToolboxToolViewModel> { | ||
@Input() creator!: CreatorBase; | ||
@Input() model!: Action; | ||
@Input() isCompact: boolean = false; | ||
@Input() viewModel!: ToolboxToolViewModel | ||
protected getModel(): ToolboxToolViewModel { | ||
return this.viewModel; | ||
} | ||
public get item() { | ||
return this.model; | ||
} | ||
public get ariaLabel(): string { | ||
return this.item.tooltip + " " + editorLocalization.getString("toolbox") + " item"; | ||
} | ||
} | ||
AngularComponentFactory.Instance.registerComponent("svc-toolbox-item", ToolboxItemComponent); |
9 changes: 9 additions & 0 deletions
9
packages/survey-creator-angular/src/toolbox/toolbox-tool.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,9 @@ | ||
<ng-template #template> | ||
<div class="svc-toolbox__tool" | ||
[class.sv-action--hidden]="!item.isVisible" [class]="item.css" (pointerdown)="model.onPointerDown($event)"> | ||
<div class="sv-action__content"> | ||
<div class="svc-toolbox__category-separator" *ngIf="item.needSeparator && isCompact"></div> | ||
<ng-template [component]="{ name: item.component || 'svc-toolbox-item', default: 'svc-toolbox-item', data: { model: item, viewModel: model, creator: creator, isCompact: isCompact } }"></ng-template> | ||
</div> | ||
</div> | ||
</ng-template> |
25 changes: 25 additions & 0 deletions
25
packages/survey-creator-angular/src/toolbox/toolbox-tool.component.ts
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,25 @@ | ||
import { Component, Input } from "@angular/core"; | ||
import { CreatorModelComponent } from "../creator-model.component"; | ||
import { CreatorBase, IQuestionToolboxItem, ToolboxToolViewModel } from "survey-creator-core"; | ||
import { Action } from "survey-core"; | ||
|
||
@Component({ | ||
selector: "svc-toolbox-tool", | ||
templateUrl: "./toolbox-tool.component.html", | ||
styles: [":host { display: none; }"] | ||
}) | ||
export class ToolboxToolComponent extends CreatorModelComponent<Action> { | ||
@Input() creator!: CreatorBase; | ||
@Input() item!: Action; | ||
@Input() isCompact: boolean = false; | ||
public model!: ToolboxToolViewModel; | ||
createModel() { | ||
this.model = new ToolboxToolViewModel(<any>this.item, this.creator); | ||
} | ||
protected getPropertiesToTrack(): string[] { | ||
return ["creator", "item"]; | ||
} | ||
protected getModel(): Action { | ||
return this.item; | ||
} | ||
} |