From e1a8e44a02700236d582c4b88c829a7faf41340f Mon Sep 17 00:00:00 2001 From: Cora Johnson-Roberson Date: Wed, 18 Nov 2015 11:17:29 -0800 Subject: [PATCH] export clusters button added --- .../modules/core/langs/translation-default.json | 1 + .../modules/core/langs/translation-en.json | 1 + .../core/scripts/dialogs/clustering-dialog.html | 1 + .../core/scripts/dialogs/clustering-dialog.js | 16 ++++++++++++++++ 4 files changed, 19 insertions(+) diff --git a/main/webapp/modules/core/langs/translation-default.json b/main/webapp/modules/core/langs/translation-default.json index 425157c9f..cb6a7cf35 100644 --- a/main/webapp/modules/core/langs/translation-default.json +++ b/main/webapp/modules/core/langs/translation-default.json @@ -644,6 +644,7 @@ "pick-record": "Pick Record Elements", "merge-cluster": "Merge Selected & Re-Cluster", "merge-close": "Merge Selected & Close", + "export-cluster": "Export Clusters", "close": "Close", "reset-template": "Reset Template", "export": "Export", diff --git a/main/webapp/modules/core/langs/translation-en.json b/main/webapp/modules/core/langs/translation-en.json index ab8737628..ccd67afa2 100644 --- a/main/webapp/modules/core/langs/translation-en.json +++ b/main/webapp/modules/core/langs/translation-en.json @@ -644,6 +644,7 @@ "pick-record": "Pick Record Elements", "merge-cluster": "Merge Selected & Re-Cluster", "merge-close": "Merge Selected & Close", + "export-cluster": "Export Clusters", "close": "Close", "reset-template": "Reset Template", "export": "Export", diff --git a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.html b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.html index 3e23fbf43..de8a6e3ca 100644 --- a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.html +++ b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.html @@ -56,6 +56,7 @@ + diff --git a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js index 4b3951f81..13bb58aa1 100644 --- a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js @@ -69,6 +69,7 @@ ClusteringDialog.prototype._createDialog = function() { this._elmts.or_dialog_blockChars.html($.i18n._('core-dialogs')["block-chars"]); this._elmts.selectAllButton.html($.i18n._('core-buttons')["select-all"]); this._elmts.deselectAllButton.html($.i18n._('core-buttons')["unselect-all"]); + this._elmts.exportClusterButton.html($.i18n._('core-buttons')["export-cluster"]); this._elmts.applyReClusterButton.html($.i18n._('core-buttons')["merge-cluster"]); this._elmts.applyCloseButton.html($.i18n._('core-buttons')["merge-close"]); this._elmts.closeButton.html($.i18n._('core-buttons')["close"]); @@ -121,6 +122,7 @@ ClusteringDialog.prototype._createDialog = function() { this._elmts.selectAllButton.click(function() { self._selectAll(); }); this._elmts.deselectAllButton.click(function() { self._deselectAll(); }); + this._elmts.exportClusterButton.click(function() { self._onExportCluster(); }); this._elmts.applyReClusterButton.click(function() { self._onApplyReCluster(); }); this._elmts.applyCloseButton.click(function() { self._onApplyClose(); }); this._elmts.closeButton.click(function() { self._dismiss(); }); @@ -333,6 +335,11 @@ ClusteringDialog.prototype._onApplyReCluster = function() { }); }; +ClusteringDialog.prototype._onExportCluster = function() { + var self = this; + self._export(); +}; + ClusteringDialog.prototype._apply = function(onDone) { var clusters = this._getRestrictedClusters(); var edits = []; @@ -373,6 +380,15 @@ ClusteringDialog.prototype._apply = function(onDone) { } }; +ClusteringDialog.prototype._export = function() { + var clusters = this._getRestrictedClusters(); + var data = "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(clusters)); + var link=document.createElement('a'); + link.href='data:' + data; + link.download="clusters" + (new Date()).toISOString() + ".json"; + link.click(); +}; + ClusteringDialog.prototype._dismiss = function() { DialogSystem.dismissUntil(this._level - 1); };