Skip to content
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

Fix export summary #204

Merged
merged 2 commits into from
Aug 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/label/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const styleBehaviour = require('../../mixin/stylable');
* Label mixin for form.
* @type {Object}
*/
let labelMixin = {
const labelMixin = {
mixins: [i18nBehaviour, styleBehaviour],
/** @inheritdoc */
propTypes: {
Expand Down
66 changes: 36 additions & 30 deletions src/list/summary/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,53 @@
<meta name="description" content="Example of the component.">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Place favicon.ico in the root directory -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"/>
<script src="https://fb.me/react-0.13.3.js"></script>
<script src="/focus-components/dist/js/focus.js"></script>
<script src="/focus-components/dist/js/focus-components.js"></script>
<link rel="stylesheet" href="/focus-components/dist/css/focus-components.css"/>
<script src="https://fb.me/JSXTransformer-0.13.3.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.9.3/lodash.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.1/backbone.js"></script>

<!-- Material degign-->
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js" ></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/0.2.2/css/material-wfont.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/0.2.2/css/material.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/0.2.2/css/ripples.css">
<script src='https://cdnjs.cloudflare.com/ajax/libs/i18next/1.6.3/i18next-1.6.3.min.js'></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/bootstrap.material-design/0.3.0/css/material-wfont.min.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/bootstrap.material-design/0.3.0/css/material.min.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/bootstrap.material-design/0.3.0/css/ripples.min.css">
<script src="//cdn.jsdelivr.net/bootstrap.material-design/0.3.0/js/material.min.js"></script>
<script src="//cdn.jsdelivr.net/bootstrap.material-design/0.3.0/js/ripples.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/0.4.0/Showdown.js"></script>

<!-- Include Date Range Picker -->
<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/2.9.0/moment.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/1/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css"
href="//cdn.jsdelivr.net/bootstrap.daterangepicker/1/daterangepicker-bs3.css"/>

<link rel="font" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/0.2.2/fonts/Material-Design-Icons.eot">
<link rel="font" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/0.2.2/fonts/Material-Design-Icons.svg">
<link rel="font" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/0.2.2/fonts/Material-Design-Icons.ttf">
<link rel="font" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/0.2.2/fonts/Material-Design-Icons.woff">

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/0.2.2/js/material.js"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/0.2.2/js/ripples.min.js"></script>
<!-- Material degign-->
<script src="/focus-components/dist/js/focus.js"></script>
<script src="/focus-components/dist/js/focus-components.js"></script>
<script src="/focus-components/example/js/initFocus.js"></script>
<link rel="stylesheet" href="/focus-components/dist/css/focus-components.css"/>
<link rel="stylesheet" href="/focus-components/example/js/picker.css"/>

</head>
<body>
<div id="list-summary-container"></div>
<script type="text/javascript">
<div id="list-summary-container"></div>
<script type="text/javascript">
React.render(
React.createElement(React.createClass(FocusComponents.list.summary.mixin),
{
nb: 52,
queryText: "fantastic",
scopeList: {mov: "Movie"},
scopeClickAction: function(scopeKey) { console.log("Removed scope : " + scopeKey)},
exportAction: function() { console.log("Export action") }
}
),
document.querySelector("#list-summary-container")
);
React.createElement(React.createClass(FocusComponents.list.summary.mixin), {
nb: 52,
queryText: "fantastic",
scopeList: {mov: "Movie"},
scopeClickAction: function(scopeKey) { console.log("Removed scope : " + scopeKey)},
exportAction: function() { console.log("Export action") }
}
),
document.querySelector("#list-summary-container")
);
</script>

</body>

</html>
57 changes: 37 additions & 20 deletions src/list/summary/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/**@jsx*/
var builder = require('focus').component.builder;
var TopicDisplayer = require('../../common/topic-displayer').component;
var Button = require('../../common/button/action').component;
var numberFormatter = Focus.definition.formatter.number;
const {builder, types} = require('focus').component;
const i18nBehaviour = require('../../common/i18n/mixin');
const styleBehaviour = require('../../mixin/stylable');

var listSummaryMixin = {
mixins: [require('../../common/i18n/mixin')],
const TopicDisplayer = require('../../common/topic-displayer').component;
const Button = require('../../common/button/action').component;
const numberFormatter = Focus.definition.formatter.number;

const listSummaryMixin = {
mixins: [i18nBehaviour, styleBehaviour],
/**
* Display name.
*/
Expand All @@ -15,41 +18,55 @@ var listSummaryMixin = {
* Init the default props.
* @returns {objet} default props.
*/
getDefaultProps: function () {
getDefaultProps () {
return {
nb: undefined,
queryText: undefined,
scopeList: {},
scopeClickAction: function (scopeKey) {
},
exportAction: function () {
}
/**
* Action on click on scope.
*/
scopeClickAction() {}
};
},
/** @inheritdoc */
propTypes: {
nb: types('number'),
queryText: types('string'),
scopeList: types('array').isRequired,
scopeClickAction: types('func'),
exportAction: types('func')
},
/**
* Return result sentence.
* @return {object} Result sentence
*/
_getResultSentence() {
const {nb, queryText} = this.props;
return (
<span>
<strong>{numberFormatter.format(this.props.nb)}</strong> {this.i18n('result.for')} &#34;{this.props.queryText}&#34;
<strong>{numberFormatter.format(nb)}</strong> {this.i18n('result.for')} &#34;{queryText}&#34;
</span>
);
},
/**
* Render the html.
* @returns {JSX} Html rendering.
*/
render: function renderActionBar() {
render() {
const {exportAction, scopeList, scopeClickAction} = this.props;
return (
<div data-focus="list-summary">
<div className="print">
<Button shape="link" icon="print" label="result.export" handleOnClick={this.props.exportAction} />
</div>
{exportAction &&
<div className="print">
<Button handleOnClick={exportAction} icon="print" label="result.export" shape="link" />
</div>
}
<span className="sentence">{this._getResultSentence()}</span>
<span className="topics">
<TopicDisplayer topicList={this.props.scopeList} topicClickAction={this.props.scopeClickAction} />
<TopicDisplayer topicClickAction={scopeClickAction} topicList={scopeList} />
</span>
</div>
);
}
};

module.exports = builder(listSummaryMixin);
module.exports = builder(listSummaryMixin);