Browse Source

[https://github.com/tracim/tracim/issues/764] workspace content list is now sorted by slug

Skylsmoi 6 years ago
parent
commit
df2f4cb97a
1 changed files with 15 additions and 13 deletions
  1. 15 13
      frontend/src/reducer/workspaceContentList.js

+ 15 - 13
frontend/src/reducer/workspaceContentList.js View File

@@ -11,19 +11,21 @@ import {
11 11
 export default function workspaceContentList (state = [], action) {
12 12
   switch (action.type) {
13 13
     case `${SET}/${WORKSPACE_CONTENT}`:
14
-      return action.workspaceContentList.map(wsc => ({
15
-        id: wsc.content_id,
16
-        label: wsc.label,
17
-        slug: wsc.slug,
18
-        type: wsc.content_type,
19
-        idWorkspace: wsc.workspace_id,
20
-        isArchived: wsc.is_archived,
21
-        idParent: wsc.parent_id,
22
-        isDeleted: wsc.is_deleted,
23
-        showInUi: wsc.show_in_ui,
24
-        statusSlug: wsc.status,
25
-        subContentTypeSlug: wsc.sub_content_type_slug
26
-      }))
14
+      return action.workspaceContentList
15
+        .sort((a, b) => a.slug < b.slug ? -1 : 1)
16
+        .map(wsc => ({
17
+          id: wsc.content_id,
18
+          label: wsc.label,
19
+          slug: wsc.slug,
20
+          type: wsc.content_type,
21
+          idWorkspace: wsc.workspace_id,
22
+          isArchived: wsc.is_archived,
23
+          idParent: wsc.parent_id,
24
+          isDeleted: wsc.is_deleted,
25
+          showInUi: wsc.show_in_ui,
26
+          statusSlug: wsc.status,
27
+          subContentTypeSlug: wsc.sub_content_type_slug
28
+        }))
27 29
 
28 30
     case `${UPDATE}/${WORKSPACE}/Filter`: // not used anymore ?
29 31
       return {...state, filter: action.filterList}