Added google sheet feature and moved features to the export drop-down (#2458)
* fixed minor typos * Added google sheet feature and moved features to the export drop-down menu * minor change * removed redundant text and moved code and translations into their respective extensions
This commit is contained in:
parent
a915f9847f
commit
cff88e6267
@ -35,11 +35,14 @@
|
|||||||
"gdata-source/title": "Title",
|
"gdata-source/title": "Title",
|
||||||
"gdata-source/authors": "Authors",
|
"gdata-source/authors": "Authors",
|
||||||
"gdata-source/updated": "Updated",
|
"gdata-source/updated": "Updated",
|
||||||
|
"gdata-exporter/export-to-google-drive": "OpenRefine project archive to Google Drive...",
|
||||||
|
"gdata-exporter/google-sheets": "Google Sheets...",
|
||||||
"gdata-exporter/uploading": "Uploading…",
|
"gdata-exporter/uploading": "Uploading…",
|
||||||
"gdata-exporter/upload-error": "Upload error: ",
|
"gdata-exporter/upload-error": "Upload error: ",
|
||||||
"gdata-exporter/upload-success": "Project was uploaded successfully to Google Drive ",
|
"gdata-exporter/upload-google-drive-success": "Project was uploaded successfully to Google Drive ",
|
||||||
"gdata-exporter/new-spreadsheet": "A new Google spreadsheet",
|
"gdata-exporter/new-spreadsheet": "A new Google spreadsheet",
|
||||||
"gdata-exporter/enter-spreadsheet": "Enter a name for the new Google spreadsheet",
|
"gdata-exporter/enter-spreadsheet": "Enter a name for the new Google spreadsheet",
|
||||||
|
"gdata-exporter/upload-google-sheets-success": "Project was uploaded successfully to Google Drive ",
|
||||||
"gdata-exporter/enter-filename": "Enter a file name for the project export in Google Drive",
|
"gdata-exporter/enter-filename": "Enter a file name for the project export in Google Drive",
|
||||||
"gdata-auth/authorize-label": "OpenRefine - Authorization",
|
"gdata-auth/authorize-label": "OpenRefine - Authorization",
|
||||||
"gdata-auth/authorized-label": "Authorization process completed. Close this window and return to OpenRefine."
|
"gdata-auth/authorized-label": "Authorization process completed. Close this window and return to OpenRefine."
|
||||||
|
@ -48,6 +48,20 @@ $.ajax({
|
|||||||
$.i18n().load(dictionary, lang);
|
$.i18n().load(dictionary, lang);
|
||||||
// End internationalization
|
// End internationalization
|
||||||
|
|
||||||
|
ExporterManager.MenuItems.push({});
|
||||||
|
ExporterManager.MenuItems.push(
|
||||||
|
{
|
||||||
|
"id": "export-to-google-drive",
|
||||||
|
"label": $.i18n('gdata-exporter/export-to-google-drive'),
|
||||||
|
"click": function () { ExporterManager.handlers.exportProjectToGoogleDrive(); }
|
||||||
|
});
|
||||||
|
ExporterManager.MenuItems.push(
|
||||||
|
{
|
||||||
|
"id": "export-to-google-sheets",
|
||||||
|
"label": $.i18n('gdata-exporter/google-sheets'),
|
||||||
|
"click": function () { ExporterManager.handlers.exportProjectToGoogleSheets(); }
|
||||||
|
});
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var handleUpload = function(options, exportAllRows, onDone, prompt) {
|
var handleUpload = function(options, exportAllRows, onDone, prompt) {
|
||||||
var doUpload = function() {
|
var doUpload = function() {
|
||||||
@ -84,7 +98,7 @@ $.i18n().load(dictionary, lang);
|
|||||||
GdataExtension.showAuthorizationDialog(doUpload);
|
GdataExtension.showAuthorizationDialog(doUpload);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CustomTabularExporterDialog.uploadTargets.push({
|
CustomTabularExporterDialog.uploadTargets.push({
|
||||||
id: 'gdata/google-spreadsheet',
|
id: 'gdata/google-spreadsheet',
|
||||||
label: $.i18n('gdata-exporter/new-spreadsheet'),
|
label: $.i18n('gdata-exporter/new-spreadsheet'),
|
||||||
@ -93,3 +107,71 @@ $.i18n().load(dictionary, lang);
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
ExporterManager.handlers.exportProjectToGoogleDrive = function () {
|
||||||
|
var doExportToGoogleDrive = function () {
|
||||||
|
var name = window.prompt($.i18n('gdata-exporter/enter-filename'), theProject.metadata.name);
|
||||||
|
if (name) {
|
||||||
|
var dismiss = DialogSystem.showBusy($.i18n('gdata-exporter/uploading'));
|
||||||
|
Refine.postCSRF(
|
||||||
|
"command/gdata/upload",
|
||||||
|
{
|
||||||
|
"project": theProject.id,
|
||||||
|
"name": name,
|
||||||
|
"format": "raw/openrefine-project"
|
||||||
|
},
|
||||||
|
function (o) {
|
||||||
|
dismiss();
|
||||||
|
|
||||||
|
if (o.url) {
|
||||||
|
alert($.i18n('gdata-exporter/upload-google-drive-success'));
|
||||||
|
} else {
|
||||||
|
alert($.i18n('gdata-exporter/upload-error') + o.message)
|
||||||
|
}
|
||||||
|
onDone();
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (GdataExtension.isAuthorized()) {
|
||||||
|
doExportToGoogleDrive();
|
||||||
|
} else {
|
||||||
|
GdataExtension.showAuthorizationDialog(doExportToGoogleDrive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ExporterManager.handlers.exportProjectToGoogleSheets = function () {
|
||||||
|
var doExportToGoogleSheets = function () {
|
||||||
|
var name = window.prompt($.i18n('gdata-exporter/enter-spreadsheet'), theProject.metadata.name);
|
||||||
|
if (name) {
|
||||||
|
var dismiss = DialogSystem.showBusy($.i18n('gdata-exporter/uploading'));
|
||||||
|
Refine.postCSRF(
|
||||||
|
"command/gdata/upload",
|
||||||
|
{
|
||||||
|
"project": theProject.id,
|
||||||
|
"name": name,
|
||||||
|
"format": "gdata/google-spreadsheet"
|
||||||
|
},
|
||||||
|
function (o) {
|
||||||
|
dismiss();
|
||||||
|
|
||||||
|
if (o.url) {
|
||||||
|
alert($.i18n('gdata-exporter/upload-google-sheets-success'));
|
||||||
|
} else {
|
||||||
|
alert($.i18n('gdata-exporter/upload-error') + o.message)
|
||||||
|
}
|
||||||
|
onDone();
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (GdataExtension.isAuthorized()) {
|
||||||
|
doExportToGoogleSheets();
|
||||||
|
} else {
|
||||||
|
GdataExtension.showAuthorizationDialog(doExportToGoogleSheets);
|
||||||
|
}
|
||||||
|
}
|
@ -3,10 +3,11 @@
|
|||||||
"wikidata-extension/edit-wikidata-schema": "Edit Wikidata schema",
|
"wikidata-extension/edit-wikidata-schema": "Edit Wikidata schema",
|
||||||
"wikidata-extension/import-wikidata-schema": "Import schema",
|
"wikidata-extension/import-wikidata-schema": "Import schema",
|
||||||
"wikidata-extension/manage-wikidata-account": "Manage Wikidata account",
|
"wikidata-extension/manage-wikidata-account": "Manage Wikidata account",
|
||||||
"wikidata-extension/perform-edits-on-wikidata": "Upload edits to Wikidata",
|
"wikidata-extension/perform-edits-on-wikidata": "Wikidata edits...",
|
||||||
"wikidata-extension/export-to-qs": "Export to QuickStatements",
|
"wikidata-extension/export-to-qs": "QuickStatements file...",
|
||||||
"wikidata-extension/export-schema": "Export schema",
|
"wikidata-extension/export-schema": "Export schema",
|
||||||
"wikidata-extension/export-wikidata-schema": "Export Wikidata schema",
|
"wikidata-extension/export-wikidata-schema": "Export Wikidata schema",
|
||||||
|
"wikidata-extension/wikidata-schema": "Wikidata schema",
|
||||||
"wikidata-extension/quickstatements-export-name": "QuickStatements",
|
"wikidata-extension/quickstatements-export-name": "QuickStatements",
|
||||||
"wikidata-schema/dialog-header": "Align to Wikidata",
|
"wikidata-schema/dialog-header": "Align to Wikidata",
|
||||||
"wikidata-schema/dialog-explanation": "The Wikidata schema below specifies how your tabular data will be transformed into Wikidata edits. You can drag and drop the column names below in most input boxes: for each row, edits will be generated with the values in these columns.",
|
"wikidata-schema/dialog-explanation": "The Wikidata schema below specifies how your tabular data will be transformed into Wikidata edits. You can drag and drop the column names below in most input boxes: for each row, edits will be generated with the values in these columns.",
|
||||||
|
@ -33,7 +33,7 @@ ExporterManager.MenuItems.push(
|
|||||||
ExporterManager.MenuItems.push(
|
ExporterManager.MenuItems.push(
|
||||||
{
|
{
|
||||||
id:"exportWikibaseSchema",
|
id:"exportWikibaseSchema",
|
||||||
label: $.i18n('wikidata-extension/export-wikidata-schema'),
|
label: $.i18n('wikidata-extension/wikidata-schema'),
|
||||||
click: function() { WikibaseExporterMenuBar.checkSchemaAndExport("wikibase-schema"); }
|
click: function() { WikibaseExporterMenuBar.checkSchemaAndExport("wikibase-schema"); }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -284,8 +284,7 @@
|
|||||||
"core-dialogs/for-include-if-exist-drop-stmt-checkbox": "Include 'IF EXISTS' in DROP statement",
|
"core-dialogs/for-include-if-exist-drop-stmt-checkbox": "Include 'IF EXISTS' in DROP statement",
|
||||||
"core-dialogs/for-null-cell-value-to-empty-str-label": "Convert null value to NULL in INSERT",
|
"core-dialogs/for-null-cell-value-to-empty-str-label": "Convert null value to NULL in INSERT",
|
||||||
"core-dialogs/choose-export-destination": "Please choose the destination for project export",
|
"core-dialogs/choose-export-destination": "Please choose the destination for project export",
|
||||||
"core-dialogs/export-to-local": "Export to local",
|
"core-dialogs/export-to-local": "OpenRefine project archive to file",
|
||||||
"core-dialogs/export-to-google-drive": "Export to Google Drive",
|
|
||||||
"core-facets/remove-facet": "Remove this facet",
|
"core-facets/remove-facet": "Remove this facet",
|
||||||
"core-facets/reset": "reset",
|
"core-facets/reset": "reset",
|
||||||
"core-facets/invert": "invert",
|
"core-facets/invert": "invert",
|
||||||
|
@ -38,9 +38,9 @@ ExporterManager.handlers = {};
|
|||||||
|
|
||||||
ExporterManager.MenuItems = [
|
ExporterManager.MenuItems = [
|
||||||
{
|
{
|
||||||
"id" : "core/export-project",
|
"id": "core/export-local",
|
||||||
"label": $.i18n('core-project/export-project'),
|
"label": $.i18n('core-dialogs/export-to-local'),
|
||||||
"click": function() { ExporterManager.handlers.exportProject(); }
|
"click": function () { ExporterManager.handlers.exportProjectToLocal(); }
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
@ -80,9 +80,9 @@ ExporterManager.MenuItems = [
|
|||||||
"click": function() { new CustomTabularExporterDialog(); }
|
"click": function() { new CustomTabularExporterDialog(); }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "core/export-sql",
|
"id" : "core/export-sql",
|
||||||
"label": $.i18n('core-project/sql-export'),
|
"label": $.i18n('core-project/sql-export'),
|
||||||
"click": function() { new SqlExporterDialog(); }
|
"click": function() { new SqlExporterDialog(); }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "core/export-templating",
|
"id" : "core/export-templating",
|
||||||
@ -115,7 +115,7 @@ ExporterManager.handlers.exportRows = function(format, ext) {
|
|||||||
.attr("name", "contentType")
|
.attr("name", "contentType")
|
||||||
.attr("value", "application/x-unknown") // force download
|
.attr("value", "application/x-unknown") // force download
|
||||||
.appendTo(form);
|
.appendTo(form);
|
||||||
|
|
||||||
document.body.appendChild(form);
|
document.body.appendChild(form);
|
||||||
|
|
||||||
window.open(" ", "refine-export");
|
window.open(" ", "refine-export");
|
||||||
@ -150,90 +150,27 @@ ExporterManager.prepareExportRowsForm = function(format, includeEngine, ext) {
|
|||||||
.attr("value", JSON.stringify(ui.browsingEngine.getJSON()))
|
.attr("value", JSON.stringify(ui.browsingEngine.getJSON()))
|
||||||
.appendTo(form);
|
.appendTo(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
return form;
|
return form;
|
||||||
};
|
};
|
||||||
|
|
||||||
ExporterManager.handlers.exportProject = function() {
|
ExporterManager.handlers.exportProjectToLocal = function() {
|
||||||
var name = ExporterManager.stripNonFileChars(theProject.metadata.name);
|
var name = ExporterManager.stripNonFileChars(theProject.metadata.name);
|
||||||
// dialog
|
var form = document.createElement("form");
|
||||||
var dialog = $(DOM.loadHTML("core", "scripts/dialogs/export-project-dialog.html"));
|
$(form)
|
||||||
var _elmts = DOM.bind(dialog);
|
.css("display", "none")
|
||||||
|
.attr("method", "post")
|
||||||
_elmts.dialogHeader.html($.i18n('core-dialogs/choose-export-destination'));
|
.attr("action", "command/core/export-project/" + name + ".openrefine.tar.gz")
|
||||||
_elmts.toLocalRadio.html($.i18n('core-dialogs/export-to-local'));
|
.attr("target", "refine-export");
|
||||||
_elmts.toGoogleDriveRadio.html($.i18n('core-dialogs/export-to-google-drive'));
|
$('<input />')
|
||||||
_elmts.exportButton.html($.i18n('core-buttons/export'));
|
.attr("name", "project")
|
||||||
_elmts.cancelButton.html($.i18n('core-buttons/cancel'));
|
.attr("value", theProject.id)
|
||||||
|
.appendTo(form);
|
||||||
_elmts.exportButton.click(function() {
|
|
||||||
if ($("input[name='export-destination']")[0].checked) {
|
|
||||||
exportToLocal(name);
|
|
||||||
} else {
|
|
||||||
exportToGoogleDrive(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
DialogSystem.dismissAll();
|
|
||||||
});
|
|
||||||
|
|
||||||
_elmts.cancelButton.click(function() { DialogSystem.dismissAll(); });
|
|
||||||
|
|
||||||
DialogSystem.showDialog(dialog);
|
|
||||||
|
|
||||||
// save to google drive
|
|
||||||
var doExportToGoogleDrive = function() {
|
|
||||||
var name = window.prompt($.i18n('gdata-exporter/enter-filename'), theProject.metadata.name);
|
|
||||||
if (name) {
|
|
||||||
var dismiss = DialogSystem.showBusy($.i18n('gdata-exporter/uploading'));
|
|
||||||
Refine.postCSRF(
|
|
||||||
"command/gdata/upload",
|
|
||||||
{
|
|
||||||
"project" : theProject.id,
|
|
||||||
"name" : name,
|
|
||||||
"format" : "raw/openrefine-project"
|
|
||||||
},
|
|
||||||
function(o) {
|
|
||||||
dismiss();
|
|
||||||
|
|
||||||
if (o.url) {
|
document.body.appendChild(form);
|
||||||
alert($.i18n('gdata-exporter/upload-success'));
|
|
||||||
} else {
|
|
||||||
alert($.i18n('gdata-exporter/upload-error') + o.message)
|
|
||||||
}
|
|
||||||
onDone();
|
|
||||||
},
|
|
||||||
"json"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function exportToGoogleDrive(name) {
|
window.open(" ", "refine-export");
|
||||||
if (GdataExtension.isAuthorized()) {
|
form.submit();
|
||||||
doExportToGoogleDrive();
|
|
||||||
} else {
|
document.body.removeChild(form);
|
||||||
GdataExtension.showAuthorizationDialog(doExportToGoogleDrive);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// save to local
|
|
||||||
function exportToLocal(name) {
|
|
||||||
var form = document.createElement("form");
|
|
||||||
$(form)
|
|
||||||
.css("display", "none")
|
|
||||||
.attr("method", "post")
|
|
||||||
.attr("action", "command/core/export-project/" + name + ".openrefine.tar.gz")
|
|
||||||
.attr("target", "refine-export");
|
|
||||||
$('<input />')
|
|
||||||
.attr("name", "project")
|
|
||||||
.attr("value", theProject.id)
|
|
||||||
.appendTo(form);
|
|
||||||
|
|
||||||
document.body.appendChild(form);
|
|
||||||
|
|
||||||
window.open(" ", "refine-export");
|
|
||||||
form.submit();
|
|
||||||
|
|
||||||
document.body.removeChild(form);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user