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

[Modules] Add user prompt #1407

Closed
baterflyrity opened this issue Apr 8, 2020 · 13 comments
Closed

[Modules] Add user prompt #1407

baterflyrity opened this issue Apr 8, 2020 · 13 comments
Labels
type/discussion Anything which is up for discussion type/feat Any feature requests or improvements
Milestone

Comments

@baterflyrity
Copy link

Feature Request

Since Fomantic UI presents not only UI but some interactive modules it would be great to add a user prompt module.

The module should ask user for some decision like "File 1.txt already exists. Would you like to overwrite this file?" And also can be invoked from js with text, label and buttons (actions) with callbacks.

Example

From one hand poor prompt is already can be constructed via toast actions but it displays only toast but prompt (no dimmer, no visual highlights). From another hand prompt can be displayed via modal but with no dynamic content, actions and callbacks.
So I suggest to merge modal UI with toast actions.

Example

Run confirm('Implement this?') in browser console to see default implementation.

@baterflyrity baterflyrity added state/awaiting-triage Any issues or pull requests which haven't yet been triaged type/feat Any feature requests or improvements labels Apr 8, 2020
@jamessampford
Copy link
Contributor

Unless I’ve totally missed something, these are both covered in the docs....

Modal has callbacks for approving and denying
https://fomantic-ui.com/modules/modal.html#approve--deny-callbacks

Toast also has the same callbacks
https://fomantic-ui.com/modules/toast.html#approve--deny-callbacks

@baterflyrity
Copy link
Author

baterflyrity commented Apr 8, 2020

@jamessampford I think u've missed the main idea))

  1. Toast is a small box in corner of page that notifies user about something. Prompt (user dialog) is big overlay with emphasized text and buttons. Just like modal.

  2. So u suggest to use modal? Ok, one has to execute something like this to show promt via modal:

    function prompt(label,text,yes,no) {
        $('.modal .header').html(label);
        $('.modal.content').html(text);
        $('.modal').modal({
            closable  : false,
            onDeny  : no,
            onApprove : yes
        })
        .modal('show');
    }

As you can see this is not so hard to implement but this is not actually in modal module scope now.

@lubber-de lubber-de added type/discussion Anything which is up for discussion and removed state/awaiting-triage Any issues or pull requests which haven't yet been triaged labels Apr 8, 2020
@jamessampford
Copy link
Contributor

In my mind, what you have in your example is easier (and quicker) than adding a whole new module/feature that will bloat the underlining Fomantic JS to do essentially the same thing but with a different name

If something, on the other hand, can be made easier where logic is needed to do various calculations, take into account other various things to stitch different aspects together, then that would be cool (like my Sidebar idea #1243)

Perhaps some kind of widget/extension factory/thingamajig could be useful to define/repurpose what you’re looking for 🤔

@baterflyrity
Copy link
Author

baterflyrity commented Apr 9, 2020

@jamessampford as you've mentioned in #1370 both the jQuery and HTML approaches are used for small size user dialogs. But why for large size user dialogs can't jQuery exists?

Ok, but the same applies to other modules (modal, popup, dropdown) as well 😉

Contributors would better decide whether Fomantic is UI or Framework then to not make others confused.

@prudho
Copy link
Contributor

prudho commented Oct 19, 2020

Hello, I have started a discussion about an eventual alert plugin that may be relevant for you: #1716 !

@lubber-de
Copy link
Member

I added the same functionality from toast to modal to create them out of JS properties or reuse existing modals as templates
See #1774

@lubber-de lubber-de added the state/has-pr An issue which has a related PR open label Nov 19, 2020
@lubber-de lubber-de added this to the 2.8.8 milestone Nov 19, 2020
@baterflyrity
Copy link
Author

I added the same functionality from toast to modal to create them out of JS properties or reuse existing modals as templates
See #1774

Very nice, thank you for well done work.

But what about more simplification like above? Just to be more convenient as in JS, C# and other popular message.

@lubber-de
Copy link
Member

lubber-de commented Nov 19, 2020

@baterflyrity Maybe, once my PR is approved and merged, we can think about how/if additional and configurable templates for a prompt/alert could work/make sense. The fui-alert plugin by @prudho is currently a much better approach using promises

@baterflyrity
Copy link
Author

baterflyrity commented Nov 19, 2020

@lubber-de, no problems until you close this issue with wrong PR.
Btw current state of the project has messed up semantic, dynamic, static, modern JS-like approaches. So users always be confused without strict architecture guidelines through whole modules.

@lubber-de
Copy link
Member

My current PR solves what you initially suggested

From another hand prompt can be displayed via modal but with no dynamic content, actions and callbacks.
So I suggest to merge modal UI with toast actions.

Dynamic content and actions with callbacks are now possible using js given properties just as in toast

title: 'MyTitle',
content: 'MyContent'
actions: [{
  text: 'Alright',
  class: 'green',
  click: function() {
    // do something when clicked
  } 
}]  

We definately won't create a completely additional module such as .alert() or .prompt() in the current state of 2.x as this is all doable easily with the current modal module as already discussed earlier.

The only thing i can think of is an alert, confirm or prompt behavior with a predefined layout (customizable as templates as we have in dropdown as well)) to somehow provide what you want.

However, it would still be

$('body').modal('alert','MyTitle','MyText',function(){/* my callback code*/});
$('body').modal('confirm','MyTitle','MyText',function(confirmed){/* my callback code depending if confirmed is true/false*/});
$('body').modal('prompt','MyTitle','MyText',function(inputValue){/* my callback code using the entered value from an input field*/});

which matches the base functionaliy of existing JS confirm/prompt/alert methods.

btw, i was also thinking of adding a centered and dimmer option to the toast module, which should then satisfy most use cases

@baterflyrity
Copy link
Author

baterflyrity commented Nov 19, 2020

@lubber-de ,

However, it would still be

$('body').modal('alert','MyTitle','MyText',function(){/* my callback code*/});
$('body').modal('confirm','MyTitle','MyText',function(confirmed){/* my callback code depending if confirmed is true/false*/});
$('body').modal('prompt','MyTitle','MyText',function(inputValue){/* my callback code using the entered value from an input field*/});

which matches the base functionaliy of existing JS confirm/prompt/alert methods.

This is closer to correct user dialog box. I'd be great to also see save and load predefined dialogs.

p.s.

We definately won't create a completely additional module such as .alert() or .prompt() in the current state of 2.x as this is all doable easily with the current modal module as already discussed earlier.

All things can be done easily but think what about writing 5 more higher level lines to save 5 minutes in future scaled by projects and users.

@lubber-de
Copy link
Member

alert, confirm, prompt and any custom predefined modal are now possible by #1869. For examples and explanation see the PR.

@baterflyrity
Copy link
Author

@lubber-de great job, i like it!

@lubber-de lubber-de added tag/next-release/nightly Any issue which has a corresponding PR which has been merged and is available in the nightly build and removed state/has-pr An issue which has a related PR open labels Feb 25, 2021
@lubber-de lubber-de removed the tag/next-release/nightly Any issue which has a corresponding PR which has been merged and is available in the nightly build label Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/discussion Anything which is up for discussion type/feat Any feature requests or improvements
Projects
None yet
Development

No branches or pull requests

4 participants