diff --git a/cvat-core/src/session.js b/cvat-core/src/session.js index 87b545157df6..236893897302 100644 --- a/cvat-core/src/session.js +++ b/cvat-core/src/session.js @@ -77,12 +77,6 @@ return result; }, - async hasUnsavedChanges() { - const result = await PluginRegistry - .apiWrapper.call(this, prototype.annotations.hasUnsavedChanges); - return result; - }, - async merge(objectStates) { const result = await PluginRegistry .apiWrapper.call(this, prototype.annotations.merge, objectStates); @@ -107,6 +101,12 @@ .apiWrapper.call(this, prototype.annotations.exportDataset, format); return result; }, + + hasUnsavedChanges() { + const result = prototype.annotations + .hasUnsavedChanges.implementation.call(this); + return result; + }, }, writable: true, }), @@ -381,14 +381,14 @@ * @async */ /** - * Indicate if there are any changes in + * Method indicates if there are any changes in * annotations which haven't been saved on a server + *
This function cannot be wrapped with a plugin * @method hasUnsavedChanges * @memberof Session.annotations * @returns {boolean} * @throws {module:API.cvat.exceptions.PluginError} * @instance - * @async */ /** * Export as a dataset. diff --git a/cvat-core/tests/api/annotations.js b/cvat-core/tests/api/annotations.js index 3400ea4efc1a..5bd97bd8206c 100644 --- a/cvat-core/tests/api/annotations.js +++ b/cvat-core/tests/api/annotations.js @@ -298,11 +298,11 @@ describe('Feature: save annotations', () => { label: task.labels[0], }); - expect(await task.annotations.hasUnsavedChanges()).toBe(false); + expect(task.annotations.hasUnsavedChanges()).toBe(false); await task.annotations.put([state]); - expect(await task.annotations.hasUnsavedChanges()).toBe(true); + expect(task.annotations.hasUnsavedChanges()).toBe(true); await task.annotations.save(); - expect(await task.annotations.hasUnsavedChanges()).toBe(false); + expect(task.annotations.hasUnsavedChanges()).toBe(false); annotations = await task.annotations.get(0); expect(annotations).toHaveLength(length + 1); }); @@ -311,23 +311,23 @@ describe('Feature: save annotations', () => { const task = (await window.cvat.tasks.get({ id: 101 }))[0]; const annotations = await task.annotations.get(0); - expect(await task.annotations.hasUnsavedChanges()).toBe(false); + expect(task.annotations.hasUnsavedChanges()).toBe(false); annotations[0].occluded = true; await annotations[0].save(); - expect(await task.annotations.hasUnsavedChanges()).toBe(true); + expect(task.annotations.hasUnsavedChanges()).toBe(true); await task.annotations.save(); - expect(await task.annotations.hasUnsavedChanges()).toBe(false); + expect(task.annotations.hasUnsavedChanges()).toBe(false); }); test('delete & save annotations for a task', async () => { const task = (await window.cvat.tasks.get({ id: 101 }))[0]; const annotations = await task.annotations.get(0); - expect(await task.annotations.hasUnsavedChanges()).toBe(false); + expect(task.annotations.hasUnsavedChanges()).toBe(false); await annotations[0].delete(); - expect(await task.annotations.hasUnsavedChanges()).toBe(true); + expect(task.annotations.hasUnsavedChanges()).toBe(true); await task.annotations.save(); - expect(await task.annotations.hasUnsavedChanges()).toBe(false); + expect(task.annotations.hasUnsavedChanges()).toBe(false); }); test('create & save annotations for a job', async () => { @@ -343,11 +343,11 @@ describe('Feature: save annotations', () => { label: job.task.labels[0], }); - expect(await job.annotations.hasUnsavedChanges()).toBe(false); + expect(job.annotations.hasUnsavedChanges()).toBe(false); await job.annotations.put([state]); - expect(await job.annotations.hasUnsavedChanges()).toBe(true); + expect(job.annotations.hasUnsavedChanges()).toBe(true); await job.annotations.save(); - expect(await job.annotations.hasUnsavedChanges()).toBe(false); + expect(job.annotations.hasUnsavedChanges()).toBe(false); annotations = await job.annotations.get(0); expect(annotations).toHaveLength(length + 1); }); @@ -356,23 +356,23 @@ describe('Feature: save annotations', () => { const job = (await window.cvat.jobs.get({ jobID: 100 }))[0]; const annotations = await job.annotations.get(0); - expect(await job.annotations.hasUnsavedChanges()).toBe(false); + expect(job.annotations.hasUnsavedChanges()).toBe(false); annotations[0].points = [0, 100, 200, 300]; await annotations[0].save(); - expect(await job.annotations.hasUnsavedChanges()).toBe(true); + expect(job.annotations.hasUnsavedChanges()).toBe(true); await job.annotations.save(); - expect(await job.annotations.hasUnsavedChanges()).toBe(false); + expect(job.annotations.hasUnsavedChanges()).toBe(false); }); test('delete & save annotations for a job', async () => { const job = (await window.cvat.jobs.get({ jobID: 100 }))[0]; const annotations = await job.annotations.get(0); - expect(await job.annotations.hasUnsavedChanges()).toBe(false); + expect(job.annotations.hasUnsavedChanges()).toBe(false); await annotations[0].delete(); - expect(await job.annotations.hasUnsavedChanges()).toBe(true); + expect(job.annotations.hasUnsavedChanges()).toBe(true); await job.annotations.save(); - expect(await job.annotations.hasUnsavedChanges()).toBe(false); + expect(job.annotations.hasUnsavedChanges()).toBe(false); }); test('delete & save annotations for a job when there are a track and a shape with the same id', async () => { @@ -613,11 +613,11 @@ describe('Feature: clear annotations', () => { expect(annotations.length).not.toBe(0); annotations[0].occluded = true; await annotations[0].save(); - expect(await task.annotations.hasUnsavedChanges()).toBe(true); + expect(task.annotations.hasUnsavedChanges()).toBe(true); await task.annotations.clear(true); annotations = await task.annotations.get(0); expect(annotations.length).not.toBe(0); - expect(await task.annotations.hasUnsavedChanges()).toBe(false); + expect(task.annotations.hasUnsavedChanges()).toBe(false); }); test('clear annotations with reload in a job', async () => { @@ -626,11 +626,11 @@ describe('Feature: clear annotations', () => { expect(annotations.length).not.toBe(0); annotations[0].occluded = true; await annotations[0].save(); - expect(await job.annotations.hasUnsavedChanges()).toBe(true); + expect(job.annotations.hasUnsavedChanges()).toBe(true); await job.annotations.clear(true); annotations = await job.annotations.get(0); expect(annotations.length).not.toBe(0); - expect(await job.annotations.hasUnsavedChanges()).toBe(false); + expect(job.annotations.hasUnsavedChanges()).toBe(false); }); test('clear annotations with bad reload parameter', async () => {