@things-factory/dataset 8.0.0-alpha.8 → 8.0.0-alpha.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,6 +30,14 @@ const USECASE_OPTIONS = () => {
30
30
  }
31
31
 
32
32
  const showEntryView = async (columns, data, column, record, rowIndex) => {
33
+ if (!record.isEntryAllowed) {
34
+ notify({
35
+ message: 'You are not allowed to enter data for this dataset',
36
+ level: 'error'
37
+ })
38
+ return
39
+ }
40
+
33
41
  const { name, entryType, entryView } = record
34
42
  const title = `${name} - ${i18next.t('title.data-entry-form')}`
35
43
 
@@ -82,6 +90,14 @@ const showEntryView = async (columns, data, column, record, rowIndex) => {
82
90
  }
83
91
 
84
92
  const issueDataEntry = async (columns, data, column, record, rowIndex) => {
93
+ if (!record.isSupervisor) {
94
+ notify({
95
+ message: 'You are not allowed to issue data collection for this dataset',
96
+ level: 'error'
97
+ })
98
+ return
99
+ }
100
+
85
101
  const response = await client.mutate({
86
102
  mutation: gql`
87
103
  mutation ($dataSetId: String!) {
@@ -180,16 +196,11 @@ export class DataEntryListPage extends connect(store)(localize(i18next)(PageView
180
196
  {
181
197
  type: 'gutter',
182
198
  gutterName: 'button',
183
- icon: record => (!record ? 'assignment_add' : !record.id ? '' : 'assignment_add'),
199
+ icon: record => (record?.isSupervisor ? 'assignment_add' : ''),
184
200
  iconOnly: false,
185
201
  width: 96,
186
202
  fixed: true,
187
- title: record =>
188
- !record
189
- ? i18next.t('button.assign-data-collection')
190
- : !record.id
191
- ? ''
192
- : i18next.t('button.assign-data-collection'),
203
+ title: record => (record?.isSupervisor ? i18next.t('button.assign-data-collection') : ''),
193
204
  handlers: {
194
205
  click: issueDataEntry
195
206
  }
@@ -197,12 +208,11 @@ export class DataEntryListPage extends connect(store)(localize(i18next)(PageView
197
208
  {
198
209
  type: 'gutter',
199
210
  gutterName: 'button',
200
- icon: record => (!record ? 'fact_check' : !record.id ? '' : 'fact_check'),
211
+ icon: record => (record?.isEntryAllowed ? 'fact_check' : ''),
201
212
  iconOnly: false,
202
213
  width: 96,
203
214
  fixed: true,
204
- title: record =>
205
- !record ? i18next.t('button.enter-data') : !record.id ? '' : i18next.t('button.enter-data'),
215
+ title: record => (record?.isEntryAllowed ? i18next.t('button.enter-data') : ''),
206
216
  handlers: {
207
217
  click: showEntryView
208
218
  }
@@ -383,6 +393,8 @@ export class DataEntryListPage extends connect(store)(localize(i18next)(PageView
383
393
  useCase
384
394
  schedule
385
395
  timezone
396
+ isSupervisor
397
+ isEntryAllowed
386
398
  entryRole {
387
399
  id
388
400
  name
@@ -25,6 +25,13 @@ const USECASE_OPTIONS = () => {
25
25
  });
26
26
  };
27
27
  const showEntryView = async (columns, data, column, record, rowIndex) => {
28
+ if (!record.isEntryAllowed) {
29
+ notify({
30
+ message: 'You are not allowed to enter data for this dataset',
31
+ level: 'error'
32
+ });
33
+ return;
34
+ }
28
35
  const { name, entryType, entryView } = record;
29
36
  const title = `${name} - ${i18next.t('title.data-entry-form')}`;
30
37
  switch (entryType) {
@@ -67,6 +74,13 @@ const showEntryView = async (columns, data, column, record, rowIndex) => {
67
74
  }
68
75
  };
69
76
  const issueDataEntry = async (columns, data, column, record, rowIndex) => {
77
+ if (!record.isSupervisor) {
78
+ notify({
79
+ message: 'You are not allowed to issue data collection for this dataset',
80
+ level: 'error'
81
+ });
82
+ return;
83
+ }
70
84
  const response = await client.mutate({
71
85
  mutation: gql `
72
86
  mutation ($dataSetId: String!) {
@@ -134,15 +148,11 @@ let DataEntryListPage = class DataEntryListPage extends connect(store)(localize(
134
148
  {
135
149
  type: 'gutter',
136
150
  gutterName: 'button',
137
- icon: record => (!record ? 'assignment_add' : !record.id ? '' : 'assignment_add'),
151
+ icon: record => ((record === null || record === void 0 ? void 0 : record.isSupervisor) ? 'assignment_add' : ''),
138
152
  iconOnly: false,
139
153
  width: 96,
140
154
  fixed: true,
141
- title: record => !record
142
- ? i18next.t('button.assign-data-collection')
143
- : !record.id
144
- ? ''
145
- : i18next.t('button.assign-data-collection'),
155
+ title: record => ((record === null || record === void 0 ? void 0 : record.isSupervisor) ? i18next.t('button.assign-data-collection') : ''),
146
156
  handlers: {
147
157
  click: issueDataEntry
148
158
  }
@@ -150,11 +160,11 @@ let DataEntryListPage = class DataEntryListPage extends connect(store)(localize(
150
160
  {
151
161
  type: 'gutter',
152
162
  gutterName: 'button',
153
- icon: record => (!record ? 'fact_check' : !record.id ? '' : 'fact_check'),
163
+ icon: record => ((record === null || record === void 0 ? void 0 : record.isEntryAllowed) ? 'fact_check' : ''),
154
164
  iconOnly: false,
155
165
  width: 96,
156
166
  fixed: true,
157
- title: record => !record ? i18next.t('button.enter-data') : !record.id ? '' : i18next.t('button.enter-data'),
167
+ title: record => ((record === null || record === void 0 ? void 0 : record.isEntryAllowed) ? i18next.t('button.enter-data') : ''),
158
168
  handlers: {
159
169
  click: showEntryView
160
170
  }
@@ -333,6 +343,8 @@ let DataEntryListPage = class DataEntryListPage extends connect(store)(localize(
333
343
  useCase
334
344
  schedule
335
345
  timezone
346
+ isSupervisor
347
+ isEntryAllowed
336
348
  entryRole {
337
349
  id
338
350
  name
@@ -1 +1 @@
1
- {"version":3,"file":"data-entry-list-page.js","sourceRoot":"","sources":["../../../client/pages/data-entry/data-entry-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,qBAAqB,CAAA;AAC5B,OAAO,6CAA6C,CAAA;AACpD,OAAO,mCAAmC,CAAA;AAC1C,OAAO,qCAAqC,CAAA;AAE5C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAY,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAEnD,OAAO,EAAgB,SAAS,EAA+B,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACvG,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAk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AAS,CAAC,KAAK,IAAI,EAAE;SAC7C,CAAA;IACH,CAAC;;AA/UM,wBAAM,GAAG;IACd,eAAe;IACf,kBAAkB;IAClB,GAAG,CAAA;;;;;;;;;;;;;;;;;;KAkBF;CACF,AAtBY,CAsBZ;AAEgB;IAAhB,KAAK,EAAE;;sDAAyB;AAEN;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;gDAAA;AA3BjC,iBAAiB;IAD7B,aAAa,CAAC,sBAAsB,CAAC;GACzB,iBAAiB,CAiV7B","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/data-grist'\nimport '@operato/context/ox-context-page-toolbar.js'\nimport '@operato/board/ox-board-viewer.js'\nimport '../../components/data-entry-form.js'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\n\nimport { ColumnConfig, DataGrist, FetchOption, SortersControl, getRenderer } from '@operato/data-grist'\nimport { OxDataUseCase } from '@operato/dataset'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { openPopup, notify } from '@operato/layout'\nimport { InheritedValueType, navigate, PageView, store } from '@operato/shell'\nimport { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'\nimport { provider } from '@things-factory/board-ui/dist-client'\nimport { OxPopup } from '@operato/popup'\n\nconst USECASE_OPTIONS = () => {\n return ['', ...OxDataUseCase.getUseCaseNames()].map(name => {\n return {\n display: name,\n value: name\n }\n })\n}\n\nconst showEntryView = async (columns, data, column, record, rowIndex) => {\n const { name, entryType, entryView } = record\n const title = `${name} - ${i18next.t('title.data-entry-form')}`\n\n switch (entryType) {\n case 'generated':\n openPopup(html` <data-entry-form .dataSet=${record} style=\"background-color: white;\"></data-entry-form> `, {\n closable: true,\n backdrop: true,\n size: 'large',\n title\n })\n break\n\n case 'board':\n const board = {\n id: entryView\n }\n openPopup(\n html`\n <ox-board-viewer\n style=\"background-color: white;\"\n .board=${board}\n .provider=${provider}\n hide-fullscreen\n hide-navigation\n ></ox-board-viewer>\n `,\n {\n closable: true,\n backdrop: true,\n size: 'large',\n title\n }\n )\n\n // navigate(`board-viewer/${entryView}?interactive=true&title=${title}`)\n break\n\n case 'custom-element':\n break\n\n case 'page':\n navigate(entryView)\n break\n\n case 'external':\n window.open(entryView, '_blank')\n break\n }\n}\n\nconst issueDataEntry = async (columns, data, column, record, rowIndex) => {\n const response = await client.mutate({\n mutation: gql`\n mutation ($dataSetId: String!) {\n issueDataCollection(dataSetId: $dataSetId)\n }\n `,\n variables: { dataSetId: record.id }\n })\n\n if (response.errors) {\n notify({\n message: response.errors[0].message,\n level: 'error'\n })\n } else {\n notify({\n message: 'Data entry task issued successfully'\n })\n }\n}\n\n@customElement('data-entry-list-page')\nexport class DataEntryListPage extends connect(store)(localize(i18next)(PageView)) {\n static styles = [\n ScrollbarStyles,\n CommonHeaderStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\n\n .header {\n grid-template-areas: 'filters actions';\n }\n `\n ]\n\n @state() private gristConfig: any\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.data-entry list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'dataset/data-entry-list',\n toolbar: false\n }\n }\n\n render() {\n return html`\n <ox-grist\n mode=\"CARD\"\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n ?url-params-sensitive=${this.active}\n >\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form autofocus without-search></ox-filters-form>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle) {\n this.gristConfig = {\n list: {\n thumbnail: 'entryView',\n fields: ['name', 'description'],\n details: ['schedule', 'type', 'useCase', 'latestCollectedAt', 'prevSchedule', 'nextSchedule']\n },\n columns: [\n {\n type: 'gutter',\n gutterName: 'button',\n icon: record => (!record ? 'assignment_add' : !record.id ? '' : 'assignment_add'),\n iconOnly: false,\n width: 96,\n fixed: true,\n title: record =>\n !record\n ? i18next.t('button.assign-data-collection')\n : !record.id\n ? ''\n : i18next.t('button.assign-data-collection'),\n handlers: {\n click: issueDataEntry\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: record => (!record ? 'fact_check' : !record.id ? '' : 'fact_check'),\n iconOnly: false,\n width: 96,\n fixed: true,\n title: record =>\n !record ? i18next.t('button.enter-data') : !record.id ? '' : i18next.t('button.enter-data'),\n handlers: {\n click: showEntryView\n }\n },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: false\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n editable: false\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'select',\n name: 'type',\n label: true,\n header: i18next.t('field.type'),\n record: {\n editable: false,\n options: [\n {},\n {\n display: i18next.t('text.manually collected'),\n value: 'manual'\n },\n {\n display: i18next.t('text.automatically collected'),\n value: 'automatic'\n }\n ]\n },\n sortable: true,\n filter: true,\n width: 60\n },\n {\n type: 'select',\n name: 'useCase',\n label: true,\n header: i18next.t('field.use-case'),\n record: {\n editable: false,\n options: USECASE_OPTIONS\n },\n sortable: true,\n filter: {\n operator: 'eq',\n options: USECASE_OPTIONS /* in case select options type is a function, filter should have its own options */\n },\n width: 80\n },\n {\n type: 'crontab',\n name: 'schedule',\n label: true,\n header: i18next.t('field.schedule'),\n record: {\n editable: false\n },\n width: 80\n },\n {\n type: 'resource-object',\n name: 'entryRole',\n header: i18next.t('field.entry-role'),\n record: {\n editable: false\n },\n width: 120\n },\n {\n type: 'resource-object',\n name: 'supervisoryRole',\n header: i18next.t('field.supervisory-role'),\n record: {\n editable: false\n },\n width: 120\n },\n {\n type: 'datetime',\n name: 'latestCollectedAt',\n label: true,\n header: i18next.t('field.latest-collected-at'),\n record: {\n editable: false\n },\n width: 180\n },\n {\n type: 'datetime',\n name: 'prevSchedule',\n label: true,\n header: i18next.t('field.prev-schedule'),\n record: {\n editable: false\n },\n width: 180\n },\n {\n type: 'datetime',\n name: 'nextSchedule',\n label: true,\n header: i18next.t('field.next-schedule'),\n record: {\n editable: false\n },\n width: 180\n },\n {\n type: 'string',\n name: 'entryView',\n hidden: true,\n record: {\n editable: false,\n renderer: function (value, column, record, rowIndex, field) {\n const type = record.entryType !== 'board' ? 'string' : 'image'\n\n let renderedValue\n\n if (record.entryType === 'board' && record.entryBoard?.thumbnail) {\n renderedValue = record.entryBoard.thumbnail\n } else {\n renderedValue = html`<md-icon style=\"--md-icon-size: 64px;\">assignment</md-icon>`\n }\n\n return getRenderer(type)(renderedValue, column, record, rowIndex, field)\n }\n }\n }\n ],\n rows: {\n appendable: false,\n editable: false,\n selectable: {\n multiple: false\n },\n classifier: function (record, rowIndex) {}\n },\n sorters: [\n {\n name: 'name'\n }\n ]\n }\n }\n\n async fetchHandler({ page, limit, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $inherited: InheritedValueType) {\n responses: dataSetsForEntry(\n filters: $filters\n pagination: $pagination\n sortings: $sortings\n inherited: $inherited\n ) {\n items {\n id\n name\n description\n partitionKeys\n active\n type\n useCase\n schedule\n timezone\n entryRole {\n id\n name\n }\n supervisoryRole {\n id\n name\n }\n entryType\n entryView\n entryBoard {\n thumbnail\n }\n monitorType\n monitorView\n updater {\n id\n name\n }\n reportType\n reportView\n updatedAt\n dataItems {\n name\n description\n active\n hidden\n tag\n group\n type\n unit\n options\n quota\n spec\n stat\n }\n latestCollectedAt\n nextSchedule\n prevSchedule\n nextSummarySchedule\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings,\n inherited: InheritedValueType.Include\n }\n })\n\n return {\n total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n}\n"]}
1
+ {"version":3,"file":"data-entry-list-page.js","sourceRoot":"","sources":["../../../client/pages/data-entry/data-entry-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,qBAAqB,CAAA;AAC5B,OAAO,6CAA6C,CAAA;AACpD,OAAO,mCAAmC,CAAA;AAC1C,OAAO,qCAAqC,CAAA;AAE5C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAY,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAEnD,OAAO,EAAgB,SAAS,EAA+B,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACvG,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAA;AAG/D,MAAM,eAAe,GAAG,GAAG,EAAE;IAC3B,OAAO,CAAC,EAAE,EAAE,GAAG,aAAa,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACzD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ato/context/ox-context-page-toolbar.js'\nimport '@operato/board/ox-board-viewer.js'\nimport '../../components/data-entry-form.js'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\n\nimport { ColumnConfig, DataGrist, FetchOption, SortersControl, getRenderer } from '@operato/data-grist'\nimport { OxDataUseCase } from '@operato/dataset'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { openPopup, notify } from '@operato/layout'\nimport { InheritedValueType, navigate, PageView, store } from '@operato/shell'\nimport { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'\nimport { provider } from '@things-factory/board-ui/dist-client'\nimport { OxPopup } from '@operato/popup'\n\nconst USECASE_OPTIONS = () => {\n return ['', ...OxDataUseCase.getUseCaseNames()].map(name => {\n return {\n display: name,\n value: name\n }\n })\n}\n\nconst showEntryView = async (columns, data, column, record, rowIndex) => {\n if (!record.isEntryAllowed) {\n notify({\n message: 'You are not allowed to enter data for this dataset',\n level: 'error'\n })\n return\n }\n\n const { name, entryType, entryView } = record\n const title = `${name} - ${i18next.t('title.data-entry-form')}`\n\n switch (entryType) {\n case 'generated':\n openPopup(html` <data-entry-form .dataSet=${record} style=\"background-color: white;\"></data-entry-form> `, {\n closable: true,\n backdrop: true,\n size: 'large',\n title\n })\n break\n\n case 'board':\n const board = {\n id: entryView\n }\n openPopup(\n html`\n <ox-board-viewer\n style=\"background-color: white;\"\n .board=${board}\n .provider=${provider}\n hide-fullscreen\n hide-navigation\n ></ox-board-viewer>\n `,\n {\n closable: true,\n backdrop: true,\n size: 'large',\n title\n }\n )\n\n // navigate(`board-viewer/${entryView}?interactive=true&title=${title}`)\n break\n\n case 'custom-element':\n break\n\n case 'page':\n navigate(entryView)\n break\n\n case 'external':\n window.open(entryView, '_blank')\n break\n }\n}\n\nconst issueDataEntry = async (columns, data, column, record, rowIndex) => {\n if (!record.isSupervisor) {\n notify({\n message: 'You are not allowed to issue data collection for this dataset',\n level: 'error'\n })\n return\n }\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($dataSetId: String!) {\n issueDataCollection(dataSetId: $dataSetId)\n }\n `,\n variables: { dataSetId: record.id }\n })\n\n if (response.errors) {\n notify({\n message: response.errors[0].message,\n level: 'error'\n })\n } else {\n notify({\n message: 'Data entry task issued successfully'\n })\n }\n}\n\n@customElement('data-entry-list-page')\nexport class DataEntryListPage extends connect(store)(localize(i18next)(PageView)) {\n static styles = [\n ScrollbarStyles,\n CommonHeaderStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\n\n .header {\n grid-template-areas: 'filters actions';\n }\n `\n ]\n\n @state() private gristConfig: any\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.data-entry list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'dataset/data-entry-list',\n toolbar: false\n }\n }\n\n render() {\n return html`\n <ox-grist\n mode=\"CARD\"\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n ?url-params-sensitive=${this.active}\n >\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form autofocus without-search></ox-filters-form>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle) {\n this.gristConfig = {\n list: {\n thumbnail: 'entryView',\n fields: ['name', 'description'],\n details: ['schedule', 'type', 'useCase', 'latestCollectedAt', 'prevSchedule', 'nextSchedule']\n },\n columns: [\n {\n type: 'gutter',\n gutterName: 'button',\n icon: record => (record?.isSupervisor ? 'assignment_add' : ''),\n iconOnly: false,\n width: 96,\n fixed: true,\n title: record => (record?.isSupervisor ? i18next.t('button.assign-data-collection') : ''),\n handlers: {\n click: issueDataEntry\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: record => (record?.isEntryAllowed ? 'fact_check' : ''),\n iconOnly: false,\n width: 96,\n fixed: true,\n title: record => (record?.isEntryAllowed ? i18next.t('button.enter-data') : ''),\n handlers: {\n click: showEntryView\n }\n },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: false\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n editable: false\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'select',\n name: 'type',\n label: true,\n header: i18next.t('field.type'),\n record: {\n editable: false,\n options: [\n {},\n {\n display: i18next.t('text.manually collected'),\n value: 'manual'\n },\n {\n display: i18next.t('text.automatically collected'),\n value: 'automatic'\n }\n ]\n },\n sortable: true,\n filter: true,\n width: 60\n },\n {\n type: 'select',\n name: 'useCase',\n label: true,\n header: i18next.t('field.use-case'),\n record: {\n editable: false,\n options: USECASE_OPTIONS\n },\n sortable: true,\n filter: {\n operator: 'eq',\n options: USECASE_OPTIONS /* in case select options type is a function, filter should have its own options */\n },\n width: 80\n },\n {\n type: 'crontab',\n name: 'schedule',\n label: true,\n header: i18next.t('field.schedule'),\n record: {\n editable: false\n },\n width: 80\n },\n {\n type: 'resource-object',\n name: 'entryRole',\n header: i18next.t('field.entry-role'),\n record: {\n editable: false\n },\n width: 120\n },\n {\n type: 'resource-object',\n name: 'supervisoryRole',\n header: i18next.t('field.supervisory-role'),\n record: {\n editable: false\n },\n width: 120\n },\n {\n type: 'datetime',\n name: 'latestCollectedAt',\n label: true,\n header: i18next.t('field.latest-collected-at'),\n record: {\n editable: false\n },\n width: 180\n },\n {\n type: 'datetime',\n name: 'prevSchedule',\n label: true,\n header: i18next.t('field.prev-schedule'),\n record: {\n editable: false\n },\n width: 180\n },\n {\n type: 'datetime',\n name: 'nextSchedule',\n label: true,\n header: i18next.t('field.next-schedule'),\n record: {\n editable: false\n },\n width: 180\n },\n {\n type: 'string',\n name: 'entryView',\n hidden: true,\n record: {\n editable: false,\n renderer: function (value, column, record, rowIndex, field) {\n const type = record.entryType !== 'board' ? 'string' : 'image'\n\n let renderedValue\n\n if (record.entryType === 'board' && record.entryBoard?.thumbnail) {\n renderedValue = record.entryBoard.thumbnail\n } else {\n renderedValue = html`<md-icon style=\"--md-icon-size: 64px;\">assignment</md-icon>`\n }\n\n return getRenderer(type)(renderedValue, column, record, rowIndex, field)\n }\n }\n }\n ],\n rows: {\n appendable: false,\n editable: false,\n selectable: {\n multiple: false\n },\n classifier: function (record, rowIndex) {}\n },\n sorters: [\n {\n name: 'name'\n }\n ]\n }\n }\n\n async fetchHandler({ page, limit, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $inherited: InheritedValueType) {\n responses: dataSetsForEntry(\n filters: $filters\n pagination: $pagination\n sortings: $sortings\n inherited: $inherited\n ) {\n items {\n id\n name\n description\n partitionKeys\n active\n type\n useCase\n schedule\n timezone\n isSupervisor\n isEntryAllowed\n entryRole {\n id\n name\n }\n supervisoryRole {\n id\n name\n }\n entryType\n entryView\n entryBoard {\n thumbnail\n }\n monitorType\n monitorView\n updater {\n id\n name\n }\n reportType\n reportView\n updatedAt\n dataItems {\n name\n description\n active\n hidden\n tag\n group\n type\n unit\n options\n quota\n spec\n stat\n }\n latestCollectedAt\n nextSchedule\n prevSchedule\n nextSummarySchedule\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings,\n inherited: InheritedValueType.Include\n }\n })\n\n return {\n total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n}\n"]}