Added method to generate SQL in Item Type Manager for easier export
This commit is contained in:
parent
bec5e78417
commit
4fefaf1edf
2 changed files with 43 additions and 4 deletions
|
@ -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
|
||||
**/
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue