Commit Graph

59 Commits

Author SHA1 Message Date
merdan 9489f49958 home page start 2021-03-11 15:16:57 +05:00
Ben Thomson ed06a6f1ac
Do minItem initialization before checking current value in repeater prep
Fixes https://github.com/octobercms/october/issues/5274
2020-09-17 12:45:55 +08:00
Ben Thomson 3f982c25c7
Add "styles" for repeater widgets (#4877)
Can be one of three values:
- "default": Shows all repeater items expanded on load.
- "collapsed": Shows all repeater items collapsed on load.
- "accordion": Shows only the first repeater item expanded on load. When another item is clicked, all other open items are collapsed.

Implements  #4801. Refs: https://github.com/rainlab/builder-plugin/issues/165, #2631
2020-02-02 09:12:01 +08:00
Ben Thomson c17cb58aa1 More strict checking of addItem request for child repeaters (#4814)
Similarly named repeater fields being used in viewBag variables were being assigned aliases which succeeded the `strpos` check on line 407. This will more clearly look for a child repeater form and index.

Fixes #4808
2019-12-12 21:44:10 +11:00
Luke Towers 9ac292d921
Merge pull request #4690 from pkarecki/master
Credit to @pkarecki
2019-10-11 12:46:01 -06:00
Piotr Karecki 06b7031131
Move prompt to lang
Move default prompt text to i18n file.
2019-10-11 20:12:08 +02:00
Luke Towers 96e335aebc
Fix #3415, #4672 (#4674)
Handle child FormWidgets making AJAX requests outside of the repeater's form container. Note that this won't pass on the state of the repeater item as it exists on the webpage because that information won't be sent to the server in an AJAX request sent from outside of the repeater's form container unless the FormWidget sending the orphaned request specifically includes that data in their request, in which case the regular handling will kick in and initialize the widget properly. A discussion should be had whether this fix makes sense to be done in the Repeater FormWidget or if we should force FormWidgets to have the responsibility of initializing their parent repeaters if they're going to be making orphaned AJAX requests.

Should fix #3415, #4672.
Related: octoberrain/test-plugin#78
2019-10-09 08:08:21 -06:00
Luke Towers b75d0af966 Improve support for previewMode in Repeaters & NestedForms
Fixes #4521
2019-08-10 09:28:01 -06:00
Ben Thomson b5a3c64bf1
Fix "widget not bound to controller" error for nested repeaters (#4434)
Since repeaters have no value by themselves, a repeater that contains only another repeater was throwing a "widget not bound to controller" exception when adding a new item - the repeater item processing was not creating a form widget for the inner repeater on load, or in an AJAX call. This fix specifically checks if a child repeater has called for a new item, and if so and the current repeater has no value for this particular item, it will add a "stub" form widget to correctly bind the widget.

Fixes #4344.
2019-08-07 22:44:31 +08:00
Ben Thomson 3eac21219f
Clean up index functionality in Repeater widget (#4424)
- Remove $indexCount property, as it is no longer needed
- Determine highest key number in data, and increment when adding item
- Remove some old code and dependencies

Fixes #4402.
2019-06-29 13:42:45 +08:00
datune a8d9dcf985 Fix group index mapping in Repeater widget (#4334)
Fixes a bug which causes grouped repeaters to lose data when repeater items are re-ordered and saved, due to the data indexes not being correctly mapped to the corresponding form widget.

Credit to @datune.
2019-05-14 23:34:12 +08:00
Ben Thomson ee2b53fe71 Add hidden "loaded" flag for repeaters
This allows the repeater to retrieve the load value
from the model only on initialisation. Any further
requests to the repeater (ie. AJAX requests) should
use the POST data.
2019-04-11 17:57:27 +08:00
Ben Thomson ac98f70a25 Revert reordering handler changes 2019-04-11 10:37:39 +08:00
Ben Thomson a00e546f5f Clean up processItems() method 2019-04-10 13:20:51 +08:00
Ben Thomson 9b5bd83f10 Reset indexes when processing POST data 2019-04-09 15:35:07 +08:00
Ben Thomson f49b5ab4b8 Add callback for handling sorted repeater items 2019-04-08 23:40:41 +08:00
Ben Thomson 332ed62931 Increment index count after new item is created
Effectively starts the repeater item indexes from 0
2019-04-08 14:37:36 +08:00
Luke Towers bfe03803e6 Fix the repeater on every context, not just static page fields 2019-04-05 09:00:26 -06:00
Luke Towers b4b4b1b566 Remove extra __index_ and __group_ fields from the Repeater and use only the data itself to handle initializing widgets and processing data.
Refs: #4230
2019-04-04 01:23:32 -06:00
Luke Towers 4fbe3fdd8f removed extra line of whitespace 2019-04-01 12:41:08 -06:00
Luke Towers ecccafa319 Fix issue where grouped repeaters stopped working in a recent build. Refs: 13a7cc915d (commitcomment-32986586) 2019-04-01 12:37:32 -06:00
Luke Towers 3954704dda Fix issue with multiple repeaters with the same fieldname embedded in the same controller
There was a conflict between two repeaters that had the same fieldName (data) bound to the same controller. Example:

Controller: Events
Manages a ReportTemplate model with a custom popup Form widget that uses a grouped repeater with the field name data to define the available "fields" within a ReportTemplate
Also manages Report models through a relation controller that uses a Form widget with a regular repeater with the field name data that defines the values of the fields defined by the associated ReportTemplate.

Since both repeaters had the field name of "data", but one of them was grouped and the other wasn't, this would cause an issue in Repeater::processExistingItems() where the grouped repeater would attempt to process the ungrouped repeater's data which would then fail. This issue could easily cause many other vastly more confusing and difficult to detect issues in cases where multiple repeaters with the same field name AND the same mode (grouped vs regular) existed on the same page under different contexts. The simple solution is just to ensure that the indexInputName and groupInputName are both taking the repeater's alias into account when being generated to ensure that everything stays unique like it should.
2019-03-18 12:39:12 -06:00
Ben Thomson 13a7cc915d Use Form getSaveData method when saving form widgets within repeaters (#4160)
Credit to @bennothommo
2019-03-15 22:39:34 -06:00
Luke Towers d5e7419312 Support enableDefaults on repeaters using grouped mode 2019-03-12 01:19:37 -06:00
Panagiotis Koursaris bb0a23f54c fixes enable Defaults on repeater (#4129)
Credit to @panakour
2019-02-11 09:54:55 -06:00
Ben Thomson 970d5622c0 Allow datatables to work within a repeater (#4102)
Fixes #4063. Credit to @bennothommo.
2019-02-04 12:50:40 -06:00
Antonie Hogewoning 16ca521cd0 Fix setting default values for repeater in update context (#4098)
Credit to @CptMeatball
2019-01-31 13:50:21 -06:00
Nathan van der Werf 0f0d108da0
Remove unused imports 2018-08-24 19:51:59 +02:00
Nathan van der Werf 66fa03f17e
Revert "Remove unused imports"
This reverts commit 742a5f415b.
2018-08-24 19:40:40 +02:00
Nathan van der Werf 3a918ad200 Remove "null" assignments 2018-08-15 18:33:24 +02:00
Nathan van der Werf 742a5f415b Remove unused imports 2018-08-15 18:27:36 +02:00
Luke Towers cbed54a263 Implemented minItems repeater property on client & server
Also implemented maxItems on server (previously only client). Fixes https://github.com/octobercms/october/issues/3668
2018-08-12 01:33:51 -06:00
Luke Towers 6774920003 Finish implementing titleFrom option for Repeaters
Ref: e7609aa5e8
2018-08-11 20:27:53 -06:00
Luke Towers d164145229
Fixes #2613
This fixes #2613 by reloading the form widgets with the modified data after `model.filterFields`. **NOTE**: `$this->processExistingItems()` isn't simply just moved to `prepareVars()` because that messes up the adding new repeater item functionality by repeating the content from the fields for the last item in that group that already exists on the repeater.
2017-11-01 14:18:41 -06:00
Luke Towers 2a16847724 Add support for readOnly Repeater Widgets (#2960)
* Add support for previewMode in Repeater FormWidget
Refs: #2724, 5f91c45f79
* Add support for previewMode in Repeater FormWidget

Refs: #2724, 5f91c45f79

* Add support for previewMode in Repeater FormWidget

Refs: #2724, 5f91c45f79

* Add support for previewMode in Repeater FormWidget

Refs: #2724, 5f91c45f79
2017-07-08 13:34:04 -06:00
Samuel Georges 6a6378a24d Strip indexes from repeater data sets 2017-04-26 08:10:45 +10:00
Samuel Georges cb56c61e36 Retain true backward compatibility with early repeater 2017-04-24 19:06:59 +10:00
Samuel Georges d7ef8cdcf8 Minor logic change 2017-04-24 13:24:57 +10:00
Samuel Georges 6825ce12c8 Allow external group field definition - Refs #2772 2017-04-24 13:24:57 +10:00
Samuel Georges c52f91a6d2 Collapsed items should default to or include the group name - Refs #2772 2017-04-24 13:24:56 +10:00
Samuel Georges acfe619cb9 Add button lacks loading state - Refs #2772 2017-04-24 13:24:55 +10:00
Samuel Georges ac7da4634a Implement working prototype of a grouped repeater
Refs #2772
2017-04-22 22:01:17 +10:00
Samuel Georges 83e80745b3 Fixes issue with index incrementation 2017-04-22 21:40:35 +10:00
Samuel Georges 46fcdbc636 Progress on repeater field groups
Refs #2772
2017-04-22 21:04:37 +10:00
Samuel Georges b841f9e066 {@inheritDoc} -> @inheritDoc 2017-03-16 06:26:14 +11:00
Samuel Georges e9cc782120 Peer review #2723 2017-03-01 14:31:37 +11:00
Luke Towers 5c56c9579d Add support for maxItems to the Repeater FormWidget
Refs: #2710
2017-02-28 20:36:32 -06:00
Samuel Georges 29040b416c Allow redirect: false on importExportController
Implement getFieldName() method
2016-11-28 07:50:06 +11:00
Samuel Georges 7b0f33e9b3 Adds an isNested flag to Form widget
This is useful when a form renders another form inside, specifically the repeater. In these cases the model and data will diverge, and it also provides an opportunity to not apply extension logic to nested form fields.
Fixes #2257
2016-11-05 09:53:23 +11:00
Samuel Georges 675a6a4224 Code improvements
Refs #2235
2016-07-23 14:22:36 +10:00