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

fix(text-value): display line breaks in read mode of paragraph text values (DEV-211) #584

Merged
merged 1 commit into from Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
<span [ngSwitch]="property.objectType">
<app-text-value-as-string #createVal *ngSwitchCase="'ReadTextValueAsString'" [mode]="mode" [valueRequiredValidator]="isRequiredProp" [parentForm]="parentForm" [formName]="formName" [textArea]="textArea"></app-text-value-as-string>
<app-text-value-as-string #createVal *ngSwitchCase="'ReadTextValueAsString'" [mode]="mode" [valueRequiredValidator]="isRequiredProp" [parentForm]="parentForm" [formName]="formName" [guiElement]="textValueGuiEle"></app-text-value-as-string>
<app-text-value-as-xml #createVal *ngSwitchCase="'ReadTextValueAsXml'" [mode]="mode" [valueRequiredValidator]="isRequiredProp" [parentForm]="parentForm" [formName]="formName"></app-text-value-as-xml>
<app-int-value #createVal *ngSwitchCase="constants.IntValue" [mode]="mode" [valueRequiredValidator]="isRequiredProp" [parentForm]="parentForm" [formName]="formName"></app-int-value>
<app-boolean-value #createVal *ngSwitchCase="constants.BooleanValue" [mode]="mode" [valueRequiredValidator]="isRequiredProp" [parentForm]="parentForm" [formName]="formName" [moreSpace]="true"></app-boolean-value>
Expand Down
Expand Up @@ -2,6 +2,7 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { Constants, ReadResource, ResourcePropertyDefinition } from '@dasch-swiss/dsp-js';
import { BaseValueDirective } from 'src/app/main/directive/base-value.directive';
import { ValueService } from '../../../services/value.service';

@Component({
selector: 'app-switch-properties',
Expand All @@ -23,19 +24,23 @@ export class SwitchPropertiesComponent implements OnInit {
@Input() isRequiredProp: boolean;

mode = 'create';
textArea = false;

// gui element in case of textValue
textValueGuiEle: 'simpleText' | 'textArea' | 'richText';

constants = Constants;

constructor() { }
constructor(
private _valueService: ValueService
) { }

ngOnInit(): void {

// the input isRequiredProp provided by KeyValuePair is stored as a number
// a conversion from a number to a boolean is required by the input valueRequiredValidator
this.isRequiredProp = !!+this.isRequiredProp;
if(this.property.guiElement === Constants.SalsahGui + Constants.HashDelimiter + 'Textarea') {
this.textArea = true;
}

this.textValueGuiEle = this._valueService.getTextValueGuiEle(this.property.guiElement);
}

saveNewValue() {
Expand Down
@@ -1,5 +1,5 @@
<span *ngIf="mode === 'read'; else showForm" class="read-mode-view">
<span class="rm-value" [innerHtml]="valueFormControl.value | appLinkify"></span>
<span class="rm-value text-value" [innerHtml]="valueFormControl.value | appLinkify" style="white-space: pre-wrap;"></span>
<span class="rm-comment" *ngIf="shouldShowComment">{{commentFormControl.value}}</span>
</span>
<ng-template #showForm>
Expand Down
4 changes: 4 additions & 0 deletions src/assets/style/_viewer.scss
Expand Up @@ -6,6 +6,10 @@
display: block;
margin: 0px;
}

.rm-value.text-value {
white-space: pre-wrap;
}
}

.child-value-component,
Expand Down