Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(resource): draw regions (DSP-1845) (#524)
* Implemented drawing of regions * get coordinates for region * implemented form * Compiled search * Finalized request * fix(resource): correct dspApiConnectionToken * feat(resource): add color picker to region form * refactor: fix formatting * test: fixes unit tests * feat(resource): regions update automatically after a new one is submitted * feat(resource): Update regions and highlight new region on submit * refactor(region): make lint happy Co-authored-by: André Kilchenmann <github@milchkannen.ch> Co-authored-by: mdelez <60604010+mdelez@users.noreply.github.com>
- Loading branch information
1 parent
b07ec63
commit f08706b
Showing
12 changed files
with
8,436 additions
and
2,861 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/app/workspace/resource/representation/add-region-form/add-region-form.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<form [formGroup]="regionForm"> | ||
<mat-form-field> | ||
<mat-label>Comment*</mat-label> | ||
<textarea matInput formControlName="comment"></textarea> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Label*</mat-label> | ||
<input matInput formControlName="label"> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Color*</mat-label> | ||
<app-color-picker | ||
#colorInput | ||
[formControlName]="'color'" | ||
class="value"> | ||
</app-color-picker> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Is Region Of</mat-label> | ||
<input matInput disabled [value]="resourceIri"> | ||
</mat-form-field> | ||
<!-- Further inputs would be status, lineColor and lineWidth if we want to have these options--> | ||
<div class="form-panel large-field"> | ||
<span> | ||
<button mat-button type="button" mat-dialog-close> | ||
{{ 'appLabels.form.action.cancel' | translate }} | ||
</button> | ||
</span> | ||
<span class="fill-remaining-space"></span> | ||
<span> | ||
<button | ||
mat-raised-button | ||
[mat-dialog-close]="regionForm.value" | ||
type="button" | ||
color="primary" | ||
[disabled]="!regionForm.valid" | ||
class="form-submit"> | ||
Submit | ||
</button> | ||
</span> | ||
</div> | ||
</form> |
Empty file.
35 changes: 35 additions & 0 deletions
35
src/app/workspace/resource/representation/add-region-form/add-region-form.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FormBuilder } from '@angular/forms'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
import { AddRegionFormComponent } from './add-region-form.component'; | ||
|
||
describe('AddRegionFormComponent', () => { | ||
let component: AddRegionFormComponent; | ||
let fixture: ComponentFixture<AddRegionFormComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ | ||
AddRegionFormComponent | ||
], | ||
imports: [ | ||
TranslateModule.forRoot() | ||
], | ||
providers:[ | ||
FormBuilder | ||
] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AddRegionFormComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
src/app/workspace/resource/representation/add-region-form/add-region-form.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Component, OnInit, Input } from '@angular/core'; | ||
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'app-add-region-form', | ||
templateUrl: './add-region-form.component.html', | ||
styleUrls: ['./add-region-form.component.scss'] | ||
}) | ||
export class AddRegionFormComponent implements OnInit { | ||
@Input() resourceIri: string; | ||
regionForm: FormGroup; | ||
colorPattern = '^#[a-f0-9]{6}$'; | ||
constructor(private _fb: FormBuilder) { | ||
} | ||
|
||
ngOnInit(): void { | ||
this.regionForm = this._fb.group({ | ||
color: ['#ff3333', [Validators.required, Validators.pattern(this.colorPattern)]], | ||
comment: [null, Validators.required], | ||
label: [null, Validators.required] | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.