changes
This commit is contained in:
@@ -47,3 +47,4 @@
|
|||||||
|
|
||||||
.row-section
|
.row-section
|
||||||
padding: 20px
|
padding: 20px
|
||||||
|
overflow-y: auto
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ import { ApiService } from 'src/app/_services';
|
|||||||
})
|
})
|
||||||
export class VeriableFormComponent implements OnInit {
|
export class VeriableFormComponent implements OnInit {
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
|
|
||||||
// Sample variable list for dropdown
|
|
||||||
variableList = ['Variable 1', 'Variable 2', 'Variable 3'];
|
|
||||||
public componentDestroyed = new Subject();
|
public componentDestroyed = new Subject();
|
||||||
rdsValues: any;
|
rdsValues: any;
|
||||||
selectedParamValue: any = {};
|
selectedParamValue: any = {};
|
||||||
@@ -22,7 +19,7 @@ export class VeriableFormComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private fb: FormBuilder, private api: ApiService) {
|
constructor(private fb: FormBuilder, private api: ApiService) {
|
||||||
this.form = this.fb.group({
|
this.form = this.fb.group({
|
||||||
rows: this.fb.array([]) // Form array for multiple rows
|
rows: this.fb.array([])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,9 +49,9 @@ export class VeriableFormComponent implements OnInit {
|
|||||||
|
|
||||||
createColumn(): FormGroup {
|
createColumn(): FormGroup {
|
||||||
return this.fb.group({
|
return this.fb.group({
|
||||||
type: [''], // Type can be 'text' or 'variable'
|
type: [''],
|
||||||
textValue: [''], // For text input
|
textValue: [''],
|
||||||
variableValue: [''] // For variable select
|
variableValue: ['']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +62,7 @@ export class VeriableFormComponent implements OnInit {
|
|||||||
|
|
||||||
addRow(): void {
|
addRow(): void {
|
||||||
const row = this.fb.group({
|
const row = this.fb.group({
|
||||||
columns: this.fb.array([this.createColumn()]) // Initialize with one column
|
columns: this.fb.array([this.createColumn()])
|
||||||
});
|
});
|
||||||
this.rows.push(row);
|
this.rows.push(row);
|
||||||
}
|
}
|
||||||
@@ -85,16 +82,13 @@ export class VeriableFormComponent implements OnInit {
|
|||||||
|
|
||||||
for (let item of this.rdsValues.modbus) {
|
for (let item of this.rdsValues.modbus) {
|
||||||
if (item.hasOwnProperty(selectedParam)) {
|
if (item.hasOwnProperty(selectedParam)) {
|
||||||
// Initialize the row if not present
|
|
||||||
if (!this.selectedParamValue[rowIndex]) {
|
if (!this.selectedParamValue[rowIndex]) {
|
||||||
this.selectedParamValue[rowIndex] = {};
|
this.selectedParamValue[rowIndex] = {};
|
||||||
}
|
}
|
||||||
// Assign the selected param value to the specific row and column
|
|
||||||
this.selectedParamValue[rowIndex][colIndex] = item[selectedParam];
|
this.selectedParamValue[rowIndex][colIndex] = item[selectedParam];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.inputValue = this.selectedParamValue[rowIndex][colIndex]
|
this.inputValue = this.selectedParamValue[rowIndex][colIndex]
|
||||||
console.log(`Row: ${rowIndex}, Column: ${colIndex}, Value:`, this.selectedParamValue[rowIndex][colIndex]);
|
console.log(`Row: ${rowIndex}, Column: ${colIndex}, Value:`, this.selectedParamValue[rowIndex][colIndex]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user