{{!
    This file is part of Moodle - http://moodle.org/

    Moodle 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 3 of the License, or
    (at your option) any later version.

    Moodle 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 Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template tool_policy/page_viewalldoc

    Template for viewing all policy versions, one under another.

    Classes required for JS:
    -

    Data attributes required for JS:
    -

    Context variables required for this template:
    * returnurl - url to the previous page
    * policies - policy array

    Example context (json):
    {
        "returnurl": "#",
        "policies": [
            {
                "id": "2",
                "name": "Terms &amp; conditions",
                "summary": "Policy <u>summary</u>",
                "content": "Policy <em>content</em>",
                "policytypestr": "Site policy",
                "policyaudiencestr": "All users"
            },
            {
                "id": "5",
                "name": "Privacy",
                "summary": "We keep your information private",
                "content": "Very private",
                "policytypestr": "Privacy policy",
                "policyaudiencestr": "Authenticated users"
            }
        ]
    }
}}

{{#returnurl}}
<div class="text-end mb-1">
    <a href="{{returnurl}}">{{# str }} backtoprevious, tool_policy {{/ str }}</a>
</div>
{{/returnurl}}

<a id="top"></a>
<div id="policies_index">
<h1>{{# str }} listactivepolicies, tool_policy {{/ str }}</h1>
<table class="table">
    <thead>
    <tr>
        <th scope="col">{{# str }}policydocname, tool_policy {{/ str }}</th>
        <th scope="col">{{# str }}policydoctype, tool_policy {{/ str }}</th>
        <th scope="col">{{# str }}policydocaudience, tool_policy {{/ str }}</th>
    </tr>
    </thead>
    <tbody>
    {{#policies }}
        <tr>
            <td><a href="#policy-{{id}}">{{{name}}}</a></td>
            <td>{{{ policytypestr }}}</td>
            <td>{{{ policyaudiencestr }}}</td>
        </tr>
    {{/policies }}
    </tbody>
</table>
</div>

{{^policies }}
    {{# str }} noactivepolicies, tool_policy {{/ str }}
{{/policies }}

{{#policies }}
        <hr>
    <div class="policy_version mb-3">
        <div class="clearfix mt-2">
            <h2><a id="policy-{{id}}">{{{name}}}</a></h2>
        </div>
        <div class="policy_document_summary clearfix mb-1">
            <h3>{{# str }} policydocsummary, tool_policy {{/ str }}</h3>
            {{{summary}}}
        </div>
        <div class="policy_document_content mt-2">
            <h3>{{# str }} policydoccontent, tool_policy {{/ str }}</h3>
            {{{content}}}
        </div>
        <div class="float-end">
            <a href="#top">
                {{# str }} backtotop, tool_policy {{/ str }}
                <i class="icon text-primary fa fa-caret-up" title="{{# str }} backtotop, tool_policy {{/ str }}" ></i>
            </a>
        </div>
    </div>

{{/policies }}
