added item deletion
This commit is contained in:
parent
2237384ca2
commit
2065385ea8
|
@ -1 +1 @@
|
|||
{"categories":[{"name":"to do","content":[{"name":"clean up","description":"using the feedback from ourstory discord","id":1},{"name":"be able to delete item","description":"in project mode add a button in item edit window to delete an item","id":4},{"name":"be able to delete category","description":"in project mode, if no focus and name is empty => delete category\n\nalready did xD I am a geniius\nfor clarification, I had a loong pause in develompent, and had forgotten I had this implemented, and while looking for where to code it, i found at the exact right place, the exact code needed","id":5},{"name":"update category layout","description":"take inspo form tab layout (number of column is max( min col, n_col +1)\nor scroll ?","id":6},{"name":"keep tree in save","description":"keep track of the opened tabs and reopens them\n","id":1},{"name":"u","description":"// Hello there","id":2},{"name":"less enter trigger (project)","description":"if in a textbox, don't open the item window when enter is pressed","id":3}]},{"name":"in progress","content":[]},{"name":"done","content":[{"name":"mark tab as unsaved (project)","description":"when modifying a project, mark it as unsaved","id":2},{"name":"fix + color in project","description":"the '+' to add an item has a wrong color if last item in list is selected","id":3}]},{"name":"bugs","content":[]},{"name":"+","content":[]}]}
|
||||
{"categories":[{"name":"to do","content":[{"name":"clean up","description":"using the feedback from ourstory discord","id":1},{"name":"keep tree in save","description":"keep track of the opened tabs and reopens them\n","id":1},{"name":"u","description":"// Hello there","id":2}]},{"name":"in progress","content":[]},{"name":"done","content":[{"name":"mark tab as unsaved (project)","description":"when modifying a project, mark it as unsaved","id":2},{"name":"fix + color in project","description":"the '+' to add an item has a wrong color if last item in list is selected","id":3},{"name":"be able to delete category","description":"in project mode, if no focus and name is empty => delete category\n\nalready did xD I am a geniius\nfor clarification, I had a loong pause in develompent, and had forgotten I had this implemented, and while looking for where to code it, i found at the exact right place, the exact code needed","id":5},{"name":"update category layout","description":"take inspo form tab layout (number of column is max( min col, n_col +1)\nor scroll ?","id":6},{"name":"less enter trigger (project)","description":"if in a textbox, don't open the item window when enter is pressed","id":3},{"name":"be able to delete item","description":"in project mode add a button in item edit window to delete an item","id":4}]},{"name":"bugs","content":[]},{"name":"+","content":[]}]}
|
|
@ -345,12 +345,22 @@ impl Calcifer {
|
|||
.content
|
||||
.is_empty()
|
||||
{
|
||||
self.project_content.item_window.show(
|
||||
let delete_item = self.project_content.item_window.show(
|
||||
ctx,
|
||||
&mut self.project_content.categories
|
||||
[self.project_content.selected_item.category]
|
||||
.content[self.project_content.selected_item.row],
|
||||
);
|
||||
|
||||
if delete_item {
|
||||
self.project_content.item_window.visible = false;
|
||||
self.project_content.categories
|
||||
[self.project_content.selected_item.category]
|
||||
.content.remove(self.project_content.selected_item.row);
|
||||
if self.project_content.selected_item.row >= self.project_content.categories[self.project_content.selected_item.category].content.len() && self.project_content.selected_item.row > 0 {
|
||||
self.project_content.selected_item.row -= 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.project_content.item_window.visible = false;
|
||||
}
|
||||
|
|
|
@ -11,24 +11,38 @@ impl ProjectItemWindow {
|
|||
Self { visible: false }
|
||||
}
|
||||
|
||||
pub fn show(&mut self, ctx: &egui::Context, item: &mut panels::Item) {
|
||||
pub fn show(&mut self, ctx: &egui::Context, item: &mut panels::Item) -> bool {
|
||||
let mut visible = self.visible;
|
||||
egui::Window::new("Item")
|
||||
let maybe_response = egui::Window::new("Item")
|
||||
.open(&mut visible)
|
||||
.vscroll(true)
|
||||
.hscroll(true)
|
||||
.show(ctx, |ui| self.ui(ui, item));
|
||||
self.visible = self.visible && visible;
|
||||
|
||||
if let Some(response) = maybe_response {
|
||||
if let Some(delete_option) = response.inner {
|
||||
return delete_option
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fn ui(&mut self, ui: &mut egui::Ui, item: &mut panels::Item) {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, item: &mut panels::Item) -> bool {
|
||||
let mut delete_item = false;
|
||||
ui.set_min_width(250.0);
|
||||
ui.set_min_height(250.0);
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||
if ui.add(egui::Button::new("delete")).clicked() {
|
||||
delete_item = true;
|
||||
}
|
||||
ui.add(egui::TextEdit::singleline(&mut item.name).desired_width(f32::INFINITY));
|
||||
});
|
||||
ui.separator();
|
||||
ui.add_sized(
|
||||
ui.available_size(),
|
||||
egui::TextEdit::multiline(&mut item.description),
|
||||
);
|
||||
return delete_item.clone()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue