-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Relation controller popup: fix size, add cssClass and allowDismiss #1044
base: develop
Are you sure you want to change the base?
Conversation
@LukeTowers Should be finished |
Could add allowDismiss (see comments) |
@AIC-BV just a thought, is there a way we could integrate with the change monitor used in the cms section for the tabs to detect when a change has happened inside of a modal and warn / prevent the dismiss behaviour from being triggered in those cases? |
I assume something like this could be a basic for that kind of behaviour if (this.options.allowDismiss) {
modal.on('click', function(e) {
const target = e.target;
if (target.classList.contains('control-popup')) {
if (!modal.dataset.hasChanges) {
modal.hide()
$('.popup-backdrop').remove()
$(document.body).removeClass('modal-open')
} else {
// popup warning them about unsaved changes
}
}
});
const inputs = modal.querySelectorAll('input')
for (const input of inputs) {
input.addEventListener('change', function() {
modal.dataset.hasChanges = true
})
}
} |
Thoughts @LukeTowers @mjauvin ? |
@AIC-BV seems fine, have you tested it out? |
I'm using everything except the latest comment: #1044 (comment) |
@AIC-BV can we remove allowDismiss from this PR for now then? I don't want to support it unless it can be a bit safer first. |
If its ok for you I will add the popup shortly instead |
Can you help me getting started? Also, will this be enough? PS:
|
There's existing code for tracking changes here: https://wintercms.com/docs/v1.2/ui/script/input-monitor |
Was making another relation popup and added these properties in the relation_config:
I tried the change monitor and it doesn't show the warning when closing the popup.
What is left for finishing this PR is a way to show a popup warning the user about unsaved changes using either Input Monitor or custom written JS.
|
@jaxwilko any input? |
You can use Apart from that looks cool, I'll check it out and have a play when I have time :) |
Only trigger on mousedown, because when selecting text to copy you sometimes leave the modal and that would close it.
Strongly suggest to try it out :) |
@AIC-BV are you able to record a loom or something showing the new functionality and make a PR to the docs? If you can get those done then I should be able to quickly review and merge this before I push out 1.2.7. |
allowDismiss = Clicking next to the modal closes it (on mousedown because if you drag to select something and release the mouse button outside the modal, it would close the modal too) |
$(document.body).removeClass('modal-open') | ||
} | ||
}); | ||
} |
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.
Were you able to get the change monitoring to work?
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.
No there is no change monitor.
I remember trying to add it but it was looking at the main record instead of the related record
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.
@jaxwilko is this something you could take a look at? I'm concerned that if we add this functionality without that as a failsafe it could make accidental data loss for users too easy when in theory it shouldn't be too difficult to add the change monitoring before we merge this.
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.
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.
Yes
Add the possibility to define the popup size and its custom CSS classes.
You can now define these properties at the manage part of the config_relation.yaml:
See all popup sizes at https://wintercms.com/docs/v1.2/ui/controls/popup#data-attributes
size
already existed, but was hardcoded and not dynamically filled in.cssClass
is added.