Skip to content

Commit

Permalink
Merge 02cf9ff into 3a8572a
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredup committed Feb 29, 2024
2 parents 3a8572a + 02cf9ff commit 51b3066
Show file tree
Hide file tree
Showing 15 changed files with 2,663 additions and 2,246 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"esversion": 6
"esversion": 11
}
2,928 changes: 1,529 additions & 1,399 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file modified .yarn/install-state.gz
Binary file not shown.
14 changes: 14 additions & 0 deletions assets/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"controllers": {
"@symfony/ux-dropzone": {
"dropzone": {
"enabled": true,
"fetch": "eager",
"autoimport": {
"@symfony/ux-dropzone/dist/style.min.css": true
}
}
}
},
"entrypoints": []
}
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,14 @@
"symfony/security-bundle": "^5.4",
"symfony/sendgrid-mailer": "^5.4",
"symfony/serializer": "^5.4",
"symfony/stimulus-bundle": "^2.15",
"symfony/swiftmailer-bundle": "^3.4",
"symfony/translation": "^5.4",
"symfony/twig-bridge": "^5.4.31",
"symfony/twig-bundle": "^5.4",
"symfony/ux-dropzone": "*",
"symfony/validator": "^5.4",
"symfony/webpack-encore-bundle": "^1.8",
"symfony/webpack-encore-bundle": "^2.0",
"symfony/workflow": "^6.2",
"symfony/yaml": "^5.4",
"tijsverkoyen/css-to-inline-styles": "^2.2",
Expand Down
1,796 changes: 978 additions & 818 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@
Zenstruck\ScheduleBundle\ZenstruckScheduleBundle::class => ['all' => true],
DAMA\DoctrineTestBundle\DAMADoctrineTestBundle::class => ['test' => true],
Sentry\SentryBundle\SentryBundle::class => ['all' => true],
Symfony\UX\Dropzone\DropzoneBundle::class => ['all' => true],
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
];
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
"@babel/eslint-parser": "^7.22.5",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/preset-env": "^7.22.4",
"@symfony/webpack-encore": "^4.3.0",
"@hotwired/stimulus": "^3.0.0",
"@symfony/stimulus-bridge": "^3.2.0",
"@symfony/stimulus-bundle": "file:vendor/symfony/stimulus-bundle/assets",
"@symfony/ux-dropzone": "file:vendor/symfony/ux-dropzone/assets",
"@symfony/webpack-encore": "^4.6.0",
"babel-loader": "^9.1.2",
"cloudinary": "^1.40.0",
"eslint": "^8.52.0",
Expand Down
4 changes: 2 additions & 2 deletions src/CoreBundle/Form/Type/ImageUploadType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\UX\Dropzone\Form\DropzoneType;

class ImageUploadType extends AbstractType
{
Expand Down Expand Up @@ -58,7 +58,7 @@ public function reverseTransform($value): ?string

public function getParent(): string
{
return FileType::class;
return DropzoneType::class;
}

public function getBlockPrefix(): string
Expand Down
11 changes: 8 additions & 3 deletions src/CoreBundle/Resources/public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ import 'select2';
import 'jquery-placeholder';
import 'regenerator-runtime/runtime';

import { startStimulusApp } from '@symfony/stimulus-bridge';


const Application = MnApplication.extend({
module: null,
regions: {},
initialize (options) {

startStimulusApp();

this.regions = options.regions;

/**
Expand Down Expand Up @@ -108,7 +113,7 @@ const Application = MnApplication.extend({
'template': () => {
return content.render.apply(content).$el;
}
}) );
}))();

view.render.apply(view);

Expand Down Expand Up @@ -138,9 +143,9 @@ export default function(module) {
if (isFunction(action)) {
app.on(event, action);
} else if (includes(functionsIn(module), action)) {
app.on(event, module[action])
app.on(event, module[action]);
} else {
throw `Callback specified for event ${event} is not a valid callback`
throw `Callback specified for event ${event} is not a valid callback`;
}
});
}
Expand Down
15 changes: 15 additions & 0 deletions src/CoreBundle/Resources/views/Form/fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,18 @@
</div>
</div>
{% endblock discount_row %}

{% block image_upload_widget %}
{%- if compound is defined and compound -%}
{%- set element = 'fieldset' -%}
{%- endif -%}
{%- set widget_attr = {} -%}
{%- if help is not empty -%}
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
{%- endif -%}
<{{ element|default('div') }}{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}{{ stimulus_controller('logo_upload') }}>
{{ app_logo(width=100, showDefault=false) }}
{{- form_widget(form, widget_attr) -}}
{{- form_help(form) -}}
</{{ element|default('div') }}>
{% endblock image_upload_widget %}
23 changes: 13 additions & 10 deletions src/CoreBundle/Twig/Extension/GlobalExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use Carbon\Carbon;
use DateTime;
use Ramsey\Uuid\UuidInterface;
use SolidInvoice\CoreBundle\Company\CompanySelector;
use SolidInvoice\CoreBundle\Pdf\Generator;
use SolidInvoice\CoreBundle\SolidInvoiceCoreBundle;
Expand Down Expand Up @@ -93,9 +92,9 @@ protected function getQuery(): array
public function getFilters(): array
{
return [
new TwigFilter('percentage', fn ($amount, float $percentage = 0.0): float => $this->calculator->calculatePercentage($amount, $percentage)),
new TwigFilter('percentage', $this->calculator->calculatePercentage(...)),

new TwigFilter('diff', fn (DateTime $date): string => $this->dateDiff($date)),
new TwigFilter('diff', $this->dateDiff(...)),

new TwigFilter('md5', 'md5'),
];
Expand All @@ -104,9 +103,9 @@ public function getFilters(): array
public function getFunctions(): array
{
return [
new TwigFunction('icon', fn (string $iconName, array $options = []): string => $this->displayIcon($iconName, $options), ['is_safe' => ['html']]),
new TwigFunction('icon', $this->displayIcon(...), ['is_safe' => ['html']]),

new TwigFunction('app_logo', fn (Environment $env, string $width = 'auto'): string => $this->displayAppLogo($env, $width), ['is_safe' => ['html'], 'needs_environment' => true]),
new TwigFunction('app_logo', $this->displayAppLogo(...), ['is_safe' => ['html'], 'needs_environment' => true]),

new TwigFunction('company_name', function (): string {
if ($this->security->getUser() instanceof UserInterface) {
Expand All @@ -116,27 +115,31 @@ public function getFunctions(): array
return SolidInvoiceCoreBundle::APP_NAME;
}),

new TwigFunction('company_id', fn (): UuidInterface => $this->companySelector->getCompany()),
new TwigFunction('company_id', $this->companySelector->getCompany(...)),

new TwigFunction('can_print_pdf', fn (): bool => $this->pdfGenerator->canPrintPdf()),
new TwigFunction('can_print_pdf', $this->pdfGenerator->canPrintPdf(...)),
];
}

/**
* @throws InvalidArgumentException|ServiceCircularReferenceException|ServiceNotFoundException|LoaderError|SyntaxError
*/
public function displayAppLogo(Environment $env, string $width = 'auto'): string
public function displayAppLogo(Environment $env, string $width = 'auto', bool $showDefault = true): string
{
$logo = self::DEFAULT_LOGO;
$logo = $showDefault ? self::DEFAULT_LOGO : null;

if ($this->installed) {
$logo = $this->systemConfig->get('system/company/logo');

if (null === $logo) {
$logo = self::DEFAULT_LOGO;
$logo = $showDefault ? self::DEFAULT_LOGO : null;
}
}

if (null === $logo) {
return '';
}

[$type, $logo] = explode('|', $logo);

return $env->createTemplate('<img src="data:image/{{ type }};base64,{{ logo }}" class="brand-image" width="' . $width . '"/>')->render(['type' => $type, 'logo' => $logo]);
Expand Down
15 changes: 12 additions & 3 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@
"egulias/email-validator": {
"version": "2.1.18"
},
"fp/klarna-invoice": {
"version": "0.1.2"
},
"friendsofphp/proxy-manager-lts": {
"version": "v1.0.3"
},
Expand Down Expand Up @@ -775,6 +772,15 @@
"symfony/serializer": {
"version": "v4.4.11"
},
"symfony/stimulus-bundle": {
"version": "2.15",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "2.8",
"ref": "9e33a8a3794b603fb4be6c04ee5ecab901ce549e"
}
},
"symfony/stopwatch": {
"version": "v5.1.3"
},
Expand Down Expand Up @@ -825,6 +831,9 @@
"templates/base.html.twig"
]
},
"symfony/ux-dropzone": {
"version": "v2.15.0"
},
"symfony/validator": {
"version": "4.3",
"recipe": {
Expand Down
4 changes: 3 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ Encore
options: {
pfx: path.join(process.env.HOME, '.symfony5/certs/default.p12'),
}
}
};
})

.enableStimulusBridge('./assets/controllers.json')
;

const pagesDir = path.resolve(__dirname, 'assets/js/pages');
Expand Down
84 changes: 77 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,22 @@ __metadata:
languageName: node
linkType: hard

"@hotwired/stimulus-webpack-helpers@npm:^1.0.1":
version: 1.0.1
resolution: "@hotwired/stimulus-webpack-helpers@npm:1.0.1"
peerDependencies:
"@hotwired/stimulus": ">= 3.0"
checksum: 2575b44cf625df2d6853996d0c0f39527114875f81184d078886f603a5652331894a84fb6ded1bd7ff3e18667e955d6388794ae912ce61d2682c5079f9dd1950
languageName: node
linkType: hard

"@hotwired/stimulus@npm:^3.0.0":
version: 3.2.2
resolution: "@hotwired/stimulus@npm:3.2.2"
checksum: 3793919e353d28424f57d07e6b634bf6e8821c227acfa2a608aaa8bdfe7e80479acef12705168ca866f3c231399f4a939fb0cd089aaae04c406b3d885a3b35ea
languageName: node
linkType: hard

"@humanwhocodes/config-array@npm:^0.11.13":
version: 0.11.13
resolution: "@humanwhocodes/config-array@npm:0.11.13"
Expand Down Expand Up @@ -1780,9 +1796,43 @@ __metadata:
languageName: node
linkType: hard

"@symfony/webpack-encore@npm:^4.3.0":
version: 4.5.0
resolution: "@symfony/webpack-encore@npm:4.5.0"
"@symfony/stimulus-bridge@npm:^3.2.0":
version: 3.2.2
resolution: "@symfony/stimulus-bridge@npm:3.2.2"
dependencies:
"@hotwired/stimulus-webpack-helpers": "npm:^1.0.1"
"@types/webpack-env": "npm:^1.16.4"
acorn: "npm:^8.0.5"
loader-utils: "npm:^2.0.0"
schema-utils: "npm:^3.0.0"
peerDependencies:
"@hotwired/stimulus": ^3.0
checksum: 3ba997685b45eaf7214807847d9626835011641a580286fc9c90c595da2c3d6cda67b358e15dca0d95c719941fd4074b77655902dd2dc710850ac8840fb5d266
languageName: node
linkType: hard

"@symfony/stimulus-bundle@file:vendor/symfony/stimulus-bundle/assets::locator=solidinvoice%40workspace%3A.":
version: 1.0.0
resolution: "@symfony/stimulus-bundle@file:vendor/symfony/stimulus-bundle/assets#vendor/symfony/stimulus-bundle/assets::hash=09b15e&locator=solidinvoice%40workspace%3A."
peerDependencies:
"@hotwired/stimulus": ^3.0.0
"@symfony/stimulus-bridge": ^3.2.0
checksum: 2789d09d47d1630c09de11ed402605fea9c566c37d968fde53b43edfc25a2c7ed4f98d9b0b354ff7f7b9996f8a6720980c14a55c38cb67228e92baf183059662
languageName: node
linkType: hard

"@symfony/ux-dropzone@file:vendor/symfony/ux-dropzone/assets::locator=solidinvoice%40workspace%3A.":
version: 1.1.0
resolution: "@symfony/ux-dropzone@file:vendor/symfony/ux-dropzone/assets#vendor/symfony/ux-dropzone/assets::hash=9212d5&locator=solidinvoice%40workspace%3A."
peerDependencies:
"@hotwired/stimulus": ^3.0.0
checksum: 1d5dcfb143c07c3cae915b3443618c1eab81421413119d844dee8a74683a2d45fe17571a6953a21a7370f94c844f76856cc9d8c2d557fbde62dd3eed364d4bb2
languageName: node
linkType: hard

"@symfony/webpack-encore@npm:^4.6.0":
version: 4.6.1
resolution: "@symfony/webpack-encore@npm:4.6.1"
dependencies:
"@nuxt/friendly-errors-webpack-plugin": "npm:^2.5.1"
assets-webpack-plugin: "npm:7.0.*"
Expand Down Expand Up @@ -1825,7 +1875,7 @@ __metadata:
postcss: ^8.3.0
postcss-loader: ^7.0.0
sass: ^1.17.0
sass-loader: ^13.0.0
sass-loader: ^13.0.0 || ^14.0.0
stylus: ^0.58.1
stylus-loader: ^7.0.0
ts-loader: ^9.0.0
Expand Down Expand Up @@ -1901,7 +1951,7 @@ __metadata:
optional: true
bin:
encore: bin/encore.js
checksum: 3bfd8d57497641598148994f5df48bb5f0aa44ae5a0e2519a1fa10fd6429d1afed81d8115bd3d8934b2b34da3d1adf0665a68ebfb2b4c1c3a48116db332fbb6a
checksum: f8006c36205098f4ca29b04d127d447126d1b673ee8cb6279d0a9ce0b3c466a1eae0c2bddd9eda0441257e288417e67c5f55fa1226414b919c1a8782a712f290
languageName: node
linkType: hard

Expand Down Expand Up @@ -2193,6 +2243,13 @@ __metadata:
languageName: node
linkType: hard

"@types/webpack-env@npm:^1.16.4":
version: 1.18.4
resolution: "@types/webpack-env@npm:1.18.4"
checksum: 3fa77dbff0ed71685404576b0a1cf74587567fe2ee1cfd11d56d6eefcab7a61e4c9ead0eced264e289d2cf0fc74296dbd55ed6c95774fe0fd6264d156c5a59f0
languageName: node
linkType: hard

"@types/ws@npm:^8.5.5":
version: 8.5.8
resolution: "@types/ws@npm:8.5.8"
Expand Down Expand Up @@ -2555,6 +2612,15 @@ __metadata:
languageName: node
linkType: hard

"acorn@npm:^8.0.5":
version: 8.11.3
resolution: "acorn@npm:8.11.3"
bin:
acorn: bin/acorn
checksum: 3ff155f8812e4a746fee8ecff1f227d527c4c45655bb1fad6347c3cb58e46190598217551b1500f18542d2bbe5c87120cb6927f5a074a59166fbdd9468f0a299
languageName: node
linkType: hard

"acorn@npm:^8.7.1, acorn@npm:^8.8.2, acorn@npm:^8.9.0":
version: 8.11.2
resolution: "acorn@npm:8.11.2"
Expand Down Expand Up @@ -8868,7 +8934,7 @@ __metadata:
languageName: node
linkType: hard

"schema-utils@npm:^3.1.1, schema-utils@npm:^3.2.0":
"schema-utils@npm:^3.0.0, schema-utils@npm:^3.1.1, schema-utils@npm:^3.2.0":
version: 3.3.0
resolution: "schema-utils@npm:3.3.0"
dependencies:
Expand Down Expand Up @@ -9212,7 +9278,11 @@ __metadata:
"@babel/plugin-syntax-dynamic-import": "npm:^7.8.3"
"@babel/preset-env": "npm:^7.22.4"
"@fortawesome/fontawesome-free": "npm:^6.4.0"
"@symfony/webpack-encore": "npm:^4.3.0"
"@hotwired/stimulus": "npm:^3.0.0"
"@symfony/stimulus-bridge": "npm:^3.2.0"
"@symfony/stimulus-bundle": "file:vendor/symfony/stimulus-bundle/assets"
"@symfony/ux-dropzone": "file:vendor/symfony/ux-dropzone/assets"
"@symfony/webpack-encore": "npm:^4.6.0"
accounting: "npm:^0.4.1"
admin-lte: "git+https://github.com/ColorlibHQ/AdminLTE.git#7748b38a6e7afc2415975b9c41adab4e1733d330"
babel-loader: "npm:^9.1.2"
Expand Down

0 comments on commit 51b3066

Please sign in to comment.