r7-labs / R7.Dnn.Extensions

A base library for DNN Platform extensions development
GNU Lesser General Public License v3.0
5 stars 5 forks source link

Modal popup refresh enabler #15

Closed roman-yagodin closed 5 years ago

roman-yagodin commented 6 years ago

Enables page refresh on closing popup, i.e. then user trigger some data changes on server. May have issues in mobile browsers.

Reference code: https://github.com/dnnsoftware/Dnn.Platform/blob/d988e269c2d93b86edf8392e816bae54b903df86/Website/js/Debug/dnn.modalpopup.js

// Usage:
// r7_dnnModal.enableRefresh (r7_dnnModal.getPopup (window.parent));

(function ($, window) {
  window.r7_dnnModal = {
    getPopup: function (_window) {
      return _window.jQuery("#iPopUp");
    },
    enableRefresh: function (popup) {
      popup.dialog("option", "refresh", true);
      popup.dialog("option", "close", function() {
        window.dnnModal.closePopUp(true, popup.dialog("option", "closingUrl"));
        // console.log ("custom close!");
      });
    }
  }
}) (jQuery, window);    
roman-yagodin commented 6 years ago

It looks more safe to re-enable refresh instead of trying to enable it if it was initially disabled.

  1. Use default EditUrl() method to get edit URL - it will provide edit URL with refresh=true
  2. On edit control load, disable refresh by calling r7_dnnModal.disableRefresh() via JavaScript. This will store close popup function with refresh=true.
  3. If user do some changes which require page refresh, re-enable refresh by calling r7_dnnModal.reEnableRefresh() via JavaScript - this will restore close popup function with refresh=true.
roman-yagodin commented 6 years ago

Need testing in real module. After that, some support could be added to EditPortalModuleBase.