@operato/data-grist 2.0.0-alpha.139 → 2.0.0-alpha.140

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.
@@ -22,7 +22,7 @@ export class DataManipulator extends LitElement {
22
22
  constructor() {
23
23
  super()
24
24
 
25
- this.addEventListener('select-record-change', e => {
25
+ this.addEventListener('select-record-change', async e => {
26
26
  var {
27
27
  records: selectedRecords,
28
28
  added = [],
@@ -41,7 +41,7 @@ export class DataManipulator extends LitElement {
41
41
  })
42
42
 
43
43
  /* field change processing */
44
- this.addEventListener('field-change', e => {
44
+ this.addEventListener('field-change', async e => {
45
45
  var { after, before, column, record, row } = (e as CustomEvent).detail as {
46
46
  after: any
47
47
  before: any
@@ -50,7 +50,7 @@ export class DataManipulator extends LitElement {
50
50
  row: number
51
51
  }
52
52
 
53
- this.onFieldChange({ after, before, column, record, row })
53
+ await this.onFieldChange({ after, before, column, record, row })
54
54
  })
55
55
 
56
56
  /* record reset processing */
@@ -76,7 +76,7 @@ export class DataManipulator extends LitElement {
76
76
  this.addEventListener('add-child-node', (e: Event) => this.addChildNode((e as CustomEvent).detail as GristRecord))
77
77
  }
78
78
 
79
- onFieldChange({
79
+ async onFieldChange({
80
80
  after,
81
81
  before,
82
82
  column,
@@ -96,7 +96,7 @@ export class DataManipulator extends LitElement {
96
96
 
97
97
  var validation = column.validation
98
98
  if (validation && typeof validation == 'function') {
99
- if (!validation.call(this, after, before, record, column)) {
99
+ if (!(await validation.call(this, after, before, record, column))) {
100
100
  return
101
101
  }
102
102
  }
package/src/types.ts CHANGED
@@ -377,7 +377,12 @@ export type ColumnConfig = {
377
377
  * @param {ColumnConfig} column - The configuration of the column being edited.
378
378
  * @returns {boolean} - Returns `true` if the value is valid, `false` otherwise.
379
379
  */
380
- export type ValidationCallback = (after: any, before: any, record: GristRecord, column: ColumnConfig) => boolean
380
+ export type ValidationCallback = (
381
+ after: any,
382
+ before: any,
383
+ record: GristRecord,
384
+ column: ColumnConfig
385
+ ) => boolean | Promise<boolean>
381
386
 
382
387
  /**
383
388
  * Configuration options for column labels.
@@ -17,6 +17,7 @@ import {
17
17
  } from '../src/types.js'
18
18
 
19
19
  import { CommonHeaderStyles, CommonGristStyles } from '@operato/styles'
20
+ import { OxPrompt } from '@operato/popup'
20
21
 
21
22
  const fetchHandler: FetchHandler = async ({ page, limit }) => {
22
23
  var total = 120993
@@ -176,20 +177,18 @@ const config = {
176
177
  filter: 'search',
177
178
  sortable: true,
178
179
  width: 130,
179
- validation: function (after, before, record, column) {
180
+ validation: (async (after, before, record, column) => {
180
181
  if (after.indexOf('@') == -1) {
181
- document.dispatchEvent(
182
- new CustomEvent('notify', {
183
- detail: {
184
- type: 'error',
185
- message: `invalid value - ${after}`
186
- }
187
- })
188
- )
189
- return false
182
+ return await OxPrompt.open({
183
+ title: '잘못된 이메일 포맷',
184
+ text: '그래도 변경하시겠습니까?',
185
+ cancelButton: { text: 'No' },
186
+ confirmButton: { text: 'Yes' }
187
+ })
190
188
  }
189
+
191
190
  return true
192
- } as ValidationCallback
191
+ }) as ValidationCallback
193
192
  },
194
193
  {
195
194
  type: 'boolean',
@@ -23,6 +23,7 @@ import {
23
23
  PersonalGristPreference,
24
24
  ValidationCallback
25
25
  } from '../src/types.js'
26
+ import { OxPrompt } from '@operato/popup'
26
27
 
27
28
  const fetchHandler: FetchHandler = async ({ page, limit }) => {
28
29
  var total = 120993
@@ -181,20 +182,17 @@ const config = {
181
182
  filter: 'search',
182
183
  sortable: true,
183
184
  width: 130,
184
- validation: function (after, before, record, column) {
185
+ validation: (async (after, before, record, column) => {
185
186
  if (after.indexOf('@') == -1) {
186
- document.dispatchEvent(
187
- new CustomEvent('notify', {
188
- detail: {
189
- type: 'error',
190
- message: `invalid value - ${after}`
191
- }
192
- })
193
- )
194
- return false
187
+ return await OxPrompt.open({
188
+ title: '잘못된 이메일 포맷',
189
+ text: '그래도 변경하시겠습니까?',
190
+ cancelButton: { text: 'No' },
191
+ confirmButton: { text: 'Yes' }
192
+ })
195
193
  }
196
194
  return true
197
- } as ValidationCallback
195
+ }) as ValidationCallback
198
196
  },
199
197
  {
200
198
  type: 'boolean',
@@ -17,6 +17,7 @@ import {
17
17
  GristRecord,
18
18
  ValidationCallback
19
19
  } from '../src/types.js'
20
+ import { OxPrompt } from '@operato/popup'
20
21
 
21
22
  const fetchHandler: FetchHandler = async ({ page, limit }) => {
22
23
  var total = 120993
@@ -175,20 +176,17 @@ const config = {
175
176
  filter: 'search',
176
177
  sortable: true,
177
178
  width: 130,
178
- validation: function (after, before, record, column) {
179
+ validation: (async (after, before, record, column) => {
179
180
  if (after.indexOf('@') == -1) {
180
- document.dispatchEvent(
181
- new CustomEvent('notify', {
182
- detail: {
183
- type: 'error',
184
- message: `invalid value - ${after}`
185
- }
186
- })
187
- )
188
- return false
181
+ return await OxPrompt.open({
182
+ title: '잘못된 이메일 포맷',
183
+ text: '그래도 변경하시겠습니까?',
184
+ cancelButton: { text: 'No' },
185
+ confirmButton: { text: 'Yes' }
186
+ })
189
187
  }
190
188
  return true
191
- } as ValidationCallback
189
+ }) as ValidationCallback
192
190
  },
193
191
  {
194
192
  type: 'boolean',
@@ -17,6 +17,7 @@ import {
17
17
  GristRecord,
18
18
  ValidationCallback
19
19
  } from '../src/types.js'
20
+ import { OxPrompt } from '@operato/popup'
20
21
 
21
22
  const fetchHandler: FetchHandler = async ({ page, limit }) => {
22
23
  var total = 120993
@@ -186,20 +187,17 @@ const config = {
186
187
  filter: 'search',
187
188
  sortable: true,
188
189
  width: 130,
189
- validation: function (after, before, record, column) {
190
+ validation: (async (after, before, record, column) => {
190
191
  if (after.indexOf('@') == -1) {
191
- document.dispatchEvent(
192
- new CustomEvent('notify', {
193
- detail: {
194
- type: 'error',
195
- message: `invalid value - ${after}`
196
- }
197
- })
198
- )
199
- return false
192
+ return await OxPrompt.open({
193
+ title: '잘못된 이메일 포맷',
194
+ text: '그래도 변경하시겠습니까?',
195
+ cancelButton: { text: 'No' },
196
+ confirmButton: { text: 'Yes' }
197
+ })
200
198
  }
201
199
  return true
202
- } as ValidationCallback
200
+ }) as ValidationCallback
203
201
  },
204
202
  {
205
203
  type: 'boolean',