-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drag validation #32
Drag validation #32
Conversation
I'm still trying to understand it! Tabledrag is kind of big black box =))) |
Initial review is completed. Conceptually it's very good! Configuration form looks clear and straightforward. And I can confirm that nesting validation is working (with some bugs, but working)! Bug 1:
|
I have been working on this, it is a bit difficult, |
@danielbeeke sure- no pressure! |
It is a bit better now, but still one ugly bug that I can not find. |
It's much, much better!!! Main validation functionality works for me. I reproduced the same bug in a more simple way: https://youtu.be/cthjwseTQmM. Probably this can help. Also, some ideas:
So if the following conditions will be skipped => we can have a bug.
|
https://www.youtube.com/watch?v=v4VIbKz3wKg&feature=youtu.be&t=34 I still got one very strange bug. Strange! |
bricks.libraries.yml
Outdated
@@ -1,3 +1,12 @@ | |||
tabledrag.relationship-all: | |||
js: | |||
js/tabledrag.relationship-all.js: {} | |||
|
|||
nesting-validation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This validation is:
- for tabledrag
- Bricks-specific
=> so I think a better name would be tabledrag.bricks-validation
or just tabledrag.bricks
(can be used further for over UI stuff).
bricks.links.menu.yml
Outdated
@@ -0,0 +1,5 @@ | |||
bricks.settings: | |||
title: 'Bricks settings' | |||
parent: system.admin_config_media |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about system.admin_structure
? Imho, more obvious (like ECK, View modes, Paragraphs etc).
bricks.module
Outdated
/** | ||
* Returns the nesting settings in a format that the javascript can handle. | ||
*/ | ||
function bricks_get_nesting_data($return_entity_type = NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_bricks_get_nesting_data
?
bricks.module
Outdated
@@ -187,6 +187,9 @@ function _bricks_preprocess_tabledrag_form(&$variables, $element_key, $widget, $ | |||
if ($key !== 'add_more') { | |||
$depth = $element[$key]['depth']['#value']; | |||
|
|||
$variables['table']['#rows'][$key]['data-depth'] = $depth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to store depth as data-attribute? We already have hidden input with depth and can get value right from there! https://github.com/highweb/drupal-bricks/blob/8.x-1.4/bricks.module#L234
bricks.routing.yml
Outdated
@@ -0,0 +1,7 @@ | |||
bricks.config: | |||
path: '/admin/config/media/bricks' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/admin/structure/bricks
?
js/nesting-validation.js
Outdated
var prevBundle = $(prevRow).attr('data-bundle'); | ||
var parentBundle = $(this.group[0]).prev('tr').attr('data-bundle'); | ||
|
||
if ($.inArray(prevBundle, settings.bricks.nesting[currentBundle]) !== -1 || $.inArray(parentBundle, settings.bricks.nesting[currentBundle]) !== -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is currentBundle
nestable under prevBundle
? => increment values.max
. Why to care about parentBundle
?
Also: not sure but what if this code is running for say depth 3? Shouldn't values.max
equal 3+1?
And what if there is no parent? (depth = 0, delta = 3 in example)
I have been working on this, but it seems more difficult. I am also replacing the validSwap function |
@danielbeeke the code looks much better! Are we still have some critical bugs or must-have refactoring? |
@danielbeeke the implementation seems to be not that straightforward and simple… I suggest the following:
What do you think? |
d.org issue: https://www.drupal.org/node/2868539
In this commit are a settings form, a bit of preprocessing data-attributes and a little proof of concept javascript. The javascript is not yet bug free. I am still trying to wrap my mind around how the tabledrag things work.
What are the opinions about the approach? What needs to be changed?