Skip to content

Commit 738de67

Browse files
committed
fixed renames
1 parent a107ef2 commit 738de67

File tree

4 files changed

+16
-42
lines changed

4 files changed

+16
-42
lines changed

src/client/applications/pivot-application/collection-view-delegate/collection-view-delegate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class CollectionViewDelegate {
175175
this.save(this.getSettings().addCollectionAt(collection, oldIndex));
176176
};
177177

178-
return this.save(appSettings.deleteCollection(collection)).then( () => {
178+
return this.save(appSettings.deleteCollection(collection.name)).then( () => {
179179
window.location.hash = `#/home`;
180180
Notifier.success('Collection removed', {label: STRINGS.undo, callback: undo});
181181
});

src/client/applications/pivot-application/pivot-application.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ export class PivotApplication extends React.Component<PivotApplicationProps, Piv
468468

469469
deleteDataCube(dataCube: DataCube) {
470470
const appSettings = this.state.appSettings as AppSettings;
471-
472-
this.saveDataCubes(appSettings.deleteDataCube(dataCube));
471+
this.saveDataCubes(appSettings.deleteDataCube(dataCube.name));
473472
}
474473

475474

src/client/views/settings-view/data-cubes/data-cubes.tsx

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,13 @@ export class DataCubes extends React.Component<DataCubesProps, DataCubesState> {
4848
});
4949
}
5050

51-
editCube(cube: DataCube) {
52-
window.location.hash += `/${cube.name}`;
51+
editDataCube(dataCube: DataCube) {
52+
window.location.hash += `/${dataCube.name}`;
5353
}
5454

55-
removeCube(cube: DataCube) {
55+
removeDataCube(dataCube: DataCube) {
5656
const remove = () => {
57-
var settings: AppSettings = this.state.newSettings;
58-
var index = settings.dataCubes.indexOf(cube);
59-
60-
if (index < 0) return;
61-
62-
var newCubes = settings.dataCubes;
63-
newCubes.splice(index, 1);
64-
65-
this.props.onSave(settings.changeDataCubes(newCubes), 'Cube removed');
57+
this.props.onSave(this.state.newSettings.deleteDataCube(dataCube.name), 'Date cube removed');
6658
Notifier.removeQuestion();
6759
};
6860

@@ -71,9 +63,9 @@ export class DataCubes extends React.Component<DataCubesProps, DataCubesState> {
7163
};
7264

7365
Notifier.ask({
74-
title: 'Remove this cube',
66+
title: 'Remove this data cube',
7567
message: [
76-
`Are you sure you would like to delete the data cube "${cube.title}"?`,
68+
`Are you sure you would like to delete the data cube "${dataCube.title}"?`,
7769
'This action is not reversible.'
7870
],
7971
choices: [
@@ -110,8 +102,8 @@ export class DataCubes extends React.Component<DataCubesProps, DataCubesState> {
110102
];
111103

112104
const actions: SimpleTableAction[] = [
113-
{icon: require(`../../../icons/full-edit.svg`), callback: this.editCube.bind(this)},
114-
{icon: require(`../../../icons/full-remove.svg`), callback: this.removeCube.bind(this)}
105+
{icon: require(`../../../icons/full-edit.svg`), callback: this.editDataCube.bind(this)},
106+
{icon: require(`../../../icons/full-remove.svg`), callback: this.removeDataCube.bind(this)}
115107
];
116108

117109
return <div className="data-cubes">
@@ -124,7 +116,7 @@ export class DataCubes extends React.Component<DataCubesProps, DataCubesState> {
124116
columns={columns}
125117
rows={newSettings.dataCubes}
126118
actions={actions}
127-
onRowClick={this.editCube.bind(this)}
119+
onRowClick={this.editDataCube.bind(this)}
128120
/>
129121
</div>
130122
</div>;

src/common/models/app-settings/app-settings.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -213,33 +213,16 @@ export class AppSettings implements Instance<AppSettingsValue, AppSettingsJS> {
213213
return new AppSettings(value);
214214
}
215215

216-
public deleteCollection(collection: Collection): AppSettings {
216+
public deleteCollection(collectionName: string): AppSettings {
217217
var value = this.valueOf();
218-
var index = value.collections.indexOf(collection);
219-
220-
if (index === -1) {
221-
throw new Error(`Unknown collection : ${collection.toString()}`);
222-
}
223-
224-
var newCollections = value.collections.concat();
225-
newCollections.splice(index, 1);
226-
227-
value.collections = newCollections;
218+
value.collections = value.collections.filter(collection => collection.name !== collectionName);
228219
return new AppSettings(value);
229220
}
230221

231-
public deleteDataCube(dataCube: DataCube): AppSettings {
222+
public deleteDataCube(dataCubeName: string): AppSettings {
232223
var value = this.valueOf();
233-
var index = value.dataCubes.indexOf(dataCube);
234-
235-
if (index === -1) {
236-
throw new Error(`Unknown dataCube : ${dataCube.toString()}`);
237-
}
238-
239-
var newDataCubes = value.dataCubes.concat();
240-
newDataCubes.splice(index, 1);
241-
242-
value.dataCubes = newDataCubes;
224+
value.dataCubes = value.dataCubes.filter(dataCube => dataCube.name !== dataCubeName);
225+
value.collections = value.collections.map(collection => collection.deleteTilesContainingCube(dataCubeName));
243226
return new AppSettings(value);
244227
}
245228

0 commit comments

Comments
 (0)