{{!
    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-left mb-3">
    <a href="{{returnurl}}" class="btn btn-secondary">{{# str }} backtoprevious, tool_policy {{/ str }}</a>
</div>
{{/returnurl}}

<a id="top"></a>
<div id="policies_index">
    <h2 class="my-2">{{# str }} listactivepolicies, tool_policy {{/ str }}</h2>
    <table class="rui-viewalldoc generaltable">
        <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 class="my-5">
    <div class="policy_version mb-3">
        <div class="clearfix mt-2">
            <h4><a id="policy-{{id}}">{{{name}}}</a></h4>
        </div>
        <div class="policy_document_summary clearfix mb-1">
            <h5>{{# str }} policydocsummary, tool_policy {{/ str }}</h5>
            {{{summary}}}
        </div>
        <div class="policy_document_content mt-2">
            <h5>{{# str }} policydoccontent, tool_policy {{/ str }}</h5>
            {{{content}}}
        </div>
        <div class="float-right">
            <a href="#top" class="btn btn-sm btn-secondary">
                {{# str }} backtotop, tool_policy {{/ str }}
            </a>
        </div>
    </div>

{{/policies }}
