Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
dbba3b8
UX FormCollection
stakovicz May 3, 2021
83ec2ea
Remove hard coded property_name __name__
stakovicz May 4, 2021
d983cf0
PHP CS Fixer
stakovicz May 4, 2021
a35ff32
First jests
stakovicz May 4, 2021
e1d7574
Rename CollectionType > UXCollectionType
stakovicz May 6, 2021
409c8e7
Rename CollectionType > UXCollectionType
stakovicz May 6, 2021
a624f25
DependencyInjection Clean
stakovicz May 6, 2021
f4ba011
Fix .gitattributes
stakovicz May 6, 2021
7741907
Move default values
stakovicz May 7, 2021
66defab
Predefined theme or not
stakovicz May 23, 2021
145b1cb
Update src/FormCollection/README.md
stakovicz May 24, 2021
2b900cc
Update src/FormCollection/README.md
stakovicz May 24, 2021
25c1454
Update src/FormCollection/README.md
stakovicz May 24, 2021
d66250d
Update src/FormCollection/Resources/views/form_theme_div.html.twig
stakovicz May 24, 2021
2db95e0
Update src/FormCollection/README.md
stakovicz May 24, 2021
8f8b5c2
Update src/FormCollection/Resources/views/form_theme_table.html.twig
stakovicz May 24, 2021
4a68faa
Split in 4 options
stakovicz May 24, 2021
a170618
Default startIndex value
stakovicz Jun 6, 2021
13561e7
Update src/FormCollection/Resources/views/form_theme_div.html.twig
stakovicz Jul 21, 2021
fb847c6
Update src/FormCollection/Resources/views/form_theme_div.html.twig
stakovicz Jul 21, 2021
740d19b
Update src/FormCollection/Resources/views/form_theme_table.html.twig
stakovicz Jul 21, 2021
c57d86e
Update src/FormCollection/Resources/views/form_theme_table.html.twig
stakovicz Jul 21, 2021
0bbac2f
Fix coding-style-js
stakovicz Nov 6, 2021
edfe323
Prettier
stakovicz Nov 6, 2021
086c3a3
Rebase and refresh the code
stakovicz May 21, 2022
480dbb5
fix TU
stakovicz May 21, 2022
3223fae
change buttons attr
stakovicz May 21, 2022
911f18f
Move logic from twig files to form types
alexander-schranz Jul 18, 2022
4cfa27d
Fix types and not used imports
alexander-schranz Jul 18, 2022
0976a9e
Allow overriding the data-controller via attr
alexander-schranz Jul 18, 2022
dc18974
Simplify controller integration
alexander-schranz Jul 18, 2022
9ee00dc
Fix handling of nested blocks
alexander-schranz Jul 18, 2022
d294592
Move docs to index.rst
alexander-schranz Jul 18, 2022
4edfefb
Fix add problem
alexander-schranz Jul 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Default startIndex value
  • Loading branch information
stakovicz authored and alexander-schranz committed Jul 18, 2022
commit a170618aec95f5b5e7007182d8d05fdfd2871627
5 changes: 3 additions & 2 deletions src/FormCollection/Resources/assets/dist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var _default = /*#__PURE__*/function (_Controller) {
key: "connect",
value: function connect() {
this.controllerName = this.context.scope.identifier;
this.index = this.entryTargets.length - 1;
this.index = this.startIndexValue ? this.startIndexValue : this.entryTargets.length - 1;

if (!this.prototypeNameValue) {
this.prototypeNameValue = '__name__';
Expand Down Expand Up @@ -210,5 +210,6 @@ _defineProperty(_default, "values", {
buttonAdd: String,
buttonDelete: String,
prototypeName: String,
prototype: String
prototype: String,
startIndex: Number
});
5 changes: 3 additions & 2 deletions src/FormCollection/Resources/assets/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default class extends Controller {
buttonAdd: String,
buttonDelete: String,
prototypeName: String,
prototype: String
prototype: String,
startIndex: Number
};

/**
Expand All @@ -30,7 +31,7 @@ export default class extends Controller {

connect() {
this.controllerName = this.context.scope.identifier;
this.index = this.entryTargets.length - 1;
this.index = this.startIndexValue ? this.startIndexValue : this.entryTargets.length - 1;

if (!this.prototypeNameValue) {
this.prototypeNameValue = '__name__';
Expand Down
4 changes: 4 additions & 0 deletions src/FormCollection/Resources/views/form_theme_div.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@
{% endif %}
{%- set attr = attr|merge({('data-' ~ controllerName ~ '-target'): 'container' }) -%}

{% set indexKeys = data|keys %}
{% set startIndex = indexKeys|length == 0 ? 0 : max(indexKeys) %}

<div data-controller="{{ dataController }}"
data-{{ controllerName }}-allow-add-value="{{ allow_add|json_encode }}"
data-{{ controllerName }}-allow-delete-value="{{ allow_delete|json_encode }}"
data-{{ controllerName }}-button-add-value="{{ block('button_add')|e('html_attr') }}"
data-{{ controllerName }}-button-delete-value="{{ block('button_delete')|e('html_attr') }}"
data-{{ controllerName }}-prototype-name-value="{{ prototype_name }}"
data-{{ controllerName }}-start-index-value="{{ startIndex }}"
{{ block('widget_container_attributes') }}
>
{%- if form is rootform -%}
Expand Down
4 changes: 4 additions & 0 deletions src/FormCollection/Resources/views/form_theme_table.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@
{%- set attr = attr|merge({'data-prototype': form_row(prototype, {'row_attr': prototype_attr}) }) -%}
{% endif %}

{% set indexKeys = data|keys %}
{% set startIndex = indexKeys|length == 0 ? 0 : max(indexKeys) %}

<div data-controller="{{ dataController }}"
data-{{ controllerName }}-allow-add-value="{{ allow_add|json_encode }}"
data-{{ controllerName }}-allow-delete-value="{{ allow_delete|json_encode }}"
data-{{ controllerName }}-button-add-value="{{ block('button_add')|e('html_attr') }}"
data-{{ controllerName }}-button-delete-value="{{ block('button_delete')|e('html_attr') }}"
data-{{ controllerName }}-prototype-name-value="{{ prototype_name }}"
data-{{ controllerName }}-start-index-value="{{ startIndex }}"
{{ block('widget_container_attributes') }}
>
<table>
Expand Down