Skip to content

Commit e879a80

Browse files
author
Ville Jyrkkä
committed
Merge pull request #548 from apinf/feature/user-admin-communication-channel
Feature/user admin communication channel
2 parents fdefa4e + 093f49a commit e879a80

File tree

17 files changed

+293
-0
lines changed

17 files changed

+293
-0
lines changed

both/collections/feedback.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
Feedback = new Mongo.Collection('feedback');
2+
3+
Schemas.FeedbackSchema = new SimpleSchema({
4+
topic: {
5+
type: String,
6+
label: "Topic",
7+
max: 50,
8+
optional: false,
9+
autoform: {
10+
placeholder: 'Feedback topic'
11+
}
12+
},
13+
message: {
14+
type: String,
15+
label: "Your Message",
16+
max: 1000,
17+
optional: false,
18+
autoform: {
19+
rows: 5,
20+
placeholder: 'Your message'
21+
}
22+
},
23+
messageType: {
24+
type: String,
25+
label: "Choose message type",
26+
allowedValues: ['Feedback', 'Error report', 'Feature request'],
27+
autoform: {
28+
options: [
29+
{label: "Feedback", value: "Feedback"},
30+
{label: "Error report", value: "Error report"},
31+
{label: "Feature request", value: "Feature request"}
32+
]
33+
}
34+
},
35+
authorId: {
36+
type: String,
37+
autoValue: function() {
38+
if (this.isInsert) {
39+
return Meteor.userId();
40+
} else {
41+
this.unset();
42+
}
43+
},
44+
denyUpdate: true
45+
},
46+
apiBackendId: {
47+
type: String
48+
},
49+
createdAt: {
50+
type: Date,
51+
autoValue: function() {
52+
if (this.isInsert) {
53+
return new Date();
54+
} else if (this.isUpsert) {
55+
return {$setOnInsert: new Date()};
56+
} else {
57+
this.unset();
58+
}
59+
}
60+
}
61+
});
62+
63+
Feedback.attachSchema(Schemas.FeedbackSchema);
64+
65+
Feedback.allow({
66+
insert: function () {
67+
return true;
68+
}
69+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FeedbackAnswers = new Mongo.Collection('feedbackAnswers');
2+
3+
Schemas.FeedbackAnswersSchema = new SimpleSchema({
4+
message: {
5+
type: String,
6+
label: "Answer to the message",
7+
max: 1000,
8+
optional: false,
9+
autoform: {
10+
rows: 5,
11+
placeholder: 'Type your message here'
12+
}
13+
},
14+
author: {
15+
type: String,
16+
autoValue: function () {
17+
return Meteor.userId()
18+
}
19+
},
20+
createdAt: {
21+
type: Date,
22+
autoValue: function() {
23+
if (this.isInsert) {
24+
return new Date();
25+
} else if (this.isUpsert) {
26+
return {$setOnInsert: new Date()};
27+
} else {
28+
this.unset();
29+
}
30+
}
31+
}
32+
});
33+
34+
FeedbackAnswers.attachSchema(Schemas.FeedbackAnswersSchema);
35+
36+
FeedbackAnswers.allow({
37+
insert: function () {
38+
return true;
39+
}
40+
});

client/views/api_backends/view_api_backend/view_api_backend.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ <h2>{{_ "view-ApiBackend-Export-Title"}}</h2>
5353
</div>
5454
</div>
5555
</div>
56+
{{> feedbackList}}
5657
</template>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.supportButton {
2+
float: right;
3+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
AutoForm.hooks({
2+
feedback: {
3+
before: {
4+
insert: function (feedback) {
5+
feedback.apiBackendId = Router.current().params._id;
6+
return feedback;
7+
}
8+
},
9+
beginSubmit: function () {
10+
// Disable form elements while submitting form
11+
$('[data-schema-key],button').attr("disabled", "disabled");
12+
},
13+
endSubmit: function () {
14+
// Enable form elements after form submission
15+
$('[data-schema-key],button').removeAttr("disabled");
16+
}
17+
}
18+
});
19+
20+
AutoForm.addHooks(['feedback'], {
21+
// Success message
22+
onSuccess: function () {
23+
FlashMessages.sendSuccess('Thank you! Your feedback has been successfully sent.');
24+
}
25+
});
26+
27+
FlashMessages.configure({
28+
// Configuration for FlashMessages
29+
autoHide: true,
30+
hideDelay: 5000,
31+
autoScroll: false
32+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template name="feedbackForm">
2+
<button type="button" class="btn btn-info btn-sm pull-right feedback-form-button" data-toggle="modal" data-target="#feedbackForm" data-backdrop="static" data-keyboard="false"><i class="fa fa-comments-o"></i>&nbsp;{{_ "feedback-feedbackForm-button"}}</button>
3+
<div class="modal fade" id="feedbackForm" tabindex="-1" role="dialog" aria-labelledby="feedbackFormLabel">
4+
<div class="modal-dialog" role="document">
5+
<div class="modal-content">
6+
<div class="modal-header">
7+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
8+
<h4 class="modal-title" id="feedbackFormLabel">{{_ "feedback-feedbackForm-title"}}</h4>
9+
</div>
10+
<div class="modal-body">
11+
<p>{{_ "feedback-feedbackForm-description"}}</p>
12+
{{> quickForm collection="Feedback" id="feedback" type="insert" omitFields="authorId, createdAt, apiBackendId"}}
13+
</div>
14+
</div>
15+
{{> flashMessages}}
16+
</div>
17+
</div>
18+
</template>

client/views/feedback/feedback_form/feedback_form.less

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Template.feedbackItem.created = function () {
2+
// Subscription to feedback collection
3+
this.subscribe('feedback');
4+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<template name="feedbackItem">
2+
<div class="feedback-page">
3+
<div class="feedback">
4+
<h1>{{ topic }}</h1>
5+
<span class="user-name"><strong>{{ messageType }}</strong>, </span>
6+
<span class="feedback-date">{{ createdAt }}</span>
7+
<div class="row feedback-message">
8+
<div class="col-lg-8">
9+
<p class="message-body">{{ message }}</p>
10+
</div>
11+
</div>
12+
</div>
13+
</div>
14+
</template>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.feedback-page {
2+
margin-left: 2em;
3+
}
4+
5+
.feedback h1 {
6+
line-height: 1.4;
7+
font-size: 1.8em;
8+
margin-bottom: 0;
9+
}
10+
11+
.feedback-message {
12+
margin-top: 1em;
13+
}
14+
15+
.author-name {
16+
display: inline-block;
17+
}

0 commit comments

Comments
 (0)