-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #2660 implemented first version of save functionalities for dashb…
…oard (#2832)
- Loading branch information
1 parent
fb3b1f1
commit f595cde
Showing
43 changed files
with
2,411 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,43 @@ | ||
const SET_EDITOR_AVAILABLE = "DASHBOARD:SET_AVAILABLE"; | ||
const SET_EDITING = "DASHBOARD:SET_EDITING"; | ||
const SHOW_CONNECTIONS = "DASHBOARD:SHOW_CONNECTIONS"; | ||
const TRIGGER_SAVE_MODAL = "DASHBOARD:TRIGGER_SAVE_MODAL"; | ||
|
||
const SAVE_DASHBOARD = "DASHBOARD:SAVE_DASHBOARD"; | ||
const SAVE_ERROR = "DASHBOARD:SAVE_ERROR"; | ||
const DASHBOARD_SAVED = "DASHBOARD:DASHBOARD_SAVED"; | ||
|
||
const LOAD_DASHBOARD = "DASHBOARD:LOAD_DASHBOARD"; | ||
const DASHBOARD_LOADED = "DASHBOARD:DASHBOARD_LOADED"; | ||
const DASHBOARD_LOADING = "DASHBOARD:DASHBOARD_LOADING"; | ||
|
||
module.exports = { | ||
SET_EDITING, | ||
setEditing: (editing) => ({type: SET_EDITING, editing }), | ||
SET_EDITOR_AVAILABLE, | ||
setEditorAvailable: available => ({type: SET_EDITOR_AVAILABLE, available}), | ||
SHOW_CONNECTIONS, | ||
triggerShowConnections: show => ({ type: SHOW_CONNECTIONS, show}) | ||
triggerShowConnections: show => ({ type: SHOW_CONNECTIONS, show}), | ||
TRIGGER_SAVE_MODAL, | ||
triggerSave: show => ({ type: TRIGGER_SAVE_MODAL, show}), | ||
SAVE_DASHBOARD, | ||
saveDashboard: resource => ({ type: SAVE_DASHBOARD, resource}), | ||
SAVE_ERROR, | ||
dashboardSaveError: error => ({type: SAVE_ERROR, error}), | ||
DASHBOARD_SAVED, | ||
dashboardSaved: id => ({type: DASHBOARD_SAVED, id}), | ||
LOAD_DASHBOARD, | ||
loadDashboard: id => ({ type: LOAD_DASHBOARD, id}), | ||
DASHBOARD_LOADED, | ||
dashboardLoaded: (resource, data) => ({ type: DASHBOARD_LOADED, resource, data}), | ||
DASHBOARD_LOADING, | ||
/** | ||
* @param {boolean} value the value of the flag | ||
* @param {string} [name] the name of the flag to set. loading is anyway always triggered | ||
*/ | ||
dashboardLoading: (value, name = "loading") => ({ | ||
type: DASHBOARD_LOADING, | ||
name, | ||
value | ||
}) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Copyright 2016, 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. | ||
*/ | ||
/** | ||
* Copyright 2016, 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 PropTypes = require('prop-types'); | ||
const {FormControl: BFormControl, FormGroup, ControlLabel} = require('react-bootstrap'); | ||
const FormControl = require('../../misc/enhancers/localizedProps')('placeholder')(BFormControl); | ||
|
||
/** | ||
* A DropDown menu for user details: | ||
*/ | ||
class Metadata extends React.Component { | ||
static propTypes = { | ||
resource: PropTypes.object, | ||
// CALLBACKS | ||
onChange: PropTypes.func, | ||
|
||
// I18N | ||
nameFieldText: PropTypes.node, | ||
descriptionFieldText: PropTypes.node, | ||
namePlaceholderText: PropTypes.string, | ||
descriptionPlaceholderText: PropTypes.string | ||
}; | ||
|
||
static defaultProps = { | ||
// CALLBACKS | ||
onChange: () => {}, | ||
resource: {}, | ||
// I18N | ||
nameFieldText: "Name", | ||
descriptionFieldText: "Description", | ||
namePlaceholderText: "Map Name", | ||
descriptionPlaceholderText: "Map Description" | ||
}; | ||
|
||
render() { | ||
return (<form ref="metadataForm" onSubmit={this.handleSubmit}> | ||
<FormGroup> | ||
<ControlLabel>{this.props.nameFieldText}</ControlLabel> | ||
<FormControl | ||
key="mapName" | ||
type="text" | ||
onChange={this.changeName} | ||
disabled={this.props.resource.saving} | ||
placeholder={this.props.namePlaceholderText} | ||
defaultValue={this.props.resource ? this.props.resource.name : ""} | ||
value={this.props.resource && this.props.resource.metadata && this.props.resource.metadata.name || ""}/> | ||
</FormGroup> | ||
<FormGroup> | ||
<ControlLabel>{this.props.descriptionFieldText}</ControlLabel> | ||
<FormControl | ||
key="mapDescription" | ||
type="text" | ||
onChange={this.changeDescription} | ||
disabled={this.props.resource.saving} | ||
placeholder={this.props.descriptionPlaceholderText} | ||
defaultValue={this.props.resource ? this.props.resource.description : ""} | ||
value={this.props.resource && this.props.resource.metadata && this.props.resource.metadata.description || ""}/> | ||
</FormGroup> | ||
</form>); | ||
} | ||
|
||
changeName = (e) => { | ||
this.props.onChange('metadata.name', e.target.value); | ||
}; | ||
|
||
changeDescription = (e) => { | ||
this.props.onChange('metadata.description', e.target.value); | ||
}; | ||
} | ||
|
||
|
||
module.exports = Metadata; |
Oops, something went wrong.