Add the ability to quickly delete a couple of stuff

This commit is contained in:
Ozbolt Menegatti 2020-01-23 20:01:33 +01:00
parent c16819dab7
commit 9c88a2b5cf
5 changed files with 37 additions and 6 deletions

View File

@ -191,6 +191,11 @@
} }
} }
.modal-delete {
float: right;
margin-right: 1em;
}
// TODO: // TODO:
// #log { // #log {
// overflow: scroll; // overflow: scroll;

View File

@ -1,9 +1,10 @@
from message.simple_messages import NoReset, Reset, ModalNotOkClose, ClickMessage, DataChgClickMessage, KeyboardPress from message.simple_messages import NoReset, Reset, ModalNotOkClose, ClickMessage, DataChgClickMessage, KeyboardPress
from message.translation_edit import EditTranslation, MoveRight, MoveLeft, BinTranslation from message.translation_edit import EditTranslation, MoveRight, MoveLeft, BinTranslation
from message.show_messages import ShowEntryLabelsEdit, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation, ShowExampleEdit, ShowExampleTranslationEdit, ShowVariantsEdit, ShowRelatedEntriesEdit from message.show_messages import ShowEntryLabelsEdit, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation, ShowExampleEdit, ShowExampleTranslationEdit, ShowVariantsEdit, ShowRelatedEntriesEdit
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, EditExample, AddExampleTranslation, EditExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditRelatedEntries, EditEntryLabel from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, EditExample, AddExampleTranslation, EditExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditRelatedEntries, EditEntryLabels
from message.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu from message.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu
from message.sense_edit import SenseMoveUp, SenseMoveDown, SenseBin from message.sense_edit import SenseMoveUp, SenseMoveDown, SenseBin
from message.delete_messages import DeleteComment, DeleteVariants, DeleteRelatedEntries, DeleteEntryLabels
from message.message import msg from message.message import msg

View File

@ -0,0 +1,21 @@
from message.message import Message
class DeleteComment(Message):
def update_model(self, model):
model.entry.comment = ""
class DeleteVariants(Message):
def update_model(self, model):
model.entry.variants = []
class DeleteRelatedEntries(Message):
def update_model(self, model):
model.entry.related_entries = []
class DeleteEntryLabels(Message):
def update_model(self, model):
model.entry.labels = []

View File

@ -3,13 +3,17 @@ from lib.snabbdom import h
from model.tags import TAGS from model.tags import TAGS
from browser import document from browser import document
def modal_template(content, title, msg): def modal_template(content, title, msg, delete_msg=None):
reset = message.msg(message.ModalNotOkClose()) reset = message.msg(message.ModalNotOkClose())
footer = [] footer = []
if msg is not None: if msg is not None:
footer.append(h("a#modal-ok.button", {"on": {"click": message.msg(msg)}}, "OK")) footer.append(h("a#modal-ok.button", {"on": {"click": message.msg(msg)}}, "OK"))
footer.append(h("label.button.dangerous", {"on": {"click": reset}}, "Cancel")) footer.append(h("label.button.dangerous", {"on": {"click": reset}}, "Cancel"))
if delete_msg is not None:
footer.append(h("label.button.warning.modal-delete", {"on": {"click": message.msg(delete_msg)}}, "🗑"))
return [ return [
h("header", {}, [ h("header", {}, [

View File

@ -40,18 +40,18 @@ def edit_example(example):
def edit_variants(entry): def edit_variants(entry):
vget = lambda: entry.copy().variants vget = lambda: entry.copy().variants
content = generic_list_editor("Variants", vget) content = generic_list_editor("Variants", vget)
return modal_template(content, "Add or remove variants", message.EditVariants()) return modal_template(content, "Add or remove variants", message.EditVariants(), message.DeleteVariants())
def edit_related_entries(entry): def edit_related_entries(entry):
reget = lambda: entry.copy().related_entries reget = lambda: entry.copy().related_entries
content = generic_list_editor("Related entries", reget) content = generic_list_editor("Related entries", reget)
return modal_template(content, "Add or remove related entries", message.EditRelatedEntries()) return modal_template(content, "Add or remove related entries", message.EditRelatedEntries(), message.DeleteRelatedEntries())
def edit_entry_labels(entry): def edit_entry_labels(entry):
content = label_list_editor(entry.copy().labels, message.AddToLabelList(entry.copy().labels)) content = label_list_editor(entry.copy().labels, message.AddToLabelList(entry.copy().labels))
return modal_template(content, "Translation", message.EditEntryLabels()) return modal_template(content, "Translation", message.EditEntryLabels(), message.DeleteEntryLabels())
def edit_sense_definition(sense): def edit_sense_definition(sense):
@ -59,7 +59,7 @@ def edit_sense_definition(sense):
def edit_comment(comment): def edit_comment(comment):
return modal_template(question("Edit comment", comment), "Comment", message.EditComment()) return modal_template(question("Edit comment", comment), "Comment", message.EditComment(), message.DeleteComment())
def do_chosen_examples(example_list, entry): def do_chosen_examples(example_list, entry):