<eg-staff-banner bannerText="Course List" i18n-bannerText>
</eg-staff-banner>
-<eg-string #successString i18n-text text="{{table_name}} Update Succeeded"></eg-string>
-<eg-string #createString i18n-text text="{{table_name}} Was Created Successfully"></eg-string>
-<eg-string #deleteFailedString i18n-text text="Deletion of {{table_name}} failed or was not allowed"></eg-string>
-<eg-string #deleteSuccessString i18n-text text="Deletion of {{table_name}} was successful"></eg-string>
-<eg-string #archiveFailedString i18n-text text="Archival of {{table_name}} failed or was not allowed"></eg-string>
-<eg-string #archiveSuccessString i18n-text text="Archival of {{table_name}} succeeded"></eg-string>
+<eg-string #successString i18n-text text="{{tableName}} Update Succeeded"></eg-string>
+<eg-string #createString i18n-text text="{{tableName}} Was Created Successfully"></eg-string>
+<eg-string #deleteFailedString i18n-text text="Deletion of {{tableName}} failed or was not allowed"></eg-string>
+<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 #flairTooltip i18n-text text="Limited Editing"></eg-string>
<div class="w-100 mt-2 mb-2">
- <eg-grid #grid idlClass={{idl_class}}
+ <eg-grid #grid idlClass={{idlClass}}
[dataSource]="grid_source"
[sortable]="true">
<eg-grid-toolbar-button
- label="Create {{table_name}}" (onClick)="createNew()" i18n-label>
+ label="Create {{tableName}}" (onClick)="createNew()" i18n-label>
</eg-grid-toolbar-button>
<eg-grid-toolbar-action label="Edit Selected" i18n-label (onClick)="editSelected($event)">
</eg-grid-toolbar-action>
import {Component, Input, ViewChild, OnInit} from '@angular/core';
-import { Router, ActivatedRoute } from '@angular/router';
+import {Router} from '@angular/router';
import {IdlObject} from '@eg/core/idl.service';
import {PcrudService} from '@eg/core/pcrud.service';
-import {AuthService} from '@eg/core/auth.service';
import {CourseService} from '@eg/staff/share/course.service';
-import {NetService} from '@eg/core/net.service';
-import {OrgService} from '@eg/core/org.service';
import {GridComponent} from '@eg/share/grid/grid.component';
import {Pager} from '@eg/share/util/pager';
import {GridDataSource, GridColumn} from '@eg/share/grid/grid';
templateUrl: './course-list.component.html'
})
-export class CourseListComponent implements OnInit {
-
+export class CourseListComponent implements OnInit {
+
@ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent;
@ViewChild('grid', { static: true }) grid: GridComponent;
@ViewChild('successString', { static: true }) successString: StringComponent;
@ViewChild('courseUserDialog', {static: true})
private courseUserDialog: CourseAssociateUsersComponent;
- @Input() sort_field: string;
- @Input() idl_class = "acmc";
+ @Input() sortField: string;
+ @Input() idlClass = 'acmc';
@Input() dialog_size: 'sm' | 'lg' = 'lg';
- @Input() table_name = "Course";
+ @Input() tableName = 'Course';
grid_source: GridDataSource = new GridDataSource();
currentMaterials: any[] = [];
search_value = '';
constructor(
- private auth: AuthService,
private courseSvc: CourseService,
private locale: LocaleService,
- private net: NetService,
- private org: OrgService,
private pcrud: PcrudService,
- private route: ActivatedRoute,
private router: Router,
private toast: ToastService
- ){}
+ ) {}
ngOnInit() {
this.getSource();
- this.grid.onRowActivate.subscribe((course:IdlObject) => {
- let idToEdit = course.id();
+ this.grid.onRowActivate.subscribe((course: IdlObject) => {
+ const idToEdit = course.id();
this.navigateToCoursePage(idToEdit);
- })
+ });
}
/**
const orderBy: any = {};
if (sort.length) {
// Sort specified from grid
- orderBy[this.idl_class] = sort[0].name + ' ' + sort[0].dir;
- } else if (this.sort_field) {
+ orderBy[this.idlClass] = sort[0].name + ' ' + sort[0].dir;
+ } else if (this.sortField) {
// Default sort field
- orderBy[this.idl_class] = this.sort_field;
+ orderBy[this.idlClass] = this.sortField;
}
const searchOps = {
offset: pager.offset,
limit: pager.limit,
order_by: orderBy
};
- return this.pcrud.retrieveAll(this.idl_class, searchOps, {fleshSelectors: true})
+ return this.pcrud.retrieveAll(this.idlClass, searchOps, {fleshSelectors: true});
};
}
navigateToCoursePage(id_arr: IdlObject[]) {
- if (typeof id_arr == 'number') id_arr = [id_arr];
- let urls = [];
+ if (typeof id_arr === 'number') { id_arr = [id_arr]; }
+ const urls = [];
id_arr.forEach(id => {console.log(this.router.url);
urls.push([this.locale.currentLocaleCode() + this.router.url + '/' + id]);
});
- if (id_arr.length == 1) {
+ if (id_arr.length === 1) {
this.router.navigate([this.router.url + '/' + id_arr[0]]);
} else {
urls.forEach(url => {
- window.open(url)
+ window.open(url);
});
}
}
editSelected(fields: IdlObject[]) {
// Edit each IDL thing one at a time
- let course_ids = [];
+ const course_ids = [];
fields.forEach(field => {
- if (typeof field['id'] == 'function') {
+ if (typeof field['id'] === 'function') {
course_ids.push(field.id());
} else {
course_ids.push(field['id']);
archiveSelected(course: IdlObject[]) {
this.courseSvc.disassociateMaterials(course).then(res => {
- course.forEach(course => {
- console.log(course);
- course.is_archived(true);
+ course.forEach(courseToArchive => {
+ courseToArchive.is_archived(true);
});
this.pcrud.update(course).subscribe(
val => {
});
}
- deleteSelected(idl_object: IdlObject[]) {
- this.courseSvc.disassociateMaterials(idl_object).then(res => {
- idl_object.forEach(idl_object => {
- idl_object.isdeleted(true)
+ deleteSelected(idlObject: IdlObject[]) {
+ this.courseSvc.disassociateMaterials(idlObject).then(res => {
+ idlObject.forEach(object => {
+ object.isdeleted(true);
});
- this.pcrud.autoApply(idl_object).subscribe(
+ this.pcrud.autoApply(idlObject).subscribe(
val => {
console.debug('deleted: ' + val);
this.deleteSuccessString.current()
() => this.grid.reload()
);
});
- };
+ }
}
import {Component, Input, ViewChild, OnInit, TemplateRef} from '@angular/core';
-import {Router, ActivatedRoute} from '@angular/router';
-import {Observable, Observer, of} from 'rxjs';
-import {DialogComponent} from '@eg/share/dialog/dialog.component';
-import {AuthService} from '@eg/core/auth.service';
-import {NetService} from '@eg/core/net.service';
-import {EventService} from '@eg/core/event.service';
-import {OrgService} from '@eg/core/org.service';
+import {ActivatedRoute} from '@angular/router';
import {PcrudService} from '@eg/core/pcrud.service';
-import {Pager} from '@eg/share/util/pager';
-import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
-import {GridDataSource} from '@eg/share/grid/grid';
-import {GridComponent} from '@eg/share/grid/grid.component';
import {IdlObject, IdlService} from '@eg/core/idl.service';
import {StringComponent} from '@eg/share/string/string.component';
-import {StaffBannerComponent} from '@eg/staff/share/staff-banner.component';
import {ToastService} from '@eg/share/toast/toast.service';
import {CourseService} from '@eg/staff/share/course.service';
import {CourseAssociateUsersComponent} from './course-associate-users.component';
private courseMaterialDialog: CourseAssociateMaterialComponent;
@ViewChild('courseUserDialog', {static: true})
private courseUserDialog: CourseAssociateUsersComponent;
-
+
// Edit Tab
@ViewChild('archiveFailedString', { static: true })
archiveFailedString: StringComponent;
// Materials Tab
constructor(
- private auth: AuthService,
private course: CourseService,
- private event: EventService,
- private idl: IdlService,
- private net: NetService,
- private org: OrgService,
private pcrud: PcrudService,
private route: ActivatedRoute,
private toast: ToastService
}
ngOnInit() {
- this.courseId = parseInt(this.route.snapshot.paramMap.get('id'));
+ this.courseId = +this.route.snapshot.paramMap.get('id');
this.course.getCourses([this.courseId]).then(course => {
this.currentCourse = course[0];
});
}
// Materials Tab
-
-}
\ No newline at end of file
+
+}