From c343e4efd3714a269dbc4882bdbf2fea8b1abd60 Mon Sep 17 00:00:00 2001 From: Tomas Bures Date: Tue, 22 Aug 2017 08:15:13 +0200 Subject: [PATCH] Rendering of custom fields in subscription list --- client/src/lists/CUD.js | 3 +- client/src/lists/subscriptions/List.js | 11 +- client/src/lists/subscriptions/helpers.js | 197 +++++++++++----------- lib/dt-helpers.js | 5 +- models/fields.js | 6 +- models/subscriptions.js | 140 ++++++++++++++- 6 files changed, 253 insertions(+), 109 deletions(-) diff --git a/client/src/lists/CUD.js b/client/src/lists/CUD.js index 5837bad0..c2b1bfda 100644 --- a/client/src/lists/CUD.js +++ b/client/src/lists/CUD.js @@ -12,6 +12,7 @@ import { withErrorHandling } from '../lib/error-handling'; import { DeleteModalDialog } from '../lib/modals'; import { validateNamespace, NamespaceSelect } from '../lib/namespace'; import { UnsubscriptionMode } from '../../../shared/lists'; +import styles from "../lib/styles.scss"; @translate() @withForm @@ -162,7 +163,7 @@ export default class CUD extends Component { {isEdit && - + {this.getFormValue('cid')} } diff --git a/client/src/lists/subscriptions/List.js b/client/src/lists/subscriptions/List.js index 51377d8e..3d8e677c 100644 --- a/client/src/lists/subscriptions/List.js +++ b/client/src/lists/subscriptions/List.js @@ -14,7 +14,7 @@ import { } from '../../lib/form'; import {Icon} from "../../lib/bootstrap-components"; import axios from '../../lib/axios'; -import {getSubscriptionStatusLabels} from './helpers'; +import {getFieldTypes, getSubscriptionStatusLabels} from './helpers'; @translate() @withForm @@ -30,6 +30,7 @@ export default class List extends Component { this.state = {}; this.subscriptionStatusLabels = getSubscriptionStatusLabels(t); + this.fieldTypes = getFieldTypes(t); this.initForm({ onChange: { @@ -90,10 +91,16 @@ export default class List extends Component { ]; let colIdx = 5; + for (const fld of list.listFields) { + + const indexable = this.fieldTypes[fld.type].indexable; + columns.push({ data: colIdx, - title: fld.name + title: fld.name, + sortable: indexable, + searchable: indexable }); colIdx += 1; diff --git a/client/src/lists/subscriptions/helpers.js b/client/src/lists/subscriptions/helpers.js index d3e03841..68d41a96 100644 --- a/client/src/lists/subscriptions/helpers.js +++ b/client/src/lists/subscriptions/helpers.js @@ -20,156 +20,163 @@ export function getSubscriptionStatusLabels(t) { export function getFieldTypes(t) { - const fieldTypes = {}; + const groupedFieldTypes = {}; const stringFieldType = long => ({ - form: field => long ?