Moving Scholar.Notes in the code -- ignore
This commit is contained in:
parent
e22bdaab33
commit
20bad3609d
1 changed files with 49 additions and 49 deletions
|
@ -1214,55 +1214,6 @@ Scholar.Item.prototype._loadItemData = function(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Scholar.Notes = new function(){
|
|
||||||
this.add = add;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new item of type 'note' and add the note text to the itemNotes table
|
|
||||||
*
|
|
||||||
* Returns the itemID of the new note item
|
|
||||||
**/
|
|
||||||
function add(text, sourceItemID){
|
|
||||||
Scholar.DB.beginTransaction();
|
|
||||||
|
|
||||||
if (sourceItemID){
|
|
||||||
var sourceItem = Scholar.Items.get(sourceItemID);
|
|
||||||
if (!sourceItem){
|
|
||||||
Scholar.DB.commitTransaction();
|
|
||||||
throw ("Cannot set note source to invalid item " + sourceItemID);
|
|
||||||
}
|
|
||||||
if (sourceItem.isNote()){
|
|
||||||
Scholar.DB.commitTransaction();
|
|
||||||
throw ("Cannot set note source to another note (" + sourceItemID + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var note = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('note'));
|
|
||||||
note.save();
|
|
||||||
|
|
||||||
var sql = "INSERT INTO itemNotes VALUES (?,?,?)";
|
|
||||||
var bindParams = [
|
|
||||||
note.getID(),
|
|
||||||
(sourceItemID ? {int:sourceItemID} : null),
|
|
||||||
{string:text}
|
|
||||||
];
|
|
||||||
Scholar.DB.query(sql, bindParams);
|
|
||||||
Scholar.DB.commitTransaction();
|
|
||||||
|
|
||||||
if (sourceItemID){
|
|
||||||
sourceItem.incrementNoteCount();
|
|
||||||
Scholar.Notifier.trigger('modify', 'item', sourceItemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
Scholar.Notifier.trigger('add', 'item', note.getID());
|
|
||||||
|
|
||||||
return note.getID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Primary interface for accessing Scholar items
|
* Primary interface for accessing Scholar items
|
||||||
*/
|
*/
|
||||||
|
@ -1473,6 +1424,55 @@ Scholar.Items = new function(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Scholar.Notes = new function(){
|
||||||
|
this.add = add;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new item of type 'note' and add the note text to the itemNotes table
|
||||||
|
*
|
||||||
|
* Returns the itemID of the new note item
|
||||||
|
**/
|
||||||
|
function add(text, sourceItemID){
|
||||||
|
Scholar.DB.beginTransaction();
|
||||||
|
|
||||||
|
if (sourceItemID){
|
||||||
|
var sourceItem = Scholar.Items.get(sourceItemID);
|
||||||
|
if (!sourceItem){
|
||||||
|
Scholar.DB.commitTransaction();
|
||||||
|
throw ("Cannot set note source to invalid item " + sourceItemID);
|
||||||
|
}
|
||||||
|
if (sourceItem.isNote()){
|
||||||
|
Scholar.DB.commitTransaction();
|
||||||
|
throw ("Cannot set note source to another note (" + sourceItemID + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var note = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('note'));
|
||||||
|
note.save();
|
||||||
|
|
||||||
|
var sql = "INSERT INTO itemNotes VALUES (?,?,?)";
|
||||||
|
var bindParams = [
|
||||||
|
note.getID(),
|
||||||
|
(sourceItemID ? {int:sourceItemID} : null),
|
||||||
|
{string:text}
|
||||||
|
];
|
||||||
|
Scholar.DB.query(sql, bindParams);
|
||||||
|
Scholar.DB.commitTransaction();
|
||||||
|
|
||||||
|
if (sourceItemID){
|
||||||
|
sourceItem.incrementNoteCount();
|
||||||
|
Scholar.Notifier.trigger('modify', 'item', sourceItemID);
|
||||||
|
}
|
||||||
|
|
||||||
|
Scholar.Notifier.trigger('add', 'item', note.getID());
|
||||||
|
|
||||||
|
return note.getID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor for Collection object
|
* Constructor for Collection object
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue