diff --git a/e2e/paths/02-client-module/04_edit_pay_method.spec.js b/e2e/paths/02-client-module/04_edit_billing_data.spec.js similarity index 100% rename from e2e/paths/02-client-module/04_edit_pay_method.spec.js rename to e2e/paths/02-client-module/04_edit_billing_data.spec.js diff --git a/front/core/components/multi-check/multi-check.html b/front/core/components/multi-check/multi-check.html index 53c0262ed..2d51324f0 100644 --- a/front/core/components/multi-check/multi-check.html +++ b/front/core/components/multi-check/multi-check.html @@ -1 +1,5 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/front/core/components/multi-check/multi-check.js b/front/core/components/multi-check/multi-check.js index 14c5d6a9a..bb0279706 100644 --- a/front/core/components/multi-check/multi-check.js +++ b/front/core/components/multi-check/multi-check.js @@ -12,21 +12,74 @@ export default class MultiCheck extends Input { super($element, $scope); this._checkAll = false; this.checkField = 'checked'; + this.isIntermediate = false; } - get checkAll() { - return this._checkAll; + /** + * Gets array model instance + * + * @return {ArrayModel} - Array model instance + */ + get model() { + return this._model; } - set checkAll(value) { - this._checkAll = value; - this.switchChecks(); + /** + * Sets the array model instance + * Changes intermediate property for + * the check component + * + * @param {ArrayModel} value - Array model instance + */ + set model(value) { + this._model = value; + + if (value) { + value.on('rowChange', () => { + this.isIntermediate = this.allChecked && !this.areAllChecked(); + if (this.isIntermediate) + this._checked = undefined; + else if (this.areAllChecked()) + this._checked = true; + }); + } } - switchChecks() { - if (!this.data) return; - this.data.forEach(el => { - el[this.checkField] = this._checkAll; + /** + * Returns a bolean result for + * checked instances + * + * @return {Boolean} - True if all instances are checked + */ + areAllChecked() { + if (!this.model || !this.model.data) return; + + const data = this.model.data; + return data.every(item => { + return item[this.checkField] === true; + }); + } + + /** + * Gets current check state + */ + get checked() { + return this._checked; + } + + /** + * Sets current check state + * + * @param {Boolean} value - Checkbox state [undefined, true, false] + */ + set checked(value) { + this._checked = value; + this.allChecked = value; + + const data = this.model.data; + if (!data) return; + data.forEach(el => { + el[this.checkField] = value; }); } } @@ -35,7 +88,7 @@ ngModule.component('vnMultiCheck', { template: require('./multi-check.html'), controller: MultiCheck, bindings: { - data: '=', + model: '<', checkField: ' + model="model"> Order diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index c5c82bc75..7cfbbf244 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -36,7 +36,7 @@ + model="model"> diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 89848a99f..d57c0b7c2 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -56,7 +56,7 @@ + model="model">