Skip to content

Commit

Permalink
Fixed FE
Browse files Browse the repository at this point in the history
  • Loading branch information
mantasmuliar committed Aug 28, 2024
1 parent f9193e6 commit f02e34c
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 91 deletions.
21 changes: 3 additions & 18 deletions frontend/merchant-portal/update-config-paths.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
const fs = require('fs');
const path = require('path');
const { spawnSync } = require('child_process');
const {
SPRYKER_PROJECT_DIR,
SPRYKER_CORE_DIR,
MP_CORE_ENTRY_POINT_FILE,
MP_PUBLIC_API_FILE,
ROOT_DIR,
} = require('./mp-paths');const { getMPEntryPoints, entryPointPathToName } = require('./utils');
const { SPRYKER_CORE_DIR, MP_CORE_ENTRY_POINT_FILE, MP_PUBLIC_API_FILE, ROOT_DIR } = require('./mp-paths');
const { getMPEntryPoints, entryPointPathToName } = require('./utils');

const TSCONFIG_FILES = ['tsconfig.mp.json'];

function toPascalCase(str) {
return str
.split('-')
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join('');
}

async function getMPPathsMap() {
const entryPoints = await getMPEntryPoints(SPRYKER_CORE_DIR, MP_CORE_ENTRY_POINT_FILE);

return entryPoints.sort().reduce(
(acc, entryPoint) => ({
...acc,
[`${entryPointPathToName('@mp/', entryPoint)}/project`]: [
path.join(SPRYKER_PROJECT_DIR, toPascalCase(entryPoint.split('/src')[0]), MP_PUBLIC_API_FILE),
],
[entryPointPathToName('@mp/', entryPoint)]: [
path.join(SPRYKER_CORE_DIR, entryPoint.split('/src')[0], MP_PUBLIC_API_FILE),
],
Expand All @@ -43,8 +28,8 @@ async function updateConfigPaths() {
const config = require(path.join(ROOT_DIR, fileName));

config.compilerOptions.paths = {
...config.compilerOptions.paths,
...mpPaths,
...config.compilerOptions.paths,
};

fs.writeFileSync(fileName, JSON.stringify(config));
Expand Down
163 changes: 101 additions & 62 deletions src/Pyz/Zed/ProductMerchantPortalGui/Presentation/Products/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,71 +25,110 @@
table-id="{{ idTableProductList }}"
table-config='{{ guiTableConfiguration(productAbstractTableConfiguration) }}'>
<h1 title>{{ 'Products' | trans }}</h1>
<div class="spy-col-basis-auto spy-col-gutter-md">
{% set imagesTypes = constant('Pyz\\Shared\\FileUpload\\FileUploadConfig::ACCEPTED_IMAGE_CONTENT_TYPES') | join(', ') %}
{% set videoTypes = constant('Pyz\\Shared\\FileUpload\\FileUploadConfig::ACCEPTED_VIDEO_CONTENT_TYPES') | join(', ') %}
{% set docTypes = constant('Pyz\\Shared\\FileUpload\\FileUploadConfig::ACCEPTED_DOCUMENT_CONTENT_TYPES') | join(', ') %}
{% set types = "#{imagesTypes}, #{videoTypes}, #{docTypes}" %}
<div button-action class="spy-row spy-row-gutter-md">
<div class="spy-col-basis-auto spy-col-gutter-md">
{% set mediaData = [
{
size: 15,
errorSize: 'The file should be less then %size% MB' | trans({
'%size%': 15,
}),
types: 'text/csv',
},
] %}

{% embed 'ZedUi/Partials/file-upload.twig' with {
data: {
errorType: 'Only %types% file formats are allowed' | trans({
'%types%': 'text/csv'
}),
noCDNPreview: true,
import: '/product-merchant-portal-gui/products/get-import-url',
hook: '/product-merchant-portal-gui/products/save-import-url',
download: '/import_template.csv',
fileData: mediaData,
}
} %}
{% block textData %}
<span modal-title>{{ 'Import Products' | trans }}</span>
<span input-label>{{ 'Choose or drag your csv file' | trans }}</span>
<span modal-download-btn>{{ 'Download Template' | trans }}</span>
{{ 'Import Products' | trans }}
{% endblock %}
{% endembed %}
</div>

{% set mediaData = [
{
size: 2,
errorSize: 'The file should be less then %size% MB' | trans({
'%size%': 2,
}),
types: imagesTypes,
},
{
size: 100,
errorSize: 'The file should be less then %size% MB' | trans({
'%size%': 100,
}),
types: videoTypes,
},
{
size: 25,
errorSize: 'The file should be less then %size% MB' | trans({
'%size%': 25,
}),
types: docTypes,
}
] %}
<div class="spy-col-basis-auto spy-col-gutter-md">
{% set imagesTypes = constant('Pyz\\Shared\\FileUpload\\FileUploadConfig::ACCEPTED_IMAGE_CONTENT_TYPES') | join(', ') %}
{% set videoTypes = constant('Pyz\\Shared\\FileUpload\\FileUploadConfig::ACCEPTED_VIDEO_CONTENT_TYPES') | join(', ') %}
{% set docTypes = constant('Pyz\\Shared\\FileUpload\\FileUploadConfig::ACCEPTED_DOCUMENT_CONTENT_TYPES') | join(', ') %}
{% set types = "#{imagesTypes}, #{videoTypes}, #{docTypes}" %}

{% embed 'ZedUi/Partials/file-upload.twig' with {
data: {
errorType: 'Only %types% file formats are allowed' | trans({
'%types%': types
{% set mediaData = [
{
size: 2,
errorSize: 'The file should be less then %size% MB' | trans({
'%size%': 2,
}),
types: imagesTypes,
},
{
size: 100,
errorSize: 'The file should be less then %size% MB' | trans({
'%size%': 100,
}),
import: '/product-merchant-portal-gui/products/get-import-url',
hook: '/product-merchant-portal-gui/products/save-import-url',
multiple: true,
fileData: mediaData,
buttonSize: 'md',
download: false,
noCDNPreview: false,
}
} %}
{% block textData %}
<ul description>
<li>
{{ 'Maximum %value% media can be uploaded in one upload.' | trans({
'%value%': 20,
}) }}
</li>
</ul>
<span modal-title>{{ 'Import Media' | trans }}</span>
<span input-label>{{ 'Choose or drag your media' | trans }}</span>
{{ 'Import Media' | trans }}
{% endblock %}
{% endembed %}
types: videoTypes,
},
{
size: 25,
errorSize: 'The file should be less then %size% MB' | trans({
'%size%': 25,
}),
types: docTypes,
}
] %}

{% embed 'ZedUi/Partials/file-upload.twig' with {
data: {
errorType: 'Only %types% file formats are allowed' | trans({
'%types%': types
}),
multiple: true,
fileData: mediaData,
}
} %}
{% block textData %}
<ul description>
<li>
{{ 'Maximum %value% media can be uploaded in one upload.' | trans({
'%value%': 20,
}) }}
</li>
<li>
{{ 'Maximum %value% media can be uploaded in one upload.' | trans({
'%value%': 20,
}) }}
</li>
<li>
{{ 'Maximum %value% media can be uploaded in one upload.' | trans({
'%value%': 20,
}) }}
</li>
</ul>
<span modal-title>{{ 'Import Media' | trans }}</span>
<span input-label>{{ 'Choose or drag your media' | trans }}</span>
{{ 'Import Media' | trans }}
{% endblock %}
{% endembed %}
</div>

<web-spy-button-action
class="spy-col-basis-auto spy-col-gutter-md"
size="lg"
variant="primary"
action="{{ actionConfig }}">
{{ 'Create Product' | trans }}
</web-spy-button-action>
</div>
<web-spy-button-action
button-action
type="button"
size="lg"
variant="primary"
action="{{ actionConfig }}">
{{ 'Create Product' | trans }}
</web-spy-button-action>
</web-mp-product-list>
{% endblock %}
14 changes: 7 additions & 7 deletions src/Pyz/Zed/ZedUi/Presentation/Partials/file-upload.twig
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{% set translations = {
mb: 'MB' | trans,
copy: 'Copy' | trans,
errorType: data.errorType,
errorType: data.errorType | default(''),
} %}

<web-mp-media-file-upload
{% if data.import %}import-url="{{ data.import }}"{% endif %}
{% if data.hook %}hook-url="{{ data.hook }}"{% endif %}
{% if data.import is defined %}import-url="{{ data.import }}"{% endif %}
{% if data.hook is defined %}hook-url="{{ data.hook }}"{% endif %}
data="{{ data.fileData | json_encode }}"
button-size="{{ data.buttonSize ?: 'lg' }}"
button-size="{{ data.buttonSize is defined ?: 'lg' }}"
max-call-amount="20"
translations="{{ translations | json_encode }}"
{% if data.multiple %}multiple{% endif %}
{% if data.download %}download-url="{{ data.download }}"{% endif %}
{% if data.noCDNPreview %}show-cdn="false"{% endif %}
{% if data.multiple is defined %}multiple{% endif %}
{% if data.download is defined %}download-url="{{ data.download }}"{% endif %}
{% if data.noCDNPreview is defined %}show-cdn="false"{% endif %}
>
{% block textData %}{% endblock %}

Expand Down
2 changes: 0 additions & 2 deletions src/Pyz/Zed/ZedUi/Presentation/mp.public-api.ts

This file was deleted.

3 changes: 1 addition & 2 deletions tsconfig.mp.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"@mp/zed-ui": ["vendor/spryker/zed-ui/mp.public-api.ts"],
"@mp/*": ["vendor/spryker/*/mp.public-api.ts"],
"@mp/gui-table": ["vendor/spryker/gui-table/mp.public-api.ts"],
"@mp/polyfills": ["./vendor/spryker/zed-ui/src/Spryker/Zed/ZedUi/Presentation/Components/mp.polyfills.ts"],
"@mp/zed-ui/project": ["src/Pyz/Zed/ZedUi/mp.public-api.ts"]
"@mp/polyfills": ["./vendor/spryker/zed-ui/src/Spryker/Zed/ZedUi/Presentation/Components/mp.polyfills.ts"]
}
},
"include": [
Expand Down

0 comments on commit f02e34c

Please sign in to comment.