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">
<my-instance-about-accordion
#instanceAboutAccordion
[displayInstanceName]="false"
(init)="onInstanceAboutAccordionInit($event)" [panels]="instanceInformationPanels"
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('otpTokenInput') otpTokenInput: InputTextComponent
@ViewChild('instanceAboutAccordion') instanceAboutAccordion: InstanceAboutAccordionComponent
accordion: NgbAccordionDirective
error: string = null
@ -70,8 +71,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
onTermsClick (event: Event, instanceInformation: HTMLElement) {
event.preventDefault()
if (this.accordion) {
this.accordion.expand('terms')
if (this.instanceAboutAccordion) {
this.instanceAboutAccordion.expandTerms()
instanceInformation.scrollIntoView({ behavior: 'smooth' })
}
}

View File

@ -43,6 +43,7 @@
</my-signup-step-title>
<my-instance-about-accordion
#instanceAboutAccordion
[displayInstanceName]="false"
(init)="onInstanceAboutAccordionInit($event)" [panels]="instanceInformationPanels"
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 { HooksService } from '@app/core/plugins/hooks.service'
import { InstanceAboutAccordionComponent } from '@app/shared/shared-instance'
import { NgbAccordionDirective } from '@ng-bootstrap/ng-bootstrap'
import { UserRegister } from '@shared/models'
import { ServerConfig } from '@shared/models/server'
import { SignupService } from '../shared/signup.service'
@ -17,8 +16,7 @@ import { SignupService } from '../shared/signup.service'
})
export class RegisterComponent implements OnInit {
@ViewChild('lastStep') lastStep: CdkStep
accordion: NgbAccordionDirective
@ViewChild('instanceAboutAccordion') instanceAboutAccordion: InstanceAboutAccordionComponent
signupError: string
signupSuccess = false
@ -121,15 +119,14 @@ export class RegisterComponent implements OnInit {
}
onTermsClick () {
if (this.accordion) this.accordion.toggle('terms')
this.instanceAboutAccordion.expandTerms()
}
onCodeOfConductClick () {
if (this.accordion) this.accordion.toggle('code-of-conduct')
this.instanceAboutAccordion.expandCodeOfConduct()
}
onInstanceAboutAccordionInit (instanceAboutAccordion: InstanceAboutAccordionComponent) {
this.accordion = instanceAboutAccordion.accordion
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 ngbAccordion #accordion="ngbAccordion" [closeOthers]="true">
<div ngbAccordionItem *ngIf="panels.features" id="instance-features">
<div ngbAccordionItem="instance-features" *ngIf="panels.features">
<div ngbAccordionHeader>
<button ngbAccordionButton>
<my-global-icon iconName="playlists"></my-global-icon>
@ -53,7 +53,7 @@
</div>
</div>
<div ngbAccordionItem *ngIf="termsPanel" id="terms">
<div ngbAccordionItem="terms" *ngIf="termsPanel">
<div ngbAccordionHeader>
<button ngbAccordionButton>
<my-global-icon iconName="playlists"></my-global-icon>
@ -71,7 +71,7 @@
</div>
</div>
<div ngbAccordionItem *ngIf="moderationPanel" id="moderation-information">
<div ngbAccordionItem="moderation-information" *ngIf="moderationPanel">
<div ngbAccordionHeader>
<button ngbAccordionButton>
<my-global-icon iconName="playlists"></my-global-icon>
@ -89,7 +89,7 @@
</div>
</div>
<div ngbAccordionItem *ngIf="codeOfConductPanel" id="code-of-conduct">
<div ngbAccordionItem="code-of-conduct" *ngIf="codeOfConductPanel">
<div ngbAccordionHeader>
<button ngbAccordionButton>
<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)
}
expandTerms () {
this.accordion.expand('terms')
}
expandCodeOfConduct () {
this.accordion.expand('code-of-conduct')
}
getAdministratorsPanel () {
if (!this.about) return false
if (!this.panels.administrators) return false