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

Fixed bug for save functionality: #141

Merged
merged 1 commit into from
Oct 18, 2018
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
9 changes: 5 additions & 4 deletions cvat/apps/engine/static/engine/js/annotationUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ function buildAnnotationUI(job, shapeData, loadJobEvent) {
// Setup components
let annotationParser = new AnnotationParser(job, window.cvat.labelsInfo);

let shapeCollectionModel = new ShapeCollectionModel().import(shapeData).updateHash();
let shapeCollectionModel = new ShapeCollectionModel().import(shapeData).updateExportedState();
shapeCollectionModel.confirmExportedState();
let shapeCollectionController = new ShapeCollectionController(shapeCollectionModel);
let shapeCollectionView = new ShapeCollectionView(shapeCollectionModel, shapeCollectionController);

Expand Down Expand Up @@ -690,6 +691,7 @@ function saveAnnotation(shapeCollectionModel, job) {
});

const exportedData = shapeCollectionModel.export();
shapeCollectionModel.updateExportedState();
const annotationLogs = Logger.getLogs();

const data = {
Expand All @@ -702,8 +704,7 @@ function saveAnnotation(shapeCollectionModel, job) {

saveJobRequest(job.jobid, data, () => {
// success
shapeCollectionModel.reset_state();
shapeCollectionModel.updateHash();
shapeCollectionModel.confirmExportedState();
saveButton.text('Success!');
setTimeout(() => {
saveButton.prop('disabled', false);
Expand Down Expand Up @@ -741,4 +742,4 @@ function translateSVGPos(svgCanvas, clientX, clientY) {

function blurAllElements() {
document.activeElement.blur();
}
}
10 changes: 6 additions & 4 deletions cvat/apps/engine/static/engine/js/shapeCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ShapeCollectionModel extends Listener {
this._splitter = new ShapeSplitter();
this._erased = false;
this._initialShapes = {};
this._exportedShapes = {};
}

_nextIdx() {
Expand Down Expand Up @@ -239,8 +240,9 @@ class ShapeCollectionModel extends Listener {
return this;
}

reset_state() {
confirmExportedState() {
this._erased = false;
this._initialShapes = this._exportedShapes;
}

export() {
Expand Down Expand Up @@ -349,16 +351,16 @@ class ShapeCollectionModel extends Listener {
return exportData.pre_erase;
}

updateHash() {
this._initialShapes = {};
updateExportedState() {
this._exportedShapes = {};

if (this._erased) {
return this;
}

for (const shape of this._shapes) {
if (!shape.removed) {
this._initialShapes[shape.id] = shape.export();
this._exportedShapes[shape.id] = shape.export();
}
}
return this;
Expand Down