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

React-UI: settings #1164

Merged
merged 19 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from 15 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
16 changes: 8 additions & 8 deletions cvat-core/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
}),
Expand Down Expand Up @@ -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
* </br><b> This function cannot be wrapped with a plugin </b>
* @method hasUnsavedChanges
* @memberof Session.annotations
* @returns {boolean}
* @throws {module:API.cvat.exceptions.PluginError}
* @instance
* @async
*/
/**
* Export as a dataset.
Expand Down
44 changes: 22 additions & 22 deletions cvat-core/tests/api/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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 () => {
Expand All @@ -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);
});
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down
Loading