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 a540c25018b5f9852ce38f7d545dd3bb6ed4ce8d..50604d2f6a55d2380c631c2925bee815e9806c6a 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 @@ -377,8 +377,17 @@ export class SchedulingSetCreate extends Component { // TODO: This function should be modified or removed async getEmptySchedulingUnit(strategyId){ - let suList = await ScheduleService.getSchedulingUnitDraft(); - return [_.find(suList.data.results, {'observation_strategy_template_id': strategyId})]; + // let suList = await ScheduleService.getSchedulingUnitDraft(); + // return [_.find(suList.data.results, {'observation_strategy_template_id': strategyId})]; + let emptySU = {name: "", description: ""}; + let constraintTemplates = await ScheduleService.getSchedulingConstraintTemplates(); + let constraintTemplate = constraintTemplates.length>0?constraintTemplates[0]:null; + emptySU['scheduling_constraints_template_id'] = constraintTemplate?constraintTemplate.id:null; + emptySU['scheduling_constraints_doc'] = {}; + let strategy = _.find(this.observStrategies, ['id', strategyId]); + emptySU['requirements_doc'] = strategy?strategy.template:{}; + emptySU['observation_strategy_template_id'] = strategyId; + return [emptySU]; } /** @@ -455,16 +464,27 @@ export class SchedulingSetCreate extends Component { return { backgroundColor: ''}; } }, }; - cellProps['angle3'] = {isgroup: true, cellEditor: 'numericEditor',cellStyle: function(params) { if (params.value){ - if (!params.colDef.field.startsWith('gdef') && !Number(params.value)) { - return { backgroundColor: BG_COLOR}; - } - else{ - return { backgroundColor: ''}; - } - } else { - return (!params.colDef.field.startsWith('gdef')) ?{ backgroundColor: BG_COLOR} : { backgroundColor: ''} - }}}; + cellProps['angle3'] = {isgroup: true, cellEditor: 'numericEditor',cellStyle: function(params) { + // console.log(params); + // if (params.value){ + // console.log("params value - ", params.value); + // console.log(Number(params.value)); + // if (!params.colDef.field.startsWith('gdef') && isNaN(params.value)) { + // return { backgroundColor: BG_COLOR}; + // } + // else{ + // return { backgroundColor: ''}; + // } + // } else { + // console.log("No Params value"); + // return (!params.colDef.field.startsWith('gdef')) ?{ backgroundColor: BG_COLOR} : { backgroundColor: ''} + // } + if (isNaN(params.value)) { + return { backgroundColor: BG_COLOR}; + } else { + return { backgroundColor: ''}; + } + }}; cellProps['direction_type'] = {isgroup: true, cellEditor: 'agSelectCellEditor',default: schema.definitions.pointing.properties.direction_type.default, cellEditorParams: { values: schema.definitions.pointing.properties.direction_type.enum, @@ -882,9 +902,11 @@ export class SchedulingSetCreate extends Component { properties: {}, definitions:{} }; let taskDrafts = []; - await ScheduleService.getTasksDraftBySchedulingUnitId(scheduleUnit.id).then(response =>{ - taskDrafts = response.data.results; - }); + if (scheduleUnit.id) { + await ScheduleService.getTasksDraftBySchedulingUnitId(scheduleUnit.id).then(response =>{ + taskDrafts = response.data.results; + }); + } for (const taskName in tasks) { const task = tasks[taskName]; @@ -1049,8 +1071,11 @@ export class SchedulingSetCreate extends Component { } async getObservationValueFromTask(scheduleunit) { - let res = await ScheduleService.getTasksDraftBySchedulingUnitId(scheduleunit.id); - let taskDrafts = res.data.results; + let taskDrafts = []; + if (scheduleunit.id) { + let res = await ScheduleService.getTasksDraftBySchedulingUnitId(scheduleunit.id); + taskDrafts = res.data.results; + } let tasksToUpdate = {}; const observStrategy = _.find(this.observStrategies, {'id': scheduleunit.observation_strategy_template_id}); const tasks = observStrategy.template.tasks; @@ -1171,7 +1196,7 @@ export class SchedulingSetCreate extends Component { } observationProps['stations'] = await this.getStationGrops(scheduleunit); - let constraint = scheduleunit.scheduling_constraints_doc; + let constraint = scheduleunit.id?scheduleunit.scheduling_constraints_doc:null; if (constraint){ if (constraint.scheduler){ observationProps['scheduler'] = constraint.scheduler; @@ -1591,7 +1616,8 @@ export class SchedulingSetCreate extends Component { //column.colDef.cellStyle = { backgroundColor: BG_COLOR}; //rowNoColumn.colDef.cellStyle = { backgroundColor: BG_COLOR}; } else if(_.endsWith(column.colId, "angle3")){ - if (!Number(rowData[column.colId])){ + // if (!Number(rowData[column.colId])){ + if (isNaN(rowData[column.colId])) { isValidRow = false; errorMsg += column.colDef.headerName+", "; }