Annotation Panel: on edit, update languages in menu

This commit is contained in:
rlx 2014-09-02 16:12:55 +02:00
parent 923a9ea706
commit 28d8a0ddf0

View file

@ -557,6 +557,18 @@ Ox.AnnotationPanel = function(options, self) {
self.$editMenuButton[action]('delete'); self.$editMenuButton[action]('delete');
} }
function updateLanguages() {
var languages = self.languages,
enabledLanguages = self.enabledLanguages;
self.languages = getLanguages();
self.enabledLanguages = self.languages.filter(function(language) {
return Ox.contains(enabledLanguages, language)
|| !Ox.contains(languages, language);
}).map(function(language) {
return language.code;
});
}
/*@ /*@
addItem <f> add item addItem <f> add item
(layer, item) -> <o> AnnotationPanel (layer, item) -> <o> AnnotationPanel
@ -565,7 +577,7 @@ Ox.AnnotationPanel = function(options, self) {
// called from addannotation callback // called from addannotation callback
var i = Ox.getIndexById(self.options.layers, layer); var i = Ox.getIndexById(self.options.layers, layer);
self.$folder[i].addItem(item); self.$folder[i].addItem(item);
self.languages = getLanguages(); updateLanguages();
self.users = getUsers(); self.users = getUsers();
if (self.enabledUsers != 'all' && self.enabledUsers.indexOf(item.user) == -1) { if (self.enabledUsers != 'all' && self.enabledUsers.indexOf(item.user) == -1) {
self.enabledUsers.push(item.user); self.enabledUsers.push(item.user);
@ -621,7 +633,7 @@ Ox.AnnotationPanel = function(options, self) {
} else { } else {
// called from removeannotation callback // called from removeannotation callback
self.options.selected = ''; self.options.selected = '';
self.languages = getLanguages(); updateLanguages();
self.users = getUsers(); self.users = getUsers();
renderOptionsMenu(); renderOptionsMenu();
renderEditMenu(); renderEditMenu();
@ -653,7 +665,10 @@ Ox.AnnotationPanel = function(options, self) {
// on the first update of a new annotation, the id will change // on the first update of a new annotation, the id will change
self.options.selected = item.id; self.options.selected = item.id;
getFolder(id).updateItem(id, item); getFolder(id).updateItem(id, item);
updateLanguages();
renderOptionsMenu();
renderEditMenu(); renderEditMenu();
return that;
}; };
/*@ /*@