[de] Add method to check if we can fill in with the current role

This commit is contained in:
Ilya Kirillov
2025-02-18 20:12:15 +03:00
parent c74119b351
commit 26fd5ac0e1

View File

@ -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);