Skip to content

Commit a80d769

Browse files
committed
open/close queue
1 parent 035e105 commit a80d769

File tree

9 files changed

+149
-70
lines changed

9 files changed

+149
-70
lines changed

client/app.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ Announcements = new Meteor.Collection("announcements");
33
Settings = new Meteor.Collection("settings");
44

55
Meteor.subscribe("userData");
6+
67
Meteor.subscribe("activeTickets");
8+
79
Meteor.subscribe("allAnnouncements");
8-
Meteor.subscribe("mentorsOnline");
10+
11+
Meteor.subscribe("mentorsOnline");
12+
13+
Meteor.subscribe("settings");
+71-65
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,82 @@
11
<template name="ticketPanel">
22
<div class="ticketPanel">
3-
<div class="ui segment">
4-
{{#if currentTicket}}
5-
{{#with currentTicket}}
6-
{{#if statusIs "OPEN"}}
7-
<div class="title">
8-
{{constant 'TICKET_PANEL_OPEN'}}
9-
</div>
10-
<div class="content">
11-
{{constant 'TICKET_PANEL_OPEN_MESSAGE'}}
12-
</div>
13-
{{/if}}
14-
{{#if statusIs "CLAIMED"}}
15-
<div class="title">
16-
{{constant 'TICKET_PANEL_CLAIMED'}}
17-
</div>
18-
<div class="content">
19-
{{claimName}} has claimed your ticket.
20-
<br>
21-
They're on the way!
22-
</div>
23-
{{/if}}
3+
{{#if queueEnabled}}
4+
<div class="ui segment">
5+
{{#if currentTicket}}
6+
{{#with currentTicket}}
7+
{{#if statusIs "OPEN"}}
8+
<div class="title">
9+
{{constant 'TICKET_PANEL_OPEN'}}
10+
</div>
11+
<div class="content">
12+
{{constant 'TICKET_PANEL_OPEN_MESSAGE'}}
13+
</div>
14+
{{/if}}
15+
{{#if statusIs "CLAIMED"}}
16+
<div class="title">
17+
{{constant 'TICKET_PANEL_CLAIMED'}}
18+
</div>
19+
<div class="content">
20+
{{claimName}} has claimed your ticket.
21+
<br>
22+
They're on the way!
23+
</div>
24+
{{/if}}
2425

25-
<br>
26+
<br>
2627

27-
<button class="fluid danger push button cancel">
28-
{{constant 'TICKET_PANEL_CANCEL'}}
29-
</button>
30-
{{/with}}
28+
<button class="fluid danger push button cancel">
29+
{{constant 'TICKET_PANEL_CANCEL'}}
30+
</button>
31+
{{/with}}
3132

32-
{{else}}
33+
{{else}}
3334

34-
<div class="title">
35-
Hey, I'm
36-
{{#if currentUser.profile.name}}
37-
{{currentUser.profile.name}}!
38-
{{else}}
39-
{{currentUser.services.github.username}}!
40-
{{/if}}
41-
</div>
42-
<div class="content">
43-
{{constant 'TICKET_PANEL_TOPIC'}}
44-
<br>
45-
<input id="topic"
46-
type="text"
47-
name="topic"
48-
class="clean"
49-
placeholder="{{constant 'TICKET_PANEL_TOPIC_PLACEHOLDER'}}">
50-
<br>
51-
{{constant 'TICKET_PANEL_LOCATION'}}
35+
<div class="title">
36+
Hey, I'm
37+
{{#if currentUser.profile.name}}
38+
{{currentUser.profile.name}}!
39+
{{else}}
40+
{{currentUser.services.github.username}}!
41+
{{/if}}
42+
</div>
43+
<div class="content">
44+
{{constant 'TICKET_PANEL_TOPIC'}}
45+
<br>
46+
<input id="topic"
47+
type="text"
48+
name="topic"
49+
class="clean"
50+
placeholder="{{constant 'TICKET_PANEL_TOPIC_PLACEHOLDER'}}">
51+
<br>
52+
{{constant 'TICKET_PANEL_LOCATION'}}
53+
<br>
54+
<input id="location"
55+
type="text"
56+
name="location"
57+
class="clean"
58+
placeholder="{{constant 'TICKET_PANEL_LOCATION_PLACEHOLDER'}}">
59+
<br>
60+
{{constant 'TICKET_PANEL_CONTACT'}}
61+
<br>
62+
<input id="contact"
63+
type="text"
64+
name="contact"
65+
class="clean"
66+
placeholder="{{constant 'TICKET_PANEL_CONTACT_PLACEHOLDER'}}">
67+
</div>
5268
<br>
53-
<input id="location"
54-
type="text"
55-
name="location"
56-
class="clean"
57-
placeholder="{{constant 'TICKET_PANEL_LOCATION_PLACEHOLDER'}}">
58-
<br>
59-
{{constant 'TICKET_PANEL_CONTACT'}}
60-
<br>
61-
<input id="contact"
62-
type="text"
63-
name="contact"
64-
class="clean"
65-
placeholder="{{constant 'TICKET_PANEL_CONTACT_PLACEHOLDER'}}">
66-
</div>
67-
<br>
68-
<button id="submit" class="primary push disabled fluid button">
69-
{{constant 'TICKET_PANEL_HELP'}}
70-
</button>
69+
<button id="submit" class="primary push disabled fluid button">
70+
{{constant 'TICKET_PANEL_HELP'}}
71+
</button>
7172

72-
{{/if}}
73+
{{/if}}
7374

74-
</div>
75+
</div>
76+
{{else}}
77+
<div class="ui segment">
78+
{{constant 'TICKET_PANEL_DISABLED_MSG'}}
79+
</div>
80+
{{/if}}
7581
</div>
7682
</template>

client/components/ticketPanel/ticketPanel.js

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ Template.ticketPanel.helpers({
1010
},
1111
statusIs: function(status){
1212
return this.status === status;
13+
},
14+
queueEnabled: function(){
15+
var settings = Settings.findOne({});
16+
if (settings){
17+
return settings.queueEnabled;
18+
}
19+
},
20+
hasUnratedTicket: function(){
21+
// If there is an unrated ticket
1322
}
1423
});
1524

client/views/settings/settings.html

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
<template name="settings">
22
<div class="ui top attached tertiary header segment">
33
<strong>
4-
Branding
4+
Settings
55
</strong>
66
</div>
77
<div class="ui bottom attached segment">
8-
8+
<div class="ui form">
9+
<div class="field">
10+
<div id="queueEnabled" class="ui toggle checkbox">
11+
<input type="checkbox" name="queueEnabled" checked="{{settings.queueEnabled}}">
12+
<label>Open/Close Queue</label>
13+
</div>
14+
</div>
15+
</div>
916
</div>
1017
</template>

client/views/settings/settings.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Helper to edit the settings
2+
Template.settings.rendered = function(){
3+
$(this.findAll('.ui.checkbox')).checkbox();
4+
};
5+
6+
Template.settings.helpers({
7+
settings: function(){
8+
return Settings.findOne({});
9+
}
10+
});
11+
12+
Template.settings.events({
13+
"click #queueEnabled.ui.checkbox": function(e, t){
14+
debugger
15+
Meteor.call("toggleSetting",
16+
'queueEnabled',
17+
$('#queueEnabled input').prop('checked'));
18+
}
19+
});

lib/constants.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ CONSTANTS = {
4848
TICKET_PANEL_OPEN: "Your ticket is open.",
4949
TICKET_PANEL_OPEN_MESSAGE: "We'll let you know when your ticket has been claimed!",
5050

51-
TICKET_PANEL_CLAIMED: "Your ticket has been claimed!"
51+
TICKET_PANEL_CLAIMED: "Your ticket has been claimed!",
52+
53+
TICKET_PANEL_DISABLED_MSG: "The queue is currently closed!"
5254
};
5355

server/methods.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ Meteor.methods({
1515

1616
toggleRole: toggleRole,
1717
updateUser: updateUser,
18-
createAccount: createAccount
18+
createAccount: createAccount,
19+
20+
toggleSetting: toggleSetting
1921
});
2022

2123
function createTicket(topic, location, contact) {
@@ -242,4 +244,12 @@ function createAccount(username, password, profile){
242244
profile: profile ? profile : {}
243245
});
244246
}
247+
}
248+
249+
function toggleSetting(setting, state){
250+
if (authorized.admin(this.userId)){
251+
var toSet = {};
252+
toSet[setting] = state;
253+
Settings.update({},{$set: toSet});
254+
}
245255
}

server/publications.js

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Meteor.publish("userTickets", getUserTickets);
1212

1313
Meteor.publish("allAnnouncements", getAllAnnouncements);
1414

15+
Meteor.publish("settings", getSettings);
16+
1517
// Get user data on yourself
1618
function getUserData(){
1719
if (authorized.user(this.userId)) {
@@ -101,4 +103,10 @@ function getAllAnnouncements(){
101103
if (authorized.user(this.userId)){
102104
return Announcements.find({});
103105
}
106+
}
107+
108+
function getSettings(){
109+
if (authorized.user(this.userId)){
110+
return Settings.find({});
111+
}
104112
}

server/startup.js

+13
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Meteor.startup(function(){
1414
addFacebookIntegration(config.facebook);
1515
addServiceIntegration('google', config.google);
1616

17+
// Add Base Settings
18+
setBasicSettings(config);
19+
1720
});
1821

1922
function createAdmin(username, password){
@@ -66,3 +69,13 @@ function addFacebookIntegration(fb){
6669
});
6770
}
6871
}
72+
73+
function setBasicSettings(config){
74+
// Check if the settings document already exists
75+
var settings = Settings.find({}).fetch();
76+
if (settings.length == 0 || settings.length > 1){
77+
// Remove all documents and then create the singular settings document.
78+
Settings.remove({});
79+
Settings.insert(config.settings);
80+
}
81+
}

0 commit comments

Comments
 (0)