Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into 4380-restrictor-change
Browse files Browse the repository at this point in the history
  • Loading branch information
Elblinator committed Dec 16, 2024
2 parents d545861 + e54f078 commit e42218c
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class UserRepositoryService extends BaseRepository<ViewUser, User> {
const data = usersToCreate.map(user => {
const meetingUsers = user.meeting_users as Partial<ViewMeetingUser>[];
return {
user: this.sanitizePayload(this.getBaseUserPayload(user), true),
user: this.sanitizePayload(this.getBaseUserPayloadCreate(user), true),
...(meetingUsers && meetingUsers.length
? {
first_meeting_user: this.sanitizePayload(
Expand Down Expand Up @@ -213,7 +213,7 @@ export class UserRepositoryService extends BaseRepository<ViewUser, User> {
const updates = Array.isArray(dirtyUpdate) ? dirtyUpdate : [dirtyUpdate];
return updates.map(update => ({
id: user.id,
...this.sanitizePayload(this.getBaseUserPayload(update)),
...this.sanitizePayload(this.getBaseUserPayloadUpdate(update)),
...this.sanitizePayload(this.meetingUserRepo.getBaseUserPayload(update))
}));
});
Expand Down Expand Up @@ -248,7 +248,7 @@ export class UserRepositoryService extends BaseRepository<ViewUser, User> {
return this.createAction(UserAction.ASSIGN_MEETINGS, payload);
}

private getBaseUserPayload(partialUser: Partial<ViewUser>): any {
private getBaseUserPayloadUpdate(partialUser: Partial<ViewUser>): any {
const partialPayload: Partial<User> = {
pronoun: partialUser.pronoun,
title: partialUser.title,
Expand All @@ -269,6 +269,12 @@ export class UserRepositoryService extends BaseRepository<ViewUser, User> {
return partialPayload;
}

private getBaseUserPayloadCreate(partialUser: Partial<ViewUser>): any {
const partialPayload = this.getBaseUserPayloadUpdate(partialUser);
partialPayload.is_present_in_meeting_ids = partialUser.is_present_in_meeting_ids;
return partialPayload;
}

public getTitle = (viewUser: ViewUser): string => this.getFullName(viewUser);

/**
Expand Down
9 changes: 6 additions & 3 deletions client/src/app/site/base/base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ export abstract class BaseComponent extends BaseUiComponent implements OnDestroy
* Set the title in web browser using angulars TitleService
* @param prefix The title prefix. Should be translated here.
*/
public setTitle(prefix: string): void {
const translatedPrefix = this.translate.instant(prefix);
this.titleService.setTitle(translatedPrefix + this.titleSuffix);
public setTitle(prefix: string, nonTranslate?: boolean): void {
let titlePrefix = prefix;
if (!nonTranslate) {
titlePrefix = this.translate.instant(prefix);
}
this.titleService.setTitle(titlePrefix + this.titleSuffix);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class TopicDetailComponent extends BaseMeetingComponent implements OnInit
// also ensures edition cannot be interrupted by autoupdate
if (newViewTopic) {
const title = newViewTopic.getListTitle();
super.setTitle(title);
super.setTitle(title, true);
this.topic = newViewTopic;
// personalInfoForm is undefined during 'new' and directly after reloading
if (!this.editTopic) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class AssignmentDetailComponent extends BaseMeetingComponent implements O
this.assignmentRepo.getViewModelObservable(assignmentId).subscribe(assignment => {
if (assignment) {
const title = assignment.getTitle();
super.setTitle(title);
super.setTitle(title, true);
this.assignment = assignment;
if (!this.isEditing) {
this.patchForm(this.assignment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h2>{{ 'Autopilot' | translate }}</h2>
[target]="lowerProjectionTarget"
>
<h1>
{{ title | translate }}
{{ title }}
</h1>
</a>
</mat-card-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,30 @@ describe(`MotionDiffService`, () => {
}
));

it(`does not fall back to block level replacement when replacement and tag insertion overlap (3)`, inject(
[MotionDiffService],
(service: MotionDiffService) => {
const before = `<p>es war ihnen wie eine <strong>Bestätigung</strong> ihrer neuen Träume und guten Absichten, als am Ziele ihrer Fahrt die Tochter als erste sich erhob und ihren jungen Körper dehnte.</p>`,
after = `<p>es war ihnen wie eine <strong>Bestätigung NEU</strong> NEU2 ihrer neuen Träume und guten Absichten, als am Ziele ihrer Fahrt die Tochter als erste sich erhob und ihren jungen Körper dehnte.</p>`;
const diff = service.diff(before, after);
expect(diff).toBe(
`<p>es war ihnen wie eine <strong>Bestätigung<ins> NEU</ins></strong> <ins>NEU2 </ins>ihrer neuen Träume und guten Absichten, als am Ziele ihrer Fahrt die Tochter als erste sich erhob und ihren jungen Körper dehnte.</p>`
);
}
));

it(`does not fall back to block level replacement when replacement and tag insertion overlap (4)`, inject(
[MotionDiffService],
(service: MotionDiffService) => {
const before = `<p>Und es war ihnen wie eine <strong>Bestätigung</strong> ihrer neuen Träume und guten Absichten, als am Ziele ihrer Fahrt die Tochter als erste sich erhob und ihren jungen <strong>Körper</strong> dehnte.</p>`,
after = `<p>Und es war ihnen wie eine <strong>Bestätigung</strong> ihrer neuen Träume und guten Absichten, als am Ziele ihrer Fahrt die Tochter als erste sich erhob und ihren jungen alten <strong>Körpergehülle</strong> dehnte.</p>`;
const diff = service.diff(before, after);
expect(diff).toBe(
`<p>Und es war ihnen wie eine <strong>Bestätigung</strong> ihrer neuen Träume und guten Absichten, als am Ziele ihrer Fahrt die Tochter als erste sich erhob und ihren jungen <ins>alten </ins><strong><del>Körper</del><ins>Körpergehülle</ins></strong> dehnte.</p>`
);
}
));

it(`works with multiple inserted paragraphs`, inject([MotionDiffService], (service: MotionDiffService) => {
const before = `<p>This is the text before</p>`,
after = `<p>This is the text before</p>\n<p>This is one added line</p>\n<p>Another added line</p>`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ export class MotionDiffService {

// <ins><STRONG></ins>formatted<ins></STRONG></ins> => <del>formatted</del><ins><STRONG>formatted</STRONG></ins>
diffUnnormalized = diffUnnormalized.replace(
/<ins><(span|strong|em|b|i|u|s|a|small|big|sup|sub)( [^>]*)?><\/ins>([^<]*)<ins><\/\1><\/ins>/gi,
/<ins><(mark|span|strong|em|b|i|u|s|a|small|big|sup|sub)( [^>]*)?><\/ins>([^<]*)<ins><\/\1><\/ins>/gi,
(_whole: string, inlineTag: string, tagAttributes: string, content: string): string =>
`<del>` +
content +
Expand All @@ -1598,7 +1598,7 @@ export class MotionDiffService {

// <del><STRONG></del>formatted<del></STRONG></del> => <del><STRONG>formatted</STRONG></del><ins>formatted</ins>
diffUnnormalized = diffUnnormalized.replace(
/<del><(span|strong|em|b|i|u|s|a|small|big|sup|sub)( [^>]*)?><\/del>([^<]*)<del><\/\1><\/del>/gi,
/<del><(mark|span|strong|em|b|i|u|s|a|small|big|sup|sub)( [^>]*)?><\/del>([^<]*)<del><\/\1><\/del>/gi,
(_whole: string, inlineTag: string, tagAttributes: string, content: string): string =>
`<del><` +
inlineTag +
Expand All @@ -1613,10 +1613,36 @@ export class MotionDiffService {
`</ins>`
);

// <del><STRONG>Körper</del><ins>alten <STRONG>Körpergehülle</ins></STRONG> => <ins>alten </ins><STRONG><del>Körper</del><ins>Körpergehülle</ins></STRONG>
diffUnnormalized = diffUnnormalized.replace(
/<del><(mark|span|strong|em|b|i|u|s|a|small|big|sup|sub)( [^>]*)?>([^<]*)<\/del><ins>([^<]*)<\1>([^<]*)<\/ins><\/\1>/gi,
(
_whole: string,
inlineTag: string,
tagAttributes: string,
delContent: string,
insContent1: string,
insContent2: string
): string =>
`<ins>` +
insContent1 +
`</ins><` +
inlineTag +
(tagAttributes ? tagAttributes : ``) +
`><del>` +
delContent +
`</del>` +
`<ins>` +
insContent2 +
`</ins></` +
inlineTag +
`>`
);

// <del>with a </del><ins>a <STRONG></ins>unformatted <del>word</del><ins>sentence</STRONG></ins> ->
// <del>unformatted word</del><ins><STRONG>formatted word</STRONG></ins>
diffUnnormalized = diffUnnormalized.replace(
/<del>([^<]*)<\/del><ins><(span|strong|em|b|i|u|s|a|small|big|sup|sub)( [^>]*)?>([^<]*)<\/ins>([^<]*)<ins><\/\2><\/ins>/gi,
/<del>([^<]*)<\/del><ins><(mark|span|strong|em|b|i|u|s|a|small|big|sup|sub)( [^>]*)?>([^<]*)<\/ins>([^<]*)<ins><\/\2><\/ins>/gi,
(
_whole: string,
delContent: string,
Expand All @@ -1642,7 +1668,7 @@ export class MotionDiffService {
// <ins><STRONG></ins>unformatted <del>word</del><ins>sentence</STRONG></ins> ->
// <del>unformatted word</del><ins><STRONG>unformatted sentence</STRONG></ins>
diffUnnormalized = diffUnnormalized.replace(
/<ins><(span|strong|em|b|i|u|s|a|small|big|sup|sub)( [^>]*)?><\/ins>([^<]*)<del>([^<]*)<\/del><ins>([^<]*)<\/\1><\/ins>/gi,
/<ins><(mark|span|strong|em|b|i|u|s|a|small|big|sup|sub)( [^>]*)?><\/ins>([^<]*)<del>([^<]*)<\/del><ins>([^<]*)<\/\1><\/ins>/gi,
(
_whole: string,
inlineTag: string,
Expand All @@ -1665,6 +1691,19 @@ export class MotionDiffService {
`></ins>`
);

// <STRONG>Bestätigung<del></STRONG></del><ins> NEU</STRONG> NEU2</ins> -->
// <STRONG>Bestätigung<ins> NEU</ins></STRONG><ins> NEU2</ins>
diffUnnormalized = diffUnnormalized.replace(
/<del>(<\/(mark|span|strong|em|b|i|u|s|a|small|big|sup|sub)>)<\/del><ins>([^>]*)<\/\2>([^>]*)<\/ins>/gi,
(
_whole: string,
closingTag: string,
closingTagInner: string,
insertedText1: string,
insertedText2: string
): string => `<ins>` + insertedText1 + `</ins>` + closingTag + `<ins>` + insertedText2 + `</ins>`
);

// <del>Ebene 3 <UL><LI></del><span class="line-number-4 os-line-number" contenteditable="false" data-line-number="4">&nbsp;</span><ins>Ebene 3a <UL><LI></ins>
// => <del>Ebene 3 </del><ins>Ebene 3a </ins><UL><LI><span class="line-number-4 os-line-number" contenteditable="false" data-line-number="4">&nbsp;</span>
diffUnnormalized = diffUnnormalized.replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class MotionViewComponent extends BaseMeetingComponent implements OnInit,

public onMotionUpdated(motion: ViewMotion): void {
const title = motion.getTitle();
super.setTitle(title);
super.setTitle(title, true);
this.motion = motion;
this.cd.markForCheck();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export class ParticipantDetailViewComponent extends BaseMeetingComponent {
this.repo.getViewModelObservable(this._userId!).subscribe(user => {
if (user) {
const title = user.getTitle();
super.setTitle(title);
super.setTitle(title, true);
this.user = user;
this.cd.markForCheck();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ParticipantCreateWizardComponent extends BaseMeetingComponent imple
public get patchFormValueFn(): (controlName: string, user?: ViewUser) => any | null {
return (controlName, user) => {
if (controlName === `is_present`) {
return user?.isPresentInMeeting ? user.isPresentInMeeting() : true;
return user?.isPresentInMeeting ? user.isPresentInMeeting() : false;
}
return null;
};
Expand Down Expand Up @@ -286,6 +286,9 @@ export class ParticipantCreateWizardComponent extends BaseMeetingComponent imple
id: this._accountId
})
.resolve();
if (this.personalInfoFormValue.is_present) {
this.repo.setPresent(true, { ...payload, id: this._accountId }).resolve();
}
} else {
this.repo.create(payload);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export class ProjectorDetailComponent extends BaseMeetingComponent implements On
this.repo.getViewModelObservable(this._projectorId!).subscribe(projector => {
if (projector) {
const title = projector.name;
super.setTitle(title);
super.setTitle(title, true);
this.projector = projector;
}
})
Expand Down

0 comments on commit e42218c

Please sign in to comment.