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

Tycho: Adds input addon with copy button #1289

Merged
merged 3 commits into from
Sep 22, 2023

Conversation

sabieber
Copy link
Member

@sabieber sabieber commented Sep 21, 2023

This allows to render an addon button next to a (most probably read-only) which copies the current value of the field into the clipboard on click.
It also updates the tooltip when this action worked.

image

image

Sample:

<t:textfield name="id"
             readonly="true"
             value="@token.getId()"
             label="ID"
             helpKey="PortalApiToken.id.help">
    <i:block name="addon">
        <t:copyToClipboardAddon fieldName="id"/>
    </i:block>
</t:textfield>

This is more flexible than just being able to show a simple text.
This is adapted from the OXOMI JS code base, so it should work in all modern browsers + IE 11.
This allows to render an addon button next to a (most probably read-only) which copies the current value of the field into the clipboard on click.
It also updates the tooltip when this action worked.
@sabieber sabieber added 🧬 Enhancement Contains new features 👶🏻 Trivial Easy to review labels Sep 21, 2023
@@ -691,3 +691,64 @@ sirius.extractFileExtension = function (filename) {
}
return '.' + nameAndExtension.pop();
}

/**@
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

@sabieber sabieber Sep 22, 2023

Choose a reason for hiding this comment

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

Just my opinion:

  • Better scoping (along the other helper methods)
  • More robust fake element / fallback handling
  • Tried and tested code that ran a long time in OX (I can't find a call to the function from clipboard js)
  • Marking the element with a class (which is a required use case for OX

Actually I really didn't know the other function existed as it is nowhere used in sirius-web :D

@sabieber sabieber merged commit d64218f into develop Sep 22, 2023
@sabieber sabieber deleted the feature/sbi/input-copy-addon branch September 22, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧬 Enhancement Contains new features 👶🏻 Trivial Easy to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants