{% extends "base_generic.html" %}
{% load static %}
{% block title %}<title>愛爾蘭語—華語線上辭典 - 增加條目</title>{% endblock %}
{% block content %}

<div id="successful-saved" {% if is_saved != True %}style="display:none;"{% endif %}>
<div id="close-saved-screen-bar"><span id="close-successful-saved">[X]</span></div>
<div id="successful-saved-message">儲存成功！</div>
</div>


<h1>線上愛爾蘭語—華語辭典</h1>
<h2>增加項目與解釋</h2>
<div id="sidebar"><a href="../accounts/logout">登出</a></div>

<form action="" method="POST">
    {% csrf_token %}
    <div class="form-group">
        <div class="form-group-item">
            <h3>項目</h3>
            {% for field in entry_form %}
			{{field.label_tag}} {{field}} <br/>
			{% endfor %}
			<p/>
			<div id="form-box">
     		 {{meaning_form_set.management_form}}
            {% for meaning in meaning_form_set %}
			<h3>解釋{{forloop.counter}}</h3>
	          {% for field in meaning %}
			    {{field.label_tag}} {{field}}<br/>
			  {% endfor %}
			{% endfor %}
			<p/>

            <input class="btn btn-success" type="submit" value="儲存" />
        </div>
    </div>
</form>

{% for entry in entry_list reversed%}
<form id="entry-{{entry.id}}" action="add_entry_modified" method="POST"></form>
{% endfor %}

<h3>詞條一覽（最後10筆倒著顯示）</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>id</th>
<th>愛爾蘭語<br>Gaeilge</th>
<th>發音<br>Pronoun</th>
<th>詞性<br>PoS</th>
<th>前註<br>PreScript</th>
<th>後註<br>PostScript</th>
<th>編輯</th>
<tr/>
</thead>

{% for entry in entry_list reversed%}
<tr>
<td>{{entry.id}}<input type="hidden" name="id" class="entry-modify-input ent-mod-inp-{{ forloop.counter0 }}" id="id" value="{{entry.id}}" form="entry-{{entry.id}}"></td>
<td>{{entry.Gaeilge}}<input type="text" name="Gaeilge" class="entry-modify-input ent-mod-inp-{{ forloop.counter0 }}" maxlength="100" id="Gaeilge" value="{{entry.Gaeilge}}" form="entry-{{entry.id}}" required=""></td>
<td>{% if entry.Pronoun != None %}{{entry.Pronoun}}{% endif %}<input type="text" name="Pronoun" class="entry-modify-input ent-mod-inp-{{ forloop.counter0 }}" maxlength="250" id="Pronoun" value="{{entry.Pronoun}}" form="entry-{{entry.id}}"></td>
<td>{% if entry.PoS != None %}{{entry.PoS}}{% endif %}<input type="text" name="PoS" class="entry-modify-input ent-mod-inp-{{ forloop.counter0 }}" maxlength="20" id="PoS" value="{{entry.PoS}}" form="entry-{{entry.id}}"></td>
<td>{% if entry.PreScript != None %}{{entry.PreScript}}{% endif %}<input type="text" name="PreScript" class="entry-modify-input ent-mod-inp-{{ forloop.counter0 }}" maxlength="20" id="PreScript" value="{{entry.PreScript}}" form="entry-{{entry.id}}"></td>
<td>{% if entry.PostScript != None %}{{entry.PostScript}}{% endif %}<input type="text" name="PostScript" class="entry-modify-input ent-mod-inp-{{ forloop.counter0 }}" maxlength="20" id="PostScript" value="{{entry.PostScript}}" form="entry-{{entry.id}}"></td>
<td><button class="entry-edit-button" id="entry-edit-{{ forloop.counter0 }}">編輯</button>  <input type="submit" value="更新" form="entry-{{entry.id}}"> <a class="edit">刪除</a></td>
</tr>
{% endfor %}
</table>

<h3>釋義一覽</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>id</th>
<th>條目id<br>Entry Id</th>
<th>意思<br>Meaning_content</th>
<th>例句1<br>Exam_Sentence1</th>
<th>例句中譯1<br>Exam_Sentence1_zh</th>
<th>例句2<br>Exam_Sentence2</th>
<th>例句中譯2<br>Exam_Sentence2_zh</th>
<th>例句3<br>Exam_Sentence3</th>
<th>例句中譯3<br>Exam_Sentence3_zh</th>
<th>編輯</th>
<tr/>
</thead>
{% for m in meaning_list reversed%}
<tr>
<td>{{m.id}}</td>
<td>{{m.Entry.id}}</td>
<td>{{m.Meaning_content}}</td>
<td>{% if m.Exam_Sentence1 != None %}{{m.Exam_Sentence1}}{% endif %}</td>
<td>{% if m.Exam_Sentence1_zh != None %}{{m.Exam_Sentence1_zh}}{% endif %}</td>
<td>{% if m.Exam_Sentence2 != None %}{{m.Exam_Sentence2}}{% endif %}</td>
<td>{% if m.Exam_Sentence2_zh != None %}{{m.Exam_Sentence2_zh}}{% endif %}</td>
<td>{% if m.Exam_Sentence3 != None %}{{m.Exam_Sentence3}}{% endif %}</td>
<td>{% if m.Exam_Sentence3_zh != None %}{{m.Exam_Sentence3_zh}}{% endif %}</td>
<td><a class="edit">編輯</a> <a class="update">更新</a> <a class="delete">刪除</a></td>
</tr>
{% endfor %}
</table>

<script src="{% static 'addentry/add_entry.js' %}"></script>
<link rel="stylesheet" href="{% static 'addentry/add_entry.css' %}">
{% endblock  %}
