From 38d8fbc16548d0c85a8ae5bbbfa5a0a852b80753 Mon Sep 17 00:00:00 2001
From: Muthukrishnanmatriot
 <76949556+muthukrishnanmatriot@users.noreply.github.com>
Date: Fri, 23 Jul 2021 14:38:32 +0530
Subject: [PATCH] TMSS-892 - updated for table values copy  and show default

---
 .../frontend/tmss_webapp/.vscode/launch.json  | 15 +++++++
 .../Scheduling/excelview.schedulingset.js     | 40 ++++++++++++-------
 2 files changed, 41 insertions(+), 14 deletions(-)
 create mode 100644 SAS/TMSS/frontend/tmss_webapp/.vscode/launch.json

diff --git a/SAS/TMSS/frontend/tmss_webapp/.vscode/launch.json b/SAS/TMSS/frontend/tmss_webapp/.vscode/launch.json
new file mode 100644
index 00000000000..562cc640775
--- /dev/null
+++ b/SAS/TMSS/frontend/tmss_webapp/.vscode/launch.json
@@ -0,0 +1,15 @@
+{
+    // Use IntelliSense to learn about possible attributes.
+    // Hover to view descriptions of existing attributes.
+    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "type": "pwa-chrome",
+            "request": "launch",
+            "name": "Launch Chrome against localhost",
+            "url": "http://localhost:3000",
+            "webRoot": "${workspaceFolder}"
+        }
+    ]
+}
\ No newline at end of file
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js
index 6fb9c245967..7a42a8d80e0 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js
@@ -686,6 +686,7 @@ export class SchedulingSetCreate extends Component {
      * Function to prepare row data for ag-grid. 
      */
      async prepareScheduleUnitListForGrid(){
+        let defaultCommonRowData ={};
         this.agSUWithDefaultValue = {'id': 0, 'suname': '', 'sudesc': ''};
         let schedulingUnitList = _.filter(this.state.schedulingUnitList,{'observation_strategy_template_id': this.state.observStrategy.id});
         if ( schedulingUnitList  && schedulingUnitList.length === 0) {
@@ -698,7 +699,7 @@ export class SchedulingSetCreate extends Component {
         this.tmpRowData = [];
         let totalSU = this.state.noOfSU;
         let lastRow = {};
-        let hasSameValue = true;
+        //let hasSameValue = true;
         if(schedulingUnitList && schedulingUnitList.length > 0) {
             for(const scheduleunit of schedulingUnitList){
                 let observationProps = {
@@ -798,18 +799,29 @@ export class SchedulingSetCreate extends Component {
                 //Set values for global row if all rows has same value
                 if (_.isEmpty(lastRow)) {
                     lastRow = observationProps;
-                }   else if (!_.isEqual(
+                    defaultCommonRowData = _.cloneDeep(observationProps);
+                }   else /* if (!_.isEqual(
                         _.omit(lastRow, ['id']),
                         _.omit(observationProps, ['id'])
-                    ))  {
-                    hasSameValue = false;
+                    )) */ { 
+
+                    const keys = Object.keys(lastRow);
+                    for (const key of keys) {
+                        if (key === 'daily') {
+                            console.log("key =>",key,lastRow[key], observationProps[key])
+                        }
+                        if ( !_.isEqual(lastRow[key], observationProps[key])) {
+                            defaultCommonRowData[key] = ''; 
+                        }
+                    }    
+                    //hasSameValue = false;
                 }
             }
         }   
-        let defaultCommonRowData = {};
+       /* let defaultCommonRowData = {};
         if (hasSameValue) {
             defaultCommonRowData = observationPropsList[observationPropsList.length-1];
-        }
+        }*/
         this.tmpRowData = observationPropsList;
         // find No. of rows filled in array
         let totalCount = this.tmpRowData.length;
@@ -853,7 +865,7 @@ export class SchedulingSetCreate extends Component {
             isAGLoading: false,
             commonRowData: [defaultCommonRowData],
             defaultCommonRowData: defaultCommonRowData,
-            hasSameValue: hasSameValue
+           // hasSameValue: hasSameValue
         });
         {this.state.gridApi && 
             this.state.gridApi.setRowData(this.state.rowData);
@@ -2304,16 +2316,16 @@ export class SchedulingSetCreate extends Component {
             if (key === 'id') {
                 gRowData[key] = tmpData[0][key];
             }
-            else if(this.state.hasSameValue) {
+            //else if(this.state.hasSameValue) {
                 gRowData['gdef_'+key] = tmpData[0][key];
-            } else {
+            /*} else {
                 gRowData['gdef_'+key] = '';
-            }
+            }*/
         }
-        gRowData['offset_from_max'] = this.constraintSchema.schema.properties.sky.properties.transit_offset.properties.from.maximum;
-        gRowData['offset_from_min'] =  this.constraintSchema.schema.properties.sky.properties.transit_offset.properties.from.minimum;
-        gRowData['offset_to_max'] = this.constraintSchema.schema.properties.sky.properties.transit_offset.properties.to.maximum;
-        gRowData['offset_to_min'] = this.constraintSchema.schema.properties.sky.properties.transit_offset.properties.to.minimum;
+        gRowData['gdef_offset_from_max'] = this.constraintSchema.schema.properties.sky.properties.transit_offset.properties.from.maximum;
+        gRowData['gdef_offset_from_min'] =  this.constraintSchema.schema.properties.sky.properties.transit_offset.properties.from.minimum;
+        gRowData['gdef_offset_to_max'] = this.constraintSchema.schema.properties.sky.properties.transit_offset.properties.to.maximum;
+        gRowData['gdef_offset_to_min'] = this.constraintSchema.schema.properties.sky.properties.transit_offset.properties.to.minimum;
         this.setState({commonRowData: [gRowData]});
     }
 
-- 
GitLab