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

feat(ui5-tokenizer): change indicator's text when there are no visible tokens #7327

Merged
merged 4 commits into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/main/src/Tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
TOKENIZER_ARIA_CONTAIN_TOKEN,
TOKENIZER_ARIA_CONTAIN_ONE_TOKEN,
TOKENIZER_ARIA_CONTAIN_SEVERAL_TOKENS,
TOKENIZER_SHOW_ALL_ITEMS,
} from "./generated/i18n/i18n-defaults.js";

// Styles
Expand Down Expand Up @@ -630,7 +631,11 @@ class Tokenizer extends UI5Element {
}

get _nMoreText() {
return Tokenizer.i18nBundle.getText(MULTIINPUT_SHOW_MORE_TOKENS, this._nMoreCount);
if (this._getVisibleTokens().length) {
return Tokenizer.i18nBundle.getText(MULTIINPUT_SHOW_MORE_TOKENS, this._nMoreCount);
}

return Tokenizer.i18nBundle.getText(TOKENIZER_SHOW_ALL_ITEMS, this._nMoreCount);
}

get showNMore() {
Expand Down
3 changes: 3 additions & 0 deletions packages/main/src/i18n/messagebundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ TOKENIZER_ARIA_LABEL=Tokenizer
#XFLD: Remove label for Tokenizer's Dialog on phone
TOKENIZER_POPOVER_REMOVE=Remove

#XFLD: Token number indicator which is used to show all tokens in Tokenizer when all of the tokens are hidden
elenastoyanovaa marked this conversation as resolved.
Show resolved Hide resolved
TOKENIZER_SHOW_ALL_ITEMS={0} Items

#XACT: Label text for TreeListItem
TREE_ITEM_ARIA_LABEL=Tree Item

Expand Down
17 changes: 17 additions & 0 deletions packages/main/test/pages/MultiComboBox.html
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,23 @@
<ui5-button id="dummy-btn">dummy button</ui5-button>
</div>

<br>
<div class="demo-section">
<span>Multi Input with N-Items</span>
<br>
<ui5-multi-combobox id="mc-items" style="width: 150px">
<ui5-mcb-item selected text="Token 1"></ui5-mcb-item>
<ui5-mcb-item selected text="Enim do esse anim magna enim fugiat Lorem enim nostrud sit laborum ea."></ui5-mcb-item>
</ui5-multi-combobox>
<br>
<span>Multi Input with N-More</span>
<br>
<ui5-multi-combobox id="mc-more">
<ui5-mcb-item selected text="Token 1"></ui5-mcb-item>
<ui5-mcb-item selected text="Enim do esse anim magna enim fugiat Lorem enim nostrud sit laborum ea."></ui5-mcb-item>
</ui5-multi-combobox>
</div>

<hr class="demo-section">

<div class="demo-section">
Expand Down
18 changes: 18 additions & 0 deletions packages/main/test/pages/MultiInput.html
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,24 @@ <h1 class="sample-container-title">Multi Input with Truncated token</h1>
</ui5-multi-input>

<ui5-button id="dummy-btn">dummy button</ui5-button>

<br>
<br>

<h1 class="sample-container-title">Multi Input with N-Items</h1>
<ui5-multi-input id="mi-items" style="width: 150px">
<ui5-token text="Lorem ipsum" slot="tokens"></ui5-token>
<ui5-token text="Lorem ipsum 1" slot="tokens"></ui5-token>
</ui5-multi-input>

<br>
<br>

<h1 class="sample-container-title">Multi Input with N-More</h1>
<ui5-multi-input id="mi-more">
<ui5-token text="Token 1" slot="tokens"></ui5-token>
<ui5-token text="Enim do esse anim magna enim fugiat Lorem enim nostrud sit laborum ea." slot="tokens"></ui5-token>
</ui5-multi-input>
</div>

<div class="sample-container">
Expand Down
25 changes: 25 additions & 0 deletions packages/main/test/specs/MultiComboBox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,31 @@ describe("MultiComboBox general interaction", () => {
await mcb.click();
assert.notOk(await popover.getProperty("opened"), "Popover with valueStateMessage should not be opened.");
});

it("Should apply correct text to the tokens overflow indicator", async () => {
const mcNItems = await $("#mc-items");
const mcNMore = await $("#mc-more");
const tokenizerNItems = await mcNItems.shadow$("ui5-tokenizer");
const tokenizerNMore = await mcNMore.shadow$("ui5-tokenizer");
const nItemsLabel = await tokenizerNItems.shadow$(".ui5-tokenizer-more-text");
const nMoreLabel = await tokenizerNMore.shadow$(".ui5-tokenizer-more-text");
let resourceBundleTextItems = null;
let resourceBundleTextMore = null;


resourceBundleTextItems = await browser.executeAsync(done => {
niyap marked this conversation as resolved.
Show resolved Hide resolved
const mi = document.getElementById("mc-items");
done(mi.constructor.i18nBundle.getText(window["sap-ui-webcomponents-bundle"].defaultTexts.TOKENIZER_SHOW_ALL_ITEMS, 2));
});

resourceBundleTextMore = await browser.executeAsync(done => {
const mi = document.getElementById("mc-more");
done(mi.constructor.i18nBundle.getText(window["sap-ui-webcomponents-bundle"].defaultTexts.MULTIINPUT_SHOW_MORE_TOKENS, 1));
});

assert.strictEqual(await nItemsLabel.getText(), resourceBundleTextItems, "Text should be 2 Items");
assert.strictEqual(await nMoreLabel.getText(), resourceBundleTextMore, "Text should be 1 More");
});
});

describe("MultiComboBox Truncated Token", () => {
Expand Down
25 changes: 25 additions & 0 deletions packages/main/test/specs/MultiInput.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,31 @@ describe("MultiInput general interaction", () => {

assert.strictEqual(await innerInput.getProperty("value"), "", "Input's value should be empty");
});

it("Should apply correct text to the tokens overflow indicator", async () => {
const miNItems = await $("#mi-items");
const miNMore = await $("#mi-more");
const tokenizerNItems = await miNItems.shadow$("ui5-tokenizer");
const tokenizerNMore = await miNMore.shadow$("ui5-tokenizer");
const nItemsLabel = await tokenizerNItems.shadow$(".ui5-tokenizer-more-text");
const nMoreLabel = await tokenizerNMore.shadow$(".ui5-tokenizer-more-text");
let resourceBundleTextItems = null;
let resourceBundleTextMore = null;


resourceBundleTextItems = await browser.executeAsync(done => {
const mi = document.getElementById("mi-items");
niyap marked this conversation as resolved.
Show resolved Hide resolved
done(mi.constructor.i18nBundle.getText(window["sap-ui-webcomponents-bundle"].defaultTexts.TOKENIZER_SHOW_ALL_ITEMS, 2));
});

resourceBundleTextMore = await browser.executeAsync(done => {
const mi = document.getElementById("mi-more");
done(mi.constructor.i18nBundle.getText(window["sap-ui-webcomponents-bundle"].defaultTexts.MULTIINPUT_SHOW_MORE_TOKENS, 1));
});

assert.strictEqual(await nItemsLabel.getText(), resourceBundleTextItems, "Text should be 2 Items");
assert.strictEqual(await nMoreLabel.getText(), resourceBundleTextMore, "Text should be 1 More");
});
});

describe("MultiInput Truncated Token", () => {
Expand Down
Loading