<eg-string #deleteSuccessString i18n-text text="Deletion of {{tableName}} was successful"></eg-string>
<eg-string #archiveFailedString i18n-text text="Archiving of {{tableName}} failed or was not allowed"></eg-string>
<eg-string #archiveSuccessString i18n-text text="Archiving of {{tableName}} succeeded"></eg-string>
+<eg-string #unarchiveFailedString i18n-text text="Unarchiving of {{tableName}} failed or was not allowed"></eg-string>
+<eg-string #unarchiveSuccessString i18n-text text="Unarchiving of {{tableName}} succeeded"></eg-string>
<eg-string #flairTooltip i18n-text text="Limited Editing"></eg-string>
<ul ngbNav #courseListNav="ngbNav" class="nav-tabs">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action label="Delete Selected" i18n-label (onClick)="deleteSelected($event)">
</eg-grid-toolbar-action>
- <eg-grid-toolbar-action label="Archive Selected" i18n-label (onClick)="archiveSelected($event)">
+ <eg-grid-toolbar-action label="Archive Selected" i18n-label (onClick)="archiveSelected($event)" [disabled]="is_archived">
+ </eg-grid-toolbar-action>
+ <eg-grid-toolbar-action label="Reopen Selected" i18n-label (onClick)="unarchiveSelected($event)" [disabled]="!is_archived">
</eg-grid-toolbar-action>
<eg-grid-column label="ID" path="id" [index]=true [hidden]="true" i18n-label></eg-grid-column>
<eg-grid-column label="Terms taught" name="terms_map" i18n-label [cellTemplate]="termMapLink"></eg-grid-column>
@ViewChild('deleteSuccessString', { static: true }) deleteSuccessString: StringComponent;
@ViewChild('archiveFailedString', { static: true }) archiveFailedString: StringComponent;
@ViewChild('archiveSuccessString', { static: true }) archiveSuccessString: StringComponent;
+ @ViewChild('unarchiveFailedString', { static: true }) unarchiveFailedString: StringComponent;
+ @ViewChild('unarchiveSuccessString', { static: true }) unarchiveSuccessString: StringComponent;
@ViewChild('courseMaterialDialog', {static: true})
private courseMaterialDialog: CourseAssociateMaterialComponent;
@ViewChild('courseUserDialog', {static: true})
);
});
}
+
+ courseArchiveableOrNot(course: IdlObject[], archiveBool) {
+ course.forEach(courseToMod => {
+ if (archiveBool == false) return courseToMod.is_archived() == 't';
+ return courseToMod.is_archived() == 'f';
+ });
+ }
+
+ unarchiveSelected(course: IdlObject[]) {
+ course.forEach(courseToUnarchive => {
+ courseToUnarchive.is_archived(false);
+ });
+ this.pcrud.update(course).subscribe(
+ val => {
+ course.forEach(courseEntry => {
+ this.courseSvc.removeNonPublicUsers(courseEntry.id());
+ });
+ console.debug('archived: ' + val);
+ this.unarchiveSuccessString.current()
+ .then(str => this.toast.success(str));
+ }, err => {
+ this.unarchiveFailedString.current()
+ .then(str => this.toast.danger(str));
+ }, () => {
+ this.grid.reload();
+ }
+ );
+ }
deleteSelected(idlObject: IdlObject[]) {
this.courseSvc.disassociateMaterials(idlObject).then(res => {
<button class="btn btn-danger"
(click)="archiveCourse()" [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) === 't' ">
<i class="material-icons align-middle"
- *ngIf="currentCourse && (courseIsArchived || currentCourse.is_archived()) === 't'">block</i>
+ *ngIf="currentCourse && (currentCourse.is_archived() == 't' || currentCourse.is_archived() == true)">block</i>
<span class="align-middle">Archive Course</span>
</button>
+ <button class="btn btn-primary"
+ (click)="unarchiveCourse()" *ngIf="currentCourse && 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>
<i class="material-icons align-middle">keyboard_return</i>
<span class="align-middle">Return to Course List</span>
archiveFailedString: StringComponent;
@ViewChild('archiveSuccessString', { static: true })
archiveSuccessString: StringComponent;
+ @ViewChild('unarchiveFailedString', { static: true })
+ unarchiveFailedString: StringComponent;
+ @ViewChild('unarchiveSuccessString', { static: true })
+ unarchiveSuccessString: StringComponent;
constructor(
private course: CourseService,
});
});
}
+
+ unarchiveCourse() {
+ this.course.disassociateMaterials([this.currentCourse]).then(res => {
+ this.currentCourse.is_archived('f');
+ this.pcrud.update(this.currentCourse).subscribe(val => {
+ this.course.removeNonPublicUsers(this.currentCourse.id());
+ console.debug('unarchived: ' + val);
+ this.unarchiveSuccessString.current()
+ .then(str => this.toast.success(str));
+ }, err => {
+ this.unarchiveFailedString.current()
+ .then(str => this.toast.danger(str));
+ });
+ });
+ }
// Materials Tab
});
});
}
+
+ removeNonPublicUsers(courseID: Number) {
+ return new Promise((resolve, reject) => {
+ const acmcu_ids = [];
+
+ this.getUsers([courseID]).subscribe(nonPublicUser => {
+ if(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);
+ });
+ });
+ });
+ });
+ }
updateItem(item: IdlObject, courseLib: IdlObject, callNumber: string, updatingVolume: boolean) {