Fix terms/code of conduct link toggle

This commit is contained in:
Chocobozzz 2023-07-12 10:22:43 +02:00
parent d98909f690
commit ed22eaabfa
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 20 additions and 12 deletions

View File

@ -105,6 +105,7 @@
<div #instanceInformation class="instance-information"> <div #instanceInformation class="instance-information">
<my-instance-about-accordion <my-instance-about-accordion
#instanceAboutAccordion
[displayInstanceName]="false" [displayInstanceName]="false"
(init)="onInstanceAboutAccordionInit($event)" [panels]="instanceInformationPanels" (init)="onInstanceAboutAccordionInit($event)" [panels]="instanceInformationPanels"
pluginScope="login" pluginHook="filter:login.instance-about-plugin-panels.create.result" pluginScope="login" pluginHook="filter:login.instance-about-plugin-panels.create.result"

View File

@ -22,6 +22,7 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
@ViewChild('forgotPasswordModal', { static: true }) forgotPasswordModal: ElementRef @ViewChild('forgotPasswordModal', { static: true }) forgotPasswordModal: ElementRef
@ViewChild('otpTokenInput') otpTokenInput: InputTextComponent @ViewChild('otpTokenInput') otpTokenInput: InputTextComponent
@ViewChild('instanceAboutAccordion') instanceAboutAccordion: InstanceAboutAccordionComponent
accordion: NgbAccordionDirective accordion: NgbAccordionDirective
error: string = null error: string = null
@ -70,8 +71,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
onTermsClick (event: Event, instanceInformation: HTMLElement) { onTermsClick (event: Event, instanceInformation: HTMLElement) {
event.preventDefault() event.preventDefault()
if (this.accordion) { if (this.instanceAboutAccordion) {
this.accordion.expand('terms') this.instanceAboutAccordion.expandTerms()
instanceInformation.scrollIntoView({ behavior: 'smooth' }) instanceInformation.scrollIntoView({ behavior: 'smooth' })
} }
} }

View File

@ -43,6 +43,7 @@
</my-signup-step-title> </my-signup-step-title>
<my-instance-about-accordion <my-instance-about-accordion
#instanceAboutAccordion
[displayInstanceName]="false" [displayInstanceName]="false"
(init)="onInstanceAboutAccordionInit($event)" [panels]="instanceInformationPanels" (init)="onInstanceAboutAccordionInit($event)" [panels]="instanceInformationPanels"
pluginScope="signup" pluginHook="filter:signup.instance-about-plugin-panels.create.result" pluginScope="signup" pluginHook="filter:signup.instance-about-plugin-panels.create.result"

View File

@ -5,7 +5,6 @@ import { ActivatedRoute } from '@angular/router'
import { AuthService } from '@app/core' import { AuthService } from '@app/core'
import { HooksService } from '@app/core/plugins/hooks.service' import { HooksService } from '@app/core/plugins/hooks.service'
import { InstanceAboutAccordionComponent } from '@app/shared/shared-instance' import { InstanceAboutAccordionComponent } from '@app/shared/shared-instance'
import { NgbAccordionDirective } from '@ng-bootstrap/ng-bootstrap'
import { UserRegister } from '@shared/models' import { UserRegister } from '@shared/models'
import { ServerConfig } from '@shared/models/server' import { ServerConfig } from '@shared/models/server'
import { SignupService } from '../shared/signup.service' import { SignupService } from '../shared/signup.service'
@ -17,8 +16,7 @@ import { SignupService } from '../shared/signup.service'
}) })
export class RegisterComponent implements OnInit { export class RegisterComponent implements OnInit {
@ViewChild('lastStep') lastStep: CdkStep @ViewChild('lastStep') lastStep: CdkStep
@ViewChild('instanceAboutAccordion') instanceAboutAccordion: InstanceAboutAccordionComponent
accordion: NgbAccordionDirective
signupError: string signupError: string
signupSuccess = false signupSuccess = false
@ -121,15 +119,14 @@ export class RegisterComponent implements OnInit {
} }
onTermsClick () { onTermsClick () {
if (this.accordion) this.accordion.toggle('terms') this.instanceAboutAccordion.expandTerms()
} }
onCodeOfConductClick () { onCodeOfConductClick () {
if (this.accordion) this.accordion.toggle('code-of-conduct') this.instanceAboutAccordion.expandCodeOfConduct()
} }
onInstanceAboutAccordionInit (instanceAboutAccordion: InstanceAboutAccordionComponent) { onInstanceAboutAccordionInit (instanceAboutAccordion: InstanceAboutAccordionComponent) {
this.accordion = instanceAboutAccordion.accordion
this.aboutHtml = instanceAboutAccordion.aboutHtml this.aboutHtml = instanceAboutAccordion.aboutHtml
} }

View File

@ -3,7 +3,7 @@
<div *ngIf="displayInstanceShortDescription" class="instance-short-description ellipsis-multiline-3">{{ about?.instance.shortDescription }}</div> <div *ngIf="displayInstanceShortDescription" class="instance-short-description ellipsis-multiline-3">{{ about?.instance.shortDescription }}</div>
<div ngbAccordion #accordion="ngbAccordion" [closeOthers]="true"> <div ngbAccordion #accordion="ngbAccordion" [closeOthers]="true">
<div ngbAccordionItem *ngIf="panels.features" id="instance-features"> <div ngbAccordionItem="instance-features" *ngIf="panels.features">
<div ngbAccordionHeader> <div ngbAccordionHeader>
<button ngbAccordionButton> <button ngbAccordionButton>
<my-global-icon iconName="playlists"></my-global-icon> <my-global-icon iconName="playlists"></my-global-icon>
@ -53,7 +53,7 @@
</div> </div>
</div> </div>
<div ngbAccordionItem *ngIf="termsPanel" id="terms"> <div ngbAccordionItem="terms" *ngIf="termsPanel">
<div ngbAccordionHeader> <div ngbAccordionHeader>
<button ngbAccordionButton> <button ngbAccordionButton>
<my-global-icon iconName="playlists"></my-global-icon> <my-global-icon iconName="playlists"></my-global-icon>
@ -71,7 +71,7 @@
</div> </div>
</div> </div>
<div ngbAccordionItem *ngIf="moderationPanel" id="moderation-information"> <div ngbAccordionItem="moderation-information" *ngIf="moderationPanel">
<div ngbAccordionHeader> <div ngbAccordionHeader>
<button ngbAccordionButton> <button ngbAccordionButton>
<my-global-icon iconName="playlists"></my-global-icon> <my-global-icon iconName="playlists"></my-global-icon>
@ -89,7 +89,7 @@
</div> </div>
</div> </div>
<div ngbAccordionItem *ngIf="codeOfConductPanel" id="code-of-conduct"> <div ngbAccordionItem="code-of-conduct" *ngIf="codeOfConductPanel">
<div ngbAccordionHeader> <div ngbAccordionHeader>
<button ngbAccordionButton> <button ngbAccordionButton>
<my-global-icon iconName="playlists"></my-global-icon> <my-global-icon iconName="playlists"></my-global-icon>

View File

@ -62,6 +62,14 @@ export class InstanceAboutAccordionComponent implements OnInit {
this.pluginPanels = await this.hookService.wrapObject([], this.pluginScope, this.pluginHook) this.pluginPanels = await this.hookService.wrapObject([], this.pluginScope, this.pluginHook)
} }
expandTerms () {
this.accordion.expand('terms')
}
expandCodeOfConduct () {
this.accordion.expand('code-of-conduct')
}
getAdministratorsPanel () { getAdministratorsPanel () {
if (!this.about) return false if (!this.about) return false
if (!this.panels.administrators) return false if (!this.panels.administrators) return false