Skip to content

Commit

Permalink
users: add remove of profile images (fixes #7376) (#7378)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Mutugiii and dogi authored Jan 3, 2024
1 parent cf01bb0 commit 53a61e7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.14.4",
"version": "0.14.5",
"myplanet": {
"latest": "v0.12.52",
"latest": "v0.12.55",
"min": "v0.12.0"
},
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion src/app/users/users-update/users-update.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@
</form>
</div>
<div *ngIf="!submissionMode" class="profile-image-section">
<img class="profile-image-update" [src]="previewSrc">
<div style="text-align: center;">
<img class="profile-image-update" [src]="previewSrc"><br>
<button *ngIf="(uploadImage && currentImgKey) && !file" mat-raised-button color="accent" (click)="deleteImageAttachment()">Remove</button>
</div>
<div class="profile-image-upload">
<ngx-img (onSelect)="onImageSelect($event)" (onReset)="removeImageFile()" [config]="ngxImgConfig"
[text]="ngxImgText" [errorTexts]="ngxImgErrText"></ngx-img>
Expand Down
15 changes: 14 additions & 1 deletion src/app/users/users-update/users-update.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Validators
} from '@angular/forms';
import { CouchService } from '../../shared/couchdb.service';
import { of } from 'rxjs';
import { switchMap, map } from 'rxjs/operators';
import { ActivatedRoute, Router } from '@angular/router';
import { UserService } from '../../shared/user.service';
Expand Down Expand Up @@ -181,6 +180,20 @@ export class UsersUpdateComponent implements OnInit {
this.uploadImage = false;
}

deleteImageAttachment() {
if (!this.currentImgKey) {
return;
}

if (this.user._attachments && this.user._attachments[this.currentImgKey]) {
delete this.user._attachments[this.currentImgKey];
}

this.currentProfileImg = 'assets/image.png';
this.removeImageFile();
}


appendToSurvey(user) {
const submissionId = this.route.snapshot.params.id;
this.couchService.get('submissions/' + submissionId).pipe(switchMap((submission) => {
Expand Down

0 comments on commit 53a61e7

Please sign in to comment.