Skip to content

Commit

Permalink
Section sort order, Fixes neojato#30
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCsabaToth committed Oct 1, 2018
1 parent 2c4c0a3 commit 63daa60
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app/sessions/my-schedule/my-schedule.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class MyScheduleComponent implements OnInit {

ngOnInit() {
this.sessions$ = this.sessionService.getSessionList();
this.sections$ = this.sectionService.getSectionList();
this.sections$ = this.sectionService.getSectionList({ orderByChild: 'rank' });
this.mySessions$ = this.scheduleService.getScheduleList(this.authService.userId);
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/sessions/session-edit/session-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class SessionEditComponent implements OnInit {
});
});

this.sections = this.sectionService.getSectionList();
this.sections = this.sectionService.getSectionList({ orderByChild: 'rank' });
this.speakers = this.speakerService.getSpeakerList({ orderByChild: 'name' });
}

Expand Down
7 changes: 6 additions & 1 deletion src/app/sessions/session-list/session-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h5>Stay tuned! Sessions will be added soon!</h5>
<!-- Modal -->
<div mdbModal #sectionModal="mdb-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="CreateSection" aria-hidden="true">
<div class="modal-dialog" role="document">
<form (submit)="addSection(title.value)">
<form (submit)="addSection(title.value, rank.value)">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title w-100" id="CreateSection">Create Section</h4>
Expand All @@ -70,6 +70,11 @@ <h4 class="modal-title w-100" id="CreateSection">Create Section</h4>
<input mdbActive type="text" id="sectionName" class="form-control" #title>
<label for="sectionName">Section name</label>
</div>
<div class="md-form form-sm">
<i class="fa fa-sort-numeric-asc prefix"></i>
<input mdbActive type="number" id="sectionRank" class="form-control" #rank>
<label for="sectionRank">Section rank</label>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save</button>
Expand Down
8 changes: 5 additions & 3 deletions src/app/sessions/session-list/session-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class SessionListComponent implements OnInit {

ngOnInit() {
this.sessions = this.sessionService.getSessionList();
this.sections = this.sectionService.getSectionList();
this.sections = this.sectionService.getSectionList({ orderByChild: 'rank' });
}

isLoggedIn() {
Expand All @@ -49,8 +49,10 @@ export class SessionListComponent implements OnInit {
}
}

addSection(value) {
this.section.title = value.replace(/^\s+|\s+$/g, '');
addSection(title, rank) {
this.section.title = title.replace(/^\s+|\s+$/g, '');
let integerRegex = new RegExp('^\\d+$');
this.section.rank = integerRegex.test(rank) ? parseInt(rank) : 0;
this.sectionService.createSection(this.section);
this.section = new Section();
this.sectionModal.hide();
Expand Down
2 changes: 1 addition & 1 deletion src/app/sessions/session-new/session-new.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class SessionNewComponent implements OnInit {
) { }

ngOnInit() {
this.sections = this.sectionService.getSectionList();
this.sections = this.sectionService.getSectionList({ orderByChild: 'rank' });
this.speakers = this.speakerService.getSpeakerList({ orderByChild: 'name' });
}

Expand Down
1 change: 1 addition & 0 deletions src/app/sessions/shared/section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as firebase from 'firebase/app';
export class Section {
$key: string;
title: string;
rank: number;
timeStamp: any = firebase.database.ServerValue.TIMESTAMP;
active: boolean = true;
}

0 comments on commit 63daa60

Please sign in to comment.