os-js / osjs-dialogs

OS.js Dialogs Module
https://manual.os-js.org/v3/
Other
4 stars 7 forks source link

Add wrapper for rendering in custom dialog #12

Closed andersevenrud closed 3 years ago

andersevenrud commented 3 years ago

This allows to create custom dialogs without relying on Hyperapp to construct the intial UI with buttons in the custom dialog.


Right now to create a custom dialog with buttons, following https://manual.os-js.org/tutorial/dialog the .render() call needs to be set up with some scaffolding. I added .renderCustom() that has the same signature, but gives you the buttons out of the box.

andersevenrud commented 3 years ago

By the scaffolding I was refering to the "UI Customization" step in the manuals.

oeway commented 3 years ago

Thanks for making changes, does this mean I need to use renderCustom instead of render?

const callbackRender = ($content, dialogWindow, dialog) => {
      $content.innerHTML = "Hello"
    };
    core.make('osjs/dialogs')
      .create({buttons: ["button-1", "cancel"],
      window: {
        title,
        dimension: {width: 400, height: 400}
      }}, ()=>{

      }, (button)=>{
         alert(button)
      })
      .render(callbackRender);

I just tried with this, it doesn't seem to work.

andersevenrud commented 3 years ago

Yes, renderCustom is the new method.

On Sun, Aug 1, 2021, 17:45 Wei Ouyang @.***> wrote:

Thanks for making changes, does this mean I need to use renderCustom instead of render?

const callbackRender = ($content, dialogWindow, dialog) => { $content.innerHTML = "Hello" }; core.make('osjs/dialogs') .create({buttons: ["button-1", "cancel"], window: { title, dimension: {width: 400, height: 400} }}, ()=>{

  }, (button)=>{
     alert(button)
  })
  .render(callbackRender);

I just tried with this, it doesn't seem to work.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/os-js/osjs-dialogs/pull/12#issuecomment-890542308, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABHODAK4FAMVYMHKI5JMMDT2VT3LANCNFSM5BLGZG2Q .

oeway commented 3 years ago

I had some issue with my setup, cannot make this branch work with my desktop, I will wait for your test.

andersevenrud commented 3 years ago

Update @osjs/dialogs and rebuild your client. Then you should be able to use this new method.

I've also updated the documentation: https://github.com/os-js/manual.os-js.org/commit/9283ee5606f47d759c0c1cb4545024cf9bcde5b1 (which is currently being deployed)