Skip to content
3 changes: 2 additions & 1 deletion feedback/client/form/autoform.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ AutoForm.hooks({
},
},
onSuccess () {
sAlert.success('Thank you! Your feedback has been successfully sent.');
sAlert.success(TAPi18n.__('feedbackForm_successMessage'));
Copy link
Copy Markdown
Contributor

@brylie brylie Sep 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this line is compact, it does not follow convention for other translated user alerts.

Refactor the code to follow this pattern:

// Get the success message translation
const message = TAPi18n.__('feedbackForm_successMessage');

// Alert the user of success
sAlert.success(message);

The reason is to make lines of code easier to read:

  • shorter lines
  • sAlert.success(message) is very close to English 'alert success message'

Search for other uses of sAlert in our project, to get a sense of how it is typically used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've commented on an outdated diff. That file has already been changed.

Modal.hide('feedbackForm');
},
},
});
37 changes: 23 additions & 14 deletions feedback/client/form/form.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
<template name="feedbackForm">
<button type="button" class="btn btn-info btn-xs 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>
<div class="modal fade" id="feedbackForm" tabindex="-1" role="dialog" aria-labelledby="feedbackFormLabel">
<div
class="modal fade"
id="feedbackFormModal"
tabindex="-1"
role="dialog"
aria-labelledby="feedbackFormModalLabel" >
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="feedbackFormLabel">
<i class="fa fa-comments-o"></i>&nbsp;
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="feedbackFormModalLabel">
{{_ "feedback_feedbackForm_title"}}
</h4>
</div>
<div class="modal-body">
<p>{{_ "feedback_feedbackForm_description"}}</p>
{{> quickForm
collection=feedbackCollection
id="feedbackForm"
type="insert"
omitFields="authorId, createdAt, apiBackendId"
}}
</div>
{{ # autoForm id="feedbackForm" collection=feedbackCollection type="insert" }}
<div class="modal-body">
<p>{{_ "feedback_feedbackForm_description"}}</p>
{{> afQuickField name='topic'}}
{{> afQuickField name='message' rows=4}}
{{> afQuickField name='messageType'}}
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">
{{ _ "feedback_sendFeedback" }}
</button>
</div>
{{/autoForm}}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion feedback/client/form/form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Collection import
import { Template } from 'meteor/templating';
import { Feedback } from '../../collection';

Template.feedbackForm.helpers({
Expand Down
15 changes: 12 additions & 3 deletions feedback/client/list/list.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
<template name="feedbackList">
<div class="panel panel-default">
<div class="panel-heading">
{{#if currentUser}}
{{> feedbackForm }}
{{/ if }}
{{ # if currentUser }}
<button
type="button"
class="btn btn-info btn-xs pull-right feedback-form-button"
id="add-feedback"
>
<i class="fa fa-comments-o"></i>
&nbsp;
{{_ "feedback_feedbackForm_button"}}
</button>
{{ > feedbackForm }}
{{ / if }}
<h2 class="panel-title clearfix">
{{_ "feedback_main_title"}}
</h2>
Expand Down
13 changes: 9 additions & 4 deletions feedback/client/list/list.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { Feedback } from '../../collection';

Template.feedbackList.created = function () {
Template.feedbackList.onCreated(function () {
// Get API Backend ID from URL route
const apiId = this.data.api._id;

// Subscribe for all feedback for this API Backend
this.subscribe('apiBackendFeedback', apiId);
};
});

Template.feedbackList.helpers({
'userFeedback': function () {
userFeedback () {
return Feedback.find();
},
'haveFeedback': function () {
haveFeedback () {
// Count user's feedback in feedback collection
const feedbackCount = Feedback.find().count();
return feedbackCount > 0;
Expand All @@ -24,4 +26,7 @@ Template.feedbackList.events({
'click .delete-feedback': function (event) {
Meteor.call('deleteFeedback', this._id);
},
'click #add-feedback': function () {
Modal.show('feedbackForm');
},
});
9 changes: 5 additions & 4 deletions feedback/collection/schema.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Meteor } from 'meteor/meteor';
import { Feedback } from './';

Feedback.schema = new SimpleSchema({
Expand Down Expand Up @@ -37,9 +38,9 @@ Feedback.schema = new SimpleSchema({
autoValue () {
if (this.isInsert) {
return Meteor.userId();
} else {
this.unset();
}

this.unset();
},
denyUpdate: true,
},
Expand All @@ -53,9 +54,9 @@ Feedback.schema = new SimpleSchema({
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}

this.unset();
},
},
});
Expand Down
2 changes: 2 additions & 0 deletions lib/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
"feedback_remove_button": "Remove",
"feedback_submitted_by": "submitted by",
"feedback_view_button": "View",
"feedback_sendFeedback": "Send",
"feedbackForm_successMessage": "Thank you! Your feedback has been successfully sent.",
"flagApiButton_buttonText": "Flag",
"flagApiButton_buttonText_active": "Flagged",
"flagApiModal_cancelButton": "Cancel",
Expand Down