Advertisement
FiringBlanks

Autocomplete Search (3)

Oct 27th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.43 KB | None | 0 0
  1.  
  2. // import {map, startWith, filter, scan} from 'rxjs/operators';
  3. import { Component, OnInit, OnDestroy, Pipe, PipeTransform, Input, HostListener, Injectable } from '@angular/core';
  4. import { FormControl } from '@angular/forms';
  5. import { Observable, of } from 'rxjs';
  6. import * as firebase from 'firebase';
  7. import { MatDialog, MatSnackBar } from '@angular/material';
  8. import { DialogAddSchoolComponent } from '../dialog-add-school/dialog-add-school.component';
  9. import { PersistingDataService } from '../persisting-data/persisting-data.service';
  10. import { Router } from '@angular/router';
  11. import { AngularFirestoreCollection, AngularFirestore, AngularFirestoreDocument } from '@angular/fire/firestore';
  12. import { AuthService } from '../core/auth.service';
  13. import { CommonService } from '../SvcCommon/common.service';
  14. import { PaymentService } from '../SvcPayment/payment.service';
  15. import { DialogNewUserComponent } from '../dialog-new-user/dialog-new-user.component';
  16. import { User, Action, Assignment, SvcInterfacesService } from '../SvcInterfaces/svc-interfaces.service';
  17. import { DialogAdminPanelComponent } from '../dialog-admin-panel/dialog-admin-panel.component';
  18. import { DialogEditSchoolComponent } from '../dialog-edit-school/dialog-edit-school.component';
  19. import { debounceTime, map, tap, take } from 'rxjs/operators';
  20. import { SlicePipe } from '@angular/common';
  21. import { HttpClient } from '@angular/common/http';
  22. import { DialogOpenSubmissionsComponent } from '../dialog-open-submissions/dialog-open-submissions.component';
  23. import { DialogTutorialComponent } from '../dialog-tutorial/dialog-tutorial.component';
  24. // import 'rxjs/add/operator/toPromise';
  25.  
  26. // declare const google: any;
  27.  
  28.  
  29. // export class School {
  30. // constructor(public name: string, public city: string, public state: string, public type: string) { }
  31. // }
  32.  
  33. interface School {
  34. name: string,
  35. schoolNameDisplay: string,
  36. city: string,
  37. state: string,
  38. type: string
  39. }
  40.  
  41. interface Class {
  42. className: string;
  43. classSubmittedDate: number;
  44. classUID: string;
  45. submittersName: string;
  46. submittersUID: string;
  47. teacher: string;
  48. school: string;
  49. }
  50.  
  51. @Pipe({name: 'orderBy', pure: false})
  52. export class OrderBy implements PipeTransform {
  53.  
  54. static _orderByComparator(a:any, b:any):number{
  55.  
  56. if((isNaN(parseFloat(a)) || !isFinite(a)) || (isNaN(parseFloat(b)) || !isFinite(b))){
  57. //Isn't a number so lowercase the string to properly compare
  58. // if(a.toLowerCase() < b.toLowerCase()) return -1;
  59. // if(a.toLowerCase() > b.toLowerCase()) return 1;
  60. }
  61. else{
  62. //Parse strings as numbers to compare properly
  63. if(parseFloat(a) < parseFloat(b)) return -1;
  64. if(parseFloat(a) > parseFloat(b)) return 1;
  65. }
  66.  
  67. return 0; //equal each other
  68. }
  69.  
  70. transform(input:any, [config = '+']): any{
  71.  
  72. if(!Array.isArray(input)) return input;
  73.  
  74. if(!Array.isArray(config) || (Array.isArray(config) && config.length == 1)){
  75. var propertyToCheck:string = !Array.isArray(config) ? config : config[0];
  76. var desc = propertyToCheck.substr(0, 1) == '-';
  77.  
  78. //Basic array
  79. if(!propertyToCheck || propertyToCheck == '-' || propertyToCheck == '+'){
  80. return !desc ? input.sort() : input.sort().reverse();
  81. }
  82. else {
  83. var property:string = propertyToCheck.substr(0, 1) == '+' || propertyToCheck.substr(0, 1) == '-'
  84. ? propertyToCheck.substr(1)
  85. : propertyToCheck;
  86.  
  87. return input.sort(function(a:any,b:any){
  88. return !desc ?
  89. OrderBy._orderByComparator(a[property], b[property])
  90. : -OrderBy._orderByComparator(a[property], b[property]);
  91. });
  92. }
  93. }
  94. else {
  95. //Loop over property of the array in order and sort
  96. return input.sort(function(a:any,b:any){
  97. for(var i:number = 0; i < config.length; i++){
  98. var desc = config[i].substr(0, 1) == '-';
  99. var property = config[i].substr(0, 1) == '+' || config[i].substr(0, 1) == '-'
  100. ? config[i].substr(1)
  101. : config[i];
  102.  
  103. var comparison = !desc ?
  104. OrderBy._orderByComparator(a[property], b[property])
  105. : -OrderBy._orderByComparator(a[property], b[property]);
  106.  
  107. //Don't return 0 yet in case of needing to sort by next property
  108. if(comparison != 0) return comparison;
  109. }
  110.  
  111. return 0; //equal each other
  112. });
  113. }
  114. }
  115. }
  116.  
  117. @Injectable({
  118. providedIn: 'root'
  119. })
  120. export class MyService {
  121.  
  122. constructor(private afs: AngularFirestore) { }
  123.  
  124. private schools = [];
  125.  
  126. fetchSchools() {
  127. console.log('---------------');
  128.  
  129. if(this.schools && this.schools.length) {
  130. console.log('Returning first data');
  131. return of(this.schools);
  132. } else {
  133. console.log('Returning else data');
  134. return this.afs.collection('Schools', ref => {
  135. return ref.orderBy('schoolNameDisplay')
  136. }).valueChanges().pipe(
  137. tap((schools) => this.schools = schools)
  138. ).pipe(
  139. take(1)
  140. )
  141. }
  142. }
  143. }
  144.  
  145. @Component({
  146. selector: 'app-page-home',
  147. templateUrl: './page-home.component.html',
  148. styleUrls: ['./page-home.component.css']
  149. })
  150. export class PageHomeComponent implements OnInit {
  151.  
  152. pinnedClassesCollection: AngularFirestoreCollection<Class>;
  153. pinnedClasses: Observable<Class[]>;
  154.  
  155. moderatingClassesCollection: AngularFirestoreCollection<Class>;
  156. moderatingClasses: Observable<Class[]>;
  157.  
  158. schoolsCollection: AngularFirestoreCollection<School>;
  159. schools: Observable<School[]>;
  160. // schools;
  161. schoolsArr: School[];
  162.  
  163. assignmentsCollection: AngularFirestoreCollection<Assignment>;
  164. assignments: Observable<Assignment[]>;
  165.  
  166. createdSchoolsCollection: AngularFirestoreCollection<School>;
  167. createdSchools: Observable<School[]>;
  168.  
  169. schoolsDocs: AngularFirestoreDocument<School>;
  170.  
  171. schoolCtrl: FormControl;
  172. filteredSchools: Observable<any[]>
  173.  
  174. searchedSchool;
  175.  
  176. user: User;
  177. userExists;
  178.  
  179. currentlySelectedPinnedClassUID;
  180. currentlySelectedPinnedClass;
  181. currentlySelectedPinnedTeacher;
  182. currentlySelectedPinnedSchool;
  183.  
  184. pinnedSize;
  185. moderatingSize;
  186.  
  187. pinsFetched; //'fetched' or 'stopped'
  188. modsFetched; //'fetched' or 'stopped'
  189.  
  190. windowWidth;
  191. windowHeight;
  192.  
  193. toolbarElevated;
  194.  
  195. usersPosition;
  196. usersPositionLoopCounter = 0;
  197. locationFetched = false;
  198. usersMetaHot;
  199.  
  200.  
  201.  
  202. @HostListener('window:resize', ['$event'])
  203. onresize(event) {
  204. this.windowWidth = window.innerWidth;
  205. this.windowHeight = window.innerHeight;
  206. console.log(`Window resolution: ${this.windowWidth} x ${this.windowHeight}`);
  207. }
  208.  
  209. constructor(private dialog: MatDialog, private persistingData: PersistingDataService, private router: Router, private afs: AngularFirestore, private auth: AuthService, private common: CommonService, private payment: PaymentService, private myService: MyService, private snackbar: MatSnackBar, private httpClient: HttpClient) { }
  210.  
  211. schoolsObs = of([]);
  212. searchModel = '';
  213.  
  214. ngOnInit() {
  215.  
  216. this.persistingData.changeViewWithContainer(true);
  217. this.persistingData.toolbarElevated.subscribe(message => this.toolbarElevated = message);
  218.  
  219. // this.router.events.subscribe((val) => {
  220. // console.log('ngOnInit router changed');
  221. // this.persistingData.changeToggleDisplayGradient(false)
  222. // })
  223.  
  224. this.windowWidth = window.innerWidth;
  225. this.windowHeight = window.innerHeight;
  226.  
  227. // this.fetchSchools();
  228. this.filterSchools();
  229.  
  230. this.persistingData.loggedInUser.subscribe(user => {
  231.  
  232. if(user){
  233. this.user = user;
  234. this.userExists = true;
  235. this.fetchPinnedClasses();
  236. this.fetchModeratingClasses();
  237. this.fetchCreatedSchools();
  238. this.fetchLocation();
  239. } else {
  240. this.userExists = false;
  241. this.pinsFetched = 'stopped';
  242. this.modsFetched = 'stopped';
  243. }
  244.  
  245. console.log('persistingData loggedinUser subscription:');
  246. if(user){
  247. console.log('user: ');
  248. console.log(user);
  249. }
  250.  
  251. this.user = user;
  252. });
  253.  
  254. }
  255.  
  256. filterSchools(){
  257. this.schoolsObs = this.myService.fetchSchools().pipe(
  258. debounceTime(300),
  259. map((data) => this.performFilter(data))
  260. );
  261. }
  262.  
  263. performFilter(schoolsObs){
  264. console.log('schoolsObs:');
  265. console.log(schoolsObs);
  266.  
  267. console.log('this.schools:');
  268. console.log(this.schools);
  269.  
  270. return schoolsObs.filter((x) => {
  271. return x.name.toLowerCase().startsWith(this.searchModel.trim().toLowerCase());
  272. }).slice(0,4);
  273.  
  274. }
  275.  
  276. ngOnDestroy(){
  277. console.log('Running onDestroy()');
  278. this.persistingData.changeToggleDisplayGradient(false);
  279. this.persistingData.changeToolbarElevated(true);
  280. }
  281.  
  282. updateUsersMeta(ipResponse){
  283. console.log('Running updateUsersMeta()');
  284.  
  285. //Update user's position property in firestore if current city different than stored city
  286. if(this.user.usersMeta){
  287. console.log('User has existing usersMeta obj');
  288.  
  289. if(this.user.usersMeta.city != ipResponse.city){
  290. console.log('Updating users usersMeta prop');
  291.  
  292. this.afs.collection('Users').doc(this.user.uid).ref.update({
  293. usersMeta: ipResponse
  294. }).then(() => {
  295. console.log('Finished updating user with usersMeta prop');
  296. });
  297. } else {
  298. console.log('Users city is the same as before. No need to update.');
  299.  
  300. }
  301.  
  302. } else {
  303. console.log('User does not yet have usersMeta obj');
  304.  
  305. this.afs.collection('Users').doc(this.user.uid).ref.update({
  306. usersMeta: ipResponse
  307. }).then(() => {
  308. console.log('Finished updating user with usersMeta prop');
  309. });
  310. }
  311.  
  312. }
  313.  
  314.  
  315.  
  316. // fetchSchools(){
  317. // console.log('Running fetchSchools');
  318.  
  319. // this.schoolsCollection = this.afs.collection('Schools', ref => {
  320. // console.log('In afs.collection');
  321. // // return ref.orderBy('name').limit(4);
  322. // return ref.orderBy('name');
  323. // });
  324.  
  325. // this.schools = this.schoolsCollection.valueChanges();
  326.  
  327. // console.log('schoolsCollection:');
  328. // console.log(this.schoolsCollection);
  329.  
  330. // console.log('Retreived schools:');
  331. // console.log(this.schools);
  332.  
  333. // }
  334.  
  335.  
  336. fetchPinnedClasses() {
  337. console.log('Loading Pinned classes now...');
  338.  
  339. //Get reference to current user's Users/user.uid/Pinned collection
  340. let pathPinned = 'Users/' + this.user.uid + '/Pinned';
  341.  
  342. this.pinnedClassesCollection = this.afs.collection(pathPinned, ref => {
  343. ref.get().then(coll => {
  344. this.pinnedSize = coll.size;
  345. this.pinsFetched = 'fetched';
  346. console.log(`pinnedSize: ${this.pinnedSize}`);
  347. });
  348.  
  349. return ref.orderBy('className');
  350. });
  351. this.pinnedClasses = this.pinnedClassesCollection.valueChanges();
  352. }
  353.  
  354. moderatingClassesSnap: any;
  355.  
  356. fetchModeratingClasses() {
  357. console.log('Loading Moderating classes now...');
  358.  
  359. //Get reference to current user's Users/user.uid/Pinned collection
  360. let pathModerating = 'Users/' + this.user.uid + '/Moderating';
  361.  
  362. this.moderatingClassesCollection = this.afs.collection(pathModerating, ref => {
  363. ref.get().then(coll => {
  364. this.moderatingSize = coll.size;
  365. this.modsFetched = 'fetched';
  366. console.log(`moderatingSize: ${this.moderatingSize}`);
  367. });
  368.  
  369. return ref.orderBy('class');
  370. });
  371. this.moderatingClasses = this.moderatingClassesCollection.valueChanges();
  372.  
  373. // this.moderatingClassesSnap = this.moderatingClassesCollection.snapshotChanges().pipe(map(changes => {
  374. // return changes.map(a => {
  375. // const data = a.payload.doc.data();
  376. // console.log('moderatingClassesSnap data:');
  377.  
  378. // console.log(data);
  379. // return data;
  380. // });
  381. // })).subscribe();
  382.  
  383. }
  384.  
  385. fetchAssignments(pinnedClass, i){
  386. console.log('Fetching assignment of pinnedClass instance:');
  387. console.log(pinnedClass);
  388.  
  389. let path = `Schools/${pinnedClass.school}/Teachers/${pinnedClass.teacher}/Classes/${pinnedClass.className}/Assignments`;
  390. console.log(path);
  391.  
  392. console.log('index: ' + i);
  393.  
  394. this.assignmentsCollection = this.afs.collection(path, ref => {
  395. return ref.orderBy('weekDue');
  396. });
  397. this.assignments = this.assignmentsCollection.valueChanges();
  398.  
  399. }
  400.  
  401. fetchCreatedSchools(){
  402. console.log('Loading Created classes now...');
  403.  
  404. //Get reference to current user's Users/user.uid/Pinned collection
  405. let pathCreated = 'Users/' + this.user.uid + '/Created Schools';
  406.  
  407. this.createdSchoolsCollection = this.afs.collection(pathCreated);
  408. this.createdSchools = this.createdSchoolsCollection.valueChanges();
  409. }
  410.  
  411. fetchLocation(){
  412. console.log('Running fetchLocation()');
  413.  
  414. //If user is signed in and their city/metadata is unknown, check their location
  415. if(this.locationFetched == false){
  416. console.log('LocationFetch has not yet been attempted for page');
  417. this.locationFetched = true;
  418.  
  419. //Run only if users city is unknown
  420. if(!this.user.usersMeta){
  421. console.log('Users usersMeta has no value. Fetching ip...');
  422.  
  423. this.common.getLocation().subscribe(locationData => {
  424. console.log('Returning getLocation() locationData');
  425. console.log(locationData);
  426. this.updateUsersMeta(locationData);
  427. })
  428. }
  429.  
  430. }
  431. }
  432.  
  433. searchButton(input){
  434.  
  435. if(input.length < 4){
  436. console.log('Input length is too short: ' + input.length);
  437. this.snackbar.open('Please enter more characters', 'Ok', {duration: 2000});
  438. return null;
  439. }
  440.  
  441. //Save away search
  442. this.searchedSchool = input;
  443. console.log('Searching for school: ' + this.searchedSchool);
  444.  
  445. //Persist school search
  446. this.persistingData.changeSchool(this.searchedSchool);
  447.  
  448. //Navigate to Browse Teachers page
  449. let navPath = this.searchedSchool;
  450. this.router.navigateByUrl(navPath);
  451. }
  452.  
  453. openDialogAddSchool() {
  454. console.log('Opening dialog Add School');
  455. this.dialog.open(DialogAddSchoolComponent, {width: '500px'});
  456. }
  457.  
  458. navigateToClass(school, teacher, className) {
  459. console.group('navigateToClass()')
  460. console.log('Navigating to class: ');
  461. console.log('School: ' + school);
  462. console.log('Teacher: ' + teacher);
  463. console.log('className: ' + className);
  464. console.groupEnd()
  465.  
  466. //Persist data
  467. this.persistingData.changeSchool(school);
  468. this.persistingData.changeTeacher(teacher);
  469. this.persistingData.changeClass(className);
  470.  
  471. let pathToNav = school + '/' + teacher;
  472. this.router.navigateByUrl(pathToNav);
  473.  
  474. //Move scroll back up to the top of the page (smoothly)
  475. window.scrollTo({
  476. top: 0,
  477. behavior: 'smooth'
  478. });
  479. }
  480.  
  481. unpinClass(schoolName, teacherName, className, classUID){
  482. console.log('Unpinning class...');
  483.  
  484. let classSnap = {
  485. name: className
  486. }
  487.  
  488. this.common.removeClassFromUsersPinnedCollSimple(this.user, schoolName, teacherName, classUID, className);
  489. this.common.removeUserFromClassPinners(this.user.uid, schoolName, teacherName, className);
  490. this.common.bumpTeachersPinnedCount(schoolName, teacherName, classSnap, -1);
  491.  
  492. }
  493.  
  494. asyncTest(){
  495.  
  496. var p1 = new Promise((resolve, reject) => {
  497. setTimeout(() => {
  498. console.log('In p1');
  499. resolve('p1 resolved');
  500. }, 600);
  501. });
  502.  
  503. var p2 = new Promise((resolve, reject) => {
  504. setTimeout(() => {
  505. console.log('In p2');
  506. resolve('p2 resolved');
  507. }, 200);
  508. });
  509.  
  510. var p3 = new Promise((resolve, reject) => {
  511. setTimeout(() => {
  512. console.log('In p3');
  513. resolve('p3 resolved');
  514. }, 300);
  515. });
  516.  
  517. Promise.all([p1, p2, p3]).then(() => {
  518. console.log('Running PromiseAll then');
  519. })
  520.  
  521.  
  522. }
  523.  
  524. updateCounts(request, response, counts) {
  525.  
  526. let schoolsSize;
  527. let usersSize;
  528.  
  529. console.log('Running updateCounts');
  530.  
  531.  
  532. //Get count of schools
  533. var p1 = new Promise((resolve, reject) => {
  534.  
  535. console.log('in p1');
  536.  
  537. this.afs.collection('Schools').ref.get().then(snap => {
  538. console.log('in p1 then');
  539. schoolsSize = snap.size;
  540. console.log('schoolsSize: ' + schoolsSize);
  541. resolve(schoolsSize);
  542. // return counts.schoolsCount = schoolsSize;
  543. }).catch(error => {
  544. console.log(error);
  545. response.status(500).send(error);
  546. });
  547.  
  548. });
  549.  
  550. //Get count of users
  551. var p2 = new Promise((resolve, reject) => {
  552.  
  553. console.log('in p2');
  554.  
  555. this.afs.collection('Users').ref.get().then(snap => {
  556. console.log('in p2 then');
  557. usersSize = snap.size;
  558. console.log('usersSize: ' + usersSize);
  559. resolve(usersSize);
  560. // counts.usersCount = usersSize;
  561. }).catch(error => {
  562. console.log(error);
  563. response.status(500).send(error);
  564. });
  565.  
  566. });
  567.  
  568. Promise.all([p1, p2]).then(values => {
  569. console.log('in Promise.all then');
  570. console.log('Promise.all values: ' + values);
  571. // console.log('Promise.all count: ' + counts);
  572. console.log('schoolsSize: ' + schoolsSize);
  573. console.log('usersSize: ' + usersSize);
  574. // response.send(values);
  575. });
  576.  
  577. }
  578.  
  579. showNewUserDialog(){
  580. console.log('Running showNewUserDialog');
  581. this.dialog.open(DialogNewUserComponent, { width: '400px' });
  582. }
  583.  
  584. splashPicClicked(){
  585. console.log('Running splashPicClicked()');
  586. document.getElementById('searchInput').blur();
  587. }
  588.  
  589. setCurrentPinnedVariables(classVar){
  590. console.log('classVar.school:');
  591. console.log(classVar.school);
  592.  
  593. this.currentlySelectedPinnedClassUID = classVar.classUID;
  594. this.currentlySelectedPinnedClass = classVar.className;
  595. this.currentlySelectedPinnedTeacher = classVar.teacher;
  596. this.currentlySelectedPinnedSchool = classVar.school;
  597.  
  598. // this.currentlySelectedPinnedClass = classVar;
  599. }
  600.  
  601. fetchCusID(usr){
  602. console.log('Running fetchCusID() for usr: ');
  603. console.log(usr);
  604.  
  605. this.afs.collection('Customers').ref.where('userUID', '==', usr.uid).get().then(customers => {
  606. console.log('Customers: ');
  607. if(!customers.empty){
  608. customers.forEach(customer => {
  609. console.log(`${customer.data().displayName}'s customerID: ${customer.data().customerID}`);
  610. this.addCustomerIDToUser(customer.data().userUID, customer.data().customerID);
  611. });
  612. } else {
  613. console.log('No Customer UID found for user');
  614. }
  615. });
  616. }
  617.  
  618. addCustomerIDToUser(userUID, customerID){
  619. console.log('Running addCustomerIDToUser()');
  620.  
  621. this.afs.doc(`Users/${userUID}`).ref.update({
  622. customerID: customerID
  623. });
  624.  
  625. }
  626.  
  627. openAdminPanel(){
  628. console.log('Running openAdminPanel()');
  629. this.dialog.open(DialogAdminPanelComponent);
  630. }
  631.  
  632. toggleDisplayGradient(val){
  633. this.persistingData.changeToggleDisplayGradient(val);
  634. }
  635.  
  636. toggleElevateToolbar(val){
  637. this.persistingData.changeToolbarElevated(val);
  638. }
  639.  
  640. editSchool(school){
  641. console.log('Opening editSchoolDialog with school obj:');
  642. console.log(school);
  643.  
  644. console.log('school.schoolName');
  645. console.log(school.schoolName);
  646.  
  647. //Persist school search (since Edit School dialog works off of currently persisted school)
  648. this.persistingData.changeSchool(school.schoolName);
  649.  
  650. this.dialog.open(DialogEditSchoolComponent);
  651. }
  652.  
  653. addSchoolDisabledClick(){
  654. console.log('Running addSchoolDisabledClick()');
  655. this.snackbar.open('You must be signed in to add a school', 'Ok', {duration: 2000});
  656. }
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663. sendAlertTest(){
  664. console.log('Running sendAlertTest');
  665. this.persistingData.changeMassDelete(true);
  666. this.common.alertUser(this.user.uid, "Test alert 10 - SettingMD");
  667. }
  668.  
  669. sendAlertTestWithoutSettingMassDelete(){
  670. console.log('Running sendAlertTestWithout');
  671. this.common.alertUser(this.user.uid, "Test alert 10 - NoMD");
  672. }
  673.  
  674. doAsync(){
  675. console.log('Starting doAsync');
  676.  
  677. this.delay(2000).then(() => {
  678. console.log('Done doing async. Aaaah...');
  679. })
  680. }
  681.  
  682. delay(time){
  683. console.log('Reached delay function');
  684.  
  685. return new Promise((resolve, reject) => {
  686. setTimeout(resolve, time);
  687. })
  688. }
  689.  
  690. testButton(){
  691. console.log('running testButton()');
  692.  
  693. this.dialog.open(DialogTutorialComponent, { width: '600px'});
  694.  
  695. // this.afs.doc(`Users/${this.user.uid}`).ref.update({
  696. // "misc.item3": firebase.firestore.FieldValue.increment(1)
  697. // });
  698.  
  699. }
  700.  
  701. onLoadFunc(){
  702. console.log('Thing loaded!');
  703. }
  704.  
  705. navigateToAboutPage(){
  706. console.log('Running navigateToAboutPage()');
  707.  
  708. this.persistingData.changeViewWithContainer(false);
  709.  
  710. this.router.navigateByUrl('about');
  711.  
  712. //Move scroll back up to the top of the page (smoothly)
  713. window.scrollTo({
  714. top: 0,
  715. behavior: 'smooth'
  716. });
  717.  
  718. }
  719.  
  720. openPinnedClassAssignment(selectedClass, assignment){
  721. console.log('Running openPinnedClassAssignment()');
  722. console.log(assignment);
  723. console.log(selectedClass);
  724.  
  725. this.persistingData.changeSchool(selectedClass.school);
  726. this.persistingData.changeTeacher(selectedClass.teacher);
  727. this.persistingData.changeClass(selectedClass.className);
  728.  
  729. //Set persisting data
  730. this.persistingData.changeLoadedSubmissionsType('assignments');
  731. this.persistingData.changeAssignmentObj(assignment); //Phase out old way for this new way
  732.  
  733. //Old way, but active
  734. this.persistingData.changeAssignmentUID(assignment.uid);
  735. this.persistingData.changeAssignmentName(assignment.title);
  736. // this.persistingData.changeAssignmentDueDate(assignment.dueDate);
  737. this.persistingData.changeAssignmentWeekDue(assignment.weekDue);
  738. this.persistingData.changeAssignmentType(assignment.type)
  739.  
  740. // this.dialog.open(DialogOpenSubmissionsComponent, { minWidth: '900px'});
  741. this.dialog.open(DialogOpenSubmissionsComponent, { minWidth: '800px', width: '50%'});
  742.  
  743. }
  744.  
  745.  
  746.  
  747.  
  748.  
  749. }
  750.  
  751. const data = [
  752. {'city': 'Sacramento', 'name': 'Sacramento State' },
  753. {'city': 'Rocklin', 'name': 'Sierra College' },
  754. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement