From fba183b9efaa88220c7df65d69f9c92d5b2ef8da Mon Sep 17 00:00:00 2001
From: Reinder Kraaij <kraaij@astron.nl>
Date: Mon, 5 Feb 2024 12:30:09 +0000
Subject: [PATCH] Resolve TMSS-2899 "Front end only save button tweak"

---
 .../src/components/JSONEditor/JEditor.js      |  2 +-
 .../src/routes/Scheduling/create.js           | 26 +++++++------------
 2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js b/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js
index 8b298a51636..980ee469598 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js
@@ -1386,7 +1386,7 @@ Jeditor.propTypes = {
   schema: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.oneOf([null, undefined])]),
   bandPassFilter: PropTypes.string,
   id: PropTypes.string,
-  resolveExtRef: PropTypes.func,
+  resolveExtRef: PropTypes.bool,
   showInGrid: PropTypes.bool,
   title: PropTypes.string,
   errorsOn: PropTypes.bool,
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js
index 6da0df069d2..bccdbb61f5a 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js
@@ -40,13 +40,17 @@ import ProjectScheduleSetSelector from "./components/ProjectScheduleSetSelector"
  * Component to create a new SchedulingUnit from Observation strategy template
  */
 export class SchedulingUnitCreate extends Component {
-    constructor(props) {
+        constructor(props) {
         super(props);
         this.state = {
             observStrategyFilters: {
                 states: ['active'],
                 purpose: []
             },
+            constraintValidEditor:false,
+            validForm:false,
+            validConstraints:false,
+            validSpecification:false,
             userrole: {},
             selectedProject: {},
             showAddSet: false,
@@ -552,9 +556,8 @@ export class SchedulingUnitCreate extends Component {
             }
         }
         const updatedErrors = errors.length > 0 ? [...this.state.errors, errors] : this.state.errors
-        const updatedValidFields = validFields ? {...this.state.validFields, validFields} : this.state.validFields
+        const updatedValidFields = validFields ? {...this.state.validFields, ...validFields} : this.state.validFields;
         this.setState({errors: updatedErrors, validFields: updatedValidFields});
-
         if (Object.keys(validFields).length === Object.keys(this.formRules).length) {
             validForm = true;
         }
@@ -929,6 +932,7 @@ export class SchedulingUnitCreate extends Component {
     }
 
     render() {
+        let isSaveEnabled = (  this.state.constraintValidEditor &&  this.state.validEditor  && this.state.validForm && this.state.validConstraints  && this.state.validSpecification) 
         if (this.state.redirect) {
             return <Redirect to={{pathname: this.state.redirect}}></Redirect>
         }
@@ -1071,19 +1075,7 @@ export class SchedulingUnitCreate extends Component {
                                                   onChange={(e) => this.setSchedUnitParams('output_pinned', e.target.checked)}
                                         ></Checkbox>
                                     </div>
-                                    {/*
-                            <label htmlFor="schedulingConstraintsTemp" className="col-lg-2 col-md-2 col-sm-12 hide">Scheduling Constraints Template</label>
-                            <div className="col-lg-3 col-md-3 col-sm-12 hide" data-testid="schedulingConstraintsTemp">
-                                <Dropdown inputId="schedulingConstraintsTemp" optionLabel="name" optionValue="id" 
-                                        tooltip="Scheduling Constraints Template to add scheduling constraints to a scheduling unit" tooltipOptions={this.tooltipOptions}
-                                        value={this.state.schedulingUnit.scheduling_constraints_template_id}
-                                        disabled
-                                        options={this.constraintTemplates} 
-                                        //onChange={(e) => { this.setStrategyConstraint(e);}}
-                                        placeholder="Select Constraints Template"/>
-                            
-                            </div> 
-                            */}
+                             
                                 </div>
                                 {_.keys(this.state.stationGroups).length > 0 &&
                                     <div className='grouping'>
@@ -1161,7 +1153,7 @@ export class SchedulingUnitCreate extends Component {
                                            tooltip="Select checkbox to create another Scheduling Unit after saving this Scheduling Unit"
                                            submitTitle={(!this.state.constraintValidEditor || !this.state.validEditor || !this.state.validForm || !this.state.validConstraints || !this.state.validSpecification) ? "" : "Save Scheduling Unit"}
                                            onSubmit={this.saveSchedulingUnit}
-                                           disableSaveBtn={!this.state.constraintValidEditor || !this.state.validEditor || !this.state.validForm || !this.state.validConstraints || !this.state.validSpecification}
+                                           disableSaveBtn={!isSaveEnabled} 
                                            onCancel={this.checkIsDirty}/>
                         </div>
                         <ReactTooltip id="reacttooltip" place={'left'} type={'dark'} effect={'solid'} multiline={true}/>
-- 
GitLab