Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

landing page: switch previewed file not working #211

Open
ppanero opened this issue Feb 17, 2020 · 0 comments
Open

landing page: switch previewed file not working #211

ppanero opened this issue Feb 17, 2020 · 0 comments
Labels

Comments

@ppanero
Copy link
Member

ppanero commented Feb 17, 2020

The JS points to a div with id files that was removed form here in order to use the invenio-previwer macros.

Something like this in record.html would fix it:

{% from 'invenio_previewer/macros.html' import file_list, preview_file %}

{% macro preview_file_box(file, pid) %}
  {%- if file -%}
    <div class="panel panel-default" id="preview">
      <div class="panel-heading">
        <a class="panel-toggle" data-toggle="collapse" href="#collapsablePreview">
          {{_('Preview')}} - {{ file.key }}
          <span class="pull-right show-on-collapsed"><i class="fa fa-chevron-right"></i></span>
          <span class="pull-right hide-on-collapsed"><i class="fa fa-chevron-down"></i></span>
        </a>
      </div>
      <div id="collapsablePreview" class="collapse in">
        {{- preview_file('invenio_records_ui.recid_previewer', pid=pid, filename=file.key) }}
      </div>
    </div>
  {%- endif %}
{%- endmacro %}



{% macro file_list_box(files, pid) %}
  <div class="panel panel-default files-box" id="files">
    <div class="panel-heading">
      <a class="panel-toggle" data-toggle="collapse" href="#collapsableFiles">
        {{ _("Files") }}
        <span class="pull-right show-on-collapsed"><i class="fa fa-chevron-right"></i></span>
        <span class="pull-right hide-on-collapsed"><i class="fa fa-chevron-down"></i></span>
      </a>
      <small class="text-muted">{% if files %} ({{files|sum(attribute='size')|filesizeformat}}){% endif %}</small>
    </div>
    <div class="collapse in" id="collapsableFiles">
      {{ file_list(files, pid) }}
    </div>
  </div>
{%- endmacro %}


[....]



{%- set files = record.files %}
{{ preview_file_box(files|select_preview_file) }}
{{ file_list_box(files.dumps()) }}

Mainly note the ids in the outer div of each macro.

dumps() is needed due to inveniosoftware/invenio-records-files#96

P.S: I think this is done #173 and should be closed?

@ppanero ppanero added the bug label Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant