Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export abstract class ProgramRegistrationRepositoryPort {
publish: boolean,
): Observable<RegistrationSettings>;
abstract importOptions(id: number, file: File): Observable<RegistrationImport>;
abstract connect(id: number, url: string, comment: string): Observable<RegistrationSettings>;
abstract connect(
id: number,
url: string,
comment: string,
contact: string,
): Observable<RegistrationSettings>;
abstract publicForm(id: number): Observable<RegistrationPublic>;
abstract submit(id: number, data: object, signup: boolean): Observable<RegistrationResult>;
abstract tokenAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface RegistrationSettings {
externalStatus: "not_connected" | "requested" | "connected";
externalUrl: string;
connectionComment: string;
connectionWebsiteUrl: string;
connectionContact: string;
answeredFieldIds: string[];
}
export interface RegistrationPublic {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export class ProgramRegistrationHttpAdapter implements ProgramRegistrationReposi
data,
);
}
connect(id: number, url: string, comment: string) {
connect(id: number, url: string, comment: string, contact: string) {
return this.api.post<RegistrationSettings>(
`${this.root(id)}/management/registration/connection/`,
{ url, comment },
{ url, comment, contact },
);
}
publicForm(id: number) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ <h2>Внешняя форма регистрации</h2>
</div>
} @else if (data.externalStatus === "requested") {
<div appAlert="warning">
<strong>Ожидаем подключения</strong>
<strong>Запрос передан администратору</strong>
<p>
Запрос доступен администратору платформы. После подключения можно будет опубликовать
Мы свяжемся с вами в ближайшее время. После подключения можно будет опубликовать
внешний способ регистрации.
</p>
</div>
Expand Down Expand Up @@ -317,18 +317,29 @@ <h3>Варианты ответа</h3>
} @else if (dialog() === "connection") {
<form [formGroup]="connection" class="registration__form">
<label
>Ссылка на форму *<input
>Ссылка на сайт мероприятия *<input
appField
type="url"
formControlName="url"
maxlength="200"
placeholder="https://" /></label
><label
>Комментарий<textarea appField formControlName="comment" rows="3"></textarea>
>Комментарий (необязательно)<textarea
appField
formControlName="comment"
maxlength="2000"
rows="3"
></textarea>
</label>
<p>
Администратор проверит интеграцию. Одна ссылка на сайт не создаёт участников на
платформе.
</p>
<label
>Контакт (необязательно)<input
appField
type="text"
formControlName="contact"
maxlength="500"
placeholder="Email, телефон или Telegram"
/></label>
<p>Запрос поступит администратору платформы. Мы свяжемся с вами в ближайшее время.</p>
</form>
} @else if (dialog() === "preview") {
<div class="registration__actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const snapshot: RegistrationSettings = {
externalStatus: "not_connected",
externalUrl: "",
connectionComment: "",
connectionWebsiteUrl: "",
connectionContact: "",
answeredFieldIds: [],
link: null,
};
Expand Down Expand Up @@ -78,6 +80,24 @@ describe("Редактор анкеты регистрации", () => {
expect(component.previewGroup.disabled).toBe(true);
expect(api.save).not.toHaveBeenCalled();
});
it("запрос принимает сайт без необязательных деталей и передаёт контакт отдельно", () => {
const { component, api } = setup();
component.setMode("external");
component.open("connection");
component.connection.controls.url.setValue("https://event.example.test");
expect(component.connection.valid).toBe(true);
component.connection.controls.contact.setValue("@event_organizer");
api.connect.mockReturnValue(of({ ...snapshot, externalStatus: "requested" }));
component.requestConnection();
expect(api.connect).toHaveBeenCalledWith(
42,
"https://event.example.test",
"",
"@event_organizer",
);
expect(component.message()).toContain("Мы свяжемся с вами в ближайшее время");
expect(component.dialog()).toBeNull();
});
it("ошибка импорта сохраняет старые варианты", () => {
const { component, api } = setup();
component.edit(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ export class ManagementRegistrationComponent {
position: [1, Validators.min(1)],
});
readonly connection = this.fb.group({
url: ["", [Validators.required, Validators.pattern(/^https?:\/\//)]],
url: ["", [Validators.required, Validators.pattern(/^https?:\/\//), Validators.maxLength(200)]],
comment: ["", Validators.maxLength(2000)],
contact: ["", Validators.maxLength(500)],
});
readonly fieldTypes = [
{ id: "text", label: "Короткий текст" },
Expand Down Expand Up @@ -159,6 +160,13 @@ export class ManagementRegistrationComponent {
return this.fieldTypes.find(t => t.id === field.type)?.label ?? field.type;
}
open(dialog: NonNullable<ReturnType<typeof this.dialog>>, event?: Event) {
if (dialog === "connection") {
this.connection.reset({
url: this.snapshot()?.connectionWebsiteUrl ?? "",
comment: this.snapshot()?.connectionComment ?? "",
contact: this.snapshot()?.connectionContact ?? "",
});
}
this.trigger = (event?.currentTarget as HTMLElement) ?? null;
this.dialogError.set(null);
this.dialog.set(dialog);
Expand Down Expand Up @@ -329,7 +337,7 @@ export class ManagementRegistrationComponent {
this.dialogError.set(null);
const value = this.connection.getRawValue();
this.api
.connect(this.programId(), value.url, value.comment)
.connect(this.programId(), value.url, value.comment, value.contact)
.pipe(
finalize(() => this.busy.set(false)),
takeUntilDestroyed(this.destroy),
Expand All @@ -338,7 +346,7 @@ export class ManagementRegistrationComponent {
next: data => {
this.snapshot.set(data);
this.dialog.set(null);
this.message.set("Запрос сохранён. Подключение формы выполнит администратор платформы.");
this.message.set("Запрос передан администратору. Мы свяжемся с вами в ближайшее время.");
},
error: e => this.dialogError.set(evaluationError(e)),
});
Expand Down