Changes as per my discussions with Dan:

- Separated snapshot functionality into two individual buttons, Create New Item From Current Page and Take Snapshot of Current page
- Updated schema to support primary, secondary and hidden item types (and future user customizations)
- Reorganized New Item menu, moving secondary items into sub-menu
- Removed ability to create link attachments, since it never really made much sense -- will simply use the webpage item type instead. Underlying functionality still exists for the time being, as people have existing links in their libraries--I think we're gonna have to just warn beta testers and delete them in a transition step, as converting nested links really wouldn't be worth the effort.
- Moved file link/add functions into new item menu and removed attachment drop-down
- Large, prominent View and Locate buttons in edit pane for going to an associated URL and looking up in OpenURL, respectively -- buttons gray out as appropriate
- New Item from Page stores the URL and access date (Item.save() checks for the string "CURRENT_TIMESTAMP" for accessDate and doesn't bind it as a string)
- "Website" to "Web Page" (do we prefer "Webpage"? they both look a bit funky in uppercase)

More coming.


Bugs/Known Issues:

- Since snapshots from the toolbar are now top-level in the current collection, there needs to be a way to drag them into items
- The camera icon for adding snapshots, despite being a famfamfam icon, really doesn't read too well (or perhaps just clashes with the rest of our icons). Anybody have a better one? (It also may be able to just be lightened up a bit.)
- Trying the large View/Locate buttons after discussions with Dan, but this approach may not work -- 1) a large View button for the URL makes a lot less sense when you have a parent item with a child snapshot, since people will end up clicking it all the time when they really want to view the snapshot, and 2) the Locate button is awfully big for something that only applies to certain types of items, may not get used very often when it does, and probably won't work when it is
- The access date is stored in UTC and displayed with toLocaleString() like Date Added and Date Modified, but, unlike those two, it's also user-editable. This is clearly a problem. Probably need to parse to Date on blur() with strToDate() and insert as UTC, discarding anything left over. 
- Item type itself is still "website" -- should probably change that while we still can


Closes #253, OpenURL arrow should provide visual feedback on mouseover and/or look more button-like
Addresses #304, change references to "website" to "web page"
Addresses #207, openurl arrow functionality
This commit is contained in:
Dan Stillman 2006-09-27 08:12:09 +00:00
parent da5e74a06a
commit 27f89fac5e
16 changed files with 201 additions and 89 deletions

View file

@ -372,7 +372,8 @@ var Scholar_ItemTypeManager = new function(){
sql += prefix + "INSERT INTO itemTypes VALUES ("
+ types[i]['itemTypeID'] + ", '" + types[i]['typeName'] + "', "
+ (types[i]['templateItemTypeID']
? types[i]['templateItemTypeID'] : 'NULL')
? types[i]['templateItemTypeID'] : 'NULL') + ", ",
+ types[i]['display']
+ ");\n"
}

View file

@ -39,6 +39,7 @@ var ScholarItemPane = new function()
this.viewItem = viewItem;
this.loadPane = loadPane;
this.changeTypeTo = changeTypeTo;
this.onGoToURLClick = onGoToURLClick;
this.onOpenURLClick = onOpenURLClick;
this.addCreatorRow = addCreatorRow;
this.switchCreatorMode = switchCreatorMode;
@ -127,7 +128,6 @@ var ScholarItemPane = new function()
}
_itemBeingEdited = thisItem;
_loaded = {};
loadPane(_tabs.selectedIndex);
@ -154,6 +154,39 @@ var ScholarItemPane = new function()
// Info pane
if(index == 0)
{
// Enable/disable "View =>" button
testView: try
{
var validURI = false;
var spec = _itemBeingEdited.getField('url');
if (!spec)
{
break testView;
}
var uri = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService)
.newURI(spec, null, null);
validURI = uri.scheme && uri.host;
}
catch (e){}
document.getElementById('tb-go-to-url').setAttribute('disabled', !validURI);
// Enable/disable "Locate =>" (OpenURL) button
switch (_itemBeingEdited.getType())
{
// DEBUG: handle descendents of these types as well?
case Scholar.ItemTypes.getID('book'):
case Scholar.ItemTypes.getID('bookSection'):
case Scholar.ItemTypes.getID('journalArticle'):
case Scholar.ItemTypes.getID('thesis'):
var openURL = true;
break;
default:
var openURL = false;
}
document.getElementById('tb-openurl').setAttribute('disabled', !openURL);
while(_dynamicFields.hasChildNodes())
_dynamicFields.removeChild(_dynamicFields.firstChild);
@ -174,8 +207,10 @@ var ScholarItemPane = new function()
var val = _itemBeingEdited.getField(fieldNames[i]);
// Convert dates from UTC
if (fieldNames[i]=='dateAdded' || fieldNames[i]=='dateModified'){
val = Scholar.Date.sqlToDate(val, true).toLocaleString();
if (fieldNames[i]=='dateAdded' || fieldNames[i]=='dateModified'
|| fieldNames[i]=='accessDate'){
var date = Scholar.Date.sqlToDate(val, true);
val = date ? date.toLocaleString() : '';
}
// Start tabindex at 1000 after creators
@ -347,9 +382,18 @@ var ScholarItemPane = new function()
}
}
function onGoToURLClick()
{
window.loadURI(_itemBeingEdited.getField('url'));
}
function onOpenURLClick()
{
window.open(Scholar.OpenURL.resolve(_itemBeingEdited));
var url = Scholar.OpenURL.resolve(_itemBeingEdited);
if (url)
{
window.loadURI(Scholar.OpenURL.resolve(_itemBeingEdited));
}
}
function addDynamicRow(label, value, beforeElement)

View file

@ -21,11 +21,14 @@
ScholarItemPane.modifyCreator(document.popupNode.getAttribute('fieldname').split('-')[1],
'typeID', typeID, otherFields)"/>
</popupset>
<hbox align="center">
<button id="tb-go-to-url" label="&toolbar.goToURL.label;" tooltiptext="&toolbar.goToURL.tooltip;" flex="1" oncommand="ScholarItemPane.onGoToURLClick();" disabled="false"/>
<button id="tb-openurl" label="&toolbar.openURL.label;" tooltiptext="&toolbar.openURL.tooltip;" flex="1" oncommand="ScholarItemPane.onOpenURLClick();"/>
</hbox>
<hbox align="center">
<menulist id="editpane-type-menu" oncommand="ScholarItemPane.changeTypeTo(this.value)" flex="1">
<menupopup/>
</menulist>
<toolbarbutton id="tb-openurl" tooltiptext="&toolbar.openurl.label;" oncommand="ScholarItemPane.onOpenURLClick();"/>
</hbox>
<grid flex="1">
<columns>
@ -55,7 +58,6 @@
<menupopup>
<menuitem class="menuitem-iconic" id="tb-item-attachments-link" label="&toolbar.attachment.linked;" oncommand="ScholarItemPane.addAttachmentFromDialog(true);"/>
<menuitem class="menuitem-iconic" id="tb-item-attachments-file" label="&toolbar.attachment.add;" oncommand="ScholarItemPane.addAttachmentFromDialog();"/>
<menuitem class="menuitem-iconic" id="tb-item-attachments-web-link" label="&toolbar.attachment.weblink;" oncommand="ScholarItemPane.addAttachmentFromPage(true);"/>
<menuitem class="menuitem-iconic" id="tb-item-attachments-snapshot" label="&toolbar.attachment.snapshot;" oncommand="ScholarItemPane.addAttachmentFromPage();"/>
</menupopup>
</button>

View file

@ -37,6 +37,7 @@ var ScholarPane = new function()
this.onDoubleClick = onDoubleClick;
this.openNoteWindow = openNoteWindow;
this.newNote = newNote;
this.addItemFromPage = addItemFromPage;
this.addAttachmentFromDialog = addAttachmentFromDialog;
this.addAttachmentFromPage = addAttachmentFromPage;
this.viewSelectedAttachment = viewSelectedAttachment;
@ -84,18 +85,24 @@ var ScholarPane = new function()
// Create the add menu with each item type
var addMenu = document.getElementById('tb-add').firstChild;
var itemTypes = Scholar.ItemTypes.getTypes();
var separator = document.getElementById('tb-add').firstChild.firstChild;
var moreMenu = document.getElementById('tb-add-more');
var itemTypes = Scholar.ItemTypes.getPrimaryTypes();
for(var i = 0; i<itemTypes.length; i++)
{
// Don't allow new attachments through this menu
if (itemTypes[i]['name']=='attachment')
{
continue;
}
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", Scholar.getString("itemTypes."+itemTypes[i]['name']));
menuitem.setAttribute("oncommand","ScholarPane.newItem("+itemTypes[i]['id']+")");
addMenu.appendChild(menuitem);
addMenu.insertBefore(menuitem, separator);
}
// Create submenu for secondary item types
var itemTypes = Scholar.ItemTypes.getSecondaryTypes();
for(var i = 0; i<itemTypes.length; i++)
{
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", Scholar.getString("itemTypes."+itemTypes[i]['name']));
menuitem.setAttribute("oncommand","ScholarPane.newItem("+itemTypes[i]['id']+")");
moreMenu.appendChild(menuitem);
}
}
@ -136,10 +143,18 @@ var ScholarPane = new function()
/*
* Create a new item
*
* _data_ is an optional object with field:value for itemData
*/
function newItem(typeID)
function newItem(typeID, data)
{
var item = new Scholar.Item(typeID);
for (var i in data)
{
item.setField(i, data[i]);
}
item.save();
if(itemsView && itemsView._itemGroup.isCollection())
itemsView._itemGroup.ref.addItem(item.getID());
@ -616,36 +631,25 @@ var ScholarPane = new function()
}
}
function addItemFromPage()
{
var data = {
title: window.content.document.title,
url: window.content.document.location.href,
accessDate: "CURRENT_TIMESTAMP"
}
newItem(Scholar.ItemTypes.getID('website'), data);
}
function addAttachmentFromPage(link, id)
{
var item;
if(id == null)
{
item = newItem(Scholar.ItemTypes.getID('website'));
if(item)
{
id = item.getID();
var c = getSelectedCollection();
if(c)
c.addItem(id);
}
}
var attachmentID;
if(link)
attachmentID = Scholar.Attachments.linkFromDocument(window.content.document, id);
Scholar.Attachments.linkFromDocument(window.content.document, id);
else
attachmentID = Scholar.Attachments.importFromDocument(window.content.document, id);
if(attachmentID && item)
{
var attachment = Scholar.Items.get(attachmentID);
if(attachment)
{
item.setField('title',attachment.getField('title'));
item.save();
}
}
Scholar.Attachments.importFromDocument(window.content.document, id);
}
function viewSelectedAttachment()

View file

@ -92,16 +92,19 @@
<vbox id="items-pane" persist="width" flex="1">
<toolbar align="center">
<toolbarbutton id="tb-add" tooltiptext="&toolbar.newItem.label;" type="menu">
<menupopup/>
</toolbarbutton>
<toolbarbutton id="tb-attachment-add" type="menu" tooltiptext="&toolbar.attachment.standalone;">
<!-- Built in overlay.js::onLoad() -->
<menupopup>
<menuseparator/>
<menuitem label="&toolbar.attachment.linked;" oncommand="ScholarPane.addAttachmentFromDialog(true);"/>
<menuitem label="&toolbar.attachment.add;" oncommand="ScholarPane.addAttachmentFromDialog();"/>
<menuitem label="&toolbar.attachment.weblink;" oncommand="ScholarPane.addAttachmentFromPage(true);"/>
<menuitem label="&toolbar.attachment.snapshot;" oncommand="ScholarPane.addAttachmentFromPage();"/>
<menuseparator/>
<menu label="&toolbar.moreItemTypes.label;">
<menupopup id="tb-add-more"/>
</menu>
</menupopup>
</toolbarbutton>
<toolbarbutton id="tb-item-from-page" tooltiptext="&toolbar.newItemFromPage.label;" oncommand="ScholarPane.addItemFromPage()"/>
<toolbarbutton id="tb-snapshot-page" tooltiptext="&toolbar.attachment.snapshot;" oncommand="ScholarPane.addAttachmentFromPage()"/>
<toolbarbutton id="tb-note-add" tooltiptext="&toolbar.note.standalone;" oncommand="ScholarPane.newNote();"/>
<spacer flex="1"/>
<label value="&toolbar.search.label;" control="tb-search"/>

View file

@ -556,12 +556,20 @@ Scholar.Item.prototype.save = function(){
Scholar.History.modify('itemData', 'itemID-fieldID',
[this.getID(), fieldID]);
sql = "UPDATE itemData SET value=?";
sql = "UPDATE itemData SET value=";
if (Scholar.ItemFields.getID('accessDate')==fieldID
&& this.getField(fieldID)=='CURRENT_TIMESTAMP')
{
sql += "CURRENT_TIMESTAMP";
}
// Take advantage of SQLite's manifest typing
if (Scholar.ItemFields.isInteger(fieldID)){
else if (Scholar.ItemFields.isInteger(fieldID)){
sql += '?'
sqlValues.push({'int':this.getField(fieldID)});
}
else {
sql += '?'
sqlValues.push({'string':this.getField(fieldID)});
}
sql += " WHERE itemID=? AND fieldID=?";
@ -586,7 +594,13 @@ Scholar.Item.prototype.save = function(){
{'int':fieldID},
];
if (Scholar.ItemFields.isInteger(fieldID)){
if (Scholar.ItemFields.getID('accessDate')==fieldID
&& this.getField(fieldID)=='CURRENT_TIMESTAMP')
{
sql = "INSERT INTO itemData VALUES "
+ "(?,?,CURRENT_TIMESTAMP)";
}
else if (Scholar.ItemFields.isInteger(fieldID)){
sqlValues.push({'int':this.getField(fieldID)});
}
else {
@ -697,7 +711,12 @@ Scholar.Item.prototype.save = function(){
{'int':fieldID}
];
if (Scholar.ItemFields.isInteger(fieldID)){
if (Scholar.ItemFields.getID('accessDate')==fieldID
&& this.getField(fieldID)=='CURRENT_TIMESTAMP')
{
sql = "INSERT INTO itemData VALUES (?,?,CURRENT_TIMESTAMP)";
}
else if (Scholar.ItemFields.isInteger(fieldID)){
sqlValues.push({'int':this.getField(fieldID)});
}
else {
@ -3251,9 +3270,10 @@ Scholar.CachedTypes = function(){
}
function getTypes(){
function getTypes(where){
return Scholar.DB.query('SELECT ' + this._idCol + ' AS id, '
+ this._nameCol + ' AS name FROM ' + this._table + ' order BY ' + this._nameCol);
+ this._nameCol + ' AS name FROM ' + this._table
+ (where ? ' ' + where : '') + ' ORDER BY ' + this._nameCol);
}
@ -3295,10 +3315,26 @@ Scholar.ItemTypes = new function(){
Scholar.CachedTypes.apply(this, arguments);
this.constructor.prototype = new Scholar.CachedTypes();
this.getPrimaryTypes = getPrimaryTypes;
this.getSecondaryTypes = getSecondaryTypes;
this.getHiddenTypes = getHiddenTypes;
this._typeDesc = 'item type';
this._idCol = 'itemTypeID';
this._nameCol = 'typeName';
this._table = 'itemTypes';
function getPrimaryTypes(){
return this.getTypes('WHERE display=2');
}
function getSecondaryTypes(){
return this.getTypes('WHERE display=1');
}
function getHiddenTypes(){
return this.getTypes('WHERE display=0');
}
}

View file

@ -653,6 +653,11 @@ Scholar.Date = new function(){
timeparts = [false, false, false];
}
// Invalid date part
if (dateparts.length==1){
return false;
}
if (isUTC){
return new Date(Date.UTC(dateparts[0], dateparts[1]-1, dateparts[2],
timeparts[0], timeparts[1], timeparts[2]));

View file

@ -19,6 +19,8 @@
<!ENTITY collections.name_column "Collections">
<!ENTITY toolbar.newItem.label "New Item">
<!ENTITY toolbar.moreItemTypes.label "More">
<!ENTITY toolbar.newItemFromPage.label "Create New Item from Current Page">
<!ENTITY toolbar.removeItem.label "Remove Item...">
<!ENTITY toolbar.newCollection.label "New Collection...">
<!ENTITY toolbar.newSavedSearch.label "New Saved Search...">
@ -35,16 +37,17 @@
<!ENTITY toolbar.createBibSavedSearch.label "Create Bibliography From Saved Search...">
<!ENTITY toolbar.search.label "Search:">
<!ENTITY toolbar.fullscreen.tooltip "Toggle Fullscreen Mode">
<!ENTITY toolbar.openurl.label "Find in your library's catalog">
<!ENTITY toolbar.goToURL.label "View">
<!ENTITY toolbar.goToURL.tooltip "Go to this item online">
<!ENTITY toolbar.openURL.label "Locate">
<!ENTITY toolbar.openURL.tooltip "Find through your local library">
<!ENTITY item.add "Add">
<!ENTITY toolbar.note.standalone "New Standalone Note">
<!ENTITY toolbar.attachment.standalone "New Standalone Attachment">
<!ENTITY toolbar.attachment.add "Add File...">
<!ENTITY toolbar.attachment.linked "Add Link to File...">
<!ENTITY toolbar.attachment.snapshot "Add Snapshot of Current Page">
<!ENTITY toolbar.attachment.weblink "Add Link to Current Page">
<!ENTITY toolbar.attachment.linked "Link to File...">
<!ENTITY toolbar.attachment.add "Store Copy of File...">
<!ENTITY toolbar.attachment.snapshot "Take Snapshot of Current Page">
<!ENTITY selectitems.title "Select Items">
<!ENTITY selectitems.intro.label "Select which items you'd like to add to your library">

View file

@ -52,11 +52,6 @@
height: 24px;
}
#scholar-pane toolbar toolbarbutton
{
}
#scholar-pane toolbar .toggler
{
margin: 4px;
@ -84,7 +79,7 @@
/* These fix a rendering bug in Fx2.0b2 */
#scholar-pane .toolbarbutton-text
#scholar-pane toolbarbutton .toolbarbutton-text
{
margin:0 2px;
}
@ -108,16 +103,21 @@
list-style-image: url('chrome://scholar/skin/toolbar-item-add.png');
}
#tb-item-from-page
{
list-style-image: url('chrome://scholar/skin/toolbar-item-from-page.png');
}
#tb-snapshot-page
{
list-style-image: url('chrome://scholar/skin/toolbar-snapshot-add.png');
}
#tb-note-add
{
list-style-image: url('chrome://scholar/skin/toolbar-note-add.png');
}
#tb-attachment-add
{
list-style-image: url('chrome://scholar/skin/item-attachments-add.png');
}
#tb-item-attachments-file
{
list-style-image: url('chrome://scholar/skin/treeitem-attachment-file.png');
@ -178,9 +178,15 @@
list-style-image: url('chrome://scholar/skin/search-cancel-active.png');
}
#tb-openurl
#tb-go-to-url, #tb-openurl
{
list-style-image: url('chrome://scholar/skin/toolbar-openurl.png');
list-style-image: url('chrome://scholar/skin/toolbar-go-arrow.png');
-moz-box-direction: reverse;
}
#tb-go-to-url[disabled=true], #tb-openurl[disabled=true]
{
list-style-image: url('chrome://scholar/skin/toolbar-go-arrow-disabled.png');
}
#scholar-view-item > vbox

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

View file

Before

Width:  |  Height:  |  Size: 410 B

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 635 B

After

Width:  |  Height:  |  Size: 985 B

View file

@ -1,4 +1,4 @@
-- 2
-- 3
-- This file creates system tables that can be safely wiped and reinitialized
-- at any time, as long as existing ids are preserved.
@ -9,7 +9,8 @@
CREATE TABLE itemTypes (
itemTypeID INTEGER PRIMARY KEY,
typeName TEXT,
templateItemTypeID INT
templateItemTypeID INT,
display INT DEFAULT 1 -- 0 == hide, 1 == display, 2 == primary
);
-- Describes various types of fields and their format restrictions,
@ -130,20 +131,20 @@
INSERT INTO "fieldFormats" VALUES(2, '[0-9]*', 1);
INSERT INTO "fieldFormats" VALUES(3, '[0-9]{4}', 1);
INSERT INTO itemTypes VALUES (1,'note',NULL);
INSERT INTO itemTypes VALUES (2,'book',NULL);
INSERT INTO itemTypes VALUES (3,'bookSection',2);
INSERT INTO itemTypes VALUES (4,'journalArticle',NULL);
INSERT INTO itemTypes VALUES (5,'magazineArticle',NULL);
INSERT INTO itemTypes VALUES (6,'newspaperArticle',NULL);
INSERT INTO itemTypes VALUES (7,'thesis',NULL);
INSERT INTO itemTypes VALUES (8,'letter',NULL);
INSERT INTO itemTypes VALUES (9,'manuscript',NULL);
INSERT INTO itemTypes VALUES (10,'interview',NULL);
INSERT INTO itemTypes VALUES (11,'film',NULL);
INSERT INTO itemTypes VALUES (12,'artwork',NULL);
INSERT INTO itemTypes VALUES (13,'website',NULL);
INSERT INTO itemTypes VALUES (14,'attachment',NULL);
INSERT INTO itemTypes VALUES (1,'note',NULL,2);
INSERT INTO itemTypes VALUES (2,'book',NULL,2);
INSERT INTO itemTypes VALUES (3,'bookSection',2,2);
INSERT INTO itemTypes VALUES (4,'journalArticle',NULL,2);
INSERT INTO itemTypes VALUES (5,'magazineArticle',NULL,2);
INSERT INTO itemTypes VALUES (6,'newspaperArticle',NULL,2);
INSERT INTO itemTypes VALUES (7,'thesis',NULL,1);
INSERT INTO itemTypes VALUES (8,'letter',NULL,1);
INSERT INTO itemTypes VALUES (9,'manuscript',NULL,1);
INSERT INTO itemTypes VALUES (10,'interview',NULL,1);
INSERT INTO itemTypes VALUES (11,'film',NULL,1);
INSERT INTO itemTypes VALUES (12,'artwork',NULL,1);
INSERT INTO itemTypes VALUES (13,'website',NULL,2);
INSERT INTO itemTypes VALUES (14,'attachment',NULL,0);
INSERT INTO fields VALUES (1,'url',NULL);
INSERT INTO fields VALUES (2,'rights',NULL);

View file

@ -1,4 +1,4 @@
-- 3
-- 4
-- This file creates tables containing user-specific data -- any changes
-- to existing tables made here must be mirrored in transition steps in
@ -30,6 +30,13 @@ CREATE TABLE IF NOT EXISTS userItemTypes (
PRIMARY KEY (itemTypeID)
);
-- Control visibility and placement of system and user item types
CREATE TABLE IF NOT EXISTS userItemTypeMask (
itemTypeID INT,
display INT, -- 0 == hide, 1 == show, 2 == primary
PRIMARY KEY (itemTypeID)
);
-- User-defined fields
CREATE TABLE IF NOT EXISTS userFields (
userFieldID INT,