Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update the data fields when the MSEL is updated #176

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blueprint-ui",
"version": "1.2.1",
"version": "1.2.2",
"license": "MIT",
"config": {
"openapiArgs": "--additional-properties ngVersion=15.1 --additional-properties modelPropertyNaming=original --type-mappings=DateTime=Date",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export class EventDetailPageComponent {
msel = new MselPlus();
sortedDataFields: DataField[] = [];
cardList: Card[] = [];
allDataFields: DataField[] = [];
dateFormControls = new Map<string, UntypedFormControl>();
dataValues: DataValue[] = [];
scenarioEvent: ScenarioEventPlus = {} as ScenarioEventPlus;
Expand Down Expand Up @@ -261,12 +260,9 @@ export class EventDetailPageComponent {
this.sortedDataFields = dataFields.sort((a, b) =>
+a.displayOrder > +b.displayOrder ? 1 : -1
);
this.allDataFields = dataFields.sort((a, b) =>
+a.displayOrder > +b.displayOrder ? 1 : -1
);
}
// create date form controls
this.allDataFields.forEach((df) => {
this.sortedDataFields.forEach((df) => {
if (df.dataType === DataFieldType.DateTime) {
this.dateFormControls[df.id] = new UntypedFormControl();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class ScenarioEventListComponent
viewIndex = new ScenarioEventViewIndexing();

allDataFields: DataField[] = [];
mselDataFields: DataField[] = [];
expandedScenarioEventId = '';
expandedMoreScenarioEventIds: string[] = [];
newScenarioEvent: ScenarioEventPlus;
Expand Down Expand Up @@ -201,17 +202,25 @@ export class ScenarioEventListComponent
this.msel = this.getEditableMsel(msel) as MselPlus;
this.mselUsers = this.getMselUsers();
this.scenarioEventDataService.updateScenarioEventViewUsers(this);
// in case the dataFields were received before the msel
if (this.allDataFields.length > 0) {
this.setSortedDataFields();
this.scenarioEventDataService.updateScenarioEventViewDataFields(
this
);
this.scenarioEventDataService.updateScenarioEventViewDisplayedEvents(
this
);
}
}
});
// subscribe to data fields
this.dataFieldQuery
.selectAll()
.pipe(takeUntil(this.unsubscribe$))
.subscribe((dataFields) => {
const mselDataFields = dataFields.filter(
(m) => m.mselId === this.msel.id
);
this.setSortedDataFields(mselDataFields);
this.allDataFields = dataFields;
this.setSortedDataFields();
this.scenarioEventDataService.updateScenarioEventViewDataFields(this);
this.scenarioEventDataService.updateScenarioEventViewDisplayedEvents(
this
Expand Down Expand Up @@ -361,17 +370,20 @@ export class ScenarioEventListComponent
return editableMsel;
}

setSortedDataFields(dataFields: DataField[]) {
if (dataFields) {
this.headerDataFields = dataFields
setSortedDataFields() {
this.mselDataFields = this.allDataFields;
if (this.msel && this.msel.id) {
this.mselDataFields = this.allDataFields
.filter((m) => m.mselId === this.msel.id)
.sort((a, b) => (+a.displayOrder > +b.displayOrder ? 1 : -1));
}
if (this.mselDataFields.length > 0) {
this.headerDataFields = this.mselDataFields
.filter((df) => df.onScenarioEventList)
.sort((a, b) => (+a.displayOrder > +b.displayOrder ? 1 : -1));
this.allDataFields = dataFields.sort((a, b) =>
+a.displayOrder > +b.displayOrder ? 1 : -1
);
}
// create date form controls
this.allDataFields.forEach((df) => {
this.mselDataFields.forEach((df) => {
if (df.dataType === DataFieldType.DateTime) {
this.dateFormControls[df.id] = new UntypedFormControl();
}
Expand Down Expand Up @@ -601,7 +613,7 @@ export class ScenarioEventListComponent
const seDataValues = this.dataValues.filter(
(dv) => dv.scenarioEventId === scenarioEvent.id
);
this.allDataFields.forEach((df) => {
this.mselDataFields.forEach((df) => {
let dataValue = seDataValues.find((dv) => dv.dataFieldId === df.id);
if (!dataValue) {
dataValue = this.newDataValuePlus(scenarioEvent.id, df.id);
Expand Down Expand Up @@ -645,7 +657,7 @@ export class ScenarioEventListComponent
height: '90%',
data: {
scenarioEvent: scenarioEvent,
dataFields: this.allDataFields,
dataFields: this.mselDataFields,
organizationList: this.getSortedOrganizationOptions(),
teamList: this.msel.units,
moveList: this.moveList,
Expand Down Expand Up @@ -682,7 +694,7 @@ export class ScenarioEventListComponent
dataValues: [],
scenarioEventType: EventType.Information,
};
this.allDataFields.forEach((df) => {
this.mselDataFields.forEach((df) => {
newScenarioEvent.dataValues.push({
dataFieldId: df.id,
id: uuidv4(),
Expand All @@ -701,7 +713,7 @@ export class ScenarioEventListComponent
let dataValue = this.getDataValue(scenarioEvent, dataFieldName);
if (!dataValue || !dataValue.id) {
// the dataValue doesn't exist, so create a new one
const dataFieldId = this.allDataFields.find(
const dataFieldId = this.mselDataFields.find(
(df) => df.name === dataFieldName
).id;
dataValue = this.newDataValuePlus(scenarioEvent.id, dataFieldId);
Expand All @@ -724,7 +736,7 @@ export class ScenarioEventListComponent
let dataValue = this.getDataValue(scenarioEvent, dataFieldName);
if (!dataValue || !dataValue.id) {
// the dataValue doesn't exist, so create a new one
const dataFieldId = this.allDataFields.find(
const dataFieldId = this.mselDataFields.find(
(df) => df.name === dataFieldName
).id;
dataValue = this.newDataValuePlus(scenarioEvent.id, dataFieldId);
Expand Down Expand Up @@ -965,7 +977,7 @@ export class ScenarioEventListComponent

rowDataFields(scenarioEvent: ScenarioEventPlus): DataField[] {
const dataFields = new Array<DataField>();
this.allDataFields.forEach((df) => {
this.mselDataFields.forEach((df) => {
if (
(scenarioEvent.scenarioEventType === EventType.Inject &&
df.onScenarioEventList) ||
Expand Down
Loading