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

NRPT-725 Fix mine record edit #820

Merged
merged 2 commits into from
Apr 7, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class MinesRecordsEditComponent implements OnInit {

// data
public record = null;
public bcmiFlavour = null;
public lastEditedSubText = null;
// source mine
public mine = null;
Expand Down Expand Up @@ -77,7 +76,6 @@ export class MinesRecordsEditComponent implements OnInit {
if (res && res.record && res.record[0] && res.record[0].data
&& res.record[0].data.searchResults && res.record[0].data.searchResults[0]) {
this.record = res.record[0].data.searchResults[0];
this.bcmiFlavour = this.record.flavours.find(f => f._schemaName.endsWith('BCMI'));
this.mine = res.mine[0].data;
// if we have a current flavour, use that
this.populateTextFields();
Expand Down Expand Up @@ -249,20 +247,18 @@ export class MinesRecordsEditComponent implements OnInit {
const schemaString = recordSchema[0]._schemaName;

// BCMI flavour
record[schemaString] = {};
record[schemaString] = {
// this.record._id is actually the BCMI flavour _id. So assign it to the flavour object _id
_id: this.record._id
};
record['recordName'] && (record[schemaString]['recordName'] = record['recordName']);
record['issuingAgency'] && (record[schemaString]['issuingAgency'] = record['issuingAgency']);
if (record['recordType'] === 'Permit') {
record[schemaString]['typeCode'] = this.myForm.get('typeCode').value;
}

// if we have a flavour, update the flavour.
// if we do not, create a flavour.
if (this.bcmiFlavour) {
record[schemaString]._id = this.bcmiFlavour._id;
}

record['_id'] = this.record._id;
// Use _master id here because we want to update both the BCMI flavour and master record
record['_id'] = this.record._master;
record['recordType'] = this.myForm.get('recordType').dirty ? this.myForm.get('recordType').value
: this.record.recordType;

Expand All @@ -273,7 +269,7 @@ export class MinesRecordsEditComponent implements OnInit {
this.links,
this.documents,
this.documentsToDelete,
this.record._id,
this.record._master, // Modify the document array on master instead of flavour
this.factoryService
);

Expand Down