mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-05 15:23:12 +02:00
Rename duplicateItems to duplicateItemsAllowed for clarity
This commit is contained in:
parent
f286dbc653
commit
8a21c12482
|
@ -69,7 +69,7 @@ Or include Choices directly:
|
|||
removeItems: true,
|
||||
removeItemButton: false,
|
||||
editItems: false,
|
||||
duplicateItems: true,
|
||||
duplicateItemsAllowed: true,
|
||||
delimiter: ',',
|
||||
paste: true,
|
||||
searchEnabled: true,
|
||||
|
@ -256,12 +256,12 @@ Pass an array of objects:
|
|||
|
||||
**Usage:** Whether a user can edit items. An item's value can be edited by pressing the backspace.
|
||||
|
||||
### duplicateItems
|
||||
### duplicateItemsAllowed
|
||||
**Type:** `Boolean` **Default:** `true`
|
||||
|
||||
**Input types affected:** `text`, `select-multiple`
|
||||
|
||||
**Usage:** Whether each inputted/chosen item should be unique.
|
||||
**Usage:** Whether duplicate inputted/chosen items are allowed
|
||||
|
||||
### delimiter
|
||||
**Type:** `String` **Default:** `,`
|
||||
|
|
|
@ -577,7 +577,7 @@ var DEFAULT_CONFIG = exports.DEFAULT_CONFIG = {
|
|||
removeItems: true,
|
||||
removeItemButton: false,
|
||||
editItems: false,
|
||||
duplicateItems: true,
|
||||
duplicateItemsAllowed: true,
|
||||
delimiter: ',',
|
||||
paste: true,
|
||||
searchEnabled: true,
|
||||
|
@ -2975,7 +2975,7 @@ var Choices = function () {
|
|||
canAddItem = (0, _utils.regexFilter)(value, this.config.regexFilter);
|
||||
}
|
||||
|
||||
if (!this.config.duplicateItems && !valueAlreadyExists && canAddItem) {
|
||||
if (!this.config.duplicateItemsAllowed && !valueAlreadyExists && canAddItem) {
|
||||
canAddItem = false;
|
||||
notice = (0, _utils.isType)('Function', this.config.uniqueItemText) ? this.config.uniqueItemText(value) : this.config.uniqueItemText;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
2
public/assets/scripts/choices.min.js
vendored
2
public/assets/scripts/choices.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -316,13 +316,13 @@
|
|||
|
||||
var textUniqueVals = new Choices('#choices-text-unique-values', {
|
||||
paste: false,
|
||||
duplicateItems: false,
|
||||
duplicateItemsAllowed: false,
|
||||
editItems: true,
|
||||
});
|
||||
|
||||
var texti18n = new Choices('#choices-text-i18n', {
|
||||
paste: false,
|
||||
duplicateItems: false,
|
||||
duplicateItemsAllowed: false,
|
||||
editItems: true,
|
||||
maxItemCount: 5,
|
||||
addItemText: function(value) {
|
||||
|
|
|
@ -802,7 +802,7 @@ class Choices {
|
|||
: this.config.addItemText;
|
||||
|
||||
if (!this._isSelectOneElement) {
|
||||
const valueAlreadyExists = !existsInArray(activeItems, value);
|
||||
const isDuplicateValue = existsInArray(activeItems, value);
|
||||
|
||||
if (
|
||||
this.config.maxItemCount > 0 &&
|
||||
|
@ -828,7 +828,11 @@ class Choices {
|
|||
canAddItem = regexFilter(value, this.config.regexFilter);
|
||||
}
|
||||
|
||||
if (!this.config.duplicateItems && !valueAlreadyExists && canAddItem) {
|
||||
if (
|
||||
!this.config.duplicateItemsAllowed &&
|
||||
isDuplicateValue &&
|
||||
canAddItem
|
||||
) {
|
||||
canAddItem = false;
|
||||
notice = isType('Function', this.config.uniqueItemText)
|
||||
? this.config.uniqueItemText(value)
|
||||
|
|
|
@ -39,7 +39,7 @@ export const DEFAULT_CONFIG = {
|
|||
removeItems: true,
|
||||
removeItemButton: false,
|
||||
editItems: false,
|
||||
duplicateItems: true,
|
||||
duplicateItemsAllowed: true,
|
||||
delimiter: ',',
|
||||
paste: true,
|
||||
searchEnabled: true,
|
||||
|
|
|
@ -59,7 +59,7 @@ describe('constants', () => {
|
|||
expect(DEFAULT_CONFIG.removeItems).to.be.a('boolean');
|
||||
expect(DEFAULT_CONFIG.removeItemButton).to.be.a('boolean');
|
||||
expect(DEFAULT_CONFIG.editItems).to.be.a('boolean');
|
||||
expect(DEFAULT_CONFIG.duplicateItems).to.be.a('boolean');
|
||||
expect(DEFAULT_CONFIG.duplicateItemsAllowed).to.be.a('boolean');
|
||||
expect(DEFAULT_CONFIG.delimiter).to.be.a('string');
|
||||
expect(DEFAULT_CONFIG.paste).to.be.a('boolean');
|
||||
expect(DEFAULT_CONFIG.searchEnabled).to.be.a('boolean');
|
||||
|
|
2
types/index.d.ts
vendored
2
types/index.d.ts
vendored
|
@ -320,7 +320,7 @@ declare namespace Choices {
|
|||
*
|
||||
* @default true
|
||||
*/
|
||||
duplicateItems?: boolean;
|
||||
duplicateItemsAllowed?: boolean;
|
||||
|
||||
/**
|
||||
* What divides each value. The default delimiter seperates each value with a comma: `"Value 1, Value 2, Value 3"`.
|
||||
|
|
Loading…
Reference in a new issue