-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mailing list configuration #7
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,13 @@ var BSPanel = require("react-bootstrap/Panel"); | |
var MKAlertTrigger = require("mykoop-core/components/AlertTrigger"); | ||
var MKIcon = require("mykoop-core/components/Icon"); | ||
var MKMailingListEditPanel = require("./MailingListEditPanel"); | ||
var MKMailingListConfig = require("./MailingListConfig") | ||
|
||
var __ = require("language").__; | ||
var _ = require("lodash"); | ||
var actions = require("actions"); | ||
|
||
var showPerRow = 2; | ||
var MailingListAdminPage = React.createClass({ | ||
getInitialState: function() { | ||
return { | ||
|
@@ -81,7 +83,7 @@ var MailingListAdminPage = React.createClass({ | |
var self = this; | ||
var mailingLists = _.map(this.state.mailingLists, function(mailingList, i) { | ||
return ( | ||
<BSCol md={6} sm={12} key={i}> | ||
<BSCol md={12/showPerRow} sm={12} key={i}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps round/floor it? |
||
<MKMailingListEditPanel | ||
idLink={self.makeValueLink(mailingList, "id")} | ||
nameLink={self.makeValueLink(mailingList, "name")} | ||
|
@@ -98,19 +100,46 @@ var MailingListAdminPage = React.createClass({ | |
</BSCol> | ||
); | ||
}); | ||
|
||
mailingLists.push( | ||
<BSCol md={12/showPerRow} sm={12} key="newMailingList"> | ||
<BSPanel className="mailingList-new-panel" onClick={this.createNewMailingList}> | ||
<MKIcon glyph="plus-circle" className="mailingList-new" /> | ||
</BSPanel> | ||
</BSCol> | ||
); | ||
|
||
if(showPerRow <= 1) { | ||
mailingLists = ( | ||
<BSRow> | ||
{mailingLists} | ||
</BSRow> | ||
); | ||
} else { | ||
var panels = mailingLists; | ||
var curSlice = 0; | ||
mailingLists = []; | ||
while(!_.isEmpty(panels)) { | ||
var rowContent = _.first(panels, showPerRow); | ||
panels = _.rest(panels, showPerRow); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL! |
||
mailingLists.push( | ||
<BSRow key={curSlice}> | ||
{rowContent} | ||
</BSRow> | ||
); | ||
curSlice++; | ||
} | ||
} | ||
|
||
return ( | ||
<BSCol> | ||
<h1> | ||
{__("mailinglist::adminEditWelcome")} | ||
</h1> | ||
<BSRow> | ||
{mailingLists} | ||
<BSCol md={6} sm={12} key="newMailingList"> | ||
<BSPanel className="mailingList-new-panel" onClick={this.createNewMailingList}> | ||
<MKIcon glyph="plus-circle" className="mailingList-new" /> | ||
</BSPanel> | ||
</BSCol> | ||
<BSRow key="config"> | ||
<MKMailingListConfig /> | ||
</BSRow> | ||
{mailingLists} | ||
</BSCol> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
var React = require('react'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double quotes. |
||
|
||
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}> | ||
<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> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = MailingListConfig; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ export function attachControllers( | |
binder: utils.ModuleControllersBinder<mkmailinglist.Module> | ||
) { | ||
var mailingList = binder.moduleInstance; | ||
|
||
// Add new Mailing list | ||
binder.attach( | ||
{ | ||
endPoint: endpoints.mailinglist.add, | ||
|
@@ -25,6 +27,7 @@ export function attachControllers( | |
}) | ||
); | ||
|
||
// Update Mailing list | ||
binder.attach( | ||
{ | ||
endPoint: endpoints.mailinglist.update, | ||
|
@@ -41,6 +44,7 @@ export function attachControllers( | |
}) | ||
); | ||
|
||
// Delete Mailing list | ||
binder.attach( | ||
{ | ||
endPoint: endpoints.mailinglist.delete, | ||
|
@@ -54,11 +58,13 @@ export function attachControllers( | |
}) | ||
); | ||
|
||
// Get all mailing lists | ||
binder.attach( | ||
{endPoint: endpoints.mailinglist.list}, | ||
binder.makeSimpleController(mailingList.getMailingLists) | ||
); | ||
|
||
// Get mailing for registration only | ||
binder.attach( | ||
{endPoint: endpoints.mailinglist.registration}, | ||
binder.makeSimpleController<MailingList.GetMailingList.Params>( | ||
|
@@ -71,6 +77,7 @@ export function attachControllers( | |
) | ||
); | ||
|
||
// Register a user to multiple mailing lists | ||
binder.attach( | ||
{ | ||
endPoint: endpoints.user.mailinglist.register | ||
|
@@ -86,6 +93,7 @@ export function attachControllers( | |
}) | ||
); | ||
|
||
// Unregister a user to multiple mailing lists | ||
binder.attach( | ||
{ | ||
endPoint: endpoints.user.mailinglist.unregister | ||
|
@@ -101,6 +109,7 @@ export function attachControllers( | |
}) | ||
); | ||
|
||
// Get mailing list the user is registered to | ||
binder.attach( | ||
{ | ||
endPoint: endpoints.user.mailinglist.list, | ||
|
@@ -113,4 +122,45 @@ export function attachControllers( | |
return params; | ||
}) | ||
); | ||
|
||
// Set mailing list configuration | ||
binder.attach( | ||
{ | ||
endPoint: endpoints.mailinglist.config.set | ||
}, | ||
binder.makeSimpleController<MailingList.SetConfigurations.Params>( | ||
mailingList.setConfigurations, | ||
function(req) { | ||
return { | ||
globalSender: req.param("globalSender", "") | ||
} | ||
} | ||
) | ||
); | ||
|
||
// Get mailing list configuration | ||
binder.attach( | ||
{ | ||
endPoint: endpoints.mailinglist.config.get | ||
}, | ||
binder.makeSimpleController<MailingList.GetConfigurations.Params>( | ||
mailingList.getConfigurations | ||
) | ||
); | ||
|
||
// Send email to the mailing list | ||
binder.attach( | ||
{ | ||
endPoint: endpoints.mailinglist.send | ||
}, | ||
binder.makeSimpleController<MailingList.SendEmail.Params>( | ||
mailingList.sendEmail, | ||
function(req) { | ||
return { | ||
id: parseInt(req.param("id")) || 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
content: req.param("content","") | ||
} | ||
} | ||
) | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
itemsPerRow
?