From 8abdd4993ea0ec94c134806d8e06227b713c6336 Mon Sep 17 00:00:00 2001
From: Julia Radzhabova <julia.radzhabova@onlyoffice.com>
Date: Wed, 31 Aug 2022 18:54:03 +0300
Subject: [PATCH] [DE] Disable max chars settings for form with mask

---
 .../main/app/view/FormSettings.js             | 24 ++++++++++---------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/apps/documenteditor/main/app/view/FormSettings.js b/apps/documenteditor/main/app/view/FormSettings.js
index bb4f03ac2..9e89325ea 100644
--- a/apps/documenteditor/main/app/view/FormSettings.js
+++ b/apps/documenteditor/main/app/view/FormSettings.js
@@ -619,7 +619,7 @@ define([
 
         onChMaxCharsChanged: function(field, newValue, oldValue, eOpts){
             var checked = (field.getValue()=='checked');
-            this.spnMaxChars.setDisabled(!checked || this._state.DisabledControls);
+            this.spnMaxChars.setDisabled(!checked || this._state.FormatType===Asc.TextFormFormatType.Mask || this._state.DisabledControls);
             if (!checked) {
                 this.chComb.setValue(false, true);
                 this.spnWidth.setDisabled(true);
@@ -651,7 +651,7 @@ define([
             var checked = (field.getValue()=='checked');
             if (checked) {
                 this.chMaxChars.setValue(true, true);
-                this.spnMaxChars.setDisabled(false || this._state.DisabledControls);
+                this.spnMaxChars.setDisabled(false || this._state.FormatType===Asc.TextFormFormatType.Mask || this._state.DisabledControls);
             }
             this.cmbWidthRule.setDisabled(!checked || this._state.Fixed || this._state.DisabledControls);
             this.spnWidth.setDisabled(!checked || this._state.WidthRule===Asc.CombFormWidthRule.Auto || this._state.DisabledControls);
@@ -1291,14 +1291,6 @@ define([
                         this._state.Width=val;
                     }
 
-                    val = formTextPr.get_MaxCharacters();
-                    this.chMaxChars.setValue(val && val>=0);
-                    this.spnMaxChars.setDisabled(!val || val<0 || this._state.DisabledControls);
-                    if ( (val===undefined || this._state.MaxChars===undefined)&&(this._state.MaxChars!==val) || Math.abs(this._state.MaxChars-val)>0.1) {
-                        this.spnMaxChars.setValue(val && val>=0 ? val : 10, true);
-                        this._state.MaxChars=val;
-                    }
-
                     val = formTextPr.get_FormatType();
                     if ( this._state.FormatType!==val ) {
                         this.cmbFormat.setValue((val !== null && val !== undefined) ? val : Asc.TextFormFormatType.None);
@@ -1316,6 +1308,15 @@ define([
                         this.txtFormatSymbols.setValue((val !== null && val !== undefined) ? val : '');
                         this._state.FormatSymbols=val;
                     }
+
+                    val = formTextPr.get_MaxCharacters();
+                    this.chMaxChars.setValue(val && val>=0);
+                    this.chMaxChars.setDisabled(this._state.FormatType===Asc.TextFormFormatType.Mask || this._state.DisabledControls);
+                    this.spnMaxChars.setDisabled(!val || val<0 || this._state.FormatType===Asc.TextFormFormatType.Mask || this._state.DisabledControls);
+                    if ( (val===undefined || this._state.MaxChars===undefined)&&(this._state.MaxChars!==val) || Math.abs(this._state.MaxChars-val)>0.1) {
+                        this.spnMaxChars.setValue(val && val>=0 ? val : 10, true);
+                        this._state.MaxChars=val;
+                    }
                 } else
                     this._originalTextFormProps = null;
 
@@ -1416,7 +1417,8 @@ define([
                     item.setDisabled(me._state.DisabledControls);
                 });
             }
-            this.spnMaxChars.setDisabled(this.chMaxChars.getValue()!=='checked' || this._state.DisabledControls);
+            this.chMaxChars.setDisabled(this._state.FormatType===Asc.TextFormFormatType.Mask || this._state.DisabledControls);
+            this.spnMaxChars.setDisabled(this.chMaxChars.getValue()!=='checked' || this._state.FormatType===Asc.TextFormFormatType.Mask || this._state.DisabledControls);
             this.cmbWidthRule.setDisabled(!this._state.Comb || this._state.Fixed || this._state.DisabledControls);
             this.spnWidth.setDisabled(!this._state.Comb || this._state.WidthRule===Asc.CombFormWidthRule.Auto || this._state.DisabledControls);
             this.chMulti.setDisabled(!this._state.Fixed || this._state.Comb || this._state.DisabledControls);