Commit 333a3529 by Damien Moulard

presta add and delete products on sale

parent 797782ea
...@@ -346,9 +346,19 @@ form[name="formEncaissement"] label { ...@@ -346,9 +346,19 @@ form[name="formEncaissement"] label {
} }
.presta-products-family { .presta-products-family {
display: flex;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.presta-products-family-fields {
width: 95%;
}
.presta-products-family-delete {
width: 5%;
text-align: end;
}
.presta-products-family-form-group { .presta-products-family-form-group {
display: flex; display: flex;
gap: 5px; gap: 5px;
...@@ -360,3 +370,12 @@ form[name="formEncaissement"] label { ...@@ -360,3 +370,12 @@ form[name="formEncaissement"] label {
width: 40%; width: 40%;
margin-bottom: 0; margin-bottom: 0;
} }
.delete-icon {
color: #ff4136;
}
.delete-icon:hover {
cursor: pointer;
color: #a02923;
}
\ No newline at end of file
...@@ -634,6 +634,18 @@ $(function() { ...@@ -634,6 +634,18 @@ $(function() {
} }
}); });
function deletePrestataireProductFamily(e) {
e.preventDefault();
$(this).closest('.presta-products-family')
.fadeOut()
.remove();
}
$(".presta-products-family-delete").on("click", deletePrestataireProductFamily);
/**
* Twig helper, add element to Collection in template based on collection prototype
* @param {*} e
*/
function addFormToCollection(e) { function addFormToCollection(e) {
const collectionHolder = document.querySelector('.' + e.currentTarget.dataset.collectionHolderClass); const collectionHolder = document.querySelector('.' + e.currentTarget.dataset.collectionHolderClass);
...@@ -650,6 +662,11 @@ $(function() { ...@@ -650,6 +662,11 @@ $(function() {
collectionHolder.appendChild(item); collectionHolder.appendChild(item);
collectionHolder.dataset.index++; collectionHolder.dataset.index++;
$(".presta-products-family-delete").off("click", deletePrestataireProductFamily);
$(".presta-products-family-delete").on("click", deletePrestataireProductFamily);
}; };
$("#add-prestataire-products-family").on("click", addFormToCollection); $("#add-prestataire-products-family").on("click", addFormToCollection);
}); });
...@@ -3359,9 +3359,9 @@ ...@@ -3359,9 +3359,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001491", "version": "1.0.30001589",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001491.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001589.tgz",
"integrity": "sha512-17EYIi4TLnPiTzVKMveIxU5ETlxbSO3B6iPvMbprqnKh4qJsQGk5Nh1Lp4jIMAE0XfrujsJuWZAM3oJdMHaKBA==", "integrity": "sha512-vNQWS6kI+q6sBlHbh71IIeC+sRwK2N3EDySc/updIGhIee2x5z00J4c1242/5/d6EpEMdOnk/m+6tuk4/tcsqg==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
...@@ -12880,9 +12880,9 @@ ...@@ -12880,9 +12880,9 @@
} }
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001491", "version": "1.0.30001589",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001491.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001589.tgz",
"integrity": "sha512-17EYIi4TLnPiTzVKMveIxU5ETlxbSO3B6iPvMbprqnKh4qJsQGk5Nh1Lp4jIMAE0XfrujsJuWZAM3oJdMHaKBA==", "integrity": "sha512-vNQWS6kI+q6sBlHbh71IIeC+sRwK2N3EDySc/updIGhIee2x5z00J4c1242/5/d6EpEMdOnk/m+6tuk4/tcsqg==",
"dev": true "dev": true
}, },
"chalk": { "chalk": {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
"app": { "app": {
"js": [ "js": [
"/build/runtime.6ad5c9da.js", "/build/runtime.6ad5c9da.js",
"/build/app.2576ca3f.js" "/build/app.e49db714.js"
], ],
"css": [ "css": [
"/build/app.56026e04.css" "/build/app.02f81748.css"
] ]
}, },
"admin": { "admin": {
......
{ {
"build/app.css": "/build/app.56026e04.css", "build/app.css": "/build/app.02f81748.css",
"build/app.js": "/build/app.2576ca3f.js", "build/app.js": "/build/app.e49db714.js",
"build/admin.css": "/build/admin.5dc0eea7.css", "build/admin.css": "/build/admin.5dc0eea7.css",
"build/admin.js": "/build/admin.cee4d78d.js", "build/admin.js": "/build/admin.cee4d78d.js",
"build/runtime.js": "/build/runtime.6ad5c9da.js", "build/runtime.js": "/build/runtime.6ad5c9da.js",
......
...@@ -107,8 +107,9 @@ class PrestataireInfosFormType extends AbstractType ...@@ -107,8 +107,9 @@ class PrestataireInfosFormType extends AbstractType
'entry_type' => PrestataireProductFamilyFormType::class, 'entry_type' => PrestataireProductFamilyFormType::class,
'required' => true, 'required' => true,
'allow_add' => true, 'allow_add' => true,
'allow_delete' => true,
'by_reference' => false, 'by_reference' => false,
'label' => "Produits vendus par famille ", 'label' => "Produits vendus, regroupés par famille ",
]); ]);
} }
......
...@@ -12,8 +12,9 @@ ...@@ -12,8 +12,9 @@
{# Create "template" as a macro for a product family entry in the form collection #} {# Create "template" as a macro for a product family entry in the form collection #}
{% import _self as formMacros %} {% import _self as formMacros %}
{% macro printPrestataireProductFamilyForm(prestataireProductFamilyForm) %} {% macro printPrestataireProductFamilyForm(prestataireProductFamilyForm, formName = "") %}
<div class="presta-products-family"> <div class="presta-products-family">
<div class="presta-products-family-fields">
<div class="form-group presta-products-family-form-group"> <div class="form-group presta-products-family-form-group">
{{ form_label(prestataireProductFamilyForm.productFamily) }} {{ form_label(prestataireProductFamilyForm.productFamily) }}
{{ form_widget(prestataireProductFamilyForm.productFamily) }} {{ form_widget(prestataireProductFamilyForm.productFamily) }}
...@@ -23,6 +24,13 @@ ...@@ -23,6 +24,13 @@
{{ form_widget(prestataireProductFamilyForm.products) }} {{ form_widget(prestataireProductFamilyForm.products) }}
</div> </div>
</div> </div>
<a href="#" class="presta-products-family-delete">
<i
class="fa fa-times delete-icon"
id="formPrestataireInfos_prestataireProductFamilies_{{ formName == '' ? '__name__' : formName }}_delete"
></i>
</a>
</div>
{% endmacro %} {% endmacro %}
{{form_start(form)}} {{form_start(form)}}
...@@ -45,8 +53,22 @@ ...@@ -45,8 +53,22 @@
{% if form.reconversionFrequency is defined %} {% if form.reconversionFrequency is defined %}
{{ form_row(form.reconversionFrequency) }} {{ form_row(form.reconversionFrequency) }}
{% endif %} {% endif %}
{% if form.prestataireProductFamilies is defined %}
<hr/> <hr/>
{{ form_row(form.media) }}
{{ form_row(form.description) }}
<hr/>
<h3>Adresses</h3>
<div class="geolocs" data-prototype="<div class='card p-2 mb-2 border-primary'>{{ form_widget(form.geolocs.vars.prototype)|e('html_attr') }}</div>">
{% for geoloc in form.geolocs %}
<div class='card p-2 mb-2 border-primary'>
{{ form_row(geoloc) }}
</div>
{% endfor %}
</div>
<hr/>
{{ form_row(form.newcaissiers) }}
<hr/>
{% if form.prestataireProductFamilies is defined %}
<h4>{{ form_label(form.prestataireProductFamilies) }}</h4> <h4>{{ form_label(form.prestataireProductFamilies) }}</h4>
{{ form_errors(form.prestataireProductFamilies) }} {{ form_errors(form.prestataireProductFamilies) }}
...@@ -56,7 +78,7 @@ ...@@ -56,7 +78,7 @@
data-prototype="{{ formMacros.printPrestataireProductFamilyForm(form.prestataireProductFamilies.vars.prototype)|e('html_attr') }}" data-prototype="{{ formMacros.printPrestataireProductFamilyForm(form.prestataireProductFamilies.vars.prototype)|e('html_attr') }}"
> >
{% for prestataireProductFamilyForm in form.prestataireProductFamilies %} {% for prestataireProductFamilyForm in form.prestataireProductFamilies %}
{{ formMacros.printPrestataireProductFamilyForm(prestataireProductFamilyForm) }} {{ formMacros.printPrestataireProductFamilyForm(prestataireProductFamilyForm, prestataireProductFamilyForm.vars.name) }}
{% endfor %} {% endfor %}
{% do form.prestataireProductFamilies.setRendered() %} {% do form.prestataireProductFamilies.setRendered() %}
</div> </div>
...@@ -69,22 +91,8 @@ ...@@ -69,22 +91,8 @@
> >
<i class="fa fa-plus"></i> <i class="fa fa-plus"></i>
</button> </button>
{% endif %}
<hr/>
{{ form_row(form.media) }}
{{ form_row(form.description) }}
<hr/>
<h3>Adresses</h3>
<div class="geolocs" data-prototype="<div class='card p-2 mb-2 border-primary'>{{ form_widget(form.geolocs.vars.prototype)|e('html_attr') }}</div>">
{% for geoloc in form.geolocs %}
<div class='card p-2 mb-2 border-primary'>
{{ form_row(geoloc) }}
</div>
{% endfor %}
</div>
<hr/>
{{ form_row(form.newcaissiers) }}
<hr/> <hr/>
{% endif %}
{{ form_row(form.acceptemlc) }} {{ form_row(form.acceptemlc) }}
{{ form_row(form.save) }} {{ form_row(form.save) }}
{{form_end(form)}} {{form_end(form)}}
......
...@@ -1852,9 +1852,9 @@ caniuse-api@^3.0.0: ...@@ -1852,9 +1852,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0" lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001489: caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001489:
version "1.0.30001491" version "1.0.30001589"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001491.tgz" resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001589.tgz"
integrity sha512-17EYIi4TLnPiTzVKMveIxU5ETlxbSO3B6iPvMbprqnKh4qJsQGk5Nh1Lp4jIMAE0XfrujsJuWZAM3oJdMHaKBA== integrity sha512-vNQWS6kI+q6sBlHbh71IIeC+sRwK2N3EDySc/updIGhIee2x5z00J4c1242/5/d6EpEMdOnk/m+6tuk4/tcsqg==
chalk@^2.0.0, chalk@^2.3.2, chalk@^2.4.2: chalk@^2.0.0, chalk@^2.3.2, chalk@^2.4.2:
version "2.4.2" version "2.4.2"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment