Skip to content

Commit

Permalink
Fix #2592 reorganized text widget into 1 page (#2614)
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz authored Feb 16, 2018
1 parent dbad778 commit 90e2b13
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 26 deletions.
6 changes: 2 additions & 4 deletions web/client/components/widgets/builder/wizard/TextWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/
const React = require('react');
const ReactQuill = require('react-quill');
const {wizardHanlders} = require('../../../misc/wizard/enhancers');
const WidgetOptions = require('./common/WidgetOptions');
const TextOptions = require('./text/TextOptions');
const Wizard = wizardHanlders(require('../../../misc/wizard/WizardContainer'));


Expand All @@ -22,8 +21,7 @@ module.exports = ({
setPage={setPage}
onFinish={onFinish}
hideButtons>
<ReactQuill value={editorData && editorData.text || ''} onChange={(val) => onChange("text", val)}/>
<WidgetOptions
<TextOptions
key="widget-options"
data={editorData}
onChange={onChange}
Expand Down
30 changes: 30 additions & 0 deletions web/client/components/widgets/builder/wizard/text/TextOptions.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2018, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

const React = require('react');
const { Col, Form, FormGroup, FormControl } = require('react-bootstrap');
const localizedProps = require('../../../../misc/enhancers/localizedProps');
const TitleInput = localizedProps("placeholder")(FormControl);

const ReactQuill = require('react-quill');
const Editor = localizedProps("placeholder")(ReactQuill);
module.exports = ({ data = {}, onChange = () => { }}) => (
<div>
<Col key="form" xs={12}>
<Form>
<FormGroup controlId="title">
<Col sm={12}>
<TitleInput style={{ marginBottom: 10 }} placeholder="widgets.builder.wizard.titlePlaceholder" value={data.title} type="text" onChange={e => onChange("title", e.target.value)} />
</Col>
</FormGroup>
</Form>
</Col>
<Editor placeholder="widgets.builder.wizard.textPlaceholder" value={data && data.text || ''} onChange={(val) => onChange("text", val)} />
</div>
);

19 changes: 3 additions & 16 deletions web/client/components/widgets/builder/wizard/text/Toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,14 @@ const getSaveTooltipId = (step, {id} = {}) => {
}
return "widgets.builder.wizard.addToTheMap";
};
const getNextTooltipId = () => {
return "widgets.builder.wizard.configureWidgetOptions";
};
const getBackTooltipId = () => "back"; // TODO I18N
module.exports = ({step = 0, editorData = {}, onFinish = () => {}, setPage = () => {}} = {}) => (<Toolbar btnDefaultProps={{

module.exports = ({step = 0, editorData = {}, onFinish = () => {}} = {}) => (<Toolbar btnDefaultProps={{
bsStyle: "primary",
bsSize: "sm"
}}
buttons={[{
onClick: () => setPage(Math.max(0, step - 1)),
visible: step > 0,
glyph: "arrow-left",
tooltipId: getBackTooltipId(step)
}, {
onClick: () => setPage(Math.min(step + 1, 2)),
visible: step === 0,
glyph: "arrow-right",
tooltipId: getNextTooltipId(step)
}, {
onClick: () => onFinish(Math.min(step + 1, 1)),
visible: step === 1,
visible: step === 0,
glyph: "floppy-disk",
tooltipId: getSaveTooltipId(step, editorData)
}]} />);
9 changes: 9 additions & 0 deletions web/client/reducers/__tests__/widgets-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ describe('Test the widgets reducer', () => {
it('editWidget', () => {
const state = widgets(undefined, editWidget({type: "bar"}));
expect(state.builder.editor.type).toBe("bar");
expect(state.builder.settings.step).toBe(1);
});
it('editWidget initial by kind of widget', () => {
// default chart
expect(widgets(undefined, editWidget({ type: "bar" })).builder.settings.step).toBe(1);
// chart explicit
expect(widgets(undefined, editWidget({ widgetType: "chart" })).builder.settings.step).toBe(1);
// text explicit
expect(widgets(undefined, editWidget({ widgetType: "text" })).builder.settings.step).toBe(0);
});
it('onEditorChange', () => {
const state = widgets(undefined, onEditorChange("type", "bar"));
Expand Down
6 changes: 5 additions & 1 deletion web/client/reducers/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ function widgetsReducer(state = emptyState, action) {
...action.widget,
// for backward compatibility for widgets without this
widgetType: action.widget && action.widget.widgetType || 'chart'
}, state);
}, set("builder.settings.step",
(action.widget && action.widget.widgetType || 'chart') === 'chart'
? 1
: 0
, state));
}
case EDITOR_CHANGE: {
return set(`builder.editor.${action.key}`, action.value, state);
Expand Down
4 changes: 3 additions & 1 deletion web/client/translations/data.de-DE
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,9 @@
"configureChartOptions": "Diagrammoptionen konfigurieren",
"configureWidgetOptions": "Widget-Optionen konfigurieren",
"updateWidget": "Aktualisieren Sie das Widget",
"addToTheMap": "Hinzufügen des Widgets zur Karte"
"addToTheMap": "Hinzufügen des Widgets zur Karte",
"titlePlaceholder": "Gib den Titel ein...",
"textPlaceholder": "Text eingeben..."
},
"errors": {
"noWidgetsAvailableTitle": "Keine Widgets verfügbar",
Expand Down
4 changes: 3 additions & 1 deletion web/client/translations/data.en-US
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,9 @@
"configureChartOptions": "Configure chart options",
"configureWidgetOptions": "Configure widget options",
"updateWidget": "Update the widget",
"addToTheMap": "Add the widget to the map"
"addToTheMap": "Add the widget to the map",
"titlePlaceholder": "Insert title...",
"textPlaceholder": "Insert text..."
},
"errors": {
"noWidgetsAvailableTitle": "No Widgets available",
Expand Down
4 changes: 3 additions & 1 deletion web/client/translations/data.es-ES
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,9 @@
"configureChartOptions": "Configurar opciones de gráfico",
"configureWidgetOptions": "Configurar las opciones del widget",
"updateWidget": "Actualiza el widget",
"addToTheMap": "Agrega el widget al mapa"
"addToTheMap": "Agrega el widget al mapa",
"titlePlaceholder": "Ingrese el título...",
"textPlaceholder": "Ingresar texto..."
},
"errors": {
"noWidgetsAvailableTitle": "Sin widgets disponibles",
Expand Down
4 changes: 3 additions & 1 deletion web/client/translations/data.fr-FR
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,9 @@
"configureChartOptions": "Configurer les options de graphique",
"configureWidgetOptions": "Configurer les options du widget",
"updateWidget": "Mettre à jour le widget",
"addToTheMap": "Ajouter le widget à la carte"
"addToTheMap": "Ajouter le widget à la carte",
"titlePlaceholder": "Entrez le titre...",
"textPlaceholder": "Entrez le texte..."
},
"errors": {
"noWidgetsAvailableTitle": "Aucun widget disponible",
Expand Down
4 changes: 3 additions & 1 deletion web/client/translations/data.it-IT
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,9 @@
"configureChartOptions": "Configura le opzioni del grafico",
"configureWidgetOptions": "Configura le opzioni del widget",
"updateWidget": "Aggiorna il widget",
"addToTheMap": "Aggiungi il widget alla mappa"
"addToTheMap": "Aggiungi il widget alla mappa",
"titlePlaceholder": "Inserisci il titolo...",
"textPlaceholder": "Inserisci il testo..."
},
"errors": {
"noWidgetsAvailableTitle": "Nessun widgets disponibile",
Expand Down

0 comments on commit 90e2b13

Please sign in to comment.