summaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/templates/editgroup_view.html
blob: 0142a46b5471bfd9d14773b87a02813f2fa98c1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
{% extends "base.html" %}
{% import "entity_macros.html" as entity_macros %}

{% macro entity_edit_header(auth_to, editgroup, edit, entity_type, entity_name) -%}
  <div style="float: right; font-weight: bold;">
    <a href="/editgroup/{{ editgroup.editgroup_id }}/{{ entity_type }}/{{ edit.ident }}">[view]</a>
    <a href="/editgroup/{{ editgroup.editgroup_id }}/diff#{{ entity_type }}_{{ edit.ident }}">[diff]</a>
    {% if auth_to.edit and not editgroup.changelog_index and not editgroup.submitted %}
      <br><a href="/editgroup/{{ editgroup.editgroup_id }}/{{ entity_type }}/{{ edit.ident }}/edit" style="color: green;">[re-edit]</a>
      <br>
      <form id="submit_edit_delete" method="POST" action="/editgroup/{{ editgroup.editgroup_id }}/{{ entity_type }}/edit/{{ edit.edit_id }}/delete" style="display:inline;">
          <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
          <input type="submit" value="[delete]" style="background:none; color: red; border: none; font-weight:bold; cursor:pointer; padding: 0;"></input>
      </form>
    {% endif %}
  </div>
  <div class="header">
    <a href="/{{ entity_type }}/{{ edit.ident }}">{{ entity_type }}_{{ edit.ident }}</a>
    {% if edit.redirect_ident %}
      =&gt; redirect to <a href="/{{ entity_type }}/{{ edit.redirect_ident }}">{{ entity_type }}/{{ edit.redirect_ident }}</a>
    {% elif not edit.revision %}
      deleted
    {% elif not edit.prev_revision %}
      created
    {% else %}
      updated
    {% endif %}
  </div>
  {% if edit.revision %}
    Revision: <small><code><a href="/{{ entity_type }}/rev/{{ edit.revision }}">{{ edit.revision }}</a></code></small>
  {% endif %}
{%- endmacro %}

{% macro edit_list(auth_to, editgroup, edits, entity_type, entity_name) -%}
<div class="{% if edits %}active{% endif %} title">
  <h3><i class="dropdown icon"></i>{{ entity_name }} Edits ({{ edits|count }})</h3>
</div><div class="{% if edits %}active{% endif %} content" style="padding-bottom: 0.5em;">
  <div class="ui divided list">
    {% for edit in edits %}
    <div class="item" id="{{ entity_type }}_{{ edit.ident }}">
      <div class="content" style="padding-bottom: 0.5em;">
        {{ entity_edit_header(auth_to, editgroup, edit, entity_type, entity_name) }}
        {% if edit.extra %}
          {{ entity_macros.extra_metadata(edit.extra) }}
        {% endif %}
      </div>
    </div>
    {% endfor %}
  </div>
</div>
{%- endmacro %}

{% block title %}Editgroup{% endblock %}

{% block body %}
{# extended by changelog_entry #}
{% block editgroupheader %}

<h1 class="ui header">{% block pagetitle %}Editgroup{% endblock %}
<span class="sub header"><code>editgroup_{{ editgroup.editgroup_id }}</code></span></h1>

{% if not auth_to.submit %}
<div class="ui info small message">
  <div class="header">
    What is an editgroup?
  </div>
  <p>An editgroup is a set of entity edits, bundled together into a coherent, reviewable bundle.
</div>
{% endif %}

<div class="ui three top attached ordered steps">

  {% if editgroup.changelog_index %}
    {% set editing_status = "completed" %}
    {% set submit_status = "completed" %}
    {% set accept_status = "completed" %}
  {% elif editgroup.submitted %}
    {% set editing_status = "completed" %}
    {% set submit_status = "completed" %}
    {% set accept_status = "active" %}
  {% else %}
    {% set editing_status = "completed" %}
    {% set submit_status = "active" %}
    {% set accept_status = "" %}
  {% endif %}

  <div class="{{ editing_status }} step">
    <div class="content">
      <div class="title">
        {% if not editgroup.changelog_index and auth_to.submit and editgroup.submitted %}
          <form id="submit_editgroup_form" method="POST" action="/editgroup/{{ editgroup.editgroup_id }}/unsubmit">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
            <button class="ui primary compact small button" type="submit">Edit</button>
          </form>
        {% else %}
          Edit
        {% endif %}
      </div>
      <div class="description">Make changes to entities</div>
    </div>
  </div>

  <div class="{{ submit_status }} step">
    <div class="content">
      <div class="title">
        {% if not editgroup.changelog_index and auth_to.submit and not editgroup.submitted %}
          <form id="submit_editgroup_form" method="POST" action="/editgroup/{{ editgroup.editgroup_id }}/submit">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
            <button class="ui primary compact small button" type="submit">Submit</button>
          </form>
        {% else %}
          Submitted
        {% endif %}
      </div>
      <div class="description">For review and feedback from others</div>
    </div>
  </div>

  <div class="{{ accept_status }} step">
    <div class="content">
      <div class="title">
        {% if not editgroup.changelog_index and auth_to.accept %}
          <form id="submit_editgroup_form" method="POST" action="/editgroup/{{ editgroup.editgroup_id }}/accept">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
            <button class="ui primary compact small button" type="submit">Accept</button>
          </form>
        {% else %}
          Accepted
        {% endif %}
      </div>
      <div class="description">Changes added to catalog</div>
    </div>
  </div>

</div>

{% endblock %}

<table class="ui fixed compact small definition table">
  <tbody>
    <tr>
      <td class="three wide right aligned">Status</td>
      <td class="seven wide">
        {% if editgroup.changelog_index %}
          Merged (<a href="/changelog/{{ editgroup.changelog_index }}">Changelog #{{ editgroup.changelog_index }}</a>)
        {% elif editgroup.submitted %}
          Submitted ({{ editgroup.submitted.strftime("%Y-%m-%d %H:%M:%S") }})
        {% else %}
          Not Submitted
        {% endif %}
      </td>
    </tr>
    <tr>
      <td class="right aligned">Editor</td>
      <td>
        <a href="/editor/{{editgroup.editor_id}}">{{ editgroup.editor.username }}</a>
      </td>
    </tr>
    <tr>
      <td class="right aligned">Description</td>
      <td>
        {% if editgroup.description %}
          {{ editgroup.description }}
        {% else %}
          <i>none</i>
        {% endif %}
      </td>
    </tr>
</tbody></table>

{% if editgroup.extra %}
  <h4>Extra Metadata (raw JSON)</h4>
  {{ entity_macros.extra_metadata(editgroup.extra) }}
{% endif %}

{% block editgroupedits %}
<h3 class="ui header">All Entity Changes</h3>
<div class="ui styled fluid accordion">
  {{ edit_list(auth_to, editgroup, editgroup.edits.releases, "release", "Release") }}
  {{ edit_list(auth_to, editgroup, editgroup.edits.works, "work", "Work") }}
  {{ edit_list(auth_to, editgroup, editgroup.edits.containers, "container", "Container") }}
  {{ edit_list(auth_to, editgroup, editgroup.edits.creators, "creator", "Creator") }}
  {{ edit_list(auth_to, editgroup, editgroup.edits.files, "file", "File") }}
  {{ edit_list(auth_to, editgroup, editgroup.edits.filesets, "fileset", "File Set") }}
  {{ edit_list(auth_to, editgroup, editgroup.edits.webcaptures, "webcapture", "Web Capture") }}
</div>
<div style="float: right; font-size: smaller;">
  <a href="{{ config.FATCAT_PUBLIC_API_HOST }}/editgroup/{{ editgroup.editgroup_id }}">As JSON via API</a>
</div>
{% endblock %}

<br>
{% block editgroupannotations %}
<h3 class="ui header">Comments and Annotations</h3>
{% for annotation in editgroup.annotations|reverse %}
  <div class="ui segments">
    <div class="ui top attached secondary segment">
      {% if annotation.editor.is_bot %}
        <i class="icon server"></i>
      {% else %}
        <i class="icon user"></i>
      {% endif %}
      <b><a href="/editor/{{ annotation.editor_id }}">{{ annotation.editor.username}}</a></b>
      {% if annotation.editor.is_admin %}
        <span class="ui tiny olive label">Admin</span>
      {% endif %}
      at {{ annotation.created.strftime("%Y-%m-%d %H:%M:%S") }}
      {# TODO: get individual editgroup annotation not supported yet
      (<a href="{% if config.FATCAT_DOMAIN == 'dev.fatcat.wiki' %}http://localhost:9411{% else %}https://api.{{ config.FATCAT_DOMAIN }}{% endif %}/v0/editgroup/{{ annotation.editgroup_id }}/annotation/{{ annotation.annotation_id }}">as JSON</a>)
      #}
      {% if annotation.extra and annotation.extra.disposition %}
        {% set disp = annotation.extra.disposition %}
        <span class="ui small {% if disp == "accept" %}green{% elif disp == "reject" %}red{% else %}orange{%endif %} label" style="float: right;">{{ annotation.extra.disposition|capitalize }}</span>
      {% endif %}
    </div>
    {% if annotation.extra %}
      <div class="ui attached tertiary segment accordion" style="padding-top: 0.2em; padding-bottom: 0.2em;">
        <div class="title">
          <i class="dropdown icon"></i>Review Metadata (raw JSON)
        </div>
        <div class="content" style="padding-bottom: 0.5em;">
          {{ entity_macros.extra_metadata(annotation.extra) }}
        </div>
      </div>
    {% endif %}
    <div class="ui bottom attached segment">
      {{ annotation.comment_markdown|markdown(escape=True) }}
    </div>
  </div>
{% else %}
  <i>None!</i>
{% endfor %}

{% if not editgroup.changelog_index and auth_to.annotate %}
  <div class="ui segment">
    <h3 class="ui header">Add Comment</h3>
    <form class="ui form" id="submit_editgroup_annotation_form" method="POST" action="/editgroup/{{ editgroup.editgroup_id }}/annotation">
      <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
      <div class="field">
        <textarea rows="2" name="comment_markdown" required type="text" value=""></textarea>
      </div>
      <i>Markdown is allowed</i>
      <button class="ui right floated primary button">
        <i class="icon edit"></i> Post
      </button>
      <br>
    </form><br>
  </div>
{% endif %}
{% endblock %}

{% endblock %}

{% block postscript %}
<script>
$('.ui.accordion')
  .accordion({ exclusive: false });
</script>
{% endblock %}