Skip to content

Commit

Permalink
feature (value): adapt date to common value comp. structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Schweizer committed Apr 6, 2020
1 parent 87462a5 commit def47c9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
Expand Up @@ -40,7 +40,7 @@ export class DisplayEditComponent implements OnInit {
editModeActive = false;

shouldShowCommentToggle: boolean;

// type of given displayValue
// or knora-api-js-lib class representing the value
valueTypeOrClass: string;
Expand Down Expand Up @@ -135,7 +135,7 @@ export class DisplayEditComponent implements OnInit {
checkCommentToggleVisibility() {
this.shouldShowCommentToggle = (this.mode === 'read' && this.displayValue.valueHasComment !== '' && this.displayValue.valueHasComment !== undefined);
}

/**
* Given a value, determines the type or class representing it.
*
Expand Down Expand Up @@ -174,7 +174,6 @@ export class DisplayEditComponent implements OnInit {
isReadOnly(valueTypeOrClass: string): boolean {
return valueTypeOrClass === this.readTextValueAsHtml ||
valueTypeOrClass === this.readTextValueAsXml ||
valueTypeOrClass === this.constants.DateValue ||
valueTypeOrClass === this.constants.GeomValue ||
valueTypeOrClass === this.constants.GeonameValue;
}
Expand Down
@@ -1,5 +1,5 @@
<div [formGroup]="form" class="interval-input-container">
<mat-form-field class="start">
<mat-form-field class="start child-input-component">
<span class="calendar">{{startDateControl.value?.calendarName}}</span>
<kui-jdn-datepicker [activeCalendar]="startDateControl.value?.calendarName">
<input matInput [matDatepicker]="picker1" [formControlName]="'dateStart'" (dateChange)="_handleInput()" readonly>
Expand All @@ -8,7 +8,7 @@
</kui-jdn-datepicker>
</mat-form-field>
<mat-checkbox *ngIf="!readonly" [formControlName]="'isPeriod'" (change)="_handleInput()"></mat-checkbox>
<mat-form-field *ngIf="isPeriodControl.value" class="end">
<mat-form-field *ngIf="isPeriodControl.value" class="end child-input-component">
<span class="calendar">{{endDateControl.value?.calendarName}}</span>
<kui-jdn-datepicker [activeCalendar]="endDateControl.value?.calendarName">
<input matInput [matDatepicker]="picker2" [formControlName]="'dateEnd'" (dateChange)="_handleInput()" readonly>
Expand Down
@@ -0,0 +1,14 @@
/**
* CSS changed here must also be changed in each child component of a wrapped component
* time-input.component.scss, interval-input.component.scss, etc.
*/

.child-input-component {
display: inline-block;
vertical-align: bottom;
width: 49%;
}

.child-input-component:nth-child(2) {
padding-left: 2%;
}
@@ -1,9 +1,20 @@
<span [formGroup]="form">
<mat-form-field class="large-field">
<mat-form-field class="large-field child-value-component" floatLabel="never">
<kui-date-input #dateInput [formControlName]="'dateValue'" class="value" placeholder="Date value" [readonly]="mode === 'read'" [errorStateMatcher]="matcher"></kui-date-input>
</mat-form-field>
<br>

This comment has been minimized.

Copy link
@mdelez

mdelez Apr 7, 2020

Contributor

https://github.com/dasch-swiss/knora-ui-ng-lib/blob/0bee998ec0ee602d253ebc6119ad8daf72b0eb33/projects/knora-ui/src/lib/viewer/values/date-value/date-value.component.html#L4-L6

can you remove this breakline please? due to the css grid I'm using, it's not currently affecting anything but it may in the future since the other component templates don't have it :)

This comment has been minimized.

Copy link
@tobiasschweizer

tobiasschweizer Apr 7, 2020

Contributor

done in 720106f

<mat-form-field class="large-field">
<input matInput [formControlName]="'comment'" class="comment" placeholder="Comment" type="text" [readonly]="mode === 'read'">
<mat-form-field class="large-field value-component-comment" *ngIf="shouldShowComment">
<textarea matInput
cdkTextareaAutosize
#autosize="cdkTextareaAutosize"
cdkAutosizeMinRows="1"
cdkAutosizeMaxRows="6"
[formControlName]="'comment'"
class="comment"
placeholder="Comment"
type="text"
[readonly]="mode === 'read'"
spellcheck="false">
</textarea>
</mat-form-field>
</span>
@@ -0,0 +1,11 @@
:host ::ng-deep .child-value-component {
.mat-form-field-underline {
display: none;
}
.mat-form-field-infix{
border-top: 0.2em solid transparent !important;
.mat-form-field-underline{
display: block;
}
}
}

0 comments on commit def47c9

Please sign in to comment.