Skip to content
Permalink
Browse files
feat: textarea is now provided is the gui-element is a textarea (#529)
  • Loading branch information
mdelez committed Sep 9, 2021
1 parent 3976470 commit e80a4d27fbb364a9d752153e3ce73a7290b8336a

Some generated files are not rendered by default. Learn more.

@@ -5,7 +5,7 @@
[ngClass]='backgroundColor'>
<span [ngSwitch]="valueTypeOrClass">
<!-- display value is cast as 'any' because the compiler cannot infer the value type expected by the child component -->
<app-text-value-as-string class="parent-value-component" #displayVal *ngSwitchCase="'ReadTextValueAsString'" [mode]="mode" [displayValue]="$any(displayValue)"></app-text-value-as-string>
<app-text-value-as-string class="parent-value-component" #displayVal *ngSwitchCase="'ReadTextValueAsString'" [mode]="mode" [displayValue]="$any(displayValue)" [textArea]="textArea"></app-text-value-as-string>
<app-text-value-as-html class="parent-value-component" #displayVal *ngSwitchCase="'ReadTextValueAsHtml'" [mode]="mode" [displayValue]="$any(displayValue)"></app-text-value-as-html>
<app-text-value-as-xml class="parent-value-component" #displayVal *ngSwitchCase="'ReadTextValueAsXml'" [mode]="mode" [displayValue]="$any(displayValue)"
(internalLinkClicked)="standoffLinkClicked($event)" (internalLinkHovered)="standoffLinkHovered($event)"></app-text-value-as-xml>
@@ -108,6 +108,8 @@ export class DisplayEditComponent implements OnInit {

showDateLabels = false;

textArea = false;

dateFormat: string;

user: ReadUser;
@@ -142,6 +144,10 @@ export class DisplayEditComponent implements OnInit {
(propDef: ResourcePropertyDefinition) => propDef.id === this.displayValue.property
);

if(resPropDef[0].guiElement === Constants.SalsahGui + Constants.HashDelimiter + 'Textarea') {
this.textArea = true;
}

if (resPropDef.length !== 1) {
// this should never happen because we always have the property info for the given value
throw new Error('Resource Property Definition could not be found: ' + this.displayValue.property);
@@ -1,5 +1,5 @@
<span [ngSwitch]="property.objectType">
<app-text-value-as-string #createVal *ngSwitchCase="'ReadTextValueAsString'" [mode]="mode" [valueRequiredValidator]="isRequiredProp" [parentForm]="parentForm" [formName]="formName" ></app-text-value-as-string>
<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-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"></app-boolean-value>
@@ -23,6 +23,7 @@ export class SwitchPropertiesComponent implements OnInit {
@Input() isRequiredProp: boolean;

mode = 'create';
textArea = false;
constants = Constants;

constructor() { }
@@ -32,6 +33,9 @@ export class SwitchPropertiesComponent implements OnInit {
// 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;
}
}

saveNewValue() {
@@ -5,7 +5,8 @@
<ng-template #showForm>
<span [formGroup]="form">
<mat-form-field class="large-field child-value-component" floatLabel="never">
<input matInput [formControlName]="'value'" class="value" placeholder="Text value" type="text" [errorStateMatcher]="matcher">
<input *ngIf="!textArea" matInput [formControlName]="'value'" class="value" placeholder="Text value" type="text" [errorStateMatcher]="matcher">
<textarea *ngIf="textArea" matInput [formControlName]="'value'" class="value" placeholder="Text value" type="text" [errorStateMatcher]="matcher"></textarea>
<mat-error *ngIf="valueFormControl.hasError('valueNotChanged') &&
(valueFormControl.touched || valueFormControl.dirty)">
<span class="custom-error-message">New value must be different than the current value.</span>
@@ -16,6 +16,7 @@ const resolvedPromise = Promise.resolve(null);
export class TextValueAsStringComponent extends BaseValueDirective implements OnInit, OnChanges, OnDestroy {

@Input() displayValue?: ReadTextValueAsString;
@Input() textArea?: false;

valueFormControl: FormControl;
commentFormControl: FormControl;

0 comments on commit e80a4d2

Please sign in to comment.