Introduce clone and edit button.

This commit is contained in:
James Cole
2023-10-21 07:38:08 +02:00
parent b6aa76477e
commit d632c1c7fc
9 changed files with 100 additions and 50 deletions

View File

@@ -89,6 +89,10 @@ class CreateController extends Controller
session()->flash('success', trans('firefly.stored_journal', ['description' => $title])); session()->flash('success', trans('firefly.stored_journal', ['description' => $title]));
session()->flash('success_url', $link); session()->flash('success_url', $link);
if('edit' === $request->get('redirect')) {
return response()->json(['redirect' => route('transactions.edit', [$newGroup->id])]);
}
return response()->json(['redirect' => route('transactions.show', [$newGroup->id])]); return response()->json(['redirect' => route('transactions.show', [$newGroup->id])]);
} }
} }

98
composer.lock generated
View File

@@ -2996,16 +2996,16 @@
}, },
{ {
"name": "league/flysystem", "name": "league/flysystem",
"version": "3.17.0", "version": "3.18.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/flysystem.git", "url": "https://github.com/thephpleague/flysystem.git",
"reference": "bd4c9b26849d82364119c68429541f1631fba94b" "reference": "015633a05aee22490495159237a5944091d8281e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/bd4c9b26849d82364119c68429541f1631fba94b", "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/015633a05aee22490495159237a5944091d8281e",
"reference": "bd4c9b26849d82364119c68429541f1631fba94b", "reference": "015633a05aee22490495159237a5944091d8281e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3034,7 +3034,7 @@
"google/cloud-storage": "^1.23", "google/cloud-storage": "^1.23",
"microsoft/azure-storage-blob": "^1.1", "microsoft/azure-storage-blob": "^1.1",
"phpseclib/phpseclib": "^3.0.14", "phpseclib/phpseclib": "^3.0.14",
"phpstan/phpstan": "^0.12.26", "phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.5.11|^10.0", "phpunit/phpunit": "^9.5.11|^10.0",
"sabre/dav": "^4.3.1" "sabre/dav": "^4.3.1"
}, },
@@ -3070,7 +3070,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/thephpleague/flysystem/issues", "issues": "https://github.com/thephpleague/flysystem/issues",
"source": "https://github.com/thephpleague/flysystem/tree/3.17.0" "source": "https://github.com/thephpleague/flysystem/tree/3.18.0"
}, },
"funding": [ "funding": [
{ {
@@ -3082,20 +3082,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-10-05T20:15:05+00:00" "time": "2023-10-20T17:59:40+00:00"
}, },
{ {
"name": "league/flysystem-local", "name": "league/flysystem-local",
"version": "3.16.0", "version": "3.18.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/flysystem-local.git", "url": "https://github.com/thephpleague/flysystem-local.git",
"reference": "ec7383f25642e6fd4bb0c9554fc2311245391781" "reference": "e7381ef7643f658b87efb7dbe98fe538fb1bbf32"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/ec7383f25642e6fd4bb0c9554fc2311245391781", "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/e7381ef7643f658b87efb7dbe98fe538fb1bbf32",
"reference": "ec7383f25642e6fd4bb0c9554fc2311245391781", "reference": "e7381ef7643f658b87efb7dbe98fe538fb1bbf32",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3130,7 +3130,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/thephpleague/flysystem-local/issues", "issues": "https://github.com/thephpleague/flysystem-local/issues",
"source": "https://github.com/thephpleague/flysystem-local/tree/3.16.0" "source": "https://github.com/thephpleague/flysystem-local/tree/3.18.0"
}, },
"funding": [ "funding": [
{ {
@@ -3142,7 +3142,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-08-30T10:23:59+00:00" "time": "2023-10-19T20:07:13+00:00"
}, },
{ {
"name": "league/fractal", "name": "league/fractal",
@@ -3216,16 +3216,16 @@
}, },
{ {
"name": "league/mime-type-detection", "name": "league/mime-type-detection",
"version": "1.13.0", "version": "1.14.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/mime-type-detection.git", "url": "https://github.com/thephpleague/mime-type-detection.git",
"reference": "a6dfb1194a2946fcdc1f38219445234f65b35c96" "reference": "b6a5854368533df0295c5761a0253656a2e52d9e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/a6dfb1194a2946fcdc1f38219445234f65b35c96", "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/b6a5854368533df0295c5761a0253656a2e52d9e",
"reference": "a6dfb1194a2946fcdc1f38219445234f65b35c96", "reference": "b6a5854368533df0295c5761a0253656a2e52d9e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3256,7 +3256,7 @@
"description": "Mime-type detection for Flysystem", "description": "Mime-type detection for Flysystem",
"support": { "support": {
"issues": "https://github.com/thephpleague/mime-type-detection/issues", "issues": "https://github.com/thephpleague/mime-type-detection/issues",
"source": "https://github.com/thephpleague/mime-type-detection/tree/1.13.0" "source": "https://github.com/thephpleague/mime-type-detection/tree/1.14.0"
}, },
"funding": [ "funding": [
{ {
@@ -3268,7 +3268,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-08-05T12:09:49+00:00" "time": "2023-10-17T14:13:20+00:00"
}, },
{ {
"name": "league/oauth2-server", "name": "league/oauth2-server",
@@ -5571,35 +5571,35 @@
}, },
{ {
"name": "spatie/flare-client-php", "name": "spatie/flare-client-php",
"version": "1.4.2", "version": "1.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/spatie/flare-client-php.git", "url": "https://github.com/spatie/flare-client-php.git",
"reference": "5f2c6a7a0d2c1d90c12559dc7828fd942911a544" "reference": "5db2fdd743c3ede33f2a5367d89ec1a7c9c1d1ec"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/spatie/flare-client-php/zipball/5f2c6a7a0d2c1d90c12559dc7828fd942911a544", "url": "https://api.github.com/repos/spatie/flare-client-php/zipball/5db2fdd743c3ede33f2a5367d89ec1a7c9c1d1ec",
"reference": "5f2c6a7a0d2c1d90c12559dc7828fd942911a544", "reference": "5db2fdd743c3ede33f2a5367d89ec1a7c9c1d1ec",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"illuminate/pipeline": "^8.0|^9.0|^10.0", "illuminate/pipeline": "^8.0|^9.0|^10.0|^11.0",
"nesbot/carbon": "^2.62.1", "nesbot/carbon": "^2.62.1",
"php": "^8.0", "php": "^8.0",
"spatie/backtrace": "^1.5.2", "spatie/backtrace": "^1.5.2",
"symfony/http-foundation": "^5.0|^6.0", "symfony/http-foundation": "^5.2|^6.0|^7.0",
"symfony/mime": "^5.2|^6.0", "symfony/mime": "^5.2|^6.0|^7.0",
"symfony/process": "^5.2|^6.0", "symfony/process": "^5.2|^6.0|^7.0",
"symfony/var-dumper": "^5.2|^6.0" "symfony/var-dumper": "^5.2|^6.0|^7.0"
}, },
"require-dev": { "require-dev": {
"dms/phpunit-arraysubset-asserts": "^0.3.0", "dms/phpunit-arraysubset-asserts": "^0.5.0",
"pestphp/pest": "^1.20", "pestphp/pest": "^1.20|^2.0",
"phpstan/extension-installer": "^1.1", "phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-phpunit": "^1.0",
"spatie/phpunit-snapshot-assertions": "^4.0" "spatie/phpunit-snapshot-assertions": "^4.0|^5.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@@ -5629,7 +5629,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/spatie/flare-client-php/issues", "issues": "https://github.com/spatie/flare-client-php/issues",
"source": "https://github.com/spatie/flare-client-php/tree/1.4.2" "source": "https://github.com/spatie/flare-client-php/tree/1.4.3"
}, },
"funding": [ "funding": [
{ {
@@ -5637,20 +5637,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-07-28T08:07:24+00:00" "time": "2023-10-17T15:54:07+00:00"
}, },
{ {
"name": "spatie/ignition", "name": "spatie/ignition",
"version": "1.11.2", "version": "1.11.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/spatie/ignition.git", "url": "https://github.com/spatie/ignition.git",
"reference": "48b23411ca4bfbc75c75dfc638b6b36159c375aa" "reference": "3d886de644ff7a5b42e4d27c1e1f67c8b5f00044"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/spatie/ignition/zipball/48b23411ca4bfbc75c75dfc638b6b36159c375aa", "url": "https://api.github.com/repos/spatie/ignition/zipball/3d886de644ff7a5b42e4d27c1e1f67c8b5f00044",
"reference": "48b23411ca4bfbc75c75dfc638b6b36159c375aa", "reference": "3d886de644ff7a5b42e4d27c1e1f67c8b5f00044",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -5659,19 +5659,19 @@
"php": "^8.0", "php": "^8.0",
"spatie/backtrace": "^1.5.3", "spatie/backtrace": "^1.5.3",
"spatie/flare-client-php": "^1.4.0", "spatie/flare-client-php": "^1.4.0",
"symfony/console": "^5.4|^6.0", "symfony/console": "^5.4|^6.0|^7.0",
"symfony/var-dumper": "^5.4|^6.0" "symfony/var-dumper": "^5.4|^6.0|^7.0"
}, },
"require-dev": { "require-dev": {
"illuminate/cache": "^9.52", "illuminate/cache": "^9.52|^10.0|^11.0",
"mockery/mockery": "^1.4", "mockery/mockery": "^1.4",
"pestphp/pest": "^1.20", "pestphp/pest": "^1.20|^2.0",
"phpstan/extension-installer": "^1.1", "phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-phpunit": "^1.0",
"psr/simple-cache-implementation": "*", "psr/simple-cache-implementation": "*",
"symfony/cache": "^6.0", "symfony/cache": "^5.4|^6.0|^7.0",
"symfony/process": "^5.4|^6.0", "symfony/process": "^5.4|^6.0|^7.0",
"vlucas/phpdotenv": "^5.5" "vlucas/phpdotenv": "^5.5"
}, },
"suggest": { "suggest": {
@@ -5720,7 +5720,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-09-19T15:29:52+00:00" "time": "2023-10-18T14:09:40+00:00"
}, },
{ {
"name": "spatie/laravel-html", "name": "spatie/laravel-html",
@@ -10064,16 +10064,16 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.10.38", "version": "1.10.39",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "5302bb402c57f00fb3c2c015bac86e0827e4b691" "reference": "d9dedb0413f678b4d03cbc2279a48f91592c97c4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/5302bb402c57f00fb3c2c015bac86e0827e4b691", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d9dedb0413f678b4d03cbc2279a48f91592c97c4",
"reference": "5302bb402c57f00fb3c2c015bac86e0827e4b691", "reference": "d9dedb0413f678b4d03cbc2279a48f91592c97c4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -10122,7 +10122,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-10-06T14:19:14+00:00" "time": "2023-10-17T15:46:26+00:00"
}, },
{ {
"name": "phpstan/phpstan-deprecation-rules", "name": "phpstan/phpstan-deprecation-rules",

View File

@@ -24,6 +24,7 @@ $(document).ready(function () {
updateListButtons(); updateListButtons();
addSort(); addSort();
$('.clone-transaction').click(cloneTransaction); $('.clone-transaction').click(cloneTransaction);
$('.clone-transaction-and-edit').click(cloneTransactionAndEdit);
}); });
var fixHelper = function (e, tr) { var fixHelper = function (e, tr) {
@@ -242,3 +243,18 @@ function cloneTransaction(e) {
}); });
return false; return false;
} }
function cloneTransactionAndEdit(e) {
var button = $(e.currentTarget);
var groupId = parseInt(button.data('id'));
$.post(cloneAndEditUrl, {
id: groupId
}).done(function (data) {
// lame but it works
location.href = data.redirect;
}).fail(function () {
console.error('I failed :(');
});
return false;
}

View File

@@ -48,4 +48,5 @@ function presentSearchResults(data) {
updateListButtons(); updateListButtons();
// want to clone? // want to clone?
$('.clone-transaction').click(cloneTransaction); $('.clone-transaction').click(cloneTransaction);
$('.clone-transaction-and-edit').click(cloneTransactionAndEdit);
} }

View File

@@ -22,6 +22,7 @@ $(function () {
"use strict"; "use strict";
$('.link-modal').click(getLinkModal); $('.link-modal').click(getLinkModal);
$('.clone-transaction').click(cloneTransaction); $('.clone-transaction').click(cloneTransaction);
$('.clone-transaction-and-edit').click(cloneTransactionAndEdit);
$('#linkJournalModal').on('shown.bs.modal', function () { $('#linkJournalModal').on('shown.bs.modal', function () {
makeAutoComplete(); makeAutoComplete();
}) })
@@ -94,3 +95,18 @@ function cloneTransaction(e) {
}); });
return false; return false;
} }
function cloneTransactionAndEdit(e) {
var button = $(e.currentTarget);
var groupId = parseInt(button.data('id'));
$.post(cloneAndEditUrl, {
id: groupId
}).done(function (data) {
// lame but it works
location.href = data.redirect;
}).fail(function () {
console.error('I failed :(');
});
return false;
}

View File

@@ -33,6 +33,7 @@ return [
'split' => 'Split', 'split' => 'Split',
'single_split' => 'Split', 'single_split' => 'Split',
'clone' => 'Clone', 'clone' => 'Clone',
'clone_and_edit' => 'Clone and edit',
'confirm_action' => 'Confirm action', 'confirm_action' => 'Confirm action',
'last_seven_days' => 'Last seven days', 'last_seven_days' => 'Last seven days',
'last_thirty_days' => 'Last thirty days', 'last_thirty_days' => 'Last thirty days',
@@ -1981,6 +1982,7 @@ return [
'first_split_overrules_destination' => 'The first split may overrule the destination account', 'first_split_overrules_destination' => 'The first split may overrule the destination account',
'spent_x_of_y' => 'Spent {amount} of {total}', 'spent_x_of_y' => 'Spent {amount} of {total}',
// new user: // new user:
'welcome' => 'Welcome to Firefly III!', 'welcome' => 'Welcome to Firefly III!',
'submit' => 'Submit', 'submit' => 'Submit',

View File

@@ -87,6 +87,8 @@
class="fa fa-fw fa-trash"></span> {{ 'delete'|_ }}</a></li> class="fa fa-fw fa-trash"></span> {{ 'delete'|_ }}</a></li>
<li><a href="#" data-id="{{ group.id }}" class="clone-transaction"><span <li><a href="#" data-id="{{ group.id }}" class="clone-transaction"><span
class="fa fa-copy fa-fw"></span> {{ 'clone'|_ }}</a></li> class="fa fa-copy fa-fw"></span> {{ 'clone'|_ }}</a></li>
<li><a href="#" data-id="{{ group.id }}" class="clone-transaction-and-edit"><span
class="fa fa-copy fa-fw"></span> {{ 'clone_and_edit'|_ }}</a></li>
</ul> </ul>
</div> </div>
</td> </td>
@@ -257,6 +259,8 @@
class="fa fa-fw fa-trash"></span> {{ 'delete'|_ }}</a></li> class="fa fa-fw fa-trash"></span> {{ 'delete'|_ }}</a></li>
<li><a href="#" data-id="{{ group.id }}" class="clone-transaction"><span <li><a href="#" data-id="{{ group.id }}" class="clone-transaction"><span
class="fa fa-copy fa-fw"></span> {{ 'clone'|_ }}</a></li> class="fa fa-copy fa-fw"></span> {{ 'clone'|_ }}</a></li>
<li><a href="#" data-id="{{ group.id }}" class="clone-transaction-and-edit"><span
class="fa fa-copy fa-fw"></span> {{ 'clone_and_edit'|_ }}</a></li>
<li> <li>
<a href="{{ route('rules.create-from-journal', [transaction.transaction_journal_id]) }}"><span <a href="{{ route('rules.create-from-journal', [transaction.transaction_journal_id]) }}"><span
class="fa fa-fw fa-random"></span> {{ 'create_rule_from_transaction'|_ }} class="fa fa-fw fa-random"></span> {{ 'create_rule_from_transaction'|_ }}
@@ -317,4 +321,5 @@
</table> </table>
<script type="text/javascript" nonce="{{ JS_NONCE }}"> <script type="text/javascript" nonce="{{ JS_NONCE }}">
var cloneGroupUrl = '{{ route('transactions.clone') }}'; var cloneGroupUrl = '{{ route('transactions.clone') }}';
var cloneAndEditUrl = '{{ route('transactions.clone') }}?redirect=edit';
</script> </script>

View File

@@ -151,6 +151,7 @@
var searchUrl = "{{ route('search.search') }}?page={{ page }}"; var searchUrl = "{{ route('search.search') }}?page={{ page }}";
var searchPage = {{ page }}; var searchPage = {{ page }};
var cloneGroupUrl = '{{ route('transactions.clone') }}'; var cloneGroupUrl = '{{ route('transactions.clone') }}';
var cloneAndEditUrl = '{{ route('transactions.clone') }}?redirect=edit';
</script> </script>
{# required for groups.twig #} {# required for groups.twig #}
<script type="text/javascript" src="v1/js/ff/list/groups.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script> <script type="text/javascript" src="v1/js/ff/list/groups.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>

View File

@@ -47,6 +47,8 @@
<li role="separator" class="divider"></li> <li role="separator" class="divider"></li>
<li><a href="#" class="clone-transaction" data-id="{{ transactionGroup.id }}"><span <li><a href="#" class="clone-transaction" data-id="{{ transactionGroup.id }}"><span
class="fa fa-copy"></span> {{ 'clone'|_ }}</a></li> class="fa fa-copy"></span> {{ 'clone'|_ }}</a></li>
<li><a href="#" class="clone-transaction-and-edit" data-id="{{ transactionGroup.id }}"><span
class="fa fa-copy"></span> {{ 'clone_and_edit'|_ }}</a></li>
{% endif %} {% endif %}
</ul> </ul>
@@ -246,6 +248,8 @@
<li role="separator" class="divider"></li> <li role="separator" class="divider"></li>
<li><a href="#" data-id="{{ transactionGroup.id }}" class="clone-transaction"><span <li><a href="#" data-id="{{ transactionGroup.id }}" class="clone-transaction"><span
class="fa fa-copy"></span> {{ 'clone'|_ }}</a></li> class="fa fa-copy"></span> {{ 'clone'|_ }}</a></li>
<li><a href="#" data-id="{{ transactionGroup.id }}" class="clone-transaction-and-edit"><span
class="fa fa-copy"></span> {{ 'clone_and_edit'|_ }}</a></li>
{% endif %} {% endif %}
<li><a href="#" class="link-modal" <li><a href="#" class="link-modal"
@@ -498,6 +502,7 @@
var acURL = '{{ route('api.v1.autocomplete.transactions-with-id') }}'; var acURL = '{{ route('api.v1.autocomplete.transactions-with-id') }}';
var groupURL = '{{ route('transactions.show',['%GROUP%']) }}'; var groupURL = '{{ route('transactions.show',['%GROUP%']) }}';
var cloneGroupUrl = '{{ route('transactions.clone') }}'; var cloneGroupUrl = '{{ route('transactions.clone') }}';
var cloneAndEditUrl = '{{ route('transactions.clone') }}?redirect=edit';
$('.switch-link').on('click', switchLink); $('.switch-link').on('click', switchLink);
var switchLinkUrl = '{{ route('transactions.link.switch') }}'; var switchLinkUrl = '{{ route('transactions.link.switch') }}';