mirror of
https://github.com/outline/outline.git
synced 2026-11-23 06:11:04 +03:00
Add move action and update orderedData
This commit is contained in:
1 parent
3027ae767d
commit
243da7cc05
1 file changed
+12
-1
@@ -1,4 +1,5 @@
|
||||
// @flow
|
||||
import invariant from "invariant";
|
||||
import { concat, filter, last } from "lodash";
|
||||
import { computed, action } from "mobx";
|
||||
import naturalSort from "shared/utils/naturalSort";
|
||||
@@ -34,7 +35,7 @@ export default class CollectionsStore extends BaseStore<Collection> {
|
||||
@computed
|
||||
get orderedData(): Collection[] {
|
||||
return filter(
|
||||
naturalSort(Array.from(this.data.values()), "name"),
|
||||
naturalSort(Array.from(this.data.values()), "index"),
|
||||
(d) => !d.deletedAt
|
||||
);
|
||||
}
|
||||
@@ -95,6 +96,16 @@ export default class CollectionsStore extends BaseStore<Collection> {
|
||||
});
|
||||
};
|
||||
|
||||
@action
|
||||
move = async (collectionId: string, index: string) => {
|
||||
const res = await client.post("/collections.move", {
|
||||
id: collectionId,
|
||||
index,
|
||||
});
|
||||
invariant(res && res.success, "Collection could not be moved");
|
||||
this.addPolicies(res.policies);
|
||||
};
|
||||
|
||||
async update(params: Object): Promise<Collection> {
|
||||
const result = await super.update(params);
|
||||
|
||||
|
||||
Reference in new issue
Block a user