Skip to content

Commit

Permalink
Rename maxCardinality to maxListLength due to ambiguities.
Browse files Browse the repository at this point in the history
Cardinality is not the correct term to use KISS.
  • Loading branch information
Glen Pike committed Sep 12, 2016
1 parent a871e29 commit 3ce1403
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/editors/extra/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@
},

/**
* If number of items exceeds the maxCardinality value set on the schema,
* If number of items exceeds the maxListLength value set on the schema,
* hide any 'add' button in the passed in $element
*
* @param {jQuery selector} [$el] Where to look for the add button
*/
_checkMaxCardinalityReached: function($el) {
if (this.schema.maxCardinality && this.items.length >= this.schema.maxCardinality) {
if (this.schema.maxListLength && this.items.length >= this.schema.maxListLength) {
$el.find('button[data-action="add"]').hide();
}
},
Expand Down Expand Up @@ -205,8 +205,8 @@

if (!this.items.length && !this.Editor.isAsync) this.addItem();

// show the "add" button in case the cardinality has not been reached
if (this.schema.maxCardinality && this.items.length < this.schema.maxCardinality) {
// show the "add" button in case the max-length has not been reached
if (this.schema.maxListLength && this.items.length < this.schema.maxListLength) {
this.$el.find('button[data-action="add"]').show();
}
},
Expand Down
14 changes: 7 additions & 7 deletions test/editors/extra/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module('List', {

teardown: function() {
this.sinon.restore();
$('#qunit-fixture').remove('.cardinality-test')
$('#qunit-fixture').remove('.length-test')
}
});

Expand Down Expand Up @@ -93,10 +93,10 @@ var same = deepEqual;
same(list.$('[data-action="add"]').text(), 'Agregar');
});

test('cardinality: Add button is hidden if maxCardinality is reached', function() {
test('length: Add button is hidden if maxListLength is reached', function() {
var maxLength = 10;
var list = new List({
schema: { maxCardinality: maxLength }
schema: { maxListLength: maxLength }
}).render();

$('#qunit-fixture').append(list.el);
Expand All @@ -119,8 +119,8 @@ var same = deepEqual;
}

var list = new List({
className: 'cardinality-test',
schema: { maxCardinality: maxLength },
className: 'length-test',
schema: { maxListLength: maxLength },
value: items
}).render();

Expand All @@ -133,13 +133,13 @@ var same = deepEqual;
return list;
}

test('cardinality: Add button is hidden if initial items >= maxCardinality', function() {
test('length: Add button is hidden if initial items >= maxListLength', function() {
var maxLength = 10;

createListWithMaxItems(maxLength);
});

test('cardinality: Add button is shown again if num items < maxCardinality', function() {
test('length: Add button is shown again if num items < maxListLength', function() {
var maxLength = 10;

var list = createListWithMaxItems(maxLength);
Expand Down

0 comments on commit 3ce1403

Please sign in to comment.