AngularJS wasn't activated for the documents collapsible-section. Instead, refactor it into a augmented component with a rails helper to render it. https://community.openproject.com/wp/29130pull/6887/head
parent
0015ac900e
commit
7d262955ed
@ -0,0 +1,46 @@ |
||||
#-- encoding: UTF-8 |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
module AugmentingHelper |
||||
|
||||
## |
||||
# Create a collapsible section and yield to render the block |
||||
# |
||||
# @param title [String] Section title |
||||
# |
||||
# @param initiallyExpanded [Boolean] Whether the section is initially expanded |
||||
# |
||||
# @param block [Block] A block that renders the section's body. |
||||
def augmented_collapsible_section(title:, initiallyExpanded: true, &block) |
||||
render( |
||||
partial: '/augmented/collapsible_section', |
||||
locals: { title: title, initiallyExpanded: !!initiallyExpanded, block: block } |
||||
) |
||||
end |
||||
end |
@ -0,0 +1,6 @@ |
||||
<collapsible-section-augment initially-expanded="<%= initiallyExpanded %>" |
||||
section-title="<%= title %>"> |
||||
</collapsible-section-augment> |
||||
<div class="collapsible-section-augment--body" hidden> |
||||
<%= capture(&block) %> |
||||
</div> |
@ -0,0 +1,66 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
// ++
|
||||
|
||||
|
||||
import {Component, ElementRef, OnInit, ViewChild} from "@angular/core"; |
||||
import {DynamicBootstrapper} from "core-app/globals/dynamic-bootstrapper"; |
||||
|
||||
export const collapsibleSectionAugmentSelector = 'collapsible-section-augment'; |
||||
|
||||
@Component({ |
||||
selector: collapsibleSectionAugmentSelector, |
||||
templateUrl: './collapsible-section.html' |
||||
}) |
||||
export class CollapsibleSectionComponent implements OnInit { |
||||
public expanded:boolean = false; |
||||
public sectionTitle:string; |
||||
|
||||
@ViewChild('sectionBody') public sectionBody:ElementRef; |
||||
|
||||
constructor(public elementRef:ElementRef) { |
||||
} |
||||
|
||||
ngOnInit():void { |
||||
const element:HTMLElement = this.elementRef.nativeElement; |
||||
|
||||
this.sectionTitle = element.getAttribute('section-title')!; |
||||
if (element.getAttribute('initially-expanded') === 'true') { |
||||
this.expanded = true; |
||||
} |
||||
|
||||
const target:HTMLElement = element.nextElementSibling as HTMLElement; |
||||
this.sectionBody.nativeElement.appendChild(target); |
||||
target.removeAttribute('hidden'); |
||||
} |
||||
|
||||
public toggle() { |
||||
this.expanded = !this.expanded; |
||||
} |
||||
} |
||||
|
||||
DynamicBootstrapper.register({ selector: collapsibleSectionAugmentSelector, cls: CollapsibleSectionComponent }); |
@ -0,0 +1,15 @@ |
||||
<section class="collapsible-section" |
||||
[ngClass]="{ '-expanded': expanded }"> |
||||
|
||||
<accessible-by-keyboard (execute)="toggle()" |
||||
[linkAriaLabel]="sectionTitle" |
||||
linkClass="collapsible-section--toggle-link" |
||||
spanClass="collapsible-section--legend"> |
||||
<span [textContent]="sectionTitle"></span> |
||||
</accessible-by-keyboard> |
||||
<div class="collapsible-section--body toggle-slide-animation" |
||||
#sectionBody |
||||
[hidden]="!expanded"> |
||||
<!-- Wrapped by component --> |
||||
</div> |
||||
</section> |
Loading…
Reference in new issue