<eg-string #deleteSuccessString i18n-text text="Deletion of {{tableName}} was successful"></eg-string>
<eg-string #archiveFailedString i18n-text text="Archival of {{tableName}} failed or was not allowed"></eg-string>
<eg-string #archiveSuccessString i18n-text text="Archival of {{tableName}} succeeded"></eg-string>
+<eg-string #duplicateFailedString i18n-text text="Duplication of {{tableName}} failed or was not allowed"></eg-string>
+<eg-string #duplicateSuccessString i18n-text text="Duplication 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="Archive Selected" i18n-label (onClick)="archiveSelected($event)">
</eg-grid-toolbar-action>
+ <eg-grid-toolbar-action label="Duplicate Selected" i18n-label (onClick)="duplicateSelected($event)">
+ </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>
<eg-grid-column label="Course Name" name="name" i18n-label></eg-grid-column>
@ViewChild('deleteSuccessString', { static: true }) deleteSuccessString: StringComponent;
@ViewChild('archiveFailedString', { static: true }) archiveFailedString: StringComponent;
@ViewChild('archiveSuccessString', { static: true }) archiveSuccessString: StringComponent;
+ @ViewChild('duplicateFailedString', { static: true }) duplicateFailedString: StringComponent;
+ @ViewChild('duplicateSuccessString', { static: true }) duplicateSuccessString: StringComponent;
@ViewChild('courseMaterialDialog', {static: true})
private courseMaterialDialog: CourseAssociateMaterialComponent;
@ViewChild('courseUserDialog', {static: true})
});
}
+ duplicateSelected(course: IdlObject[]) {
+ let new_course = this.idl.create('acmc');;
+ course.forEach(courseToCopy => {
+ new_course.name(courseToCopy.name());
+ new_course.course_number(courseToCopy.course_number());
+ new_course.section_number(courseToCopy.section_number());
+ new_course.owning_lib(courseToCopy.owning_lib());
+ new_course.is_archived(courseToCopy.is_archived());
+ this.pcrud.create(new_course).subscribe(val => {
+ console.debug('duplicated: ' + val);
+ this.duplicateSuccessString.current()
+ .then(str => this.toast.success(str));
+ }, err => {
+ this.duplicateFailedString.current()
+ .then(str => this.toast.danger(str));
+ }, () => this.grid.reload()
+ );
+ });
+ }
+
deleteSelected(idlObject: IdlObject[]) {
this.courseSvc.disassociateMaterials(idlObject).then(res => {
idlObject.forEach(object => {