Sfoglia il codice sorgente

extract manage table from home and room_planner to tables/manage_table

weichen 4 anni fa
parent
commit
789912b7f5

+ 1 - 0
backstage/home/routes.py

@@ -11,6 +11,7 @@ def home():
     if response.status_code == 200:
         return render_template('home.html',
                                title='首頁',
+                               page='home',
                                contents=response.json())
 
 

+ 1 - 0
backstage/room_planner/routes.py

@@ -10,6 +10,7 @@ def main():
     response = requests.get('http://127.0.0.1:5000/api/manages/data?page=room_planner')
     return render_template('room_planner.html',
                            title='規劃師服務',
+                           page='room_planner',
                            contents=response.json())
 
 

+ 1 - 43
backstage/templates/home.html

@@ -1,43 +1 @@
-{% extends "layout.html" %}
-{% block main %}
-<h1>{{ title }}</h1>
-{% for content in contents %}
-  <form action="{{ url_for('home.update', page='home', section_class=content.sectionClass) }}" method="POST">
-  <table id="example" class="table table-striped table-bordered" cellspacing="0" width="60%">
-    <thead>
-      <tr>
-        <th>數量</th>
-        <th>類型</th>
-        <th>內容</th>
-        <th style="text-align:center;width:100px;">
-            <input class="btn btn-primary" type="submit" value="提交">
-        </th>
-      </tr>
-    </thead>
-    {% for key, value in content.items() %}
-      {% if key != 'sectionClass' %}
-        {% for data in value %}
-          <tbody>
-            <tr>
-              <td>{{ loop.index }}</td>
-              <td>{{ key }}</td>
-              <td>
-                <input name="{{ key }}-{{ loop.index }}" class="form-control form-control-lg" value="{{ data }}">
-              </td>
-              <td>
-                <div>
-                  <a class="btn btn-secondary btn-sm m-1" href="#">編輯</a>
-                  <form action="#" method="POST">
-                    <input class="btn btn-danger" type="submit" value="刪除">
-                  </form>
-                </div>
-              </td>
-            </tr>
-          </tbody>
-        {% endfor %}
-      {% endif %}
-    {% endfor %}
-  </table>
-</form>
-{% endfor %}
-{% endblock main %}
+{% extends "tables/manage_table.html" %}

+ 1 - 42
backstage/templates/room_planner.html

@@ -1,42 +1 @@
-{% extends "layout.html" %}
-{% block main %}
-<h1>{{ title }}</h1>
-{% for content in contents %}
-  <form action="{{ url_for('room_planner.update', page='room_planner', section_class=content.sectionClass) }}" method="POST">
-  <table id="example" class="table table-striped table-bordered" cellspacing="0" width="60%">
-    <thead>
-      <tr>
-        <th>數量</th>
-        <th>類型</th>
-        <th>內容</th>
-        <th style="text-align:center;width:100px;">
-            <input class="btn btn-primary" type="submit" value="提交">
-        </th>
-      </tr>
-    </thead>
-    {% for key, value in content.items() %}
-      {% if key != 'sectionClass' %}
-        {% for data in value %}
-          <tbody>
-            <tr>
-              <td>{{ loop.index }}</td>
-              <td>{{ key }}</td>
-              <td>
-                <input name="{{ key }}-{{ loop.index }}" class="form-control form-control-lg" value="{{ data }}">
-              </td>
-              <td>
-                <div>
-                  <form action="#" method="POST">
-                    <input class="btn btn-danger" type="submit" value="刪除">
-                  </form>
-                </div>
-              </td>
-            </tr>
-          </tbody>
-        {% endfor %}
-      {% endif %}
-    {% endfor %}
-  </table>
-</form>
-{% endfor %}
-{% endblock main %}
+{% extends "tables/manage_table.html" %}