Skip to content

Commit

Permalink
Use the new delete dialog in more case (ls1intum#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxr96 authored and jpbernius committed Oct 7, 2019
1 parent 4fada6a commit 7c30fa0
Show file tree
Hide file tree
Showing 80 changed files with 483 additions and 1,190 deletions.
6 changes: 1 addition & 5 deletions src/main/webapp/app/admin/admin.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import {
JhiTrackerComponent,
LogsComponent,
NotificationMgmtComponent,
NotificationMgmtDeleteDialogComponent,
NotificationMgmtDetailComponent,
NotificationMgmtUpdateComponent,
UserManagementComponent,
UserManagementDeleteDialogComponent,
UserManagementDetailComponent,
UserManagementUpdateComponent,
} from './';
Expand All @@ -37,10 +35,8 @@ const ENTITY_STATES = [...adminState];
UserManagementComponent,
UserManagementDetailComponent,
UserManagementUpdateComponent,
UserManagementDeleteDialogComponent,
NotificationMgmtComponent,
NotificationMgmtDetailComponent,
NotificationMgmtDeleteDialogComponent,
NotificationMgmtUpdateComponent,
LogsComponent,
JhiConfigurationComponent,
Expand All @@ -49,6 +45,6 @@ const ENTITY_STATES = [...adminState];
JhiTrackerComponent,
JhiMetricsMonitoringComponent,
],
entryComponents: [UserManagementDeleteDialogComponent, NotificationMgmtDeleteDialogComponent, JhiHealthModalComponent],
entryComponents: [JhiHealthModalComponent],
})
export class ArtemisAdminModule {}
2 changes: 0 additions & 2 deletions src/main/webapp/app/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ export * from './metrics/metrics.service';
export * from './metrics/metrics.component';
export * from './metrics/metrics.route';
export * from './user-management/user-management-update.component';
export * from './user-management/user-management-delete-dialog.component';
export * from './user-management/user-management-detail.component';
export * from './user-management/user-management.component';
export * from './user-management/user-management.route';
export * from './notification-management/notification-management-update.component';
export * from './notification-management/notification-management-detail.component';
export * from './notification-management/notification-management-delete-dialog.component';
export * from './notification-management/notification-management.component';
export * from './notification-management/notification-management.route';
export * from './admin.route';

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ <h2>
<fa-icon [icon]="'pencil-alt'"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</button>
<button type="button" (click)="deleteNotification(notification)" class="btn btn-danger btn-sm">
<button
jhiDeleteButton
[entityTitle]="notification.id"
deleteQuestion="artemisApp.notificationManagement.delete.question"
(delete)="deleteNotification(notification.id)"
>
<fa-icon [icon]="'times'"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>
</button>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Subscription } from 'rxjs/Subscription';
import { ITEMS_PER_PAGE } from 'app/shared';
import { AccountService, User, UserService } from 'app/core';
import { SystemNotification, SystemNotificationService } from 'app/entities/system-notification';
import { NotificationMgmtDeleteDialogComponent } from 'app/admin';
import * as moment from 'moment';

@Component({
Expand Down Expand Up @@ -77,19 +76,15 @@ export class NotificationMgmtComponent implements OnInit, OnDestroy {

/**
* Deletes notification
* @param notification that we want to delete
* @param notificationId the id of the notification that we want to delete
*/
deleteNotification(notification: SystemNotification) {
const modalRef = this.modalService.open(NotificationMgmtDeleteDialogComponent, { size: 'lg', backdrop: 'static' });
modalRef.componentInstance.notification = notification;
modalRef.result.then(
result => {
// Left blank intentionally, nothing to do here
},
reason => {
// Left blank intentionally, nothing to do here
},
);
deleteNotification(notificationId: number) {
this.systemNotificationService.delete(notificationId).subscribe(() => {
this.eventManager.broadcast({
name: 'notificationListModification',
content: 'Deleted a system notification',
});
});
}

/**
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ <h2>
<fa-icon [icon]="'pencil-alt'"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</button>
<button type="button" (click)="deleteUser(user)" class="btn btn-danger btn-sm" [disabled]="currentAccount.login === user.login">
<button
jhiDeleteButton
[entityTitle]="user.login"
deleteQuestion="userManagement.delete.question"
(delete)="deleteUser(user.login)"
[disabled]="currentAccount.login === user.login"
>
<fa-icon [icon]="'times'"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>
</button>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Subscription } from 'rxjs/Subscription';

import { ITEMS_PER_PAGE } from 'app/shared';
import { AccountService, User, UserService } from 'app/core';
import { UserManagementDeleteDialogComponent } from 'app/admin';

@Component({
selector: 'jhi-user-management',
Expand Down Expand Up @@ -150,20 +149,16 @@ export class UserManagementComponent implements OnInit, OnDestroy {
}

/**
* Opens a delete dialog to delete a user
* @param user that should be deleted
* Deletes a user
* @param login of the user that should be deleted
*/
deleteUser(user: User) {
const modalRef = this.modalService.open(UserManagementDeleteDialogComponent, { size: 'lg', backdrop: 'static' });
modalRef.componentInstance.user = user;
modalRef.result.then(
result => {
// Left blank intentionally, nothing to do here
},
reason => {
// Left blank intentionally, nothing to do here
},
);
deleteUser(login: string) {
this.userService.delete(login).subscribe(() => {
this.eventManager.broadcast({
name: 'userListModification',
content: 'Deleted a user',
});
});
}

private onSuccess(data: User[], headers: HttpHeaders) {
Expand Down
15 changes: 11 additions & 4 deletions src/main/webapp/app/entities/course/course.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,21 @@ <h4 id="course-page-heading" jhiTranslate="artemisApp.course.home.title">Courses
<span class="d-none d-md-inline">{{ 'artemisApp.course.instructorDashboard' | translate }}</span>
</button>
</div>
<div class="btn-group-vertical mr-1 mb-1" *jhiHasAnyAuthority="['ROLE_ADMIN', 'ROLE_INSTRUCTOR']">
<div class="d-flex flex-column mr-1 mb-1" *jhiHasAnyAuthority="['ROLE_ADMIN', 'ROLE_INSTRUCTOR']">
<button type="submit" *ngIf="course.isAtLeastInstructor" [routerLink]="['/course', course.id, 'edit']" class="btn btn-primary btn-sm mr-1 mb-1">
<fa-icon [icon]="'pencil-alt'"></fa-icon>
<span class="d-none d-md-inline">{{ 'entity.action.edit' | translate }}</span>
</button>
<button type="submit" *jhiHasAnyAuthority="['ROLE_ADMIN']" (click)="openDeleteCourseDialog(course)" class="btn btn-danger btn-sm mr-1 mb-1">
<fa-icon [icon]="'times'"></fa-icon>
<span class="d-none d-md-inline">{{ 'entity.action.delete' | translate }}</span>

<button
*jhiHasAnyAuthority="['ROLE_ADMIN']"
jhiDeleteButton
[entityTitle]="course.title"
deleteQuestion="artemisApp.course.delete.question"
deleteConfirmationText="artemisApp.course.delete.typeNameToConfirm"
(delete)="deleteCourse(course.id)"
>
<fa-icon icon="times"></fa-icon>
</button>
</div>
</div>
Expand Down
39 changes: 10 additions & 29 deletions src/main/webapp/app/entities/course/course.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Subscription } from 'rxjs/Subscription';
import { JhiAlertService, JhiEventManager } from 'ng-jhipster';
import { Course } from './course.model';
import { CourseService } from './course.service';
import { DeleteDialogData, DeleteDialogService } from 'app/shared/delete-dialog/delete-dialog.service';

@Component({
selector: 'jhi-course',
Expand All @@ -19,12 +18,7 @@ export class CourseComponent implements OnInit, OnDestroy {
courses: Course[];
eventSubscriber: Subscription;

constructor(
private courseService: CourseService,
private jhiAlertService: JhiAlertService,
private eventManager: JhiEventManager,
private deleteDialogService: DeleteDialogService,
) {
constructor(private courseService: CourseService, private jhiAlertService: JhiAlertService, private eventManager: JhiEventManager) {
this.predicate = 'id';
// show the newest courses first and the oldest last
this.reverse = false;
Expand Down Expand Up @@ -57,31 +51,18 @@ export class CourseComponent implements OnInit, OnDestroy {
}

/**
* Opens delete course dialog
* @param course that will be deleted
* Deletes the course
* @param courseId id the course that will be deleted
*/
openDeleteCourseDialog(course: Course) {
if (!course) {
return;
}
const deleteDialogData: DeleteDialogData = {
entityTitle: course.title,
deleteQuestion: 'artemisApp.course.delete.question',
deleteConfirmationText: 'artemisApp.course.delete.typeNameToConfirm',
};
this.deleteDialogService.openDeleteDialog(deleteDialogData).subscribe(
deleteCourse(courseId: number) {
this.courseService.delete(courseId).subscribe(
() => {
this.courseService.delete(course.id).subscribe(
() => {
this.eventManager.broadcast({
name: 'courseListModification',
content: 'Deleted an course',
});
},
error => this.onError(error),
);
this.eventManager.broadcast({
name: 'courseListModification',
content: 'Deleted an course',
});
},
() => {},
error => this.onError(error),
);
}

Expand Down

This file was deleted.

Loading

0 comments on commit 7c30fa0

Please sign in to comment.