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

luci-base: add member duplicate to DynamicList #7558

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

muink
Copy link
Contributor

@muink muink commented Jan 11, 2025

  • This PR is not from my main or master branch 💩, but a separate branch ✅
  • Each commit has a valid ✒️ Signed-off-by: <[email protected]> row (via git commit --signoff)
  • Each commit and PR title has a valid 📝 <package name>: title first line subject for packages
  • Incremented 🆙 any PKG_VERSION in the Makefile
  • Tested on: (x86_64, 24.10.0-rc4, Chrome) ✅
  • ( Preferred ) Mention: @systemcrash
  • ( Preferred ) Screenshot or mp4 of changes:
  • ( Optional ) Closes: e.g. openwrt/luci#issue-number
  • ( Optional ) Depends on: e.g. openwrt/packages#pr-number in sister repo
  • Description: (describe the changes proposed in this PR)

Description:

Add member duplicate to DynamicList to allow duplicate underlying form values.

duplicate defaults is null, DynamicList will keep the same behavior as before.
If o.duplicate = true, the underlying form value will not be checked for duplication.

Screenshot:

image

Add member `duplicate` to `DynamicList` to allow duplicate
underlying form values.

`duplicate` defaults is `null`, `DynamicList` will keep the
same behavior as before.
If `true`, the underlying form value will not be checked
for duplication.

Signed-off-by: Anya Lin <[email protected]>
@@ -2505,7 +2505,8 @@ const UIDynamicList = UIElement.extend(/** @lends LuCI.ui.DynamicList.prototype
return;

sbIn.setValues(sbEl, null);
sbVal.element.setAttribute('unselectable', '');
if (!this.options.duplicate)
sbVal.element.setAttribute('unselectable', '');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is there a need for a dependency of "unselectable" on "duplicate"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we can add preset chooses to DynamicList through o.value(key, label).
And the selected key choose will become unselectable.
This will prevent us from adding the same key.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah right, just from the name I was thinking it had to do with the ability to select the text, e.g. for copy/paste.

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