Skip to content

Commit

Permalink
Delete v3 api identifiers when cloning a record in profile editor (ni…
Browse files Browse the repository at this point in the history
…ghtscout#7839)

* Delete v3 api identifiers when cloning a record

* Refactored to use lodash omit

* Move cleaning logic to correct function, add _id to list of cleaned properties

* Add back a line that was accidentally deleted

* profileeditor: add created_at, srvModified too on save to simulate API v3

Co-authored-by: Milos Kozak <m.kozak@sysop.cz>
  • Loading branch information
sulkaharo and MilosKozak committed Jan 23, 2023
1 parent c343719 commit 05de94e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/profile/profileeditor.js
Expand Up @@ -312,11 +312,10 @@ var init = function init () {
profileSubmit();
}
GUIToObject();
mongorecords.push(_.cloneDeep(mongorecords[currentrecord]));
mongorecords.push(_.omit(mongorecords[currentrecord], ['_id', 'srvModified', 'srvCreated', 'identifier', 'mills']));
currentrecord = mongorecords.length - 1;
mongorecords[currentrecord].startDate = new Date().toISOString();
currentprofile = mongorecords[currentrecord].defaultProfile;
delete mongorecords[currentrecord]._id;
initRecord();
dirty = true;

Expand Down Expand Up @@ -389,6 +388,7 @@ var init = function init () {
newname += '1';
}
record.store[newname] = _.cloneDeep(record.store[currentprofile]);

currentprofile = newname;
dirty = true;

Expand Down Expand Up @@ -651,6 +651,8 @@ var init = function init () {
profileChange(event);
var record = mongorecords[currentrecord];
record.startDate = new Date(client.utils.mergeInputTime(timeInput.val(), dateInput.val())).toISOString( );
record.created_at = new Date().toISOString( );
record.srvModified = new Date().getTime(); // remove when switching to v3 API

var adjustedRecord = _.cloneDeep(record);

Expand Down

0 comments on commit 05de94e

Please sign in to comment.