Skip to content
Snippets Groups Projects
Commit 4b7df84a authored by rhenck's avatar rhenck
Browse files

Implement strikethrough for selected ToggleButton value

Also refactor properties panel and ToggleButton class logic for striking 
values. This now relies more on CSS classes provided by Material instead 
of doing finetuned logic my ourselves. This also allows showing the 
correct preview in the editor.

#287
parent 9b7a2593
No related branches found
No related tags found
No related merge requests found
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { FormElementComponent } from '../../../../directives/form-element-component.directive'; import { FormElementComponent } from 'common/directives/form-element-component.directive';
import { ToggleButtonElement } from 'common/models/elements/compound-elements/cloze/cloze-child-elements/toggle-button'; import { ToggleButtonElement } from 'common/models/elements/compound-elements/cloze/cloze-child-elements/toggle-button';
@Component({ @Component({
...@@ -11,9 +11,8 @@ import { ToggleButtonElement } from 'common/models/elements/compound-elements/cl ...@@ -11,9 +11,8 @@ import { ToggleButtonElement } from 'common/models/elements/compound-elements/cl
[style.width]="elementModel.dynamicWidth ? 'unset' : '100%'"> [style.width]="elementModel.dynamicWidth ? 'unset' : '100%'">
<mat-button-toggle *ngFor="let option of elementModel.richTextOptions; let i = index" <mat-button-toggle *ngFor="let option of elementModel.richTextOptions; let i = index"
[value]="i" [value]="i"
[ngClass]="{ 'strike' : elementModel.strikeOtherOptions && [ngClass]="{ 'strike-other-options' : elementModel.strikeOtherOptions,
elementFormControl.value !== null && 'strike-selected-option' : elementModel.strikeSelectedOption }"
elementFormControl.value !== i }"
[style.color]="elementModel.styling.fontColor" [style.color]="elementModel.styling.fontColor"
[style.font-size.px]="elementModel.styling.fontSize" [style.font-size.px]="elementModel.styling.fontSize"
[style.font-weight]="elementModel.styling.bold ? 'bold' : ''" [style.font-weight]="elementModel.styling.bold ? 'bold' : ''"
...@@ -33,7 +32,10 @@ import { ToggleButtonElement } from 'common/models/elements/compound-elements/cl ...@@ -33,7 +32,10 @@ import { ToggleButtonElement } from 'common/models/elements/compound-elements/cl
'mat-button-toggle-group {display: inline-flex; min-width: 70px; min-height: 20px; max-width: 100%;}', 'mat-button-toggle-group {display: inline-flex; min-width: 70px; min-height: 20px; max-width: 100%;}',
'mat-button-toggle-group {justify-content: center;}', 'mat-button-toggle-group {justify-content: center;}',
':host ::ng-deep .mat-button-toggle-label-content {line-height: unset}', ':host ::ng-deep .mat-button-toggle-label-content {line-height: unset}',
':host ::ng-deep .strike .mat-button-toggle-label-content {text-decoration: line-through}', ':host ::ng-deep .strike-selected-option.mat-button-toggle-checked .mat-button-toggle-label-content' +
'{text-decoration: line-through}',
':host ::ng-deep .strike-other-options:not(.mat-button-toggle-checked) .mat-button-toggle-label-content' +
'{text-decoration: line-through}'
] ]
}) })
export class ToggleButtonComponent extends FormElementComponent { export class ToggleButtonComponent extends FormElementComponent {
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
export class ToggleButtonElement extends InputElement { export class ToggleButtonElement extends InputElement {
richTextOptions: string[] = []; richTextOptions: string[] = [];
strikeOtherOptions: boolean = false; strikeOtherOptions: boolean = false;
strikeSelectedOption: boolean = false;
verticalOrientation: boolean = false; verticalOrientation: boolean = false;
dynamicWidth: boolean = true; dynamicWidth: boolean = true;
styling: BasicStyles & { styling: BasicStyles & {
...@@ -20,6 +21,7 @@ export class ToggleButtonElement extends InputElement { ...@@ -20,6 +21,7 @@ export class ToggleButtonElement extends InputElement {
super({ height: 25, ...element }, ...args); super({ height: 25, ...element }, ...args);
if (element.richTextOptions) this.richTextOptions = element.richTextOptions; if (element.richTextOptions) this.richTextOptions = element.richTextOptions;
if (element.strikeOtherOptions) this.strikeOtherOptions = element.strikeOtherOptions; if (element.strikeOtherOptions) this.strikeOtherOptions = element.strikeOtherOptions;
if (element.strikeSelectedOption) this.strikeSelectedOption = element.strikeSelectedOption;
if (element.verticalOrientation) this.verticalOrientation = element.verticalOrientation; if (element.verticalOrientation) this.verticalOrientation = element.verticalOrientation;
if (element.dynamicWidth !== undefined) this.dynamicWidth = element.dynamicWidth; if (element.dynamicWidth !== undefined) this.dynamicWidth = element.dynamicWidth;
this.styling = { this.styling = {
......
...@@ -23,3 +23,15 @@ ...@@ -23,3 +23,15 @@
button { button {
margin-bottom: 15px; margin-bottom: 15px;
} }
:host ::ng-deep .mat-form-field {
margin-bottom: -10px;
}
:host ::ng-deep fieldset {
margin-bottom: 15px;
}
:host ::ng-deep .mat-checkbox {
margin-bottom: 8px;
}
import { import {
Component, EventEmitter, Input, Output Component, EventEmitter, Input, Output
} from '@angular/core'; } from '@angular/core';
import { CombinedProperties } from 'editor/src/app/components/properties-panel/element-properties-panel.component';
@Component({ @Component({
selector: 'aspect-select-properties', selector: 'aspect-select-properties',
...@@ -25,8 +26,10 @@ import { ...@@ -25,8 +26,10 @@ import {
] ]
}) })
export class SelectPropertiesComponent { export class SelectPropertiesComponent {
@Input() combinedProperties!: any; @Input() combinedProperties!: CombinedProperties;
@Output() updateModel = @Output() updateModel =
new EventEmitter<{ property: string; value: string | number | boolean | string[], isInputValid?: boolean | null }>(); new EventEmitter<{
property: string,
value: string | number | boolean | string[]
}>();
} }
...@@ -100,7 +100,8 @@ ...@@ -100,7 +100,8 @@
"true": "wahr", "true": "wahr",
"false": "falsch", "false": "falsch",
"appearance": "Aussehen", "appearance": "Aussehen",
"strikeOtherOptions": "Andere Optionen durchstreichen", "strikeOtherOptions": "Nicht gewählte Optionen durchstreichen",
"strikeSelectedOption": "Gewählte Option durchstreichen",
"minLength": "Minimallänge", "minLength": "Minimallänge",
"minValue": "Minimalwert", "minValue": "Minimalwert",
"minLengthWarnMessage": "Minimalwert Warnmeldung", "minLengthWarnMessage": "Minimalwert Warnmeldung",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment