include clip conditions from smart lists in clip queries, fixes #2134
This commit is contained in:
parent
522af49a73
commit
57503c7eb5
3 changed files with 57 additions and 22 deletions
|
@ -78,14 +78,19 @@ pandora.ui.clipList = function(videoRatio) {
|
||||||
query = {conditions: [], operator: '&'};
|
query = {conditions: [], operator: '&'};
|
||||||
// if the item query contains a layer condition,
|
// if the item query contains a layer condition,
|
||||||
// then this condition is added to the clip query
|
// then this condition is added to the clip query
|
||||||
itemsQuery.conditions.forEach(function(condition) {
|
addConditions(query, itemsQuery.conditions);
|
||||||
if (
|
// if a list is selected, check if its a smart list and
|
||||||
condition.key == 'annotations'
|
// add possible layer conditions from query
|
||||||
|| Ox.getIndexById(pandora.site.layers, condition.key) > -1
|
if (ui._list) {
|
||||||
) {
|
pandora.api.getList({id: ui._list}, function(result) {
|
||||||
query.conditions.push(condition);
|
if (result.data.type == 'smart') {
|
||||||
|
addConditions(query, result.data.query.conditions);
|
||||||
}
|
}
|
||||||
|
findClips();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
findClips();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
itemsQuery = {
|
itemsQuery = {
|
||||||
conditions:[{key: 'id', value: ui.item, operator: '=='}],
|
conditions:[{key: 'id', value: ui.item, operator: '=='}],
|
||||||
|
@ -99,11 +104,26 @@ pandora.ui.clipList = function(videoRatio) {
|
||||||
}],
|
}],
|
||||||
operator: '&'
|
operator: '&'
|
||||||
};
|
};
|
||||||
|
findClips();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addConditions(query, conditions) {
|
||||||
|
conditions.forEach(function(condition) {
|
||||||
|
if (
|
||||||
|
condition.key == 'annotations'
|
||||||
|
|| Ox.getIndexById(pandora.site.layers, condition.key) > -1
|
||||||
|
) {
|
||||||
|
query.conditions.push(condition);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function findClips() {
|
||||||
pandora.api.findClips(Ox.extend(data, {
|
pandora.api.findClips(Ox.extend(data, {
|
||||||
itemsQuery: itemsQuery,
|
itemsQuery: itemsQuery,
|
||||||
query: query
|
query: query
|
||||||
}), callback);
|
}), callback);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
keys: ['annotations', 'id', 'in', 'out'].concat(
|
keys: ['annotations', 'id', 'in', 'out'].concat(
|
||||||
!ui.item ? ['videoRatio'] : []
|
!ui.item ? ['videoRatio'] : []
|
||||||
|
|
|
@ -230,14 +230,16 @@ pandora.ui.list = function() {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
items: function(data, callback) {
|
items: function(data, callback) {
|
||||||
|
pandora.getClipsQuery(function(clipsQuery) {
|
||||||
pandora.api.find(Ox.extend(data, {
|
pandora.api.find(Ox.extend(data, {
|
||||||
query: ui.find,
|
query: ui.find,
|
||||||
clips: {
|
clips: {
|
||||||
query: pandora.getClipsQuery(),
|
query: clipsQuery,
|
||||||
items: pandora.getClipsItems(),
|
items: pandora.getClipsItems(),
|
||||||
keys: []
|
keys: []
|
||||||
}
|
}
|
||||||
}), callback);
|
}), callback);
|
||||||
|
});
|
||||||
return Ox.clone(data, true);
|
return Ox.clone(data, true);
|
||||||
},
|
},
|
||||||
keys: ['clips', 'director', 'duration', 'id', 'modified', 'posterRatio', 'title', 'videoRatio', 'year'],
|
keys: ['clips', 'director', 'duration', 'id', 'modified', 'posterRatio', 'title', 'videoRatio', 'year'],
|
||||||
|
|
|
@ -847,7 +847,7 @@ pandora.getClipsItems = function(width) {
|
||||||
return Math.floor((width - 8) / (128 + 8)) - 1;
|
return Math.floor((width - 8) / (128 + 8)) - 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
pandora.getClipsQuery = function() {
|
pandora.getClipsQuery = function(callback) {
|
||||||
// fixme: nice, but not needed
|
// fixme: nice, but not needed
|
||||||
function addClipsConditions(conditions) {
|
function addClipsConditions(conditions) {
|
||||||
conditions.forEach(function(condition) {
|
conditions.forEach(function(condition) {
|
||||||
|
@ -867,7 +867,20 @@ pandora.getClipsQuery = function() {
|
||||||
};
|
};
|
||||||
addClipsConditions(pandora.user.ui.find.conditions);
|
addClipsConditions(pandora.user.ui.find.conditions);
|
||||||
clipsQuery.operator = clipsQuery.conditions.length ? '|' : '&';
|
clipsQuery.operator = clipsQuery.conditions.length ? '|' : '&';
|
||||||
|
if (callback) {
|
||||||
|
if (pandora.user.ui._list) {
|
||||||
|
pandora.api.getList({id: pandora.user.ui._list}, function(result) {
|
||||||
|
if (result.data.type == 'smart') {
|
||||||
|
addClipsConditions(result.data.query.conditions);
|
||||||
|
}
|
||||||
|
callback(clipsQuery)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
callback(clipsQuery)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
return clipsQuery;
|
return clipsQuery;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pandora.getClipVideos = function(clip, resolution) {
|
pandora.getClipVideos = function(clip, resolution) {
|
||||||
|
|
Loading…
Reference in a new issue