Skip to content

Commit

Permalink
Merge pull request #23 from dexterity42/development
Browse files Browse the repository at this point in the history
Copy link button (rework)
  • Loading branch information
dexterity42 authored Nov 20, 2021
2 parents 35c1ac7 + 21d9e54 commit cf42203
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.1.0

- Reworked options to open and copy link #17

## 2.0.1

- Added missing translations
Expand Down
2 changes: 2 additions & 0 deletions Migrations/shared-project-timesheets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
# bin/console kimai:bundle:shared-project-timesheets:install
# --------------------------------------------------------------------------------------------------

table_storage:
table_name: bundle_migration_shared_project_timesheets
migrations_paths:
KimaiPlugin\SharedProjectTimesheetsBundle\Migrations: var/plugins/SharedProjectTimesheetsBundle/Migrations
3 changes: 3 additions & 0 deletions Resources/translations/messages.de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ shared_project_timesheets:

manage:
title: Geteilte Projektzeiten
open: Öffnen
copy: Kopieren
copied: Kopiert
subtitle: Verwalten Sie Ihre geteilten Projektzeiten
create_link_label: Fügen Sie einen Eintrag hinzu, um Projektzeiten zu teilen
create:
Expand Down
3 changes: 3 additions & 0 deletions Resources/translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ shared_project_timesheets:

manage:
title: Shared project timesheets
open: Open
copy: Copy
copied: Copied
subtitle: Manage your shared project timesheets
create_link_label: Create an entry to share your project timesheets
create:
Expand Down
60 changes: 52 additions & 8 deletions Resources/views/manage/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,22 @@
<td class="{{ tables.data_table_column_class(tableName, columns, 'name') }}">{{ sharedProject.project.name }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'url') }}">
{% if sharedProject.shareKey %}
<a href="{{ url('view_shared_project_timesheets', {projectId: sharedProject.project.id, shareKey: sharedProject.shareKey}) }}"
target="_blank">
<i class="fa fa-link"></i>
<span class="hidden-xs hidden-sm hidden-md">
{{ url('view_shared_project_timesheets', {projectId: sharedProject.project.id, shareKey: sharedProject.shareKey}) }}
</span>
</a>
<div class="input-group">
<a class="input-group-addon btn btn-sm btn-default"
href="{{ url('view_shared_project_timesheets', {projectId: sharedProject.project.id, shareKey: sharedProject.shareKey}) }}"
target="_blank">
{{ 'shared_project_timesheets.manage.open' | trans }}
</a>
<input class="form-control input-sm hidden-xs hidden-sm hidden-md"
id="url{{ sharedProject.shareKey }}"
value="{{ url('view_shared_project_timesheets', {projectId: sharedProject.project.id, shareKey: sharedProject.shareKey}) }}"
onclick="select()" readonly/>
<a class="input-group-addon btn btn-sm btn-default copy-btn"
id="btn{{ sharedProject.shareKey }}"
data-clipboard-target="#url{{ sharedProject.shareKey }}">
{{ 'shared_project_timesheets.manage.copy' | trans }}
</a>
</div>
{% else %}
-
{% endif %}
Expand Down Expand Up @@ -99,4 +108,39 @@
padding-bottom: 1rem;
}
</style>
{% endblock %}
{% endblock %}

{% block javascripts %}
{{ parent() }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.min.js"
integrity="sha512-sIqUEnRn31BgngPmHt2JenzleDDsXwYO+iyvQ46Mw6RL+udAUZj2n/u/PGY80NxRxynO7R9xIGx5LEzw4INWJQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>

<script type="text/javascript">
$(function() {
$('.copy-btn').tooltip({
trigger: 'manual',
placement: 'bottom',
});
var clipboard = new ClipboardJS('.copy-btn');
var clipboardTimeouts = {};
clipboard.on('success', function(e) {
var $el = $(e.trigger);
var id = $el.attr("id");
if (clipboardTimeouts[id]) {
clearTimeout(clipboardTimeouts[id]);
clipboardTimeouts[id] = undefined;
}
$el.attr('data-original-title', '{{ 'shared_project_timesheets.manage.copied' | trans }}')
.tooltip('show');
clipboardTimeouts[id] = setTimeout(function() {
$el.tooltip('hide');
}, 500);
});
});
</script>
{% endblock %}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Share project timesheets with anyone",
"homepage": "https://github.com/dexterity42/SharedProjectTimesheetsBundle",
"type": "kimai-plugin",
"version": "2.0.1",
"version": "2.1.0",
"autoload": {
"psr-4": {
"KimaiPlugin\\SharedProjectTimesheetsBundle\\": ""
Expand All @@ -20,7 +20,7 @@
"extra": {
"kimai": {
"require": "1.15",
"version": "2.0.1",
"version": "2.1.0",
"name": "ShareProjectTimesheetsBundle"
}
},
Expand Down

0 comments on commit cf42203

Please sign in to comment.