Skip to content

Commit 38bbe41

Browse files
authored
chore(resource): improve still image annotation form (DEV-53) (#549)
* chore(region): do not display "Region of" in region tab of resource * chore(value): fix type definition * style(region): better cursor to create region * fix(region): display the correct properties * style(region): redesign still image annotation form
1 parent 79abd10 commit 38bbe41

12 files changed

Lines changed: 87 additions & 48 deletions

File tree

‎src/app/workspace/resource/properties/properties.component.html‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,20 @@ <h3 class="label mat-title">
8989
<!-- list of properties -->
9090
<div *ngFor="let prop of resource.resProps; let last = last">
9191
<!-- show property; all in case of showAll === true or only the ones with prop.values -->
92-
<div *ngIf="(showAllProps || ( prop.values && prop.values.length > 0 )) &&
93-
(!prop.propDef['isLinkProperty'] &&
94-
prop.propDef.objectType !== representationConstants.stillImage &&
95-
prop.propDef.objectType !== representationConstants.movingImage &&
96-
prop.propDef.objectType !== representationConstants.audio &&
97-
prop.propDef.objectType !== representationConstants.document &&
98-
prop.propDef.objectType !== representationConstants.text)"
99-
[class.border-bottom]="prop.values && !last"
100-
class="property">
92+
<div *ngIf="(showAllProps || ( prop.values && prop.values.length > 0 )) && (
93+
!prop.propDef['isLinkProperty'] &&
94+
prop.propDef.objectType !== representationConstants.stillImage &&
95+
prop.propDef.objectType !== representationConstants.movingImage &&
96+
prop.propDef.objectType !== representationConstants.audio &&
97+
prop.propDef.objectType !== representationConstants.document &&
98+
prop.propDef.objectType !== representationConstants.text &&
99+
!(isAnnotation && (
100+
prop.propDef.subjectType === representationConstants.region &&
101+
prop.propDef.objectType !== representationConstants.color
102+
))
103+
)"
104+
[class.border-bottom]="prop.values && !last"
105+
class="property">
101106
<div class="property-label">
102107
<!-- label of the property -->
103108
<h3 class="label mat-subheading-1"

‎src/app/workspace/resource/properties/properties.component.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,23 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy {
6868
* input `displayProjectInfo` of properties component:
6969
* display project info or not; "This resource belongs to project XYZ"
7070
*/
71-
@Input() displayProjectInfo: false;
71+
@Input() displayProjectInfo = false;
7272

7373
/**
7474
* does the logged-in user has system or project admin permissions?
7575
*/
76-
@Input() adminPermissions: false;
76+
@Input() adminPermissions = false;
7777

7878
/**
7979
* is the logged-in user project member?
8080
*/
81-
@Input() editPermissions: false;
81+
@Input() editPermissions = false;
82+
83+
/**
84+
* in case properties belongs to an annotation (e.g. region in still images)
85+
* in this case we don't have to display the isRegionOf property
86+
*/
87+
@Input() isAnnotation = false;
8288

8389
/**
8490
* output `referredProjectClicked` of resource view component:

‎src/app/workspace/resource/representation/add-region-form/add-region-form.component.html‎

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,32 @@
1-
<form [formGroup]="regionForm">
2-
<mat-form-field>
3-
<mat-label>Comment*</mat-label>
4-
<textarea matInput formControlName="comment"></textarea>
5-
</mat-form-field>
6-
<mat-form-field>
7-
<mat-label>Label*</mat-label>
1+
<form [formGroup]="regionForm" class="form-content small-form">
2+
<mat-form-field class="medium-field">
3+
<mat-label>Label *</mat-label>
84
<input matInput formControlName="label">
95
</mat-form-field>
10-
<mat-form-field>
11-
<mat-label>Color*</mat-label>
12-
<app-color-picker
13-
#colorInput
14-
[formControlName]="'color'"
15-
class="value">
16-
</app-color-picker>
6+
<mat-form-field class="medium-field">
7+
<mat-label>Comment *</mat-label>
8+
<textarea matInput rows="7" formControlName="comment"></textarea>
9+
</mat-form-field>
10+
<mat-form-field class="medium-field without-border">
11+
<mat-label>Color *</mat-label>
12+
<app-color-picker #colorInput [formControlName]="'color'" class="value">
13+
</app-color-picker>
1714
</mat-form-field>
18-
<mat-form-field>
15+
<mat-form-field class="hidden">
1916
<mat-label>Is Region Of</mat-label>
2017
<input matInput disabled [value]="resourceIri">
2118
</mat-form-field>
22-
<!-- Further inputs would be status, lineColor and lineWidth if we want to have these options-->
23-
<div class="form-panel large-field">
19+
<!-- Further inputs would be status, lineColor and lineWidth if we want to have these options-->
20+
<div class="form-action form-panel medium-field">
2421
<span>
2522
<button mat-button type="button" mat-dialog-close>
2623
{{ 'appLabels.form.action.cancel' | translate }}
2724
</button>
2825
</span>
2926
<span class="fill-remaining-space"></span>
3027
<span>
31-
<button
32-
mat-raised-button
33-
[mat-dialog-close]="regionForm.value"
34-
type="button"
35-
color="primary"
36-
[disabled]="!regionForm.valid"
37-
class="form-submit">
28+
<button mat-raised-button [mat-dialog-close]="regionForm.value" type="button" color="primary"
29+
[disabled]="!regionForm.valid" class="form-submit">
3830
Submit
3931
</button>
4032
</span>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.hidden {
2+
display: none;
3+
}
4+
5+
.form-content {
6+
margin: 0;
7+
8+
.form-panel {
9+
margin-top: 16px;
10+
}
11+
}

‎src/app/workspace/resource/representation/file-representation.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ export class RepresentationConstants {
3232
static movingImage = Constants.MovingImageFileValue;
3333
static stillImage = Constants.StillImageFileValue;
3434
static text = Constants.TextFileValue;
35+
static region = Constants.Region;
36+
static color = Constants.ColorValue;
3537
};

‎src/app/workspace/resource/representation/still-image/still-image.component.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- openseadragon (osd) viewer -->
2-
<div class="osd-container">
2+
<div class="osd-container" [class.drawing]="regionDrawMode">
33
<div class="action horizontal top overlay">
44
<!-- caption -->
55
<span class="caption mat-caption">{{imageCaption}}</span>
@@ -20,7 +20,7 @@
2020
<button mat-icon-button id="DSP_OSD_FULL_PAGE" matTooltip="Open in fullscreen">
2121
<mat-icon>fullscreen</mat-icon>
2222
</button>
23-
<button (click)="drawButtonClicked()" mat-icon-button matTooltip="Draw Region">
23+
<button mat-icon-button id="DSP_OSD_DRAW_REGION" matTooltip="Draw Region" (click)="drawButtonClicked()">
2424
<mat-icon>edit</mat-icon>
2525
</button>
2626
</span>

‎src/app/workspace/resource/representation/still-image/still-image.component.scss‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ $bright: #ccc;
2626
background-color: $dark;
2727
height: 100%;
2828

29+
&.drawing {
30+
cursor: crosshair;
31+
}
32+
2933
&.fullscreen {
3034
max-width: 100vw;
3135
}

‎src/app/workspace/resource/representation/still-image/still-image.component.ts‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class StillImageComponent implements OnChanges, OnDestroy {
111111

112112
@Output() regionAdded = new EventEmitter<string>();
113113

114-
private _regionDrawMode: Boolean = false; // stores whether viewer is currently drawing a region
114+
regionDrawMode: Boolean = false; // stores whether viewer is currently drawing a region
115115
private _regionDragInfo; // stores the information of the first click for drawing a region
116116
private _viewer: OpenSeadragon.Viewer;
117117
private _regions: PolygonsForRegion = {};
@@ -201,7 +201,8 @@ export class StillImageComponent implements OnChanges, OnDestroy {
201201
* prevents navigation by mouse (so that the region can be accurately drawn).
202202
*/
203203
drawButtonClicked(): void {
204-
this._regionDrawMode = true;
204+
205+
this.regionDrawMode = true;
205206
this._viewer.setMouseNavEnabled(false);
206207
}
207208

@@ -211,9 +212,9 @@ export class StillImageComponent implements OnChanges, OnDestroy {
211212
* @param endPoint the end point of the drawing
212213
* @param imageSize the image size for calculations
213214
*/
214-
private _openRegionDialog(startPoint, endPoint, imageSize, overlay): void{
215+
private _openRegionDialog(startPoint: Point2D, endPoint: Point2D, imageSize: Point2D, overlay: Element): void{
215216
const dialogConfig: MatDialogConfig = {
216-
width: '840px',
217+
width: '337px',
217218
maxHeight: '80vh',
218219
position: {
219220
top: '112px'
@@ -243,7 +244,7 @@ export class StillImageComponent implements OnChanges, OnDestroy {
243244
* @param comment the value for the comment entered in the form
244245
* @param label the value for the label entered in the form
245246
*/
246-
private _uploadRegion(startPoint, endPoint, imageSize, color, comment, label){
247+
private _uploadRegion(startPoint: Point2D, endPoint: Point2D, imageSize: Point2D, color: string, comment: string, label: string){
247248
const x1 = Math.max(Math.min(startPoint.x, imageSize.x), 0)/imageSize.x;
248249
const x2 = Math.max(Math.min(endPoint.x, imageSize.x), 0)/imageSize.x;
249250
const y1 = Math.max(Math.min(startPoint.y, imageSize.y), 0)/imageSize.y;
@@ -290,7 +291,7 @@ export class StillImageComponent implements OnChanges, OnDestroy {
290291
new OpenSeadragon.MouseTracker({
291292
element: this._viewer.canvas,
292293
pressHandler: (event) => {
293-
if (!this._regionDrawMode){
294+
if (!this.regionDrawMode){
294295
return;
295296
}
296297
const overlayElement = document.createElement('div');
@@ -320,13 +321,13 @@ export class StillImageComponent implements OnChanges, OnDestroy {
320321
this._regionDragInfo.endPos = viewPortPos;
321322
},
322323
releaseHandler: () => {
323-
if (this._regionDrawMode) {
324+
if (this.regionDrawMode) {
324325
const imageSize = this._viewer.world.getItemAt(0).getContentSize();
325326
const startPoint = this._viewer.viewport.viewportToImageCoordinates(this._regionDragInfo.startPos);
326327
const endPoint = this._viewer.viewport.viewportToImageCoordinates(this._regionDragInfo.endPos);
327328
this._openRegionDialog(startPoint, endPoint, imageSize, this._regionDragInfo.overlayElement);
328329
this._regionDragInfo = null;
329-
this._regionDrawMode = false;
330+
this.regionDrawMode = false;
330331
this._viewer.setMouseNavEnabled(true);
331332
}
332333
}

‎src/app/workspace/resource/resource.component.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
</ng-template>
5959
<div class="region-property" *ngFor="let annotation of annotationResources" [id]="annotation.res.id"
6060
[class.active]="annotation.res.id === selectedRegion">
61-
<app-properties [resource]="annotation" [displayProjectInfo]="false"
61+
<app-properties [resource]="annotation" [displayProjectInfo]="false" [isAnnotation]="true"
6262
[adminPermissions]="adminPermissions" [editPermissions]="editPermissions">
6363
</app-properties>
6464
</div>

‎src/app/workspace/resource/values/text-value/text-value-as-string/text-value-as-string.component.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const resolvedPromise = Promise.resolve(null);
1616
export class TextValueAsStringComponent extends BaseValueDirective implements OnInit, OnChanges, OnDestroy {
1717

1818
@Input() displayValue?: ReadTextValueAsString;
19-
@Input() textArea?: false;
19+
@Input() textArea?: boolean = false;
2020

2121
valueFormControl: FormControl;
2222
commentFormControl: FormControl;

0 commit comments

Comments
 (0)