@budibase/frontend-core 2.6.17 → 2.6.19-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "2.6.17",
3
+ "version": "2.6.19-alpha.0",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
7
7
  "svelte": "src/index.js",
8
8
  "dependencies": {
9
- "@budibase/bbui": "^2.6.17",
10
- "@budibase/shared-core": "^2.6.17",
9
+ "@budibase/bbui": "2.6.19-alpha.0",
10
+ "@budibase/shared-core": "2.6.19-alpha.0",
11
11
  "dayjs": "^1.11.7",
12
12
  "lodash": "^4.17.21",
13
13
  "socket.io-client": "^4.6.1",
14
14
  "svelte": "^3.46.2"
15
15
  },
16
- "gitHead": "2a0993fe5e3cab1ec779603cc9228f824e2cea4d"
16
+ "gitHead": "82e867c0f5b41fe3af88333effeb88f29b8b4d23"
17
17
  }
package/src/api/groups.js CHANGED
@@ -52,6 +52,23 @@ export const buildGroupsEndpoints = API => {
52
52
  })
53
53
  },
54
54
 
55
+ /**
56
+ * Gets a group users by the group id
57
+ */
58
+ getGroupUsers: async ({ id, bookmark, emailSearch }) => {
59
+ let url = `/api/global/groups/${id}/users?`
60
+ if (bookmark) {
61
+ url += `bookmark=${bookmark}&`
62
+ }
63
+ if (emailSearch) {
64
+ url += `emailSearch=${emailSearch}&`
65
+ }
66
+
67
+ return await API.get({
68
+ url,
69
+ })
70
+ },
71
+
55
72
  /**
56
73
  * Adds users to a group
57
74
  * @param groupId The group to update
@@ -0,0 +1,67 @@
1
+ <script>
2
+ import { Layout } from "@budibase/bbui"
3
+ import Bulgaria from "../../assets/bulgaria.png"
4
+ import Covanta from "../../assets/covanta.png"
5
+ import Schnellecke from "../../assets/schnellecke.png"
6
+
7
+ const testimonials = [
8
+ {
9
+ text: "Budibase was the only solution that checked all the boxes for Covanta. Covanta expects to realize $3.2MM in savings due to the elimination of redundant data entry.",
10
+ name: "Charles Link",
11
+ role: "Senior Director, Data and Analytics",
12
+ image: Covanta,
13
+ imageSize: 105,
14
+ },
15
+ {
16
+ text: "Budibase was mission-critical for us and went a long way in preventing what could have become a humanitarian crisis here in Bulgaria.",
17
+ name: "Bozhidar Bozhanov",
18
+ role: "Government of Bulgaria",
19
+ image: Bulgaria,
20
+ imageSize: 49,
21
+ },
22
+ {
23
+ text: "Centralization of authentication, quick turnaround time for requests, integration with different database systems has given it the edge and it’s now used daily for internal development for those apps that you know you need but don’t feel value in losing days of development to reinvent the wheel.",
24
+ name: "Davide Lenzarini",
25
+ role: "IT manager",
26
+ image: Schnellecke,
27
+ imageSize: 141,
28
+ },
29
+ ]
30
+ const testimonial = testimonials[Math.floor(Math.random() * 3)]
31
+ </script>
32
+
33
+ <div class="testimonial">
34
+ <Layout noPadding gap="S">
35
+ <img
36
+ width={testimonial.imageSize}
37
+ alt="a-happy-budibase-user"
38
+ src={testimonial.image}
39
+ />
40
+ <div class="text">
41
+ "{testimonial.text}"
42
+ </div>
43
+ <div class="author">
44
+ <div class="name">{testimonial.name}</div>
45
+ <div class="company">{testimonial.role}</div>
46
+ </div>
47
+ </Layout>
48
+ </div>
49
+
50
+ <style>
51
+ .testimonial {
52
+ width: 380px;
53
+ padding: 40px;
54
+ }
55
+ .text {
56
+ font-size: var(--font-size-l);
57
+ font-style: italic;
58
+ }
59
+ .name {
60
+ font-weight: bold;
61
+ color: var(--spectrum-global-color-gray-900);
62
+ font-size: var(--font-size-l);
63
+ }
64
+ .company {
65
+ color: var(--spectrum-global-color-gray-700);
66
+ }
67
+ </style>
@@ -1,58 +1,15 @@
1
1
  <script>
2
2
  import SplitPage from "./SplitPage.svelte"
3
- import { Layout } from "@budibase/bbui"
4
- import Bulgaria from "../../assets/bulgaria.png"
5
- import Covanta from "../../assets/covanta.png"
6
- import Schnellecke from "../../assets/schnellecke.png"
3
+ import Testimonial from "./Testimonial.svelte"
7
4
 
8
5
  export let enabled = true
9
-
10
- const testimonials = [
11
- {
12
- text: "Budibase was the only solution that checked all the boxes for Covanta. Covanta expects to realize $3.2MM in savings due to the elimination of redundant data entry.",
13
- name: "Charles Link",
14
- role: "Senior Director, Data and Analytics",
15
- image: Covanta,
16
- imageSize: 105,
17
- },
18
- {
19
- text: "Budibase was mission-critical for us and went a long way in preventing what could have become a humanitarian crisis here in Bulgaria.",
20
- name: "Bozhidar Bozhanov",
21
- role: "Government of Bulgaria",
22
- image: Bulgaria,
23
- imageSize: 49,
24
- },
25
- {
26
- text: "Centralization of authentication, quick turnaround time for requests, integration with different database systems has given it the edge and it’s now used daily for internal development for those apps that you know you need but don’t feel value in losing days of development to reinvent the wheel.",
27
- name: "Davide Lenzarini",
28
- role: "IT manager",
29
- image: Schnellecke,
30
- imageSize: 141,
31
- },
32
- ]
33
- const testimonial = testimonials[Math.floor(Math.random() * 3)]
34
6
  </script>
35
7
 
36
8
  <SplitPage>
37
9
  <slot />
38
10
  <div class:wrapper={enabled} slot="right">
39
11
  {#if enabled}
40
- <div class="testimonial">
41
- <Layout noPadding gap="S">
42
- <img
43
- width={testimonial.imageSize}
44
- alt="a-happy-budibase-user"
45
- src={testimonial.image}
46
- />
47
- <div class="text">
48
- "{testimonial.text}"
49
- </div>
50
- <div class="author">
51
- <div class="name">{testimonial.name}</div>
52
- <div class="company">{testimonial.role}</div>
53
- </div>
54
- </Layout>
55
- </div>
12
+ <Testimonial />
56
13
  {/if}
57
14
  </div>
58
15
  </SplitPage>
@@ -64,20 +21,4 @@
64
21
  display: grid;
65
22
  place-items: center;
66
23
  }
67
- .testimonial {
68
- width: 380px;
69
- padding: 40px;
70
- }
71
- .text {
72
- font-size: var(--font-size-l);
73
- font-style: italic;
74
- }
75
- .name {
76
- font-weight: bold;
77
- color: var(--spectrum-global-color-gray-900);
78
- font-size: var(--font-size-l);
79
- }
80
- .company {
81
- color: var(--spectrum-global-color-gray-700);
82
- }
83
24
  </style>
@@ -32,6 +32,7 @@
32
32
  $: readonly =
33
33
  column.schema.autocolumn ||
34
34
  column.schema.disabled ||
35
+ column.schema.type === "formula" ||
35
36
  (!$config.allowEditRows && row._id)
36
37
 
37
38
  // Register this cell API if the row is focused
@@ -1,17 +1,22 @@
1
1
  <script>
2
2
  import dayjs from "dayjs"
3
3
  import { CoreDatePicker, Icon } from "@budibase/bbui"
4
+ import { onMount } from "svelte"
4
5
 
5
6
  export let value
6
7
  export let schema
7
8
  export let onChange
8
9
  export let focused = false
9
10
  export let readonly = false
11
+ export let api
10
12
 
11
- // adding the 0- will turn a string like 00:00:00 into a valid ISO
13
+ let flatpickr
14
+ let isOpen
15
+
16
+ // Adding the 0- will turn a string like 00:00:00 into a valid ISO
12
17
  // date, but will make actual ISO dates invalid
13
- $: time = new Date(`0-${value}`)
14
- $: timeOnly = !isNaN(time) || schema?.timeOnly
18
+ $: isTimeValue = !isNaN(new Date(`0-${value}`))
19
+ $: timeOnly = isTimeValue || schema?.timeOnly
15
20
  $: dateOnly = schema?.dateOnly
16
21
  $: format = timeOnly
17
22
  ? "HH:mm:ss"
@@ -19,12 +24,45 @@
19
24
  ? "MMM D YYYY"
20
25
  : "MMM D YYYY, HH:mm"
21
26
  $: editable = focused && !readonly
27
+ $: displayValue = getDisplayValue(value, format, timeOnly, isTimeValue)
28
+
29
+ const getDisplayValue = (value, format, timeOnly, isTimeValue) => {
30
+ if (!value) {
31
+ return ""
32
+ }
33
+ // Parse full date strings
34
+ if (!timeOnly || !isTimeValue) {
35
+ return dayjs(value).format(format)
36
+ }
37
+ // Otherwise must be a time string
38
+ return dayjs(`0-${value}`).format(format)
39
+ }
40
+
41
+ // Ensure we close flatpickr when unselected
42
+ $: {
43
+ if (!focused) {
44
+ flatpickr?.close()
45
+ }
46
+ }
47
+
48
+ const onKeyDown = () => {
49
+ return isOpen
50
+ }
51
+
52
+ onMount(() => {
53
+ api = {
54
+ onKeyDown,
55
+ focus: () => flatpickr?.open(),
56
+ blur: () => flatpickr?.close(),
57
+ isActive: () => isOpen,
58
+ }
59
+ })
22
60
  </script>
23
61
 
24
62
  <div class="container">
25
63
  <div class="value">
26
64
  {#if value}
27
- {dayjs(timeOnly ? time : value).format(format)}
65
+ {displayValue}
28
66
  {/if}
29
67
  </div>
30
68
  {#if editable}
@@ -42,6 +80,10 @@
42
80
  {timeOnly}
43
81
  time24hr
44
82
  ignoreTimezones={schema.ignoreTimezones}
83
+ bind:flatpickr
84
+ on:open={() => (isOpen = true)}
85
+ on:close={() => (isOpen = false)}
86
+ useKeyboardShortcuts={false}
45
87
  />
46
88
  </div>
47
89
  {/if}
@@ -1,6 +1,13 @@
1
1
  <script>
2
- import { clickOutside, Menu, MenuItem, notifications } from "@budibase/bbui"
2
+ import {
3
+ clickOutside,
4
+ Menu,
5
+ MenuItem,
6
+ Helpers,
7
+ notifications,
8
+ } from "@budibase/bbui"
3
9
  import { getContext } from "svelte"
10
+ import { NewRowID } from "../lib/constants"
4
11
 
5
12
  const {
6
13
  focusedRow,
@@ -14,9 +21,11 @@
14
21
  clipboard,
15
22
  dispatch,
16
23
  focusedCellAPI,
24
+ focusedRowId,
17
25
  } = getContext("grid")
18
26
 
19
27
  $: style = makeStyle($menu)
28
+ $: isNewRow = $focusedRowId === NewRowID
20
29
 
21
30
  const makeStyle = menu => {
22
31
  return `left:${menu.left}px; top:${menu.top}px;`
@@ -36,6 +45,11 @@
36
45
  $focusedCellId = `${newRow._id}-${column}`
37
46
  }
38
47
  }
48
+
49
+ const copyToClipboard = async value => {
50
+ await Helpers.copyToClipboard(value)
51
+ notifications.success("Copied to clipboard")
52
+ }
39
53
  </script>
40
54
 
41
55
  {#if $menu.visible}
@@ -58,22 +72,38 @@
58
72
  </MenuItem>
59
73
  <MenuItem
60
74
  icon="Maximize"
61
- disabled={!$config.allowEditRows}
75
+ disabled={isNewRow || !$config.allowEditRows}
62
76
  on:click={() => dispatch("edit-row", $focusedRow)}
63
77
  on:click={menu.actions.close}
64
78
  >
65
79
  Edit row in modal
66
80
  </MenuItem>
81
+ <MenuItem
82
+ icon="Copy"
83
+ disabled={isNewRow || !$focusedRow?._id}
84
+ on:click={() => copyToClipboard($focusedRow?._id)}
85
+ on:click={menu.actions.close}
86
+ >
87
+ Copy row _id
88
+ </MenuItem>
89
+ <MenuItem
90
+ icon="Copy"
91
+ disabled={isNewRow || !$focusedRow?._rev}
92
+ on:click={() => copyToClipboard($focusedRow?._rev)}
93
+ on:click={menu.actions.close}
94
+ >
95
+ Copy row _rev
96
+ </MenuItem>
67
97
  <MenuItem
68
98
  icon="Duplicate"
69
- disabled={!$config.allowAddRows}
99
+ disabled={isNewRow || !$config.allowAddRows}
70
100
  on:click={duplicate}
71
101
  >
72
102
  Duplicate row
73
103
  </MenuItem>
74
104
  <MenuItem
75
105
  icon="Delete"
76
- disabled={!$config.allowDeleteRows}
106
+ disabled={isNewRow || !$config.allowDeleteRows}
77
107
  on:click={deleteRow}
78
108
  >
79
109
  Delete row
@@ -338,15 +338,11 @@ export const deriveStores = context => {
338
338
  ...state,
339
339
  [rowId]: true,
340
340
  }))
341
- const newRow = { ...row, ...get(rowChangeCache)[rowId] }
342
- const saved = await API.saveRow(newRow)
341
+ const saved = await API.saveRow({ ...row, ...get(rowChangeCache)[rowId] })
343
342
 
344
343
  // Update state after a successful change
345
344
  rows.update(state => {
346
- state[index] = {
347
- ...newRow,
348
- _rev: saved._rev,
349
- }
345
+ state[index] = saved
350
346
  return state.slice()
351
347
  })
352
348
  rowChangeCache.update(state => {
@@ -1,3 +1,4 @@
1
1
  export { default as SplitPage } from "./SplitPage.svelte"
2
2
  export { default as TestimonialPage } from "./TestimonialPage.svelte"
3
+ export { default as Testimonial } from "./Testimonial.svelte"
3
4
  export { Grid } from "./grid"
@@ -362,13 +362,35 @@ export default class DataFetch {
362
362
  return
363
363
  }
364
364
  this.store.update($store => ({ ...$store, loading: true }))
365
- const { rows, info, error } = await this.getPage()
365
+ const { rows, info, error, cursor } = await this.getPage()
366
+
367
+ let { cursors } = get(this.store)
368
+ const { pageNumber } = get(this.store)
369
+
370
+ if (!rows.length && pageNumber > 0) {
371
+ // If the full page is gone but we have previous pages, navigate to the previous page
372
+ this.store.update($store => ({
373
+ ...$store,
374
+ loading: false,
375
+ cursors: cursors.slice(0, pageNumber),
376
+ }))
377
+ return await this.prevPage()
378
+ }
379
+
380
+ const currentNextCursor = cursors[pageNumber + 1]
381
+ if (currentNextCursor != cursor) {
382
+ // If the current cursor changed, all the next pages need to be updated, so we mark them as stale
383
+ cursors = cursors.slice(0, pageNumber + 1)
384
+ cursors[pageNumber + 1] = cursor
385
+ }
386
+
366
387
  this.store.update($store => ({
367
388
  ...$store,
368
389
  rows,
369
390
  info,
370
391
  loading: false,
371
392
  error,
393
+ cursors,
372
394
  }))
373
395
  }
374
396
 
@@ -0,0 +1,51 @@
1
+ import { get } from "svelte/store"
2
+ import DataFetch from "./DataFetch.js"
3
+ import { TableNames } from "../constants"
4
+
5
+ export default class GroupUserFetch extends DataFetch {
6
+ constructor(opts) {
7
+ super({
8
+ ...opts,
9
+ datasource: {
10
+ tableId: TableNames.USERS,
11
+ },
12
+ })
13
+ }
14
+
15
+ determineFeatureFlags() {
16
+ return {
17
+ supportsSearch: true,
18
+ supportsSort: false,
19
+ supportsPagination: true,
20
+ }
21
+ }
22
+
23
+ async getDefinition() {
24
+ return {
25
+ schema: {},
26
+ }
27
+ }
28
+
29
+ async getData() {
30
+ const { query, cursor } = get(this.store)
31
+ try {
32
+ const res = await this.API.getGroupUsers({
33
+ id: query.groupId,
34
+ emailSearch: query.emailSearch,
35
+ bookmark: cursor,
36
+ })
37
+
38
+ return {
39
+ rows: res?.users || [],
40
+ hasNextPage: res?.hasNextPage || false,
41
+ cursor: res?.bookmark || null,
42
+ }
43
+ } catch (error) {
44
+ return {
45
+ rows: [],
46
+ hasNextPage: false,
47
+ error,
48
+ }
49
+ }
50
+ }
51
+ }
@@ -6,6 +6,7 @@ import NestedProviderFetch from "./NestedProviderFetch.js"
6
6
  import FieldFetch from "./FieldFetch.js"
7
7
  import JSONArrayFetch from "./JSONArrayFetch.js"
8
8
  import UserFetch from "./UserFetch.js"
9
+ import GroupUserFetch from "./GroupUserFetch.js"
9
10
 
10
11
  const DataFetchMap = {
11
12
  table: TableFetch,
@@ -13,6 +14,7 @@ const DataFetchMap = {
13
14
  query: QueryFetch,
14
15
  link: RelationshipFetch,
15
16
  user: UserFetch,
17
+ groupUser: GroupUserFetch,
16
18
 
17
19
  // Client specific datasource types
18
20
  provider: NestedProviderFetch,