Skip to content

Commit

Permalink
mylife: smoother myachievements (fixes #6429) (#7753)
Browse files Browse the repository at this point in the history
Co-authored-by: Jesse Washburn <[email protected]>
Co-authored-by: mutugiii <[email protected]>
Co-authored-by: dogi <[email protected]>
  • Loading branch information
4 people authored Jan 7, 2025
1 parent c0c6167 commit c6797c0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.16.35",
"version": "0.16.36",
"myplanet": {
"latest": "v0.21.62",
"min": "v0.20.62"
"latest": "v0.21.74",
"min": "v0.20.74"
},
"scripts": {
"ng": "ng",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<mat-toolbar>
<button mat-icon-button (click)="goBack()"><mat-icon>arrow_back</mat-icon></button>
<span i18n>Edit Achievements</span>
<span *ngIf="achievementNotFound" i18n>Add Achievements</span>
<span *ngIf="!achievementNotFound" i18n>Edit Achievements</span>
</mat-toolbar>

<div class="planet-users-achievements-update space-container">
Expand Down Expand Up @@ -91,7 +92,7 @@
</form>
</div>
<div class="achievement-button">
<button type="button" (click)="onSubmit()" mat-raised-button [planetSubmit]="editForm.valid && profileForm.valid" color="primary" i18n>Update</button>
<button type="button" (click)="onSubmit()" mat-raised-button [planetSubmit]="editForm.valid && profileForm.valid" color="primary" i18n>Submit</button>
<button type="button" mat-raised-button color="warn" (click)="goBack()" i18n>Cancel</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import { showFormErrors } from '../../shared/table-helpers';
encapsulation: ViewEncapsulation.None
})
export class UsersAchievementsUpdateComponent implements OnInit, OnDestroy {

user = this.userService.get();
configuration = this.stateService.configuration;
docInfo = { '_id': this.user._id + '@' + this.configuration.code, '_rev': undefined };
readonly dbName = 'achievements';
achievementNotFound = false;
editForm: FormGroup;
profileForm: FormGroup;
private onDestroy$ = new Subject<void>();
Expand Down Expand Up @@ -59,20 +59,25 @@ export class UsersAchievementsUpdateComponent implements OnInit, OnDestroy {
ngOnInit() {
this.profileForm.patchValue(this.user);
this.usersAchievementsService.getAchievements(this.docInfo._id)
.pipe(catchError(() => this.usersAchievementsService.getAchievements(this.user._id)))
.subscribe((achievements) => {
this.editForm.patchValue(achievements);
this.editForm.controls.achievements = this.fb.array(achievements.achievements || []);
this.editForm.controls.references = this.fb.array(achievements.references || []);
this.editForm.controls.links = this.fb.array(achievements.links || []);
// Keeping older otherInfo property so we don't lose this info on database
this.editForm.controls.otherInfo = this.fb.array(achievements.otherInfo || []);
if (this.docInfo._id === achievements._id) {
this.docInfo._rev = achievements._rev;
}
}, (error) => {
console.log(error);
});
.pipe(
catchError(() => this.usersAchievementsService.getAchievements(this.user._id))
)
.subscribe((achievements) => {
this.editForm.patchValue(achievements);
this.editForm.controls.achievements = this.fb.array(achievements.achievements || []);
this.editForm.controls.references = this.fb.array(achievements.references || []);
this.editForm.controls.links = this.fb.array(achievements.links || []);
// Keeping older otherInfo property so we don't lose this info on database
this.editForm.controls.otherInfo = this.fb.array(achievements.otherInfo || []);

if (this.docInfo._id === achievements._id) {
this.docInfo._rev = achievements._rev;
}
}, (error) => {
console.log(error);
this.achievementNotFound = true;
});

this.planetStepListService.stepMoveClick$.pipe(takeUntil(this.onDestroy$)).subscribe(
() => this.editForm.controls.dateSortOrder.setValue('none')
);
Expand Down

0 comments on commit c6797c0

Please sign in to comment.