(
&mut self,
collection_id: Uuid,
parent_folder_id: Option<Uuid>,
request: RequestData,
cx: &mut Context<Self>,
)
| 539 | .nodes |
| 540 | .into_iter() |
| 541 | .map(CollectionNode::from_imported_node) |
| 542 | .collect(), |
| 543 | expanded: true, |
| 544 | }; |
| 545 | let id = collection.id; |
| 546 | self.collections.push(collection); |
| 547 | self.bump_revision(); |
| 548 | self.save_to_file(); |
| 549 | cx.emit(CollectionsEvent::CollectionAdded(id)); |
| 550 | cx.notify(); |
| 551 | id |
| 552 | } |
| 553 | |
| 554 | pub fn remove_collection(&mut self, id: Uuid, cx: &mut Context<Self>) { |
| 555 | if let Some(pos) = self.collections.iter().position(|c| c.id == id) { |
| 556 | self.collections.remove(pos); |
| 557 | self.bump_revision(); |
| 558 | self.save_to_file(); |
| 559 | cx.emit(CollectionsEvent::CollectionRemoved(id)); |
| 560 | cx.notify(); |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | pub fn rename_collection(&mut self, id: Uuid, new_name: &str, cx: &mut Context<Self>) { |
| 565 | if let Some(collection) = self.collections.iter_mut().find(|c| c.id == id) { |
| 566 | collection.name = new_name.to_string(); |
no test coverage detected