Set a maximum count number for each counter
This commit is contained in:
parent
ed81ff1bfc
commit
e8f4ff5c9d
2 changed files with 16 additions and 2 deletions
|
@ -6,6 +6,7 @@ export default class extends Controller {
|
|||
static values = {
|
||||
canBeNegative: Boolean,
|
||||
count: Number,
|
||||
maximumCountNumber: Number,
|
||||
};
|
||||
|
||||
connect() {
|
||||
|
@ -33,6 +34,12 @@ export default class extends Controller {
|
|||
increment() {
|
||||
console.log("count#increment");
|
||||
|
||||
const maximumCountNumber = this.maximumCountNumberValue || 10;
|
||||
|
||||
if (this.countValue === maximumCountNumber) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.countValue = this.countValue + 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue