Skip to content

Commit 7f521ac

Browse files
committed
update view components
1 parent a5b0104 commit 7f521ac

File tree

6 files changed

+57
-29
lines changed

6 files changed

+57
-29
lines changed

service/src/models/event.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const EventSchema = new Schema({
7676
_id: { type: Number, required: true },
7777
name: { type: String, required: true, unique: true },
7878
description: { type: String, required: false },
79+
noGeometry: { type: Boolean, default: false },
7980
complete: { type: Boolean },
8081
collectionName: { type: String, required: true },
8182
teamIds: [{ type: Schema.Types.ObjectId, ref: 'Team' }],
@@ -110,7 +111,7 @@ EventSchema.virtual('id')
110111
async function uniqueViolationToValidationErrorHook(err, _, next) {
111112
if (err.code === 11000 || err.code === 11001) {
112113
err = new mongoose.Error.ValidationError()
113-
err.errors = { name: { type: 'unique', message: 'Duplicate event name' }}
114+
err.errors = { name: { type: 'unique', message: 'Duplicate event name' } }
114115
}
115116
return next(err)
116117
}
@@ -491,7 +492,7 @@ exports.update = function (id, event, options, callback) {
491492
options = {};
492493
}
493494

494-
const update = ['name', 'description', 'minObservationForms', 'maxObservationForms', 'complete', 'forms'].reduce(function(o, k) {
495+
const update = ['name', 'description', 'noGeometry', 'minObservationForms', 'maxObservationForms', 'complete', 'forms'].reduce(function (o, k) {
495496
if (Object.prototype.hasOwnProperty.call(event, k)) {
496497
o[k] = event[k];
497498
}

web-app/admin/src/ng1/admin/events/event.edit.component.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ class AdminEventEditController {
77

88
$onInit() {
99
if (this.$stateParams.eventId) {
10-
this.Event.get({id: this.$stateParams.eventId}, event => {
10+
this.Event.get({ id: this.$stateParams.eventId }, event => {
1111
this.event = new this.Event({
1212
id: event.id,
1313
name: event.name,
14-
description: event.description
14+
description: event.description,
15+
noGeometry: !!event.noGeometry
1516
});
1617
});
1718
} else {
1819
this.event = new this.Event();
20+
this.event.noGeometry = false;
1921
}
2022
}
2123

web-app/admin/src/ng1/admin/events/event.edit.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,26 @@ <h2 ng-if="!$ctrl.event.id">New event</h2>
2727
<form ng-submit="$ctrl.saveEvent()" class="form">
2828
<div class="form-group">
2929
<label class="control-label">Name</label>
30-
<input class="form-control" type="text" placeholder="Event name" ng-model="$ctrl.event.name"/>
30+
<input class="form-control" type="text" placeholder="Event name" ng-model="$ctrl.event.name" />
3131
</div>
3232
<div class="form-group">
3333
<label class="control-label">Description</label>
34-
<textarea class="form-control" type="text" placeholder="Brief description of the event." ng-model="$ctrl.event.description"></textarea>
34+
<textarea class="form-control" type="text" placeholder="Brief description of the event."
35+
ng-model="$ctrl.event.description"></textarea>
36+
</div>
37+
<div class="form-group">
38+
<label>
39+
<input type="checkbox" ng-model="$ctrl.event.noGeometry">
40+
Disable Geometry data for new observations by default
41+
</label>
3542
</div>
3643
</form>
3744

3845
<div class="clearfix">
3946
<span class="pull-right">
4047
<a class="btn btn-default" ng-class="{'disabled': $ctrl.saving}" ng-click="$ctrl.cancel()">Cancel</a>
41-
<a class="btn btn-success" ng-class="{'disabled': $ctrl.saving}" ng-click="$ctrl.saveEvent($ctrl.event)"><i class="fa fa-check"></i> Save</a>
48+
<a class="btn btn-success" ng-class="{'disabled': $ctrl.saving}" ng-click="$ctrl.saveEvent($ctrl.event)"><i
49+
class="fa fa-check"></i> Save</a>
4250
</span>
4351
</div>
4452

@@ -51,4 +59,4 @@ <h2 ng-if="!$ctrl.event.id">New event</h2>
5159

5260
</div>
5361
</div>
54-
</div>
62+
</div>

web-app/src/app/observation/observation-edit/observation-edit.component.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@
3333
<observation-edit-date [formGroup]="formGroup.get('properties')"
3434
[definition]="timestampDefinition"></observation-edit-date>
3535

36-
<observation-edit-geometry [formGroup]="formGroup" [definition]="geometryDefinition"
37-
[featureId]="observation.id" [featureStyle]="geometryStyle" (onFeatureEdit)="onGeometryEdit($event)">
38-
</observation-edit-geometry>
39-
4036
<mat-checkbox [formControl]="formGroup?.get('noGeometry')" style="margin-top: 16px;">
4137
{{ noGeometryLabel }}
4238
</mat-checkbox>
39+
40+
<ng-container *ngIf="!formGroup?.get('noGeometry')?.value">
41+
<observation-edit-geometry [formGroup]="formGroup" [definition]="geometryDefinition"
42+
[featureId]="observation.id" [featureStyle]="geometryStyle" (onFeatureEdit)="onGeometryEdit($event)">
43+
</observation-edit-geometry>
44+
</ng-container>
4345
</mat-card>
4446

4547
<div class="edit-forms" cdkDropList cdkDropListLockAxis="y" (cdkDropListDropped)="reorderForm($event)"

web-app/src/app/observation/observation-list/observation-list-item.component.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@
4949
</div>
5050
</div>
5151

52-
<div class="item-thumbnail">
52+
<div *ngIf="!observation?.noGeometry" class="item-thumbnail">
5353
<img [src]="observation?.style?.iconUrl" />
5454
</div>
5555
</div>
5656

5757
<div *ngIf="attachments?.length && attachments[0]?.url" class="item-media" matCardImage>
58-
<observation-attachment [attachment]="attachments[0]" [label]="attachments.length > 1 ? '1 of ' + attachments.length : false"></observation-attachment>
58+
<observation-attachment [attachment]="attachments[0]"
59+
[label]="attachments.length > 1 ? '1 of ' + attachments.length : false"></observation-attachment>
5960
</div>
6061
</div>
6162

@@ -66,15 +67,15 @@
6667
<textarea matInput [(ngModel)]="importantEditor.description"></textarea>
6768
</mat-form-field>
6869
<div class="important__actions">
69-
<button mat-button color="primary"
70-
(click)="clearImportant()">{{observation?.important ? 'Remove' : 'Cancel'}}</button>
70+
<button mat-button color="primary" (click)="clearImportant()">{{observation?.important ? 'Remove' :
71+
'Cancel'}}</button>
7172
<button mat-flat-button color="primary" (click)="markAsImportant()"
7273
class="important__actions--confirm">{{observation?.important ? 'Update' : 'Flag As Important'}}</button>
7374
</div>
7475
</div>
7576

7677
<div class="actions">
77-
<div class="action-buttons">
78+
<div *ngIf="!observation?.noGeometry" class="action-buttons">
7879
<button mat-button color="primary" (click)="onObservationLocationClick()" class="actions__location-button">
7980
<mat-icon class="actions__location-icon">my_location</mat-icon> {{observation?.geometry | geometry:5}}
8081
</button>
@@ -98,7 +99,8 @@
9899
<span *ngIf="favorites" class="actions__favorite-label">{{favorites}}</span>
99100
</div>
100101

101-
<a mat-icon-button [href]="downloadUrl()" class="actions--inactive" matTooltip="Download" matTooltipPosition="above">
102+
<a mat-icon-button [href]="downloadUrl()" class="actions--inactive" matTooltip="Download"
103+
matTooltipPosition="above">
102104
<mat-icon>save_alt</mat-icon>
103105
</a>
104106
</div>

web-app/src/app/observation/observation-view/observation-view.component.html

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<button mat-icon-button color="primary" (click)="onClose()">
55
<mat-icon>arrow_back</mat-icon>
66
</button>
7-
7+
88
<button *ngIf="canEdit" mat-button color="primary" (click)="editObservation()">EDIT</button>
99
</mat-toolbar-row>
1010
</mat-toolbar>
@@ -60,18 +60,18 @@
6060
</div>
6161
</div>
6262

63-
<div class="item-thumbnail">
63+
<div *ngIf="!observation?.noGeometry" class="item-thumbnail">
6464
<img [src]="observation.style.iconUrl" />
6565
</div>
6666
</div>
6767

68-
<div class="item-map">
68+
<div *ngIf="!observation?.noGeometry" class="item-map">
6969
<div class="item-map__view">
7070
<map-clip [feature]="observation"></map-clip>
7171
</div>
7272
</div>
7373

74-
<div class="item-location">
74+
<div *ngIf="!observation?.noGeometry" class="item-location">
7575
<button mat-button color="primary" (click)="onObservationLocationClick()" class="actions__location-button">
7676
<mat-icon class="actions__location-icon">my_location</mat-icon> {{observation?.geometry | geometry:5}}
7777
</button>
@@ -82,6 +82,10 @@
8282
</span>
8383
</div>
8484

85+
<div *ngIf="observation?.noGeometry" class="item-no-geometry">
86+
<span>This observation does not have geometry data</span>
87+
</div>
88+
8589
<mat-divider></mat-divider>
8690

8791
<div *ngIf="importantEditor.open" class="important" @important>
@@ -90,26 +94,34 @@
9094
<textarea matInput [(ngModel)]="importantEditor.description"></textarea>
9195
</mat-form-field>
9296
<div class="important__actions">
93-
<button mat-button color="primary" (click)="clearImportant()">{{observation?.important ? 'Remove' : 'Cancel'}}</button>
94-
<button mat-flat-button color="primary" (click)="markAsImportant()" class="important__actions--confirm">{{observation?.important ? 'Update' : 'Flag As Important'}}</button>
97+
<button mat-button color="primary" (click)="clearImportant()">{{observation?.important ? 'Remove' :
98+
'Cancel'}}</button>
99+
<button mat-flat-button color="primary" (click)="markAsImportant()"
100+
class="important__actions--confirm">{{observation?.important ? 'Update' : 'Flag As Important'}}</button>
95101
</div>
96102
</div>
97103

98104
<mat-card-actions>
99105
<div class="actions">
100-
<div *ngIf="observation?.favoriteUserIds?.length" class="favorites" (click)="showFavoriteUsers()" matRipple matRippleCentered="true" matRippleUnbounded="true">
106+
<div *ngIf="observation?.favoriteUserIds?.length" class="favorites" (click)="showFavoriteUsers()" matRipple
107+
matRippleCentered="true" matRippleUnbounded="true">
101108
<span class="favorites__count">{{observation?.favoriteUserIds?.length}}</span>
102-
<span class="favorites__label">{{observation?.favoriteUserIds?.length === 1 ? "FAVORITE": "FAVORITES"}}</span>
109+
<span class="favorites__label">{{observation?.favoriteUserIds?.length === 1 ? "FAVORITE":
110+
"FAVORITES"}}</span>
103111
</div>
104112
<div class="actions-icons">
105113
<div *ngIf="canEditImportant">
106-
<button mat-icon-button (click)="onFlagAsImportant()" class="actions--inactive" [ngClass]="{'actions__important--active': observation.important}" matTooltip="Flag As Important" matTooltipPosition="above">
114+
<button mat-icon-button (click)="onFlagAsImportant()" class="actions--inactive"
115+
[ngClass]="{'actions__important--active': observation.important}" matTooltip="Flag As Important"
116+
matTooltipPosition="above">
107117
<mat-icon>{{observation.important ? 'flag' : 'outlined_flag'}}</mat-icon>
108118
</button>
109119
</div>
110120

111121
<div class="actions__favorite">
112-
<button mat-icon-button (click)="toggleFavorite()" class="actions--inactive" [ngClass]="{'actions__favorite--active': isUserFavorite}" matTooltip="Add To Favorites" matTooltipPosition="above">
122+
<button mat-icon-button (click)="toggleFavorite()" class="actions--inactive"
123+
[ngClass]="{'actions__favorite--active': isUserFavorite}" matTooltip="Add To Favorites"
124+
matTooltipPosition="above">
113125
<mat-icon>{{isUserFavorite ? 'favorite' : 'favorite_border'}}</mat-icon>
114126
</button>
115127
<span *ngIf="favorites" class="actions__favorite-label">{{favorites}}</span>
@@ -124,7 +136,8 @@
124136
</mat-card>
125137

126138
<div class="form-card" *ngFor="let form of observationForm?.forms; let i = index">
127-
<observation-view-form [form]="form" [attachments]="observation.attachments" [expand]="i === 0"></observation-view-form>
139+
<observation-view-form [form]="form" [attachments]="observation.attachments"
140+
[expand]="i === 0"></observation-view-form>
128141
</div>
129142
</div>
130143
</div>

0 commit comments

Comments
 (0)