Merge "Limit topic length"
This commit is contained in:
commit
f5061ee565
@ -69,6 +69,7 @@ limitations under the License.
|
|||||||
<input
|
<input
|
||||||
is="iron-input"
|
is="iron-input"
|
||||||
id="tagNameInput"
|
id="tagNameInput"
|
||||||
|
maxlength="1024"
|
||||||
bind-value="{{topic}}">
|
bind-value="{{topic}}">
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
|
@ -244,6 +244,7 @@ limitations under the License.
|
|||||||
<gr-editable-label
|
<gr-editable-label
|
||||||
label-text="Add a topic"
|
label-text="Add a topic"
|
||||||
value="[[change.topic]]"
|
value="[[change.topic]]"
|
||||||
|
max-length="1024"
|
||||||
placeholder="[[_computeTopicPlaceholder(_topicReadOnly)]]"
|
placeholder="[[_computeTopicPlaceholder(_topicReadOnly)]]"
|
||||||
read-only="[[_topicReadOnly]]"
|
read-only="[[_topicReadOnly]]"
|
||||||
on-changed="_handleTopicChanged"></gr-editable-label>
|
on-changed="_handleTopicChanged"></gr-editable-label>
|
||||||
|
@ -90,6 +90,7 @@ limitations under the License.
|
|||||||
<paper-input
|
<paper-input
|
||||||
id="input"
|
id="input"
|
||||||
label="[[labelText]]"
|
label="[[labelText]]"
|
||||||
|
maxlength="[[maxLength]]"
|
||||||
value="{{_inputText}}"></paper-input>
|
value="{{_inputText}}"></paper-input>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<gr-button link id="cancelBtn" on-tap="_cancel">cancel</gr-button>
|
<gr-button link id="cancelBtn" on-tap="_cancel">cancel</gr-button>
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
reflectToAttribute: true,
|
reflectToAttribute: true,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
maxLength: Number,
|
||||||
_inputText: String,
|
_inputText: String,
|
||||||
// This is used to push the iron-input element up on the page, so
|
// This is used to push the iron-input element up on the page, so
|
||||||
// the input is placed in approximately the same position as the
|
// the input is placed in approximately the same position as the
|
||||||
|
@ -39,10 +39,18 @@
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of characters to display in the tooltop.
|
||||||
|
*/
|
||||||
|
tooltipLimit: {
|
||||||
|
type: Number,
|
||||||
|
value: 1024,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
observers: [
|
observers: [
|
||||||
'_updateTitle(text, limit)',
|
'_updateTitle(text, limit, tooltipLimit)',
|
||||||
],
|
],
|
||||||
|
|
||||||
behaviors: [
|
behaviors: [
|
||||||
@ -53,10 +61,10 @@
|
|||||||
* The text or limit have changed. Recompute whether a tooltip needs to be
|
* The text or limit have changed. Recompute whether a tooltip needs to be
|
||||||
* enabled.
|
* enabled.
|
||||||
*/
|
*/
|
||||||
_updateTitle(text, limit) {
|
_updateTitle(text, limit, tooltipLimit) {
|
||||||
this.hasTooltip = !!limit && !!text && text.length > limit;
|
this.hasTooltip = !!limit && !!text && text.length > limit;
|
||||||
if (this.hasTooltip) {
|
if (this.hasTooltip) {
|
||||||
this.setAttribute('title', text);
|
this.setAttribute('title', text.substr(0, tooltipLimit));
|
||||||
} else {
|
} else {
|
||||||
this.removeAttribute('title');
|
this.removeAttribute('title');
|
||||||
}
|
}
|
||||||
|
@ -66,15 +66,20 @@ limitations under the License.
|
|||||||
assert.equal(element.getAttribute('title'), 'abc 123');
|
assert.equal(element.getAttribute('title'), 'abc 123');
|
||||||
assert.isTrue(element.hasTooltip);
|
assert.isTrue(element.hasTooltip);
|
||||||
|
|
||||||
|
element.tooltipLimit = 3;
|
||||||
|
flushAsynchronousOperations();
|
||||||
|
assert.equal(element.getAttribute('title'), 'abc');
|
||||||
|
|
||||||
|
element.tooltipLimit = 1024;
|
||||||
element.limit = 100;
|
element.limit = 100;
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
assert.equal(updateSpy.callCount, 4);
|
assert.equal(updateSpy.callCount, 6);
|
||||||
assert.isNotOk(element.getAttribute('title'));
|
assert.isNotOk(element.getAttribute('title'));
|
||||||
assert.isFalse(element.hasTooltip);
|
assert.isFalse(element.hasTooltip);
|
||||||
|
|
||||||
element.limit = null;
|
element.limit = null;
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
assert.equal(updateSpy.callCount, 5);
|
assert.equal(updateSpy.callCount, 7);
|
||||||
assert.isNotOk(element.getAttribute('title'));
|
assert.isNotOk(element.getAttribute('title'));
|
||||||
assert.isFalse(element.hasTooltip);
|
assert.isFalse(element.hasTooltip);
|
||||||
});
|
});
|
||||||
|
@ -68,7 +68,9 @@ limitations under the License.
|
|||||||
</style>
|
</style>
|
||||||
<div class$="container [[_getBackgroundClass(transparentBackground)]]">
|
<div class$="container [[_getBackgroundClass(transparentBackground)]]">
|
||||||
<a href$="[[href]]">
|
<a href$="[[href]]">
|
||||||
<gr-limited-text limit="[[limit]]" text="[[text]]"></gr-limited-text>
|
<gr-limited-text
|
||||||
|
limit="[[limit]]"
|
||||||
|
text="[[text]]"></gr-limited-text>
|
||||||
</a>
|
</a>
|
||||||
<gr-button
|
<gr-button
|
||||||
id="remove"
|
id="remove"
|
||||||
|
Loading…
Reference in New Issue
Block a user