This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 6627dba0 authored by Michael Breu's avatar Michael Breu :speech_balloon:
Browse files

Fixes

parent 3898cba3
Branches
2 merge requests!188Merging Peer Reviewing et. al to Master,!164211 peer reviewing functionality
This diff is collapsed.
package at.ac.uibk.gitsearch.repository;
import at.ac.uibk.gitsearch.domain.User;
import at.ac.uibk.gitsearch.domain.UserWatchList;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.*;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import at.ac.uibk.gitsearch.domain.UserWatchList;
/**
* Spring Data repository for the UserWatchList entity.
......
......@@ -4,9 +4,9 @@ import { HttpResponse } from '@angular/common/http';
import { FormBuilder, Validators } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { WatchlistManager } from 'app/shared/watchlist/watchlist-manager';
import { IUserWatchList, UserWatchList } from 'app/shared/model/user-watch-list.model';
import { UserWatchListService } from 'app/entities/user-watch-list/user-watch-list.service';
import { IUser } from 'app/core/user/user.model';
import { UserService } from 'app/core/user/user.service';
......@@ -25,7 +25,7 @@ export class UserWatchListUpdateComponent implements OnInit {
});
constructor(
protected userWatchListService: UserWatchListService,
protected watchlistManager: WatchlistManager,
protected userService: UserService,
protected activatedRoute: ActivatedRoute,
private fb: FormBuilder
......@@ -55,9 +55,9 @@ export class UserWatchListUpdateComponent implements OnInit {
this.isSaving = true;
const userWatchList = this.createFromForm();
if (userWatchList.id !== undefined) {
this.subscribeToSaveResponse(this.userWatchListService.update(userWatchList));
this.subscribeToSaveResponse(this.watchlistManager.update(userWatchList));
} else {
this.subscribeToSaveResponse(this.userWatchListService.create(userWatchList));
this.subscribeToSaveResponse(this.watchlistManager.createForCurrentUser(userWatchList));
}
}
......
......@@ -52,11 +52,6 @@
<td class="{{isSelected(userWatchList)?'selected':''}}" (click)="view(userWatchList)" style="cursor: pointer;">{{ userWatchList.name }}</td>
<td class="text-right">
<div class="btn-group">
<button type="submit" (click)="view(userWatchList)" style="border-width:0px;background-color: transparent;"
>
<fa-icon icon="eye"></fa-icon>
</button>
<button type="submit" style="border-width:0px;background-color: transparent;"
[routerLink]="['/bookmarks', userWatchList.id, 'edit']"
......@@ -64,7 +59,8 @@
<fa-icon icon="pencil-alt"></fa-icon>
</button>
<button type="submit" (click)="delete(userWatchList)" style="border-width:0px;background-color: transparent;"
<button type="submit" (click)="delete(userWatchList)" disabled="{{ userWatchLists.length == 1 }}" style="border-width:0px;background-color: transparent;"
title="{{ (userWatchLists.length == 1)?'The last entry cannot be deleted':'' }}"
>
<fa-icon icon="times"></fa-icon>
</button>
......
import { Injectable, OnDestroy, OnInit } from '@angular/core';
import { HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { UserWatchListService } from 'app/entities/user-watch-list/user-watch-list.service';
import { WatchListEntryService } from 'app/entities/watch-list-entry/watch-list-entry.service';
import { TranslateService } from '@ngx-translate/core'
import { IUserWatchList, UserWatchListWithContent } from 'app/shared/model/user-watch-list.model';
import { IWatchListEntry } from 'app/shared/model/watch-list-entry.model';
import { AccountService } from 'app/core/auth/account.service';
......@@ -10,6 +12,7 @@ import { Account } from 'app/core/user/account.model';
import { Exercise } from 'app/shared/model/exercise.model';
type EntityResponseType = HttpResponse<IUserWatchList>;
/**
provides infrastructure for watchlists management.
......@@ -24,11 +27,15 @@ export class WatchlistManager implements OnInit, OnDestroy {
myWatchLists?: IUserWatchList[];
currentWatchlist?: UserWatchListWithContent;
/** flag, iff default bookmark list is about to be created */
defaultBookmarkListInProgress = false;
constructor(
protected watchListService: UserWatchListService,
protected watchListEntryService: WatchListEntryService,
private accountService: AccountService,
private translate : TranslateService,
) {
this.authSubscription = this.accountService.getAuthenticationState().subscribe(account => {
......@@ -44,22 +51,28 @@ export class WatchlistManager implements OnInit, OnDestroy {
if (this.myWatchLists.length > 0) {
this.loadCurrentWatchList(this.myWatchLists[0]);
} else {
if (!this.defaultBookmarkListInProgress) {
// if watchlist is empty, define default watchlist :-)
this.defaultBookmarkListInProgress = true;
const userWatchlist: IUserWatchList = {
name: "Default Bookmarklist",
name: this.translate.instant("gitsearchApp.userWatchList.defaultName"),
userIdLogin: this.account!.login,
userIdId: 1, // unused, replaced by
userIdId: 1, // unused, replaced by correct userId by create service
};
this.watchListService.createForCurrentUser(userWatchlist).subscribe((wl: HttpResponse<IUserWatchList>) => {
this.myWatchLists = [wl.body!];
this.loadCurrentWatchList(wl.body!)
this.defaultBookmarkListInProgress = false
},
() => { // error case
this.defaultBookmarkListInProgress = false
});
this.currentWatchlist = undefined;
}
}
}
})
}} )
}
else { this.myWatchLists = undefined; this.currentWatchlist = undefined; }
......@@ -118,6 +131,30 @@ export class WatchlistManager implements OnInit, OnDestroy {
}
public createForCurrentUser(userWatchList: IUserWatchList): Observable<EntityResponseType> {
const createCall = this.watchListService.createForCurrentUser(userWatchList);
createCall.subscribe((createdWatchList) => {
this.myWatchLists!.push(createdWatchList.body!);
});
return createCall;
}
public update(userWatchList: IUserWatchList): Observable<EntityResponseType> {
const updateCall = this.watchListService.update(userWatchList);
updateCall.subscribe((createdWatchList) => {
const id = createdWatchList.body!.id!;
if (this.myWatchLists) {
for(let i = 0; i<this.myWatchLists.length; i++)
if (this.myWatchLists[i].id === id) {
this.myWatchLists[i]=createdWatchList.body!;
};
}
});
return updateCall;
}
public setCurrentWatchList(watchListName: string): void {
if (this.myWatchLists) {
......
......@@ -12,6 +12,7 @@
"created": "Leserzeichenliste erstellt",
"updated": "Leserzeichenliste aktualisiert",
"deleted": "Leserzeichenliste gelöscht",
"defaultName": "Standard-Lesezeichenliste",
"delete": {
"question": "Soll Leserzeichenliste \"{{ id }}\" wirklich dauerhaft gelöscht werden?"
},
......
......@@ -12,6 +12,7 @@
"created": "A new Bookmark List is created",
"updated": "A Bookmark List is updated",
"deleted": "A Bookmark List is deleted",
"defaultName": "Default Bookmarklist",
"delete": {
"question": "Are you sure you want to delete Bookmark List {{ id }}?"
},
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment