Skip to content

Commit

Permalink
Fix Select fieldtype's max_items: 1 limit indicator.
Browse files Browse the repository at this point in the history
This also uses green as the color when the limit has been met, and red when _exceeded_ because it would be an error state.
  • Loading branch information
jackmcdade committed Nov 18, 2020
1 parent 3185d65 commit 7ce0200
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions resources/js/components/fieldtypes/SelectFieldtype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,28 @@ export default {
return this.currentLength >= this.config.max_items;
},
limitExceeded() {
if (! this.config.max_items) return false;
return this.currentLength > this.config.max_items;
},
currentLength() {
return (this.value) ? this.value.length : 0
if (this.value) {
return (typeof this.value == 'string') ? 1 : this.value.length;
}
return 0;
},
limitIndicatorColor() {
return this.limitReached ? 'text-red' : 'text-grey'
if (this.limitExceeded) {
return 'text-red';
} else if (this.limitReached) {
return 'text-green';
}
return 'text-grey';
}
},
Expand Down

0 comments on commit 7ce0200

Please sign in to comment.