Skip to content

Commit 90e2b13

Browse files
authored
Fix #2592 reorganized text widget into 1 page (#2614)
1 parent dbad778 commit 90e2b13

10 files changed

Lines changed: 64 additions & 26 deletions

File tree

web/client/components/widgets/builder/wizard/TextWizard.jsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88
const React = require('react');
9-
const ReactQuill = require('react-quill');
109
const {wizardHanlders} = require('../../../misc/wizard/enhancers');
11-
const WidgetOptions = require('./common/WidgetOptions');
10+
const TextOptions = require('./text/TextOptions');
1211
const Wizard = wizardHanlders(require('../../../misc/wizard/WizardContainer'));
1312

1413

@@ -22,8 +21,7 @@ module.exports = ({
2221
setPage={setPage}
2322
onFinish={onFinish}
2423
hideButtons>
25-
<ReactQuill value={editorData && editorData.text || ''} onChange={(val) => onChange("text", val)}/>
26-
<WidgetOptions
24+
<TextOptions
2725
key="widget-options"
2826
data={editorData}
2927
onChange={onChange}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2018, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
const React = require('react');
10+
const { Col, Form, FormGroup, FormControl } = require('react-bootstrap');
11+
const localizedProps = require('../../../../misc/enhancers/localizedProps');
12+
const TitleInput = localizedProps("placeholder")(FormControl);
13+
14+
const ReactQuill = require('react-quill');
15+
const Editor = localizedProps("placeholder")(ReactQuill);
16+
module.exports = ({ data = {}, onChange = () => { }}) => (
17+
<div>
18+
<Col key="form" xs={12}>
19+
<Form>
20+
<FormGroup controlId="title">
21+
<Col sm={12}>
22+
<TitleInput style={{ marginBottom: 10 }} placeholder="widgets.builder.wizard.titlePlaceholder" value={data.title} type="text" onChange={e => onChange("title", e.target.value)} />
23+
</Col>
24+
</FormGroup>
25+
</Form>
26+
</Col>
27+
<Editor placeholder="widgets.builder.wizard.textPlaceholder" value={data && data.text || ''} onChange={(val) => onChange("text", val)} />
28+
</div>
29+
);
30+

web/client/components/widgets/builder/wizard/text/Toolbar.jsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,14 @@ const getSaveTooltipId = (step, {id} = {}) => {
1616
}
1717
return "widgets.builder.wizard.addToTheMap";
1818
};
19-
const getNextTooltipId = () => {
20-
return "widgets.builder.wizard.configureWidgetOptions";
21-
};
22-
const getBackTooltipId = () => "back"; // TODO I18N
23-
module.exports = ({step = 0, editorData = {}, onFinish = () => {}, setPage = () => {}} = {}) => (<Toolbar btnDefaultProps={{
19+
20+
module.exports = ({step = 0, editorData = {}, onFinish = () => {}} = {}) => (<Toolbar btnDefaultProps={{
2421
bsStyle: "primary",
2522
bsSize: "sm"
2623
}}
2724
buttons={[{
28-
onClick: () => setPage(Math.max(0, step - 1)),
29-
visible: step > 0,
30-
glyph: "arrow-left",
31-
tooltipId: getBackTooltipId(step)
32-
}, {
33-
onClick: () => setPage(Math.min(step + 1, 2)),
34-
visible: step === 0,
35-
glyph: "arrow-right",
36-
tooltipId: getNextTooltipId(step)
37-
}, {
3825
onClick: () => onFinish(Math.min(step + 1, 1)),
39-
visible: step === 1,
26+
visible: step === 0,
4027
glyph: "floppy-disk",
4128
tooltipId: getSaveTooltipId(step, editorData)
4229
}]} />);

web/client/reducers/__tests__/widgets-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ describe('Test the widgets reducer', () => {
3838
it('editWidget', () => {
3939
const state = widgets(undefined, editWidget({type: "bar"}));
4040
expect(state.builder.editor.type).toBe("bar");
41+
expect(state.builder.settings.step).toBe(1);
42+
});
43+
it('editWidget initial by kind of widget', () => {
44+
// default chart
45+
expect(widgets(undefined, editWidget({ type: "bar" })).builder.settings.step).toBe(1);
46+
// chart explicit
47+
expect(widgets(undefined, editWidget({ widgetType: "chart" })).builder.settings.step).toBe(1);
48+
// text explicit
49+
expect(widgets(undefined, editWidget({ widgetType: "text" })).builder.settings.step).toBe(0);
4150
});
4251
it('onEditorChange', () => {
4352
const state = widgets(undefined, onEditorChange("type", "bar"));

web/client/reducers/widgets.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ function widgetsReducer(state = emptyState, action) {
6262
...action.widget,
6363
// for backward compatibility for widgets without this
6464
widgetType: action.widget && action.widget.widgetType || 'chart'
65-
}, state);
65+
}, set("builder.settings.step",
66+
(action.widget && action.widget.widgetType || 'chart') === 'chart'
67+
? 1
68+
: 0
69+
, state));
6670
}
6771
case EDITOR_CHANGE: {
6872
return set(`builder.editor.${action.key}`, action.value, state);

web/client/translations/data.de-DE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,9 @@
10811081
"configureChartOptions": "Diagrammoptionen konfigurieren",
10821082
"configureWidgetOptions": "Widget-Optionen konfigurieren",
10831083
"updateWidget": "Aktualisieren Sie das Widget",
1084-
"addToTheMap": "Hinzufügen des Widgets zur Karte"
1084+
"addToTheMap": "Hinzufügen des Widgets zur Karte",
1085+
"titlePlaceholder": "Gib den Titel ein...",
1086+
"textPlaceholder": "Text eingeben..."
10851087
},
10861088
"errors": {
10871089
"noWidgetsAvailableTitle": "Keine Widgets verfügbar",

web/client/translations/data.en-US

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,9 @@
10801080
"configureChartOptions": "Configure chart options",
10811081
"configureWidgetOptions": "Configure widget options",
10821082
"updateWidget": "Update the widget",
1083-
"addToTheMap": "Add the widget to the map"
1083+
"addToTheMap": "Add the widget to the map",
1084+
"titlePlaceholder": "Insert title...",
1085+
"textPlaceholder": "Insert text..."
10841086
},
10851087
"errors": {
10861088
"noWidgetsAvailableTitle": "No Widgets available",

web/client/translations/data.es-ES

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,9 @@
10801080
"configureChartOptions": "Configurar opciones de gráfico",
10811081
"configureWidgetOptions": "Configurar las opciones del widget",
10821082
"updateWidget": "Actualiza el widget",
1083-
"addToTheMap": "Agrega el widget al mapa"
1083+
"addToTheMap": "Agrega el widget al mapa",
1084+
"titlePlaceholder": "Ingrese el título...",
1085+
"textPlaceholder": "Ingresar texto..."
10841086
},
10851087
"errors": {
10861088
"noWidgetsAvailableTitle": "Sin widgets disponibles",

web/client/translations/data.fr-FR

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,9 @@
10841084
"configureChartOptions": "Configurer les options de graphique",
10851085
"configureWidgetOptions": "Configurer les options du widget",
10861086
"updateWidget": "Mettre à jour le widget",
1087-
"addToTheMap": "Ajouter le widget à la carte"
1087+
"addToTheMap": "Ajouter le widget à la carte",
1088+
"titlePlaceholder": "Entrez le titre...",
1089+
"textPlaceholder": "Entrez le texte..."
10881090
},
10891091
"errors": {
10901092
"noWidgetsAvailableTitle": "Aucun widget disponible",

web/client/translations/data.it-IT

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,9 @@
10811081
"configureChartOptions": "Configura le opzioni del grafico",
10821082
"configureWidgetOptions": "Configura le opzioni del widget",
10831083
"updateWidget": "Aggiorna il widget",
1084-
"addToTheMap": "Aggiungi il widget alla mappa"
1084+
"addToTheMap": "Aggiungi il widget alla mappa",
1085+
"titlePlaceholder": "Inserisci il titolo...",
1086+
"textPlaceholder": "Inserisci il testo..."
10851087
},
10861088
"errors": {
10871089
"noWidgetsAvailableTitle": "Nessun widgets disponibile",

0 commit comments

Comments
 (0)