Skip to content
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

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
10 changes: 8 additions & 2 deletions modules/backend/behaviors/RelationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,12 +673,18 @@ protected function makeViewWidget()
$config->recordUrl = $this->getConfig('view[recordUrl]');
$config->customViewPath = $this->getConfig('view[customViewPath]');
$config->noRecordsMessage = $this->getConfig('view[noRecordsMessage]');
$config->size = $this->getConfig('manage[size]');
$config->cssClass = $this->getConfig('manage[cssClass]');
$config->allowDismiss = $this->getConfig('manage[allowDismiss]');

$defaultOnClick = sprintf(
"$.wn.relationBehavior.clickViewListRecord(':%s', '%s', '%s')",
"$.wn.relationBehavior.clickViewListRecord(':%s', '%s', '%s', '%s', '%s', '%s')",
$this->relationModel->getKeyName(),
$this->relationGetId(),
$this->relationGetSessionKey()
$this->relationGetSessionKey(),
$config->size,
$config->cssClass,
$config->allowDismiss
);

if ($config->recordUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@
$(el).closest('.control-list').listWidget('toggleChecked', [el])
}

this.clickViewListRecord = function(recordId, relationId, sessionKey) {
this.clickViewListRecord = function(recordId, relationId, sessionKey, size, cssClass, allowDismiss) {
var newPopup = $('<a />'),
$container = $('#'+relationId),
requestData = paramToObj('data-request-data', $container.data('request-data'))

if (!size) {
size = 'huge'
}

newPopup.popup({
handler: 'onRelationClickViewList',
size: 'huge',
size: size,
cssClass: cssClass,
allowDismiss: allowDismiss,
extraData: $.extend({}, requestData, {
'manage_id': recordId,
'_session_key': sessionKey
Expand Down
18 changes: 17 additions & 1 deletion modules/system/assets/ui/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
content: null,
size: null,
adaptiveHeight: false,
zIndex: null
zIndex: null,
cssClass: null,
allowDismiss: false
}

Popup.prototype.init = function(){
Expand Down Expand Up @@ -207,8 +209,22 @@
if (this.options.adaptiveHeight)
modalDialog.addClass('adaptive-height')

if (this.options.cssClass)
modalDialog.addClass(this.options.cssClass)

if (this.options.zIndex !== null)
modal.css('z-index', this.options.zIndex + 20)

if (this.options.allowDismiss) {
modal.on('mousedown', function(e) {
const target = e.target;
if (target.classList.contains('control-popup')) {
modal.hide()
$('.popup-backdrop').remove()
$(document.body).removeClass('modal-open')
}
});
}
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes


return modal.append(modalDialog.append(modalContent))
}
Expand Down
12 changes: 8 additions & 4 deletions modules/system/assets/ui/storm-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading