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/authors": "Authors",
|
||||
"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/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/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-auth/authorize-label": "OpenRefine - Authorization",
|
||||
"gdata-auth/authorized-label": "Authorization process completed. Close this window and return to OpenRefine."
|
||||
|
@ -48,6 +48,20 @@ $.ajax({
|
||||
$.i18n().load(dictionary, lang);
|
||||
// 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() {
|
||||
var handleUpload = function(options, exportAllRows, onDone, prompt) {
|
||||
var doUpload = function() {
|
||||
@ -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/import-wikidata-schema": "Import schema",
|
||||
"wikidata-extension/manage-wikidata-account": "Manage Wikidata account",
|
||||
"wikidata-extension/perform-edits-on-wikidata": "Upload edits to Wikidata",
|
||||
"wikidata-extension/export-to-qs": "Export to QuickStatements",
|
||||
"wikidata-extension/perform-edits-on-wikidata": "Wikidata edits...",
|
||||
"wikidata-extension/export-to-qs": "QuickStatements file...",
|
||||
"wikidata-extension/export-schema": "Export schema",
|
||||
"wikidata-extension/export-wikidata-schema": "Export Wikidata schema",
|
||||
"wikidata-extension/wikidata-schema": "Wikidata schema",
|
||||
"wikidata-extension/quickstatements-export-name": "QuickStatements",
|
||||
"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.",
|
||||
|
@ -33,7 +33,7 @@ ExporterManager.MenuItems.push(
|
||||
ExporterManager.MenuItems.push(
|
||||
{
|
||||
id:"exportWikibaseSchema",
|
||||
label: $.i18n('wikidata-extension/export-wikidata-schema'),
|
||||
label: $.i18n('wikidata-extension/wikidata-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-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/export-to-local": "Export to local",
|
||||
"core-dialogs/export-to-google-drive": "Export to Google Drive",
|
||||
"core-dialogs/export-to-local": "OpenRefine project archive to file",
|
||||
"core-facets/remove-facet": "Remove this facet",
|
||||
"core-facets/reset": "reset",
|
||||
"core-facets/invert": "invert",
|
||||
|
@ -38,9 +38,9 @@ ExporterManager.handlers = {};
|
||||
|
||||
ExporterManager.MenuItems = [
|
||||
{
|
||||
"id" : "core/export-project",
|
||||
"label": $.i18n('core-project/export-project'),
|
||||
"click": function() { ExporterManager.handlers.exportProject(); }
|
||||
"id": "core/export-local",
|
||||
"label": $.i18n('core-dialogs/export-to-local'),
|
||||
"click": function () { ExporterManager.handlers.exportProjectToLocal(); }
|
||||
},
|
||||
{},
|
||||
{
|
||||
@ -80,9 +80,9 @@ ExporterManager.MenuItems = [
|
||||
"click": function() { new CustomTabularExporterDialog(); }
|
||||
},
|
||||
{
|
||||
"id" : "core/export-sql",
|
||||
"label": $.i18n('core-project/sql-export'),
|
||||
"click": function() { new SqlExporterDialog(); }
|
||||
"id" : "core/export-sql",
|
||||
"label": $.i18n('core-project/sql-export'),
|
||||
"click": function() { new SqlExporterDialog(); }
|
||||
},
|
||||
{
|
||||
"id" : "core/export-templating",
|
||||
@ -154,86 +154,23 @@ ExporterManager.prepareExportRowsForm = function(format, includeEngine, ext) {
|
||||
return form;
|
||||
};
|
||||
|
||||
ExporterManager.handlers.exportProject = function() {
|
||||
ExporterManager.handlers.exportProjectToLocal = function() {
|
||||
var name = ExporterManager.stripNonFileChars(theProject.metadata.name);
|
||||
// dialog
|
||||
var dialog = $(DOM.loadHTML("core", "scripts/dialogs/export-project-dialog.html"));
|
||||
var _elmts = DOM.bind(dialog);
|
||||
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);
|
||||
|
||||
_elmts.dialogHeader.html($.i18n('core-dialogs/choose-export-destination'));
|
||||
_elmts.toLocalRadio.html($.i18n('core-dialogs/export-to-local'));
|
||||
_elmts.toGoogleDriveRadio.html($.i18n('core-dialogs/export-to-google-drive'));
|
||||
_elmts.exportButton.html($.i18n('core-buttons/export'));
|
||||
_elmts.cancelButton.html($.i18n('core-buttons/cancel'));
|
||||
document.body.appendChild(form);
|
||||
|
||||
_elmts.exportButton.click(function() {
|
||||
if ($("input[name='export-destination']")[0].checked) {
|
||||
exportToLocal(name);
|
||||
} else {
|
||||
exportToGoogleDrive(name);
|
||||
}
|
||||
window.open(" ", "refine-export");
|
||||
form.submit();
|
||||
|
||||
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) {
|
||||
alert($.i18n('gdata-exporter/upload-success'));
|
||||
} else {
|
||||
alert($.i18n('gdata-exporter/upload-error') + o.message)
|
||||
}
|
||||
onDone();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function exportToGoogleDrive(name) {
|
||||
if (GdataExtension.isAuthorized()) {
|
||||
doExportToGoogleDrive();
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
document.body.removeChild(form);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user