pass autocomplete with layer, support autocomplete for leyers with filters, fixes #2736

This commit is contained in:
j 2015-04-14 19:49:22 +01:00
parent c73ac10ed4
commit 3e0bd078d0
2 changed files with 24 additions and 12 deletions

View file

@ -603,6 +603,7 @@
"title": "Keywords", "title": "Keywords",
"canAddAnnotations": {"member": true, "staff": true, "admin": true}, "canAddAnnotations": {"member": true, "staff": true, "admin": true},
"item": "Keyword", "item": "Keyword",
"autocomplete": true,
"overlap": true, "overlap": true,
"type": "string" "type": "string"
}, },

View file

@ -3,7 +3,6 @@
'use strict'; 'use strict';
pandora.ui.editor = function(data) { pandora.ui.editor = function(data) {
var ui = pandora.user.ui, var ui = pandora.user.ui,
that = Ox.VideoAnnotationPanel({ that = Ox.VideoAnnotationPanel({
@ -15,16 +14,6 @@ pandora.ui.editor = function(data) {
annotationsTooltip: Ox._('annotations') annotationsTooltip: Ox._('annotations')
+ ' <span class="OxBright">' + Ox.SYMBOLS.shift + 'A</span>', + ' <span class="OxBright">' + Ox.SYMBOLS.shift + 'A</span>',
audioTrack: data.audioTrack, audioTrack: data.audioTrack,
autocomplete: function(key, value, callback) {
pandora.api.autocompleteEntities({
key: key,
operator: '=',
range: [0, 20],
value: value
}, function(result) {
callback(result.data.items);
})
},
censored: data.censored, censored: data.censored,
censoredIcon: pandora.site.cantPlay.icon, censoredIcon: pandora.site.cantPlay.icon,
censoredTooltip: Ox._(pandora.site.cantPlay.text), censoredTooltip: Ox._(pandora.site.cantPlay.text),
@ -53,7 +42,29 @@ pandora.ui.editor = function(data) {
layers: data.annotations.map(function(layer) { layers: data.annotations.map(function(layer) {
return Ox.extend({ return Ox.extend({
editable: layer.canAddAnnotations[pandora.user.level] editable: layer.canAddAnnotations[pandora.user.level]
}, layer); }, layer, {
autocomplete: layer.type == 'entity'
? function(key, value, callback) {
pandora.api.autocompleteEntities({
key: key,
operator: '=',
range: [0, 20],
value: value
}, function(result) {
callback(result.data.items);
})
} : layer.autocomplete
? function(key, value, callback) {
pandora.api.autocomplete({
key: key,
operator: '=',
range: [0, 20],
value: value
}, function(result) {
callback(result.data.items);
});
} : null
});
}), }),
loop: ui.videoLoop, loop: ui.videoLoop,
muted: ui.videoMuted, muted: ui.videoMuted,