-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dashboard layout (DHIS2-3600) (#1803)
* don't want to lose the items * don't want to lose the items * don't want to lose the items * fns and tests done, first attempt * update snapshot * should be close * fix: sorting alg bug * change the tests * random number of columns * remount the grid on auto layout * snapshot * rename dashboard layout reducer/action * add layout to edit dashboard * moved logic to reducer * add use cases * share logic in a thunk * add item to start works * minor * minor * adding vis and textbox works * adding reports works * add default value for layout columns * new layout format works * remove diff file * tmp style * ui for 'add to' * ui for 'add to' * add item to end WIP * add item to end WIP * add item to end WIP * layout + add to end works * all four combos of layout and addTo work * addItemsTo default * add to start works * delete item with layout works * delete item with layout works * avoiding reload on add/remove works * fix: proper html and css for the titlebar * chore: snapshot update * feat: add layout modal to edit mode * avoid freeflow reload * fix: i18n plural * fix: prop name count * connect columns in dialog to store * resize handles * resize handles * resize handles * keep height * save columns works * save insert position works * layout bar style * revert preserving height * disable dragging and resizing in layout mode * layout bar style * fn refactor * add important rules DONT DO THIS AT HOME * remove comments * d2 style * upgrade * update snapshots * conflict * update tests * import order Co-authored-by: Martin Ohlson <[email protected]>
- Loading branch information
1 parent
b313a39
commit 75da018
Showing
29 changed files
with
3,113 additions
and
1,347 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
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
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,27 +1,41 @@ | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import { connect } from 'react-redux' | ||
import { acRemoveDashboardItem } from '../../../actions/editDashboard' | ||
import { | ||
acRemoveDashboardItem, | ||
tSetDashboardItems, | ||
} from '../../../actions/editDashboard' | ||
import { | ||
sGetEditDashboardItems, | ||
sGetLayoutColumns, | ||
} from '../../../reducers/editDashboard' | ||
import DeleteItemButton from './DeleteItemButton' | ||
import classes from './styles/ItemHeader.module.css' | ||
|
||
const EditItemActions = ({ itemId, acRemoveDashboardItem }) => { | ||
const handleDeleteItem = () => acRemoveDashboardItem(itemId) | ||
|
||
const EditItemActions = ({ itemId, onDeleteItem }) => { | ||
return ( | ||
<div className={classes.itemActionsWrap}> | ||
<DeleteItemButton onClick={handleDeleteItem} /> | ||
<DeleteItemButton onClick={() => onDeleteItem(itemId)} /> | ||
</div> | ||
) | ||
} | ||
|
||
EditItemActions.propTypes = { | ||
acRemoveDashboardItem: PropTypes.func, | ||
itemId: PropTypes.string, | ||
onDeleteItem: PropTypes.func, | ||
} | ||
|
||
const mapDispatchToProps = { | ||
acRemoveDashboardItem, | ||
onDeleteItem: itemId => (dispatch, getState) => { | ||
const columns = sGetLayoutColumns(getState()) | ||
const dashboardItems = sGetEditDashboardItems(getState()) | ||
|
||
if (!columns.length || dashboardItems.length === 1) { | ||
dispatch(acRemoveDashboardItem(itemId)) | ||
} else { | ||
dispatch(tSetDashboardItems(null, itemId)) | ||
} | ||
}, | ||
} | ||
|
||
export default connect(null, mapDispatchToProps)(EditItemActions) |
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
Oops, something went wrong.