From 26fd5ac0e176bc3e20b3aee39095a0d3ca90cb08 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Tue, 18 Feb 2025 20:12:15 +0300 Subject: [PATCH] [de] Add method to check if we can fill in with the current role --- oform/OForm.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/oform/OForm.js b/oform/OForm.js index b3147b3..2f6d517 100644 --- a/oform/OForm.js +++ b/oform/OForm.js @@ -561,6 +561,24 @@ { this.onUndoRedo(); }; + OForm.prototype.canFillRole = function(roleName) + { + let role = this.getRole(roleName); + if (!role || role.isFilled()) + return false; + + let weight = role.getWeight(); + for (let i = 0; i < this.Roles.length; ++i) + { + if (this.Roles[i] === role || this.Roles[i].isFilled()) + continue; + + if (this.Roles[i].getWeight() < weight) + return false; + } + + return true; + }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Private area //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -598,5 +616,6 @@ OForm.prototype['asc_moveDownRole'] = OForm.prototype.moveDownRole; OForm.prototype['asc_haveRole'] = OForm.prototype.haveRole; OForm.prototype['asc_getRole'] = OForm.prototype.getRoleSettings; + OForm.prototype['asc_canFillRole'] = OForm.prototype.canFillRole; })(window);