[ARVADOS-WORKBENCH2] updated: 1.1.4-200-g9df4e35

Git user git at public.curoverse.com
Thu Jul 5 05:47:37 EDT 2018


Summary of changes:
 src/common/api/order-builder.ts                    | 15 ++++------
 .../project-panel/project-panel-middleware.ts      | 32 ++++++++++++++++++++--
 2 files changed, 34 insertions(+), 13 deletions(-)

       via  9df4e3529aee3343eba37ef5bfc004315ef28a59 (commit)
       via  c497eae178ec7398381092817b69662af5701796 (commit)
      from  c178bb7bacbb174f6b645e410323dbecd59e1a2c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 9df4e3529aee3343eba37ef5bfc004315ef28a59
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Thu Jul 5 11:47:23 2018 +0200

    Implement sorting by name and createdAt fields
    
    Feature #13703
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/views/project-panel/project-panel-middleware.ts b/src/views/project-panel/project-panel-middleware.ts
index 0ea5f1e..5230c75 100644
--- a/src/views/project-panel/project-panel-middleware.ts
+++ b/src/views/project-panel/project-panel-middleware.ts
@@ -12,6 +12,9 @@ import { resourceToDataItem, ProjectPanelItem } from "./project-panel-item";
 import FilterBuilder from "../../common/api/filter-builder";
 import { DataColumns } from "../../components/data-table/data-table";
 import { ProcessResource } from "../../models/process";
+import { CollectionResource } from "../../models/collection";
+import OrderBuilder from "../../common/api/order-builder";
+import { GroupContentsResource } from "../../services/groups-service/groups-service";
 
 export const projectPanelMiddleware: Middleware = store => next => {
     next(actions.SET_COLUMNS({ id: PROJECT_PANEL_ID, columns }));
@@ -37,24 +40,36 @@ export const projectPanelMiddleware: Middleware = store => next => {
                 store.dispatch(actions.RESET_PAGINATION({ id: PROJECT_PANEL_ID }));
                 store.dispatch(actions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
             }),
+            TOGGLE_SORT: handleProjectPanelAction(() => {
+                store.dispatch(actions.RESET_PAGINATION({ id: PROJECT_PANEL_ID }));
+                store.dispatch(actions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
+            }),
             REQUEST_ITEMS: handleProjectPanelAction(() => {
                 const state = store.getState() as RootState;
                 const dataExplorer = getDataExplorer(state.dataExplorer, PROJECT_PANEL_ID);
                 const columns = dataExplorer.columns as DataColumns<ProjectPanelItem, ProjectPanelFilter>;
                 const typeFilters = getColumnFilters(columns, "Type");
                 const statusFilters = getColumnFilters(columns, "Status");
+                const sortColumn = dataExplorer.columns.find(({ sortDirection }) => Boolean(sortDirection && sortDirection !== "none"));
+                const sortDirection = sortColumn && sortColumn.sortDirection === "asc" ? "asc" : "desc";
                 if (typeFilters.length > 0) {
                     groupsService
                         .contents(state.projects.currentItemId, {
                             limit: dataExplorer.rowsPerPage,
                             offset: dataExplorer.page * dataExplorer.rowsPerPage,
+                            order: sortColumn
+                                ? sortColumn.name === "Name"
+                                    ? getOrder("name", sortDirection)
+                                    : getOrder("createdAt", sortDirection)
+                                : OrderBuilder.create(),
                             filters: FilterBuilder
                                 .create()
-                                .addIsA("uuid", typeFilters.map(f => f.type))
+                                .concat(FilterBuilder
+                                    .create<CollectionResource>("collections")
+                                    .addIsA("uuid", typeFilters.map(f => f.type)))
                                 .concat(FilterBuilder
                                     .create<ProcessResource>("containerRequests")
-                                    .addIn("state", statusFilters.map(f => f.type))
-                                )
+                                    .addIn("state", statusFilters.map(f => f.type)))
                         })
                         .then(response => {
                             store.dispatch(actions.SET_ITEMS({
@@ -85,3 +100,14 @@ const getColumnFilters = (columns: DataColumns<ProjectPanelItem, ProjectPanelFil
     return column && column.filters ? column.filters.filter(f => f.selected) : [];
 };
 
+const getOrder = (attribute: "name" | "createdAt", direction: "asc" | "desc") =>
+    [
+        OrderBuilder.create<GroupContentsResource>("collections"),
+        OrderBuilder.create<GroupContentsResource>("container_requests"),
+        OrderBuilder.create<GroupContentsResource>("groups")
+    ].reduce((acc, b) => acc.concat(direction === "asc"
+        ? b.addAsc(attribute)
+        : b.addDesc(attribute)),
+        OrderBuilder.create());
+
+

commit c497eae178ec7398381092817b69662af5701796
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Thu Jul 5 11:44:13 2018 +0200

    Refactor OrderBuilder
    
    Feature #13703
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/common/api/order-builder.ts b/src/common/api/order-builder.ts
index 08d17b1..3163791 100644
--- a/src/common/api/order-builder.ts
+++ b/src/common/api/order-builder.ts
@@ -15,23 +15,18 @@ export default class OrderBuilder<T extends Resource = Resource> {
         private order: string[] = [], 
         private prefix = ""){}
 
-    private getRule (direction: string, attribute: keyof T) {
+    private addRule (direction: string, attribute: keyof T) {
         const prefix = this.prefix ? this.prefix + "." : "";
-        return `${prefix}${_.snakeCase(attribute.toString())} ${direction}`;
+        const order = [...this.order, `${prefix}${_.snakeCase(attribute.toString())} ${direction}`];
+        return new OrderBuilder<T>(order, prefix);
     }
 
     addAsc(attribute: keyof T) {
-        return new OrderBuilder<T>(
-            [...this.order, this.getRule("asc", attribute)],
-            this.prefix
-        );
+        return this.addRule("asc", attribute);
     }
 
     addDesc(attribute: keyof T) {
-        return new OrderBuilder<T>(
-            [...this.order, this.getRule("desc", attribute)],
-            this.prefix
-        );
+        return this.addRule("desc", attribute);
     }
 
     concat(orderBuilder: OrderBuilder){

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list