Преглед на файлове

210721 sort by date / editior.js table toolbar

yukyo преди 3 години
родител
ревизия
e56e021b19
променени са 4 файла, в които са добавени 29 реда и са изтрити 6 реда
  1. 16 4
      backstage/collections/routes.py
  2. 8 0
      backstage/static/js/editor.js
  3. 3 1
      backstage/templates/collections.html
  4. 2 1
      backstage/templates/editor.html

+ 16 - 4
backstage/collections/routes.py

@@ -1,10 +1,11 @@
 from flask import render_template, Blueprint, request, redirect, url_for, jsonify
 import requests
+from wtforms.compat import iteritems
 from backstage.collections.forms import CollectionCreateForm
 from backstage.utils import get_now_time
 from backstage.utils.routes import create_content, remove_content, get_trans_title_url_name
 from backstage.config import PORTAL_SERVER
-
+import json
 
 collections_app = Blueprint('collections', __name__)
 
@@ -13,12 +14,23 @@ collections_app = Blueprint('collections', __name__)
 def collection_list():
     response = requests.get('{}contents?url=/collection'.format(PORTAL_SERVER))
     if response.status_code == 200:
-        print(response.json()[1])
-        print(url_for('collections.create'))
+        #sortedData = sorted(response.json(), key='date', reverse=True)        
+        #print(len(response))
+        #aa = json.loads(response.text)
+        sortedData = sorted(response.json(), key=lambda x:x['date'], reverse=True)
+        """ i=1
+        for d in sortedData:
+            if i == 1:
+                print(d)
+                for key, value in d.items():
+                    print(key+' '+value)
+            i+=1 """
+
+        #print(response.text)
         return render_template('collections.html',
                                title='家具規劃作品',
                                legend='家具規劃作品列表',
-                               collections=response.json(),
+                               collections=sortedData,
                                length=len(response.json()),
                                form=CollectionCreateForm())
 

+ 8 - 0
backstage/static/js/editor.js

@@ -128,6 +128,14 @@ axios.get(contentApiUrl).then(({ data }) => {
         }
       }
       ,
+      warning: {
+        class: Warning,
+        inlineToolbar: true,
+        config: {
+          titlePlaceholder: 'Title',
+          messagePlaceholder: 'Message',
+        },
+      },
       table: Table,
       delimiter: Delimiter,
       embed: Embed,

+ 3 - 1
backstage/templates/collections.html

@@ -1,6 +1,7 @@
 {% extends "tables/editor_table.html" %}
 {% block table_body %}
-{% for idx in range(1, length) %}
+{% for idx in range(0, length) %}
+  {% if collections[idx].url != '/collection' %}
     <tbody>
       <tr>
         <td class="table__data">{{ idx }}</td>
@@ -19,6 +20,7 @@
         </td>
       </tr>
     </tbody>
+  {% endif %}
 {% endfor %}
 {% endblock table_body %}
 

+ 2 - 1
backstage/templates/editor.html

@@ -78,9 +78,10 @@
 <script src="https://cdn.jsdelivr.net/npm/@editorjs/header@latest"></script><!-- Header -->
 <script src="https://cdn.jsdelivr.net/npm/@editorjs/image@latest"></script><!-- Image -->
 <script src="https://cdn.jsdelivr.net/npm/@editorjs/delimiter@latest"></script><!-- Delimiter -->
-<script src="https://cdn.jsdelivr.net/npm/@editorjs/simple-image@latest"></script>
+<!-- <script src="https://cdn.jsdelivr.net/npm/@editorjs/simple-image@latest"></script> -->
 <script src="https://cdn.jsdelivr.net/npm/@editorjs/code@latest"></script>
 <script src="https://cdn.jsdelivr.net/npm/@editorjs/embed@latest"></script>
+<script src="https://cdn.jsdelivr.net/npm/@editorjs/warning@latest"></script>
 
 <script type="text/javascript" src="{{url_for('static', filename='js/yo.js')}}"></script>
 <script type="text/javascript" src="{{url_for('static', filename='js/editor.js')}}"></script>