Skip to content

Commit

Permalink
can now edit the mailing list configurations in the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Cellule authored and mathieumg committed Dec 1, 2014
1 parent 56080dd commit aad7d3e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 5 deletions.
61 changes: 56 additions & 5 deletions components/MailingListConfig.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,71 @@
var React = require('react');

var BSCol = require("react-bootstrap/Col");
var BSPanel = require("react-bootstrap/Panel");
var BSCol = require("react-bootstrap/Col");
var BSInput = require("react-bootstrap/Input");
var BSButton = require("react-bootstrap/Button");

var MKCollapsablePanel = require("mykoop-core/components/CollapsablePanel");
var MKFeedbacki18nMixin = require("mykoop-core/components/Feedbacki18nMixin");

var actions = require("actions");
var __ = require("language").__;

var MailingListConfig = React.createClass({
mixins: [React.addons.LinkedStateMixin, MKFeedbacki18nMixin],

getInitialState: function() {
return {
globalSender: ""
};
},

componentWillMount: function () {
var self = this;
actions.mailinglist.config.get({
i18nErrors: {}
},function(err, res) {
if(err) {
return self.setFeedback(err.i18n, "danger");
}
self.setState({
globalSender: res.globalSender
});
});
},

saveConfig: function() {
var self = this;
self.clearFeedback();
actions.mailinglist.config.set({
i18nErrors: {},
data: {
globalSender: this.state.globalSender
}
},function(err, res) {
if(err) {
return self.setFeedback(err.i18n, "danger");
}
self.setFeedback({key: "success"}, "success");
});
},

render: function () {
return (
<BSCol md={6}>
<BSPanel>
MailingListConfig
</BSPanel>
<MKCollapsablePanel header={__("mailinglist::config")}>
{this.renderFeedback()}
<BSInput
type="email"
label={__("mailinglist::globalEmail")}
valueLink={this.linkState("globalSender")}
/>
<BSButton
bsStyle="primary"
onClick={this.saveConfig}
>
{__("update")}
</BSButton>
</MKCollapsablePanel>
</BSCol>
);
}
Expand Down
3 changes: 3 additions & 0 deletions locales/en/mailinglist.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
showAtRegistrationTooltip: "Show this mailing in the registration form for new users",
registerError: "Error registering user to mailing lists",

config: "Configurations",
globalEmail: "Primary email",

errors: {
app: {
name: {
Expand Down
3 changes: 3 additions & 0 deletions locales/fr/mailinglist.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
showAtRegistrationTooltip: "Afficher cette liste de diffusion dans le formulaire d'inscription des nouveaux utilisateurs",
registerError: "Erreur survenue pendant l'inscription aux listes de diffusion",

config: "Configurations",
globalEmail: "Courriel principal",

errors: {
app: {
name: {
Expand Down

0 comments on commit aad7d3e

Please sign in to comment.