multiple layers for edits too

This commit is contained in:
j 2021-11-24 11:53:13 +01:00
parent 83228a5ead
commit db6a2f25bd

View file

@ -300,24 +300,22 @@ async function loadClips(annotations) {
} }
function loadAnnotations(config) { function loadAnnotations(config) {
var layers = config.layer
if (!Array.isArray(layers)) {
layers = [layers]
}
if (config.item) { if (config.item) {
pandoraAPI('get', {id: config.item, keys: [ pandoraAPI('get', {id: config.item, keys: [
'layers' 'layers'
]}).then(response => { ]}).then(response => {
var annotations = [] var annotations = []
if (Array.isArray(config.layer)) { layers.forEach(layer => {
config.layer.forEach(layer => {
response.data.layers[layer].forEach(annotation => { response.data.layers[layer].forEach(annotation => {
if (!(config.user && annotation.user != config.user)) { if (!(config.user && annotation.user != config.user)) {
annotations.push(annotation) annotations.push(annotation)
} }
}) })
}) })
} else {
annotations = response.data.layers[config.layer].filter(annotation => {
return !(config.user && annotation.user != config.user)
})
}
loadClips(annotations).then(annotations => { loadClips(annotations).then(annotations => {
config.annotations = annotations.filter(annotation => { config.annotations = annotations.filter(annotation => {
if (config.only_e) { if (config.only_e) {
@ -344,7 +342,8 @@ function loadAnnotations(config) {
director: clip.director, director: clip.director,
id: clip.item id: clip.item
} }
clip.layers[config.layer].forEach(annotation => { layers.forEach(layer => {
clip.layers[layer].forEach(annotation => {
if (config.user && annotation.user != config.user) { if (config.user && annotation.user != config.user) {
return return
} }
@ -362,6 +361,7 @@ function loadAnnotations(config) {
} }
} }
}) })
}
}) })
loadClips(annotations).then(annotations => { loadClips(annotations).then(annotations => {
config.annotations = annotations config.annotations = annotations