-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GDB-9969 import view help messages (#1328)
* Reimplemented help message. * Add import view persistence service backed by the local storage. * Add upload limit file size info alert. * Removed the watcher for the opened tab and replaced with explicit call to a new function `openTab(tabId)` which now handles the tab initialization. * Fix fat button text and icons align when on lower resolutions. * Split tests for user data tab. * Implemented additional tests for the help messages. * Implemented persistence for the help message on the empty state. Added more tests. * Add more code documentation * Skip copy to clipboard check test
- Loading branch information
1 parent
72d4cf0
commit 6f3ddc4
Showing
24 changed files
with
1,478 additions
and
806 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
src/js/angular/core/directives/copy-to-clipboard/copy-to-clipboard.directive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* @ngdoc directive | ||
* @name copyToClipboard | ||
* @module graphdb.framework.core.directives.copytoclipboard.copytoclipboard | ||
* @restrict E | ||
* | ||
* @description | ||
* `copyToClipboard` is a directive that creates a button which, when clicked, copies a specific text to the clipboard. | ||
* The directive uses an isolated scope with a single property, `tooltipText`, which is bound to the `tooltipText` attribute of the element where the directive is used. | ||
* The tooltip text is translated using the `$translate` service. | ||
* The button also has an `ng-click` directive that triggers the `copyToClipboard` function when the button is clicked. | ||
* | ||
* @param {string} tooltipText - The text to be displayed as a tooltip when hovering over the button. | ||
* | ||
* @example | ||
* <copy-to-clipboard tooltip-text="Your tooltip text here"></copy-to-clipboard> | ||
*/ | ||
angular | ||
.module('graphdb.framework.core.directives.copytoclipboard.copytoclipboard', []) | ||
.directive('copyToClipboard', copyToClipboard); | ||
|
||
copyToClipboard.$inject = ['$translate', 'toastr']; | ||
|
||
/** | ||
* @ngdoc method | ||
* @name copyToClipboard | ||
* @methodOf graphdb.framework.core.directives.copytoclipboard.copytoclipboard | ||
* | ||
* @description | ||
* The `copyToClipboard` function is the link function of the directive. | ||
* It defines a `copyToClipboard` function in the directive's scope that gets the text from the element with the class `copyable` that is a child of the directive's parent element. | ||
* It then uses the `navigator.clipboard.writeText` function to write this text to the clipboard. | ||
* If the text is successfully written to the clipboard, a success message is displayed using the `toastr` service. | ||
* If an error occurs, the error is logged to the console. | ||
* | ||
* @param {Object} $scope - The directive's isolated scope. | ||
* @param {Object} element - The jqLite-wrapped element that this directive matches. | ||
*/ | ||
function copyToClipboard($translate, toastr) { | ||
return { | ||
template: '<button class="copy-btn" gdb-tooltip="{{tooltipText | translate}}" ng-click="copyToClipboard()"><span class="icon-copy"></span></button>', | ||
restrict: 'E', | ||
scope: { | ||
tooltipText: '@' | ||
}, | ||
link: function ($scope, element) { | ||
$scope.copyToClipboard = function() { | ||
const textToCopy = element.parent().find('.copyable').text(); | ||
navigator.clipboard.writeText(textToCopy).then(() => { | ||
toastr.success($translate.instant('import.help.messages.copied_to_clipboard')); | ||
}, (err) => { | ||
console.error('Could not copy text: ', err); | ||
}); | ||
}; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.