Skip to content

Commit

Permalink
feat: textarea is now provided is the gui-element is a textarea (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelez committed Sep 9, 2021
1 parent 3976470 commit e80a4d2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
9 changes: 6 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -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>
Expand Down
Expand Up @@ -108,6 +108,8 @@ export class DisplayEditComponent implements OnInit {

showDateLabels = false;

textArea = false;

dateFormat: string;

user: ReadUser;
Expand Down Expand Up @@ -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);
Expand Down
@@ -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>
Expand Down
Expand Up @@ -23,6 +23,7 @@ export class SwitchPropertiesComponent implements OnInit {
@Input() isRequiredProp: boolean;

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

constructor() { }
Expand All @@ -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() {
Expand Down
Expand Up @@ -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>
Expand Down
Expand Up @@ -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;
Expand Down

0 comments on commit e80a4d2

Please sign in to comment.