Skip to content

Commit 63daa60

Browse files
committed
Section sort order, Fixes neojato#30
1 parent 2c4c0a3 commit 63daa60

File tree

6 files changed

+15
-7
lines changed

6 files changed

+15
-7
lines changed

src/app/sessions/my-schedule/my-schedule.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class MyScheduleComponent implements OnInit {
3030

3131
ngOnInit() {
3232
this.sessions$ = this.sessionService.getSessionList();
33-
this.sections$ = this.sectionService.getSectionList();
33+
this.sections$ = this.sectionService.getSectionList({ orderByChild: 'rank' });
3434
this.mySessions$ = this.scheduleService.getScheduleList(this.authService.userId);
3535
}
3636

src/app/sessions/session-edit/session-edit.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class SessionEditComponent implements OnInit {
3535
});
3636
});
3737

38-
this.sections = this.sectionService.getSectionList();
38+
this.sections = this.sectionService.getSectionList({ orderByChild: 'rank' });
3939
this.speakers = this.speakerService.getSpeakerList({ orderByChild: 'name' });
4040
}
4141

src/app/sessions/session-list/session-list.component.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ <h5>Stay tuned! Sessions will be added soon!</h5>
5656
<!-- Modal -->
5757
<div mdbModal #sectionModal="mdb-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="CreateSection" aria-hidden="true">
5858
<div class="modal-dialog" role="document">
59-
<form (submit)="addSection(title.value)">
59+
<form (submit)="addSection(title.value, rank.value)">
6060
<div class="modal-content">
6161
<div class="modal-header">
6262
<h4 class="modal-title w-100" id="CreateSection">Create Section</h4>
@@ -70,6 +70,11 @@ <h4 class="modal-title w-100" id="CreateSection">Create Section</h4>
7070
<input mdbActive type="text" id="sectionName" class="form-control" #title>
7171
<label for="sectionName">Section name</label>
7272
</div>
73+
<div class="md-form form-sm">
74+
<i class="fa fa-sort-numeric-asc prefix"></i>
75+
<input mdbActive type="number" id="sectionRank" class="form-control" #rank>
76+
<label for="sectionRank">Section rank</label>
77+
</div>
7378
</div>
7479
<div class="modal-footer">
7580
<button type="submit" class="btn btn-primary">Save</button>

src/app/sessions/session-list/session-list.component.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class SessionListComponent implements OnInit {
3232

3333
ngOnInit() {
3434
this.sessions = this.sessionService.getSessionList();
35-
this.sections = this.sectionService.getSectionList();
35+
this.sections = this.sectionService.getSectionList({ orderByChild: 'rank' });
3636
}
3737

3838
isLoggedIn() {
@@ -49,8 +49,10 @@ export class SessionListComponent implements OnInit {
4949
}
5050
}
5151

52-
addSection(value) {
53-
this.section.title = value.replace(/^\s+|\s+$/g, '');
52+
addSection(title, rank) {
53+
this.section.title = title.replace(/^\s+|\s+$/g, '');
54+
let integerRegex = new RegExp('^\\d+$');
55+
this.section.rank = integerRegex.test(rank) ? parseInt(rank) : 0;
5456
this.sectionService.createSection(this.section);
5557
this.section = new Section();
5658
this.sectionModal.hide();

src/app/sessions/session-new/session-new.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class SessionNewComponent implements OnInit {
2626
) { }
2727

2828
ngOnInit() {
29-
this.sections = this.sectionService.getSectionList();
29+
this.sections = this.sectionService.getSectionList({ orderByChild: 'rank' });
3030
this.speakers = this.speakerService.getSpeakerList({ orderByChild: 'name' });
3131
}
3232

src/app/sessions/shared/section.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as firebase from 'firebase/app';
33
export class Section {
44
$key: string;
55
title: string;
6+
rank: number;
67
timeStamp: any = firebase.database.ServerValue.TIMESTAMP;
78
active: boolean = true;
89
}

0 commit comments

Comments
 (0)