editing example clusters on main view
This commit is contained in:
parent
ec5f72969c
commit
9a184011c1
|
@ -1,7 +1,7 @@
|
||||||
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, ShowVariantsEdit, ShowRelatedEntriesEdit
|
from message.show_messages import ShowEntryLabelsEdit, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation, ShowExampleEdit, ShowVariantsEdit, ShowRelatedEntriesEdit
|
||||||
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, AddExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditRelatedEntries, EditEntryLabels
|
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, AddExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditRelatedEntries, EditEntryLabels, ExampleClusterEdit
|
||||||
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.example_edit import ExampleMoveUp, ExampleMoveDown, ExampleBin, ExampleRoleChange, ExampleComponentAdd, ExampleComponentRemove, EditExampleText, ToggleExamples
|
from message.example_edit import ExampleMoveUp, ExampleMoveDown, ExampleBin, ExampleRoleChange, ExampleComponentAdd, ExampleComponentRemove, EditExampleText, ToggleExamples
|
||||||
|
|
|
@ -100,4 +100,9 @@ class EditEntryLabels(Message):
|
||||||
model.entry.labels = labels
|
model.entry.labels = labels
|
||||||
|
|
||||||
|
|
||||||
|
class ExampleClusterEdit(Message):
|
||||||
|
def update_model(self, model):
|
||||||
|
example = self.get_arg(0, Example)
|
||||||
|
cluster = self.get_arg(1, int)
|
||||||
|
example.set_cluster(cluster)
|
||||||
|
|
||||||
|
|
|
@ -27,19 +27,20 @@ class Sense(Editable):
|
||||||
sense_xml.querySelectorAll("exampleContainerList exampleContainer")]
|
sense_xml.querySelectorAll("exampleContainerList exampleContainer")]
|
||||||
|
|
||||||
# set limit for example cluster
|
# set limit for example cluster
|
||||||
self.reserved_example = max(cluster_mappings.values()) + 1
|
cluster_min =max(cluster_mappings.values()) + 2
|
||||||
cluster_min = self.reserved_example + 1
|
|
||||||
|
self._original_examples = set([cluster_min - 1])
|
||||||
|
self._original_examples = set(self.example_clusters())
|
||||||
|
|
||||||
def merge_labels(self):
|
def merge_labels(self):
|
||||||
return ", ".join(val for _, val in self.labels)
|
return ", ".join(val for _, val in self.labels)
|
||||||
|
|
||||||
def example_clusters(self):
|
def example_clusters(self):
|
||||||
result = set()
|
result = self._original_examples
|
||||||
for ex in self.examples:
|
for ex in self.examples:
|
||||||
cluster = ex.get_cluster()
|
cluster = ex.get_cluster()
|
||||||
if cluster is not None:
|
if cluster is not None:
|
||||||
result.add(cluster)
|
result.add(cluster)
|
||||||
result.add(self.reserved_example)
|
|
||||||
|
|
||||||
return sorted(result)
|
return sorted(result)
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,25 @@
|
||||||
from export import export_to_xml
|
from export import export_to_xml
|
||||||
from browser import window
|
from browser import window
|
||||||
from lib.snabbdom import h
|
from lib.snabbdom import h
|
||||||
|
import message
|
||||||
|
|
||||||
|
|
||||||
NUM2STR = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
NUM2STR = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||||
|
|
||||||
def show_toggle_cluster_buttons(sense, example):
|
def show_toggle_cluster_buttons(sense, example):
|
||||||
|
cls = example.get_cluster()
|
||||||
|
if cls is None:
|
||||||
|
return []
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
for opt in sense.example_clusters():
|
for opt in sense.example_clusters():
|
||||||
tag = "input.cluster-list-button"
|
tag = "input.cluster-list-button"
|
||||||
if opt == example.get_cluster():
|
if opt == cls:
|
||||||
tag += ".cluster-button-checked"
|
tag += ".cluster-button-checked"
|
||||||
|
|
||||||
result.append(h(tag, {"attrs": {"value": NUM2STR[opt], "type": "button"}}, []))
|
result.append(h(tag,
|
||||||
|
{"attrs": {"value": NUM2STR[opt], "type": "button"},
|
||||||
|
"on": {"click": message.msg(message.ExampleClusterEdit(example, opt))}}, []))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user