@mixd-id/web-scaffold 0.1.240411071 → 0.1.240411073

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.240411071",
4
+ "version": "0.1.240411073",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -94,7 +94,7 @@
94
94
  clearable="1"
95
95
  maxlength="100"
96
96
  v-model="preset.search"
97
- @clear="delete preset.search; load()"
97
+ @clear="clearSearch"
98
98
  @keyup.enter="load">
99
99
  <template #start>
100
100
  <div class="p-2 pr-0">
@@ -355,6 +355,21 @@ export default{
355
355
 
356
356
  },
357
357
 
358
+ clearSearch(){
359
+ delete this.preset.search;
360
+
361
+ if('search' in this.$route.query){
362
+ const query = { ...this.$route.query }
363
+ delete query.search
364
+ this.$router.push({
365
+ ...this.$route,
366
+ query
367
+ })
368
+ }
369
+
370
+ this.load()
371
+ },
372
+
358
373
  getEnumText(key, value){
359
374
 
360
375
  let enumText
@@ -1292,16 +1292,22 @@ const filtersToSequelizeInclude = async(filters, opt, includes) => {
1292
1292
  return includes
1293
1293
  }
1294
1294
 
1295
- const syntaxSearchToSequelizeOpt = async(search, opt) => {
1295
+ const syntaxSearchToSequelizeOpt = async(search, opt = {}) => {
1296
1296
 
1297
1297
  let where = {}
1298
1298
  let replacements = []
1299
1299
 
1300
- const { config } = opt
1300
+ const { config = {} } = opt
1301
+ const { columns } = config
1301
1302
 
1302
1303
  let syntaxKey = search[1]
1303
1304
  let syntaxVal = search[2].trim()
1304
1305
 
1306
+ const keyExists = (columns ?? []).find(_ => _.key === syntaxKey)
1307
+ if(keyExists){
1308
+ where[syntaxKey] = syntaxVal
1309
+ }
1310
+
1305
1311
  return {
1306
1312
  where,
1307
1313
  replacements
@@ -1363,7 +1369,7 @@ const presetToSequelizeList = async(preset, {
1363
1369
  if(search){
1364
1370
  const syntaxSearch = (search ?? '').match(/^(\w+)\:(.*)/)
1365
1371
  if(syntaxSearch !== null){
1366
- const syntaxSearchOpt = syntaxSearchToSequelizeOpt(syntaxSearch, { config })
1372
+ const syntaxSearchOpt = await syntaxSearchToSequelizeOpt(syntaxSearch, { config })
1367
1373
  searchWhere = syntaxSearchOpt.where
1368
1374
  searchReplacements = syntaxSearchOpt.replacements
1369
1375
  }