<div class="row">
<div class="col text-right">
- <button class="btn btn-danger"
- (click)="archiveCourse()" [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) === 't' ">
- <i class="material-icons align-middle"
- *ngIf="currentCourse && (currentCourse.is_archived() == 't' || currentCourse.is_archived() == true)">block</i>
+ <button class="btn btn-danger" *ngIf="currentCourse && (courseIsArchived || currentCourse.is_archived()) === 'f' "
+ (click)="archiveCourse()">
<span class="align-middle">Archive Course</span>
</button>
<button class="btn btn-primary"
- (click)="unarchiveCourse()" *ngIf="currentCourse && currentCourse.is_archived() == 't'">
+ (click)="unarchiveCourse()" *ngIf="currentCourse && (courseIsArchived || currentCourse.is_archived()) === 't' ">
<span class="align-middle">Unarchive Course</span>
</button>
<a class="btn btn-warning ml-3" routerLink="/staff/admin/local/asset/course_list" i18n>
<eg-string #archiveFailedString i18n-text text="Archiving of Course failed or was not allowed"></eg-string>
<eg-string #archiveSuccessString i18n-text text="Archiving of Course succeeded"></eg-string>
+<eg-string #unarchiveSuccessString i18n-text text="Unarchiving of Course succeeded"></eg-string>
this.course.disassociateMaterials([this.currentCourse]).then(res => {
this.currentCourse.is_archived('f');
this.pcrud.update(this.currentCourse).subscribe(val => {
+ this.courseIsArchived = 'f';
+ console.debug('archived: ' + val);
this.course.removeNonPublicUsers(this.currentCourse.id());
- console.debug('unarchived: ' + val);
this.unarchiveSuccessString.current()
.then(str => this.toast.success(str));
}, err => {
const acmcu_ids = [];
this.getUsers([courseID]).subscribe(nonPublicUser => {
- if(nonPublicUser.usr_role().is_public() !== 't') acmcu_ids.push(nonPublicUser.id());
+ if(nonPublicUser && nonPublicUser.usr_role().is_public() !== 't') acmcu_ids.push(nonPublicUser.id());
}, err => {
reject(err);
}, () => {
resolve(acmcu_ids);
- this.pcrud.search('acmcu', {course: courseID, id: acmcu_ids}).subscribe(userToDelete => {
- userToDelete.isdeleted(true);
- this.pcrud.autoApply(userToDelete).subscribe(val => {
- console.debug('deleted: ' + val);
- }, err => {
- console.log("Error: " + err);
- reject(err);
- }, () => {
- console.log("Resolving");
- resolve(userToDelete);
+ if (acmcu_ids.length) {
+ this.pcrud.search('acmcu', {course: courseID, id: acmcu_ids}).subscribe(userToDelete => {
+ userToDelete.isdeleted(true);
+ this.pcrud.autoApply(userToDelete).subscribe(val => {
+ console.debug('deleted: ' + val);
+ }, err => {
+ console.log("Error: " + err);
+ reject(err);
+ }, () => {
+ console.log("Resolving");
+ resolve(userToDelete);
+ });
});
- });
+ }
});
});
}