Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
#905 Dashboard edit mode - keeping order & placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
damianprzygodzki committed Jun 26, 2017
1 parent 4465ad7 commit c17f1ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/actions/BoardActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ export function filterCards(boardId, viewId) {
);
}

export function addDashboardWidget(entity, id) {
export function addDashboardWidget(entity, id, pos) {
return axios.post(
config.API_URL +
'/dashboard/' + entity + '/new', {
'kpiId': id
'kpiId': id,
'position': pos
}
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/charts/RawChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class RawChart extends Component {
<BarChart
{...{
data, groupBy, caption, chartType, height,
fields, isMaximized, chartTitle
fields, isMaximized, chartTitle, noData
}}
chartClass={'chart-' + id}
reRender={forceChartReRender}
Expand All @@ -134,7 +134,7 @@ class RawChart extends Component {
case 'PieChart':
return(
<PieChart
{...{data, fields, groupBy, height,
{...{data, fields, groupBy, height, noData,
isMaximized, chartTitle}}
chartClass={'chart-' + id}
responsive={true}
Expand Down
13 changes: 7 additions & 6 deletions src/components/dashboard/DraggableWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class DraggableWrapper extends Component {

addCard = (entity, id) => {
const tmpItemIndex = this.state[entity].findIndex(i => i.id === id);
addDashboardWidget(this.getType(entity), id).then(res => {
addDashboardWidget(this.getType(entity), id, tmpItemIndex).then(res => {
this.setState(prev => update(prev, {
[entity]: {
[tmpItemIndex]: {$set: res.data}
Expand All @@ -84,15 +84,16 @@ export class DraggableWrapper extends Component {
const newItem = {
id: item.id,
fetchOnDrop: true,
text: "Metric",
caption: "New",
kpi: {chartType: "Indicator"}
kpi: {chartType: this.getType(entity)}
};
this.setState(prev => update(prev, {
[entity]: prev[entity].length === 0 ? {
$set: [newItem]
} : {
$splice: [[dragIndex, 0, newItem]]
$splice: [
[dragIndex, 1],
[hoverIndex, 0, newItem]
]
}
}));
}
Expand Down Expand Up @@ -222,7 +223,7 @@ export class DraggableWrapper extends Component {
idMaximized={idMaximized}
maximizeWidget={this.maximizeWidget}
text={item.caption}
noData={false}
noData={item.fetchOnDrop}
{...{editmode}}
/>
</DndWidget>
Expand Down

0 comments on commit c17f1ed

Please sign in to comment.