Add ' et al.' to firstCreator field when more than one creator
This commit is contained in:
parent
60f7c8fccd
commit
6c55e63eab
1 changed files with 7 additions and 2 deletions
|
@ -64,7 +64,9 @@ Scholar.Item.prototype.isEditableField = function(field){
|
||||||
* Build object from database
|
* Build object from database
|
||||||
*/
|
*/
|
||||||
Scholar.Item.prototype.loadFromID = function(id){
|
Scholar.Item.prototype.loadFromID = function(id){
|
||||||
var sql = 'SELECT I.*, lastName AS firstCreator '
|
var sql = 'SELECT I.*, lastName || '
|
||||||
|
+ 'CASE ((SELECT COUNT(*) FROM itemCreators WHERE itemID=' + id + ')>1) '
|
||||||
|
+ "WHEN 0 THEN '' ELSE ' et al.' END AS firstCreator "
|
||||||
+ 'FROM items I '
|
+ 'FROM items I '
|
||||||
+ 'LEFT JOIN itemCreators IC ON (I.itemID=IC.itemID) '
|
+ 'LEFT JOIN itemCreators IC ON (I.itemID=IC.itemID) '
|
||||||
+ 'LEFT JOIN creators C ON (IC.creatorID=C.creatorID) '
|
+ 'LEFT JOIN creators C ON (IC.creatorID=C.creatorID) '
|
||||||
|
@ -934,12 +936,15 @@ Scholar.Items = new function(){
|
||||||
function _load(){
|
function _load(){
|
||||||
// Should be the same as query in Scholar.Item.loadFromID, just
|
// Should be the same as query in Scholar.Item.loadFromID, just
|
||||||
// without itemID clause
|
// without itemID clause
|
||||||
var sql = 'SELECT I.*, lastName AS firstCreator '
|
var sql = 'SELECT I.*, lastName || '
|
||||||
|
+ 'CASE ((SELECT COUNT(*) FROM itemCreators WHERE itemID=I.itemID)>1) '
|
||||||
|
+ "WHEN 0 THEN '' ELSE ' et al.' END AS firstCreator "
|
||||||
+ 'FROM items I '
|
+ 'FROM items I '
|
||||||
+ 'LEFT JOIN itemCreators IC ON (I.itemID=IC.itemID) '
|
+ 'LEFT JOIN itemCreators IC ON (I.itemID=IC.itemID) '
|
||||||
+ 'LEFT JOIN creators C ON (IC.creatorID=C.creatorID) '
|
+ 'LEFT JOIN creators C ON (IC.creatorID=C.creatorID) '
|
||||||
+ 'WHERE (IC.orderIndex=0 OR IC.orderIndex IS NULL)';
|
+ 'WHERE (IC.orderIndex=0 OR IC.orderIndex IS NULL)';
|
||||||
|
|
||||||
|
Scholar.debug(arguments[0]);
|
||||||
if (arguments[0]){
|
if (arguments[0]){
|
||||||
sql += ' AND I.itemID IN (' + Scholar.join(arguments,',') + ')';
|
sql += ' AND I.itemID IN (' + Scholar.join(arguments,',') + ')';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue