diff --git a/.chipperci.yml b/.chipperci.yml index 0c1ad8ba15..0c18b253c9 100644 --- a/.chipperci.yml +++ b/.chipperci.yml @@ -20,10 +20,8 @@ on: pipeline: - name: Setup cmd: | - cp -v .env.example .env -# This is simply to allow passing the guard in TestCase@setUp() -# https://chipperci.com/docs/builds/env - touch .env.testing + cp -v .env.testing.example .env + cp -v .env.testing.example .env.testing composer install --no-interaction --prefer-dist --optimize-autoloader - name: Generate Key @@ -36,15 +34,15 @@ pipeline: - name: Run Migrations cmd: | - # php artisan migrate --force + php artisan migrate --force - name: PHPUnit Unit Tests cmd: | - # php artisan test --testsuite Unit + php artisan test --testsuite Unit - name: PHPUnit Feature Tests cmd: | - # php artisan test --testsuite Feature + php artisan test --testsuite Feature # - name: Browser Tests # cmd: | diff --git a/app/Http/Livewire/CategoryEditForm.php b/app/Http/Livewire/CategoryEditForm.php new file mode 100644 index 0000000000..05a1fe9d45 --- /dev/null +++ b/app/Http/Livewire/CategoryEditForm.php @@ -0,0 +1,67 @@ +originalSendCheckInEmailValue = $this->sendCheckInEmail; + + if ($this->eulaText || $this->useDefaultEula) { + $this->sendCheckInEmail = 1; + } + } + + public function render() + { + return view('livewire.category-edit-form'); + } + + public function updated($property, $value) + { + if (! in_array($property, ['eulaText', 'useDefaultEula'])) { + return; + } + + $this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula ? 1 : $this->originalSendCheckInEmailValue; + } + + public function getShouldDisplayEmailMessageProperty(): bool + { + return $this->eulaText || $this->useDefaultEula; + } + + public function getEmailMessageProperty(): string + { + if ($this->useDefaultEula) { + return trans('admin/categories/general.email_will_be_sent_due_to_global_eula'); + } + + return trans('admin/categories/general.email_will_be_sent_due_to_category_eula'); + } + + public function getEulaTextDisabledProperty() + { + return (bool)$this->useDefaultEula; + } + + public function getSendCheckInEmailDisabledProperty() + { + return $this->eulaText || $this->useDefaultEula; + } +} diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php index 2e1137bcd2..7899182a60 100644 --- a/app/Http/Livewire/Importer.php +++ b/app/Http/Livewire/Importer.php @@ -215,6 +215,7 @@ class Importer extends Component 'manufacturer' => trans('general.manufacturer'), 'order_number' => trans('general.order_number'), 'image' => trans('general.importer.image_filename'), + 'asset_eol_date' => trans('admin/hardware/form.eol_date'), /** * Checkout fields: * Assets can be checked out to other assets, people, or locations, but we currently diff --git a/config/services.php b/config/services.php index de8c4ed71a..21acb6778a 100644 --- a/config/services.php +++ b/config/services.php @@ -25,6 +25,7 @@ return [ 'mailgun' => [ 'domain' => env('MAILGUN_DOMAIN'), 'secret' => env('MAILGUN_SECRET'), + 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), ], 'mandrill' => [ diff --git a/package-lock.json b/package-lock.json index 2c334fd025..649581f940 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1565,9 +1565,9 @@ } }, "@types/eslint": { - "version": "8.44.0", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.44.0.tgz", - "integrity": "sha512-gsF+c/0XOguWgaOgvFs+xnnRqt9GwgTvIks36WpE6ueeI4KCEHHd8K/CKHqhOqrJKsYH8m27kRzQEvWXAwXUTw==", + "version": "8.44.2", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.44.2.tgz", + "integrity": "sha512-sdPRb9K6iL5XZOmBubg8yiFp5yS/JdUDQsq5e6h95km91MCYMuvp7mh1fjPEYUhvHepKpZOjnEaMBR4PxjWDzg==", "requires": { "@types/estree": "*", "@types/json-schema": "*" @@ -15962,9 +15962,9 @@ } }, "jspdf-autotable": { - "version": "3.5.25", - "resolved": "https://registry.npmjs.org/jspdf-autotable/-/jspdf-autotable-3.5.25.tgz", - "integrity": "sha512-BIbDd/cilRbVm5PmR+ZonolSqRtm0AvZDpTz+rrWed7BnFj5mqF7x7lkxDAMzPudLapktHUk6cxipcvUzal8cg==" + "version": "3.5.31", + "resolved": "https://registry.npmjs.org/jspdf-autotable/-/jspdf-autotable-3.5.31.tgz", + "integrity": "sha512-Lc1KuLGDQWW/5t57Z/+c2E94XQV3jV2QVU3xMRiwvcm/nMx79aCkpPCsxLzJZVFneZvz4XoA8+egQR1QajYiWw==" }, "junk": { "version": "3.1.0", @@ -19705,9 +19705,9 @@ } }, "webpack": { - "version": "5.88.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.88.1.tgz", - "integrity": "sha512-FROX3TxQnC/ox4N+3xQoWZzvGXSuscxR32rbzjpXgEzWudJFEJBpdlkkob2ylrv5yzzufD1zph1OoFsLtm6stQ==", + "version": "5.88.2", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.88.2.tgz", + "integrity": "sha512-JmcgNZ1iKj+aiR0OvTYtWQqJwq37Pf683dY9bVORwVbUrDhLhdn/PlO2sHsFHPkj7sHNQF3JwaAkp49V+Sq1tQ==", "requires": { "@types/eslint-scope": "^3.7.3", "@types/estree": "^1.0.0", @@ -19736,22 +19736,22 @@ }, "dependencies": { "@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==" + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==" }, "@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" }, "@jridgewell/trace-mapping": { - "version": "0.3.18", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", - "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz", + "integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==", "requires": { - "@jridgewell/resolve-uri": "3.1.0", - "@jridgewell/sourcemap-codec": "1.4.14" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, "@types/json-schema": { @@ -19788,9 +19788,9 @@ } }, "terser": { - "version": "5.18.2", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.18.2.tgz", - "integrity": "sha512-Ah19JS86ypbJzTzvUCX7KOsEIhDaRONungA4aYBjEP3JZRf4ocuDzTg4QWZnPn9DEMiMYGJPiSOy7aykoCc70w==", + "version": "5.19.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.19.2.tgz", + "integrity": "sha512-qC5+dmecKJA4cpYxRa5aVkKehYsQKc+AHeKl0Oe62aYjBL8ZA33tTljktDHJSaxxMnbI5ZYw+o/S2DxxLu8OfA==", "requires": { "@jridgewell/source-map": "^0.3.3", "acorn": "^8.8.2", diff --git a/package.json b/package.json index 0752f284e7..67b5988541 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "jquery-ui": "^1.13.2", "jquery-ui-bundle": "^1.12.1", "jquery.iframe-transport": "^1.0.0", - "jspdf-autotable": "^3.5.24", + "jspdf-autotable": "^3.5.30", "less": "^4.1.2", "less-loader": "^5.0", "list.js": "^1.5.0", @@ -54,6 +54,6 @@ "tableexport.jquery.plugin": "1.28.0", "tether": "^1.4.0", "vue-resource": "^1.5.2", - "webpack": "^5.87.0" + "webpack": "^5.88.2" } } diff --git a/public/css/dist/all.css b/public/css/dist/all.css index 3313bdac45..6a556a42bf 100644 Binary files a/public/css/dist/all.css and b/public/css/dist/all.css differ diff --git a/public/css/dist/bootstrap-table.css b/public/css/dist/bootstrap-table.css index c8749ad4b4..301c592a5d 100644 Binary files a/public/css/dist/bootstrap-table.css and b/public/css/dist/bootstrap-table.css differ diff --git a/public/js/dist/bootstrap-table.js b/public/js/dist/bootstrap-table.js index 53d6e2d52d..c01fba3e19 100644 Binary files a/public/js/dist/bootstrap-table.js and b/public/js/dist/bootstrap-table.js differ diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 957e6e556e..b1c491bc26 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -18,7 +18,7 @@ "/css/dist/skins/skin-green.css": "/css/dist/skins/skin-green.css?id=0a82a6ae6bb4e58fe62d162c4fb50397", "/css/dist/skins/skin-contrast.css": "/css/dist/skins/skin-contrast.css?id=da6c7997d9de2f8329142399f0ce50da", "/css/dist/skins/skin-red.css": "/css/dist/skins/skin-red.css?id=44bf834f2110504a793dadec132a5898", - "/css/dist/all.css": "/css/dist/all.css?id=ae5d0ce9886bbe4ad4b021c6be19ec36", + "/css/dist/all.css": "/css/dist/all.css?id=8b29a53b11e372ceb332b1a2f7026632", "/css/dist/signature-pad.css": "/css/dist/signature-pad.css?id=6a89d3cd901305e66ced1cf5f13147f7", "/css/dist/signature-pad.min.css": "/css/dist/signature-pad.min.css?id=6a89d3cd901305e66ced1cf5f13147f7", "/css/webfonts/fa-brands-400.ttf": "/css/webfonts/fa-brands-400.ttf?id=e2e2b1797606a266ed55549f5bb5a179", @@ -29,9 +29,9 @@ "/css/webfonts/fa-solid-900.woff2": "/css/webfonts/fa-solid-900.woff2?id=eea38615e7b5dbbaf88c263f2230cc32", "/css/webfonts/fa-v4compatibility.ttf": "/css/webfonts/fa-v4compatibility.ttf?id=6ebbf5afc34f54463abc2b81ca637364", "/css/webfonts/fa-v4compatibility.woff2": "/css/webfonts/fa-v4compatibility.woff2?id=67b8a78b7e80e805cfa4ee0421895ba4", - "/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=f5935cf8eaf9c1f71da0c9245d730471", + "/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=281bcfe26549412d128f695234961081", "/js/build/vendor.js": "/js/build/vendor.js?id=3592e07ae9a6d1805a4ea3bd3c034aef", - "/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=40e2dc8b5b29e244bb545f78e2a3242b", + "/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=df78f0c4cc93c29c02a41144590f6350", "/js/dist/all.js": "/js/dist/all.js?id=ba07d399f23b294f7c4983030b757423", "/css/dist/skins/skin-green.min.css": "/css/dist/skins/skin-green.min.css?id=0a82a6ae6bb4e58fe62d162c4fb50397", "/css/dist/skins/skin-green-dark.min.css": "/css/dist/skins/skin-green-dark.min.css?id=e36e83c2aa3c3afdbb8ebe2c0309e91d", diff --git a/resources/lang/en/admin/categories/general.php b/resources/lang/en/admin/categories/general.php index 52e936d0b6..2fe448b44e 100644 --- a/resources/lang/en/admin/categories/general.php +++ b/resources/lang/en/admin/categories/general.php @@ -8,6 +8,8 @@ return array( 'clone' => 'Clone Category', 'create' => 'Create Category', 'edit' => 'Edit Category', + 'email_will_be_sent_due_to_global_eula' => 'An email will be sent to the user because the global EULA is being used.', + 'email_will_be_sent_due_to_category_eula' => 'An email will be sent to the user because a EULA is set for this category.', 'eula_text' => 'Category EULA', 'eula_text_help' => 'This field allows you to customize your EULAs for specific types of assets. If you only have one EULA for all of your assets, you can check the box below to use the primary default.', 'name' => 'Category Name', diff --git a/resources/views/categories/edit.blade.php b/resources/views/categories/edit.blade.php index 813e8463e9..1ef3b7aa6a 100755 --- a/resources/views/categories/edit.blade.php +++ b/resources/views/categories/edit.blade.php @@ -23,59 +23,13 @@ - - - -
- -
- {{ Form::textarea('eula_text', old('eula_text', $item->eula_text), array('class' => 'form-control', 'aria-label'=>'eula_text')) }} -

{!! trans('admin/categories/general.eula_text_help') !!}

-

{!! trans('admin/settings/general.eula_markdown') !!}

- - {!! $errors->first('eula_text', '') !!} -
-
- - -
-
- @if ($snipeSettings->default_eula_text!='') - - @else - - @endif -
-
- - - -
-
- -
-
- - - -
-
- -
-
- + @include ('partials.forms.edit.image-upload', ['image_path' => app('categories_upload_path')]) diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index d11d3c541f..4363584972 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -973,7 +973,12 @@ $(function () { - $('[data-tooltip="true"]').tooltip(); + // Invoke Bootstrap 3's tooltip + $('[data-tooltip="true"]').tooltip({ + container: 'body', + animation: true, + }); + $('[data-toggle="popover"]').popover(); $('.select2 span').addClass('needsclick'); $('.select2 span').removeAttr('title'); diff --git a/resources/views/livewire/category-edit-form.blade.php b/resources/views/livewire/category-edit-form.blade.php new file mode 100644 index 0000000000..33b41b71e9 --- /dev/null +++ b/resources/views/livewire/category-edit-form.blade.php @@ -0,0 +1,61 @@ +
+ +
+ +
+ {{ Form::textarea('eula_text', null, ['wire:model' => 'eulaText', 'class' => 'form-control', 'aria-label'=>'eula_text', 'disabled' => $this->eulaTextDisabled]) }} +

{!! trans('admin/categories/general.eula_text_help') !!}

+

{!! trans('admin/settings/general.eula_markdown') !!}

+ {!! $errors->first('eula_text', '') !!} +
+ @if ($this->eulaTextDisabled) + + @endif +
+ + +
+
+ @if ($defaultEulaText!='') + + @else + + @endif +
+
+ + +
+
+ +
+
+ + +
+
+ + @if ($this->shouldDisplayEmailMessage) +
+ + {{ $this->emailMessage }} +
+ @endif + @if ($this->sendCheckInEmailDisabled) + + @endif +
+
+
diff --git a/resources/views/models/custom_fields_form.blade.php b/resources/views/models/custom_fields_form.blade.php index 011ad4ca9b..bae98373e4 100644 --- a/resources/views/models/custom_fields_form.blade.php +++ b/resources/views/models/custom_fields_form.blade.php @@ -85,3 +85,12 @@ @endforeach @endif + + + diff --git a/tests/Feature/Livewire/CategoryEditFormTest.php b/tests/Feature/Livewire/CategoryEditFormTest.php new file mode 100644 index 0000000000..26719e4041 --- /dev/null +++ b/tests/Feature/Livewire/CategoryEditFormTest.php @@ -0,0 +1,105 @@ +assertStatus(200); + } + + public function testSendEmailCheckboxIsCheckedOnLoadWhenSendEmailIsExistingSetting() + { + Livewire::test(CategoryEditForm::class, [ + 'sendCheckInEmail' => true, + 'eulaText' => '', + 'useDefaultEula' => false, + ])->assertSet('sendCheckInEmail', true); + } + + public function testSendEmailCheckboxIsCheckedOnLoadWhenCategoryEulaSet() + { + Livewire::test(CategoryEditForm::class, [ + 'sendCheckInEmail' => false, + 'eulaText' => 'Some Content', + 'useDefaultEula' => false, + ])->assertSet('sendCheckInEmail', true); + } + + public function testSendEmailCheckboxIsCheckedOnLoadWhenUsingDefaultEula() + { + Livewire::test(CategoryEditForm::class, [ + 'sendCheckInEmail' => false, + 'eulaText' => '', + 'useDefaultEula' => true, + ])->assertSet('sendCheckInEmail', true); + } + + public function testSendEmailCheckBoxIsUncheckedOnLoadWhenSendEmailIsFalseNoCategoryEulaSetAndNotUsingDefaultEula() + { + Livewire::test(CategoryEditForm::class, [ + 'sendCheckInEmail' => false, + 'eulaText' => '', + 'useDefaultEula' => false, + ])->assertSet('sendCheckInEmail', false); + } + + public function testSendEmailCheckboxIsCheckedWhenCategoryEulaEntered() + { + Livewire::test(CategoryEditForm::class, [ + 'sendCheckInEmail' => false, + 'useDefaultEula' => false, + ])->assertSet('sendCheckInEmail', false) + ->set('eulaText', 'Some Content') + ->assertSet('sendCheckInEmail', true); + } + + public function testSendEmailCheckboxCheckedAndDisabledAndEulaTextDisabledWhenUseDefaultEulaSelected() + { + Livewire::test(CategoryEditForm::class, [ + 'sendCheckInEmail' => false, + 'useDefaultEula' => false, + ])->assertSet('sendCheckInEmail', false) + ->set('useDefaultEula', true) + ->assertSet('sendCheckInEmail', true) + ->assertSet('eulaTextDisabled', true) + ->assertSet('sendCheckInEmailDisabled', true); + } + + public function testSendEmailCheckboxEnabledAndSetToOriginalValueWhenNoCategoryEulaAndNotUsingGlobalEula() + { + Livewire::test(CategoryEditForm::class, [ + 'eulaText' => 'Some Content', + 'sendCheckInEmail' => false, + 'useDefaultEula' => true, + ]) + ->set('useDefaultEula', false) + ->set('eulaText', '') + ->assertSet('sendCheckInEmail', false) + ->assertSet('sendCheckInEmailDisabled', false); + + Livewire::test(CategoryEditForm::class, [ + 'eulaText' => 'Some Content', + 'sendCheckInEmail' => true, + 'useDefaultEula' => true, + ]) + ->set('useDefaultEula', false) + ->set('eulaText', '') + ->assertSet('sendCheckInEmail', true) + ->assertSet('sendCheckInEmailDisabled', false); + } + + public function testEulaFieldEnabledOnLoadWhenNotUsingDefaultEula() + { + Livewire::test(CategoryEditForm::class, [ + 'sendCheckInEmail' => false, + 'eulaText' => '', + 'useDefaultEula' => false, + ])->assertSet('eulaTextDisabled', false); + } +}