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

enhancement(Timepicker) implementation with confirmation buttons util #575

Open
wants to merge 10 commits into
base: v2-dev
Choose a base branch
from

Conversation

gselderslaghs
Copy link
Member

Proposed changes

This pull request is a follow up of #572 and #574 and handles the implementation of the Utils.createButton with callback method and the Utils.createConfirmContainer with callback methods

With the callback function, we can open and close modal (or custom) implementation in combination with timepicker with the onDone and onCancel callbacks

Example:

html

<div class="row">
    <div class="input-field datepicker-field s12">
        <input id="timepicker" type="text" class="timepicker">
        <label for="timepicker">Time</label>
    </div>
</div>

<dialog class="modal" style="width: 620px"></dialog>

script

M.Timepicker.init(document.querySelectorAll('.timepicker'), {
    autoSubmit: false,
    container: '.modal',
    onInputInteraction: () => {
        toggleModal();
    },
    onDone: () => {
        toggleModal();
    },
    onCancel: () => {
        toggleModal();
    }
});

const modal = document.querySelector('.modal');
const toggleModal = () => {
    if (!modal.hasAttribute('open')) {
        modal.setAttribute('open', 'true');
    } else {
        modal.removeAttribute('open');
    }
}
  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to change).

Checklist:

  • I have read the CONTRIBUTING document.
  • My commit messages follows the conventional commit format
  • My change requires a change to the documentation, and updated it accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@gselderslaghs
Copy link
Member Author

Implemented additional check to render confirmation container only if auto submit is false (as in #572)
Fixed incorrect callback function check

This is ready for review

@wuda-io
Copy link
Member

wuda-io commented Dec 31, 2024

Thanks for the awesome work! I will take a look next year and review it.

Best wishes to all contributors and take care going into the new year. See you all soon ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants