Skip to content

Commit

Permalink
fix(editors): invalid date should trigger onvalidationerror (#19)
Browse files Browse the repository at this point in the history
* fix(editors): invalid date should trigger onvalidationerror
- when passing a custom validator & making the date invalid, it should trigger the onValidationError event but it wasn't, that was because we need to call the commitCurrentEdit() or commitChanges() for it to trigger
  • Loading branch information
ghiscoding authored Jul 20, 2020
1 parent efa4908 commit 041087e
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 54 deletions.
10 changes: 5 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"userDataDir": "${workspaceRoot}/.chrome",
"trace": true,
"sourceMapPathOverrides": {
"webpack:///../common/*": "${webRoot}/packages/common/*",
"webpack:///../excel-export/*": "${webRoot}/packages/excel-export/*",
"webpack:///../file-export/*": "${webRoot}/packages/file-export/*",
"webpack:///../vanilla-bundle/*": "${webRoot}/packages/vanilla-bundle/*",
"webpack:///../../common/*": "${webRoot}/packages/common/*",
"webpack:///../../excel-export/*": "${webRoot}/packages/excel-export/*",
"webpack:///../../file-export/*": "${webRoot}/packages/file-export/*",
"webpack:///../../vanilla-bundle/*": "${webRoot}/packages/vanilla-bundle/*",
"webpack:///./src/*": "${webRoot}/examples/web-demo-vanilla-bundle/src/*"
}
},
Expand All @@ -36,7 +36,7 @@
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions examples/web-demo-vanilla-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@types/jquery": "^3.5.0",
"@types/moment": "^2.13.0",
"@types/node": "^14.0.19",
"@types/node": "^14.0.23",
"@types/webpack": "^4.41.21",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^6.0.3",
Expand All @@ -49,7 +49,7 @@
"node-sass": "4.14.1",
"sass-loader": "^9.0.2",
"style-loader": "^1.2.1",
"ts-loader": "^7.0.5",
"ts-loader": "^8.0.1",
"ts-node": "^8.10.2",
"url-loader": "^4.1.0",
"webpack": "^4.43.0",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
"jest-environment-jsdom": "^26.1.0",
"jest-extended": "^0.11.5",
"jest-junit": "^11.0.1",
"jsdom": "^16.2.2",
"jsdom": "^16.3.0",
"jsdom-global": "^3.0.2",
"lerna": "^3.22.1",
"mocha": "^8.0.1",
"mochawesome": "^6.1.1",
"ts-jest": "^26.1.1",
"ts-jest": "^26.1.3",
"typescript": "^3.9.7"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"dependencies": {
"dompurify": "^2.0.12",
"flatpickr": "^4.6.3",
"jquery": "^3.4.1",
"jquery": "~3.4.1",
"jquery-ui-dist": "^1.12.1",
"lodash.isequal": "^4.5.0",
"moment-mini": "^2.24.0",
Expand All @@ -69,7 +69,7 @@
"@types/dompurify": "^2.0.2",
"@types/jquery": "^3.5.0",
"@types/moment": "^2.13.0",
"autoprefixer": "^9.8.4",
"autoprefixer": "^9.8.5",
"copyfiles": "^2.3.0",
"cross-env": "^7.0.2",
"mini-css-extract-plugin": "^0.9.0",
Expand Down
15 changes: 8 additions & 7 deletions packages/common/src/editors/dateEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ export class DateEditor implements Editor {
return false;
}

return (!(elmDateStr === '' && orgDateStr === '')) && (elmDateStr !== orgDateStr);
const isChanged = (!(elmDateStr === '' && orgDateStr === '')) && (elmDateStr !== orgDateStr);
return isChanged;
}

loadValue(item: any) {
Expand All @@ -224,12 +225,12 @@ export class DateEditor implements Editor {
save() {
// autocommit will not focus the next editor
const validation = this.validate();
if (validation && validation.valid && this.isValueChanged()) {
if (this.hasAutoCommitEdit) {
this.grid.getEditorLock().commitCurrentEdit();
} else {
this.args.commitChanges();
}
const isValid = (validation && validation.valid) || false;

if (this.hasAutoCommitEdit && isValid) {
this.grid.getEditorLock().commitCurrentEdit();
} else {
this.args.commitChanges();
}
}

Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/vanilla-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
},
"devDependencies": {
"@types/webpack": "^4.41.21",
"archiver": "^4.0.1",
"archiver": "^4.0.2",
"cross-env": "^7.0.2",
"dts-bundle-webpack": "^1.0.2",
"html-loader": "^1.1.0",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"ts-loader": "^7.0.5",
"ts-loader": "^8.0.1",
"webpack": "^4.43.0"
}
}
110 changes: 76 additions & 34 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.19.tgz#994d99708822bca643a2364f8aeed04a16e0f5a1"
integrity sha512-yf3BP/NIXF37BjrK5klu//asUWitOEoUP5xE1mhSUjazotwJ/eJDgEmMQNlOeWOVv72j24QQ+3bqXHE++CFGag==

"@types/node@^14.0.23":
version "14.0.23"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.23.tgz#676fa0883450ed9da0bb24156213636290892806"
integrity sha512-Z4U8yDAl5TFkmYsZdFPdjeMa57NOvnaf1tljHzhouaPEp7LCj2JKkejpI1ODviIAQuW4CcQmxkQ77rnLsOOoKw==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
Expand Down Expand Up @@ -2254,13 +2259,13 @@ archiver-utils@^2.1.0:
normalize-path "^3.0.0"
readable-stream "^2.0.0"

archiver@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/archiver/-/archiver-4.0.1.tgz#3f722b121777e361ca9fad374ecda38e77e63c7f"
integrity sha512-/YV1pU4Nhpf/rJArM23W6GTUjT0l++VbjykrCRua1TSXrn+yM8Qs7XvtwSiRse0iCe49EPNf7ktXnPsWuSb91Q==
archiver@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/archiver/-/archiver-4.0.2.tgz#43c72865eadb4ddaaa2fb74852527b6a450d927c"
integrity sha512-B9IZjlGwaxF33UN4oPbfBkyA4V1SxNLeIhR1qY8sRXSsbdUkEHrrOvwlYFPx+8uQeCe9M+FG6KgO+imDmQ79CQ==
dependencies:
archiver-utils "^2.1.0"
async "^2.6.3"
async "^3.2.0"
buffer-crc32 "^0.2.1"
glob "^7.1.6"
readable-stream "^3.6.0"
Expand Down Expand Up @@ -2440,7 +2445,7 @@ async-limiter@~1.0.0:
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd"
integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==

async@^2.6.2, async@^2.6.3:
async@^2.6.2:
version "2.6.3"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff"
integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==
Expand Down Expand Up @@ -2472,13 +2477,13 @@ atob@^2.1.2:
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==

autoprefixer@^9.8.4:
version "9.8.4"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.8.4.tgz#736f1012673a70fa3464671d78d41abd54512863"
integrity sha512-84aYfXlpUe45lvmS+HoAWKCkirI/sw4JK0/bTeeqgHYco3dcsOn0NqdejISjptsYwNji/21dnkDri9PsYKk89A==
autoprefixer@^9.8.5:
version "9.8.5"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.8.5.tgz#2c225de229ddafe1d1424c02791d0c3e10ccccaa"
integrity sha512-C2p5KkumJlsTHoNv9w31NrBRgXhf6eCMteJuHZi2xhkgC+5Vm40MEtCKPhc0qdgAOhox0YPy1SQHTAky05UoKg==
dependencies:
browserslist "^4.12.0"
caniuse-lite "^1.0.30001087"
caniuse-lite "^1.0.30001097"
colorette "^1.2.0"
normalize-range "^0.1.2"
num2fraction "^1.2.2"
Expand Down Expand Up @@ -3056,10 +3061,10 @@ caniuse-lite@^1.0.30001043:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001066.tgz#0a8a58a10108f2b9bf38e7b65c237b12fd9c5f04"
integrity sha512-Gfj/WAastBtfxLws0RCh2sDbTK/8rJuSeZMecrSkNGYxPcv7EzblmDGfWQCFEQcSqYE2BRgQiJh8HOD07N5hIw==

caniuse-lite@^1.0.30001087:
version "1.0.30001094"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001094.tgz#0b11d02e1cdc201348dbd8e3e57bd9b6ce82b175"
integrity sha512-ufHZNtMaDEuRBpTbqD93tIQnngmJ+oBknjvr0IbFympSdtFpAUFmNv4mVKbb53qltxFx0nK3iy32S9AqkLzUNA==
caniuse-lite@^1.0.30001097:
version "1.0.30001104"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001104.tgz#4e3d5b3b1dd3c3529f10cb7f519c62ba3e579f5d"
integrity sha512-pkpCg7dmI/a7WcqM2yfdOiT4Xx5tzyoHAXWsX5/HxZ3TemwDZs0QXdqbE0UPLPVy/7BeK7693YfzfRYfu1YVpg==

capture-exit@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -7295,7 +7300,7 @@ jest-snapshot@^26.1.0:
pretty-format "^26.1.0"
semver "^7.3.2"

jest-util@^26.1.0:
jest-util@26.x, jest-util@^26.1.0:
version "26.1.0"
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.1.0.tgz#80e85d4ba820decacf41a691c2042d5276e5d8d8"
integrity sha512-rNMOwFQevljfNGvbzNQAxdmXQ+NawW/J72dmddsK0E8vgxXCMtwQ/EH0BiWEIxh0hhMcTsxwAxINt7Lh46Uzbg==
Expand Down Expand Up @@ -7357,7 +7362,7 @@ jquery-ui@>=1.8.0:
resolved "https://registry.yarnpkg.com/jquery-ui/-/jquery-ui-1.12.1.tgz#bcb4045c8dd0539c134bc1488cdd3e768a7a9e51"
integrity sha1-vLQEXI3QU5wTS8FIjN0+dop6nlE=

jquery@>=1.8.0, jquery@^3.4.1:
jquery@>=1.8.0, jquery@^3.4.1, jquery@~3.4.1:
version "3.4.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2"
integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==
Expand Down Expand Up @@ -7422,6 +7427,38 @@ jsdom@^16.2.2:
ws "^7.2.3"
xml-name-validator "^3.0.0"

jsdom@^16.3.0:
version "16.3.0"
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.3.0.tgz#75690b7dac36c67be49c336dcd7219bbbed0810c"
integrity sha512-zggeX5UuEknpdZzv15+MS1dPYG0J/TftiiNunOeNxSl3qr8Z6cIlQpN0IdJa44z9aFxZRIVqRncvEhQ7X5DtZg==
dependencies:
abab "^2.0.3"
acorn "^7.1.1"
acorn-globals "^6.0.0"
cssom "^0.4.4"
cssstyle "^2.2.0"
data-urls "^2.0.0"
decimal.js "^10.2.0"
domexception "^2.0.1"
escodegen "^1.14.1"
html-encoding-sniffer "^2.0.1"
is-potential-custom-element-name "^1.0.0"
nwsapi "^2.2.0"
parse5 "5.1.1"
request "^2.88.2"
request-promise-native "^1.0.8"
saxes "^5.0.0"
symbol-tree "^3.2.4"
tough-cookie "^3.0.1"
w3c-hr-time "^1.0.2"
w3c-xmlserializer "^2.0.0"
webidl-conversions "^6.1.0"
whatwg-encoding "^1.0.5"
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"
ws "^7.2.3"
xml-name-validator "^3.0.0"

jsesc@^2.5.1:
version "2.5.2"
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4"
Expand Down Expand Up @@ -8166,14 +8203,6 @@ methods@~1.1.2:
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=

[email protected], micromatch@^4.0.0, micromatch@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==
dependencies:
braces "^3.0.1"
picomatch "^2.0.5"

micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4:
version "3.1.10"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
Expand All @@ -8193,6 +8222,14 @@ micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4:
snapdragon "^0.8.1"
to-regex "^3.0.2"

micromatch@^4.0.0, micromatch@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==
dependencies:
braces "^3.0.1"
picomatch "^2.0.5"

miller-rabin@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d"
Expand Down Expand Up @@ -11793,26 +11830,26 @@ trim-off-newlines@^1.0.0:
dependencies:
glob "^7.1.2"

ts-jest@^26.1.1:
version "26.1.1"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.1.1.tgz#b98569b8a4d4025d966b3d40c81986dd1c510f8d"
integrity sha512-Lk/357quLg5jJFyBQLnSbhycnB3FPe+e9i7ahxokyXxAYoB0q1pPmqxxRPYr4smJic1Rjcf7MXDBhZWgxlli0A==
ts-jest@^26.1.3:
version "26.1.3"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.1.3.tgz#aac928a05fdf13e3e6dfbc8caec3847442667894"
integrity sha512-beUTSvuqR9SmKQEylewqJdnXWMVGJRFqSz2M8wKJe7GBMmLZ5zw6XXKSJckbHNMxn+zdB3guN2eOucSw2gBMnw==
dependencies:
bs-logger "0.x"
buffer-from "1.x"
fast-json-stable-stringify "2.x"
jest-util "26.x"
json5 "2.x"
lodash.memoize "4.x"
make-error "1.x"
micromatch "4.x"
mkdirp "1.x"
semver "7.x"
yargs-parser "18.x"

ts-loader@^7.0.5:
version "7.0.5"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-7.0.5.tgz#789338fb01cb5dc0a33c54e50558b34a73c9c4c5"
integrity sha512-zXypEIT6k3oTc+OZNx/cqElrsbBtYqDknf48OZos0NQ3RTt045fBIU8RRSu+suObBzYB355aIPGOe/3kj9h7Ig==
ts-loader@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.0.1.tgz#9670dcbce2a8c8506d01a37fee042350d02c8c21"
integrity sha512-I9Nmly0ufJoZRMuAT9d5ijsC2B7oSPvUnOJt/GhgoATlPGYfa17VicDKPcqwUCrHpOkCxr/ybLYwbnS4cOxmvQ==
dependencies:
chalk "^2.3.0"
enhanced-resolve "^4.0.0"
Expand Down Expand Up @@ -12293,6 +12330,11 @@ webidl-conversions@^6.0.0:
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-6.0.0.tgz#ff41d921371f43e772dba311b146ab6c0ef0ead4"
integrity sha512-jTZAeJnc6D+yAOjygbJOs33kVQIk5H6fj9SFDOhIKjsf9HiAzL/c+tAJsc8ASWafvhNkH+wJZms47pmajkhatA==

webidl-conversions@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-6.1.0.tgz#9111b4d7ea80acd40f5270d666621afa78b69514"
integrity sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==

webpack-cli@^3.3.12:
version "3.3.12"
resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-3.3.12.tgz#94e9ada081453cd0aa609c99e500012fd3ad2d4a"
Expand Down

0 comments on commit 041087e

Please sign in to comment.