Added firstCreator to primary field list
Fixed object retrieval queries to use orderIndex is 0 rather than 1, since that's the default now Scholar_Objects.getAll() now uses loaded.push() rather than loaded[objectID], since _for (objectID in objects)_ isn't an option with treeview Scholar_Object.getField() now returns an empty string rather than false for empty values
This commit is contained in:
parent
4a493e5953
commit
3711023d9a
1 changed files with 8 additions and 7 deletions
|
@ -29,12 +29,14 @@ Scholar_Object.prototype._init = function(){
|
||||||
this._changedObjectData = new Scholar.Hash();
|
this._changedObjectData = new Scholar.Hash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the specified field is a primary field from the objects table
|
* Check if the specified field is a primary field from the objects table
|
||||||
*/
|
*/
|
||||||
Scholar_Object.prototype.isPrimaryField = function(field){
|
Scholar_Object.prototype.isPrimaryField = function(field){
|
||||||
if (!Scholar_Object.primaryFields){
|
if (!Scholar_Object.primaryFields){
|
||||||
Scholar_Object.primaryFields = Scholar_DB.getColumnHash('objects');
|
Scholar_Object.primaryFields = Scholar_DB.getColumnHash('objects');
|
||||||
|
Scholar_Object.primaryFields['firstCreator'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !!Scholar_Object.primaryFields[field];
|
return !!Scholar_Object.primaryFields[field];
|
||||||
|
@ -46,7 +48,6 @@ Scholar_Object.editableFields = {
|
||||||
rights: true
|
rights: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the specified primary field can be changed with setField()
|
* Check if the specified primary field can be changed with setField()
|
||||||
*/
|
*/
|
||||||
|
@ -62,7 +63,7 @@ Scholar_Object.prototype.loadFromID = function(id){
|
||||||
var sql = 'SELECT O.*, lastName AS firstCreator FROM objects O '
|
var sql = 'SELECT O.*, lastName AS firstCreator FROM objects O '
|
||||||
+ 'LEFT JOIN objectCreators OC USING (objectID) '
|
+ 'LEFT JOIN objectCreators OC USING (objectID) '
|
||||||
+ 'LEFT JOIN creators USING (creatorID) '
|
+ 'LEFT JOIN creators USING (creatorID) '
|
||||||
+ 'WHERE objectID=' + id + ' AND OC.orderIndex=1';
|
+ 'WHERE objectID=' + id + ' AND OC.orderIndex=0';
|
||||||
var row = Scholar_DB.rowQuery(sql);
|
var row = Scholar_DB.rowQuery(sql);
|
||||||
this.loadFromRow(row);
|
this.loadFromRow(row);
|
||||||
}
|
}
|
||||||
|
@ -219,7 +220,7 @@ Scholar_Object.prototype.removeCreator = function(orderIndex){
|
||||||
*/
|
*/
|
||||||
Scholar_Object.prototype.getField = function(field){
|
Scholar_Object.prototype.getField = function(field){
|
||||||
if (this.isPrimaryField(field)){
|
if (this.isPrimaryField(field)){
|
||||||
return this._data[field] ? this._data[field] : false;
|
return this._data[field] ? this._data[field] : '';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.getID() && !this._objectDataLoaded){
|
if (this.getID() && !this._objectDataLoaded){
|
||||||
|
@ -228,7 +229,7 @@ Scholar_Object.prototype.getField = function(field){
|
||||||
|
|
||||||
var fieldID = Scholar_ObjectFields.getID(field);
|
var fieldID = Scholar_ObjectFields.getID(field);
|
||||||
|
|
||||||
return this._objectData[fieldID] ? this._objectData[fieldID] : false;
|
return this._objectData[fieldID] ? this._objectData[fieldID] : '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,7 +734,7 @@ var Scholar_Objects = new function(){
|
||||||
|
|
||||||
// Build return array
|
// Build return array
|
||||||
for (i=0; i<ids.length; i++){
|
for (i=0; i<ids.length; i++){
|
||||||
loaded[ids[i]] = _objects[ids[i]];
|
loaded.push(_objects[ids[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return loaded;
|
return loaded;
|
||||||
|
@ -750,7 +751,7 @@ var Scholar_Objects = new function(){
|
||||||
+ 'LEFT JOIN folders F ON (O.folderID=F.folderID) '
|
+ 'LEFT JOIN folders F ON (O.folderID=F.folderID) '
|
||||||
|
|
||||||
// Only get first creator
|
// Only get first creator
|
||||||
+ 'WHERE OC.orderIndex=1 '
|
+ 'WHERE OC.orderIndex=0 '
|
||||||
|
|
||||||
// folderID=0 puts root folder items after folders
|
// folderID=0 puts root folder items after folders
|
||||||
// TODO: allow folders to intermingle with items, order-wise
|
// TODO: allow folders to intermingle with items, order-wise
|
||||||
|
@ -815,7 +816,7 @@ var Scholar_Objects = new function(){
|
||||||
var sql = 'SELECT O.*, lastName AS firstCreator FROM objects O '
|
var sql = 'SELECT O.*, lastName AS firstCreator FROM objects O '
|
||||||
+ 'LEFT JOIN objectCreators OC USING (objectID) '
|
+ 'LEFT JOIN objectCreators OC USING (objectID) '
|
||||||
+ 'LEFT JOIN creators USING (creatorID) '
|
+ 'LEFT JOIN creators USING (creatorID) '
|
||||||
+ 'WHERE OC.orderIndex=1';
|
+ 'WHERE OC.orderIndex=0';
|
||||||
|
|
||||||
if (arguments[0]!='all'){
|
if (arguments[0]!='all'){
|
||||||
sql += ' AND O.objectID IN (' + Scholar.join(arguments,',') + ')';
|
sql += ' AND O.objectID IN (' + Scholar.join(arguments,',') + ')';
|
||||||
|
|
Loading…
Reference in a new issue