Skip to content

Commit

Permalink
refactor: remove deprecated User fields and functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
sleidig committed Mar 14, 2024
1 parent 2874ef3 commit b5c84d7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { StorybookBaseModule } from "../../../utils/storybook-base.module";
import { importProvidersFrom } from "@angular/core";

const user = new User();
user.paginatorSettingsPageSize["ageprojectNumbernamegendercenterstatus"] = 13;

export default {
title: "Core/Entities/Entity List",
Expand Down
17 changes: 0 additions & 17 deletions src/app/core/user/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,5 @@ describe("User", () => {
_id: "User:tester",

name: "tester",
paginatorSettingsPageSize: {},
});

it("should not allow to change the name after initialization and set it as the ID", () => {
const user = new User();
user.name = "test-name";

expect(user.name).toBe("test-name");
expect(user.getId()).toBe(`${User.ENTITY_TYPE}:test-name`);
expect(() => (user.name = "another-name")).toThrowError();
});

it("should not fail when name is actually the same", () => {
const user = new User();
user.name = "test-name";

expect(() => (user.name = "test-name")).not.toThrowError();
});
});
27 changes: 3 additions & 24 deletions src/app/core/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { IconName } from "@fortawesome/fontawesome-svg-core";
*
* Note that in addition to the User Entity there also is a "regular" CouchDB user with the same name and password
* in the CouchDB _users database which is used for remote database authentication.
*
* @Deprecated: This entity type does not provide special functionality anymore and will be replaced by a config-only type in the future
*/
@DatabaseEntity("User")
export class User extends Entity {
Expand All @@ -39,28 +41,5 @@ export class User extends Entity {
label: $localize`:Label of username:Username`,
validators: { required: true, uniqueId: "User" },
})
set name(value: string) {
if (this._name && value !== this._name) {
// Throwing error if trying to change existing username
const label = User.schema.get("name").label;
throw new Error(
$localize`:Error message when trying to change the username|e.g. username cannot be changed after initialization:${label} cannot be changed after initialization`,
);
}

// @ts-ignore allow overwriting of id in this special case, as the name is only given by user editing the form of the new entity
this.entityId = value;
this._name = value;
}

get name(): string {
return this._name;
}

private _name: string;

/**
* This map holds information for the page size settings for different tables in the app
*/
@DatabaseField() paginatorSettingsPageSize: { [id: string]: number } = {};
name: string;
}

0 comments on commit b5c84d7

Please sign in to comment.