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

:recycle: moving toward list returns instead of table from api

tags/0.9.0
j преди 4 години
родител
ревизия
a85b8cb0aa
променени са 3 файла, в които са добавени 9 реда и са изтрити 31 реда
  1. 7
    8
      plugins/cia-endpoints/includes/class.make-endpoint.php
  2. 1
    22
      vue-theme/src/pages/list.vue
  3. 1
    1
      vue-theme/src/pages/single.vue

+ 7
- 8
plugins/cia-endpoints/includes/class.make-endpoint.php Целия файл

@@ -91,7 +91,8 @@ class Make_Endpoint_For extends WP_REST_Controller {
91 91
     }
92 92
     public function prepare_all_items_for_response( $args ) {
93 93
         $collection = array();
94
-        
94
+        $alphabet_section = 'a';
95
+
95 96
         // https://developer.wordpress.org/reference/functions/get_posts/
96 97
         foreach( get_posts($args) as $item ) {
97 98
             // print_r($args);
@@ -106,15 +107,13 @@ class Make_Endpoint_For extends WP_REST_Controller {
106 107
 
107 108
             if($item->post_type == 'page') {
108 109
                 $filtered[content] = $item->post_content;
109
-                $collection[$item->post_name] = $filtered;
110
-            }
111
-            else if($item->post_type == 'exhibition' || $item->post_type == 'event') {
112
-                array_push($collection, $filtered);
113
-            }
114
-            else {
115
-                $collection[$item->ID] = $filtered;
116 110
             }
117 111
             
112
+            if($item->post_type == 'artist') {
113
+                // This is where you add to your letter counter
114
+            }
115
+
116
+            array_push($collection, $filtered);
118 117
         }
119 118
         wp_reset_postdata();
120 119
 

+ 1
- 22
vue-theme/src/pages/list.vue Целия файл

@@ -55,28 +55,7 @@ export default {
55 55
         posts() {
56 56
             let type = convertTitleCase(this.type)
57 57
             if(!type) return
58
-
59
-            /**
60
-             * We override the API to sort by date
61
-             * because items are returned by ID so
62
-             * we need to re-sort it by date
63
-             */
64
-            let unsortedOfType = Object.values(this[`all${type}`])
65
-            let sortedByRecent = unsortedOfType.sort((postA, postB) => new Date(postB.date) - new Date(postA.date))
66
-            
67
-            /**
68
-             * Sorting of this[`all${type}`] is also controlled by API
69
-             * so if a sortBy is specified we return it sorted or
70
-             * we fail over to sorted by date
71
-             */
72
-            let returnList = sortedByRecent
73
-            if(this.sortBy && sortTypes.includes(this.sortBy)) {
74
-                returnList = this[`all${type}`]
75
-            }
76
-            if(['exhibitions', 'events'].includes(this.type)) {
77
-                returnList = this[`all${type}`]
78
-            }
79
-            return returnList
58
+            return this[`all${type}`]
80 59
         },
81 60
     },
82 61
     methods: {

+ 1
- 1
vue-theme/src/pages/single.vue Целия файл

@@ -15,7 +15,7 @@
15 15
             //- p(v-if="post.type") type: {{ post.type }}
16 16
             //- p(v-if="post.subtypes") subtypes: {{ post.subtypes }}
17 17
 
18
-            .date-info(v-if="type === 'events' || post.type === 'exhibitions'")
18
+            .date-info(v-if="['exhibitions', 'events'].includes(type)")
19 19
                 p start: {{ dateFrom(post.start) }}
20 20
                 p end: {{ dateFrom(post.end) }}
21 21
 

Loading…
Отказ
Запис