www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 4fefaf1edff5729eab34919c965ff3c615ef73ab
parent bec5e78417c5e749a639743d985ca8b503aece47
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sat, 26 Aug 2006 12:05:16 +0000

Added method to generate SQL in Item Type Manager for easier export


Diffstat:
Mchrome/chromeFiles/content/scholar/admin/itemTypeManager.js | 36++++++++++++++++++++++++++++++++++++
Mchrome/chromeFiles/content/scholar/admin/itemTypeManager.xul | 11+++++++----
2 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/admin/itemTypeManager.js b/chrome/chromeFiles/content/scholar/admin/itemTypeManager.js @@ -10,6 +10,7 @@ var Scholar_ItemTypeManager = new function(){ this.handleAddField = handleAddField; this.removeField = removeField; this.removeType = removeType; + this.createSQLDump = createSQLDump; var _typesList; var _fieldsList; @@ -275,6 +276,41 @@ var Scholar_ItemTypeManager = new function(){ } + function createSQLDump(){ + var types = Scholar.DB.query("SELECT * FROM itemTypes ORDER BY itemTypeID"); + var fields = Scholar.DB.query("SELECT * FROM fields ORDER BY fieldID"); + var itemTypeFields = Scholar.DB.query("SELECT * FROM itemTypeFields ORDER BY itemTypeID, orderIndex"); + + var prefix = " "; + var sql = ''; + + for (var i in types){ + sql += prefix + "INSERT INTO itemTypes VALUES (" + + types[i]['itemTypeID'] + ",'" + types[i]['typeName'] + "');\n" + } + + sql += "\n"; + + for (var i in fields){ + sql += prefix + "INSERT INTO fields VALUES (" + + fields[i]['fieldID'] + ",'" + fields[i]['fieldName'] + "'," + + (fields[i]['fieldFormatID'] ? fields[i]['fieldFormatID'] : 'NULL') + + ");\n"; + } + + sql += "\n"; + + for (var i in itemTypeFields){ + sql += prefix + "INSERT INTO itemTypeFields VALUES (" + + itemTypeFields[i]['itemTypeID'] + "," + itemTypeFields[i]['fieldID'] + "," + + (itemTypeFields[i]['hide'] ? itemTypeFields[i]['hide'] : 'NULL') + "," + + itemTypeFields[i]['orderIndex'] + ");\n"; + } + + return sql; + } + + /** * Return the currently selected item type **/ diff --git a/chrome/chromeFiles/content/scholar/admin/itemTypeManager.xul b/chrome/chromeFiles/content/scholar/admin/itemTypeManager.xul @@ -25,7 +25,7 @@ <vbox> - <hbox style="height:30em"> + <hbox style="height:25em"> <listbox id="item-type-list" seltype="single" context="scholar-remove-type-menu" onselect="Scholar_ItemTypeManager.handleTypeSelect()"> <listhead> @@ -63,14 +63,17 @@ </hbox> </hbox> - <label style="margin:1em 0; color:red" id="status-line"></label> + <label style="margin:.5em 0; color:red" id="status-line"></label> - <description style="font-size:small; margin:.5em 0"> + <description style="font-size:small; margin:.4em 0 .3em"> Double-click a field to add it to or remove it from the currently selected item type. </description> - <description style="font-size:small; margin:.5em 0"> + <description style="font-size:small; margin:.3em 0 .8em"> Hit Return on a mapped field to toggle its default visibility. (Light blue fields are hidden.) </description> + + <button label="Generate SQL" oncommand="document.getElementById('sql-dump').value=Scholar_ItemTypeManager.createSQLDump()"/> + <textbox id="sql-dump" multiline="true" cols="100" rows="6"/> </vbox> </window>