|
|
@ -37,7 +37,7 @@ import { UITypes, SelectOptionsType } from 'nocodb-sdk'; |
|
|
|
const removeEqualFilters = async (filter, actions: any[], ncMeta) => { |
|
|
|
const removeEqualFilters = async (filter, actions: any[], ncMeta) => { |
|
|
|
// remove `is equal`, `is not equal`
|
|
|
|
// remove `is equal`, `is not equal`
|
|
|
|
if (['eq', 'neq'].includes(filter.comparison_op)) { |
|
|
|
if (['eq', 'neq'].includes(filter.comparison_op)) { |
|
|
|
actions.push(await Filter.delete(filter.id, ncMeta)); |
|
|
|
actions.push(Filter.delete(filter.id, ncMeta)); |
|
|
|
} |
|
|
|
} |
|
|
|
return actions; |
|
|
|
return actions; |
|
|
|
}; |
|
|
|
}; |
|
|
@ -45,7 +45,7 @@ const removeEqualFilters = async (filter, actions: any[], ncMeta) => { |
|
|
|
const removeArithmeticFilters = async (filter, actions: any[], ncMeta) => { |
|
|
|
const removeArithmeticFilters = async (filter, actions: any[], ncMeta) => { |
|
|
|
// remove `>`, `<`, `>=`, `<=`
|
|
|
|
// remove `>`, `<`, `>=`, `<=`
|
|
|
|
if (['gt', 'lt', 'gte', 'lte'].includes(filter.comparison_op)) { |
|
|
|
if (['gt', 'lt', 'gte', 'lte'].includes(filter.comparison_op)) { |
|
|
|
actions.push(await Filter.delete(filter.id, ncMeta)); |
|
|
|
actions.push(Filter.delete(filter.id, ncMeta)); |
|
|
|
} |
|
|
|
} |
|
|
|
return actions; |
|
|
|
return actions; |
|
|
|
}; |
|
|
|
}; |
|
|
@ -53,7 +53,7 @@ const removeArithmeticFilters = async (filter, actions: any[], ncMeta) => { |
|
|
|
const removeLikeFilters = async (filter, actions: any[], ncMeta) => { |
|
|
|
const removeLikeFilters = async (filter, actions: any[], ncMeta) => { |
|
|
|
// remove `is like`, `is not like`
|
|
|
|
// remove `is like`, `is not like`
|
|
|
|
if (['like', 'nlike'].includes(filter.comparison_op)) { |
|
|
|
if (['like', 'nlike'].includes(filter.comparison_op)) { |
|
|
|
actions.push(await Filter.delete(filter.id, ncMeta)); |
|
|
|
actions.push(Filter.delete(filter.id, ncMeta)); |
|
|
|
} |
|
|
|
} |
|
|
|
return actions; |
|
|
|
return actions; |
|
|
|
}; |
|
|
|
}; |
|
|
@ -66,7 +66,7 @@ const migrateNullAndEmptyToBlankFilters = async ( |
|
|
|
if (['empty', 'null'].includes(filter.comparison_op)) { |
|
|
|
if (['empty', 'null'].includes(filter.comparison_op)) { |
|
|
|
// migrate to blank
|
|
|
|
// migrate to blank
|
|
|
|
actions.push( |
|
|
|
actions.push( |
|
|
|
await Filter.update( |
|
|
|
Filter.update( |
|
|
|
filter.id, |
|
|
|
filter.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
comparison_op: 'blank', |
|
|
|
comparison_op: 'blank', |
|
|
@ -77,7 +77,7 @@ const migrateNullAndEmptyToBlankFilters = async ( |
|
|
|
} else if (['notempty', 'notnull'].includes(filter.comparison_op)) { |
|
|
|
} else if (['notempty', 'notnull'].includes(filter.comparison_op)) { |
|
|
|
// migrate to not blank
|
|
|
|
// migrate to not blank
|
|
|
|
actions.push( |
|
|
|
actions.push( |
|
|
|
await Filter.update( |
|
|
|
Filter.update( |
|
|
|
filter.id, |
|
|
|
filter.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
comparison_op: 'notblank', |
|
|
|
comparison_op: 'notblank', |
|
|
@ -99,7 +99,7 @@ const migrateMultiSelectEq = async ( |
|
|
|
if (!['eq', 'neq'].includes(filter.comparison_op)) return actions; |
|
|
|
if (!['eq', 'neq'].includes(filter.comparison_op)) return actions; |
|
|
|
// if there is no value -> delete this filter
|
|
|
|
// if there is no value -> delete this filter
|
|
|
|
if (!filter.value) { |
|
|
|
if (!filter.value) { |
|
|
|
actions.push(await Filter.delete(filter.id, ncMeta)); |
|
|
|
actions.push(Filter.delete(filter.id, ncMeta)); |
|
|
|
return actions; |
|
|
|
return actions; |
|
|
|
} |
|
|
|
} |
|
|
|
// options inputted from users
|
|
|
|
// options inputted from users
|
|
|
@ -116,13 +116,13 @@ const migrateMultiSelectEq = async ( |
|
|
|
const newFilterValue = validOptions.join(','); |
|
|
|
const newFilterValue = validOptions.join(','); |
|
|
|
// if all inputted options are invalid -> delete this filter
|
|
|
|
// if all inputted options are invalid -> delete this filter
|
|
|
|
if (!newFilterValue) { |
|
|
|
if (!newFilterValue) { |
|
|
|
actions.push(await Filter.delete(filter.id, ncMeta)); |
|
|
|
actions.push(Filter.delete(filter.id, ncMeta)); |
|
|
|
return actions; |
|
|
|
return actions; |
|
|
|
} |
|
|
|
} |
|
|
|
if (filter.comparison_op === 'eq') { |
|
|
|
if (filter.comparison_op === 'eq') { |
|
|
|
// migrate to `contains all of`
|
|
|
|
// migrate to `contains all of`
|
|
|
|
actions.push( |
|
|
|
actions.push( |
|
|
|
await Filter.update( |
|
|
|
Filter.update( |
|
|
|
filter.id, |
|
|
|
filter.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
comparison_op: 'anyof', |
|
|
|
comparison_op: 'anyof', |
|
|
@ -134,7 +134,7 @@ const migrateMultiSelectEq = async ( |
|
|
|
} else if (filter.comparison_op === 'neq') { |
|
|
|
} else if (filter.comparison_op === 'neq') { |
|
|
|
// migrate to `doesn't contain all of`
|
|
|
|
// migrate to `doesn't contain all of`
|
|
|
|
actions.push( |
|
|
|
actions.push( |
|
|
|
await Filter.update( |
|
|
|
Filter.update( |
|
|
|
filter.id, |
|
|
|
filter.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
comparison_op: 'nanyof', |
|
|
|
comparison_op: 'nanyof', |
|
|
@ -151,7 +151,7 @@ const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => { |
|
|
|
if (['empty', 'null'].includes(filter.comparison_op)) { |
|
|
|
if (['empty', 'null'].includes(filter.comparison_op)) { |
|
|
|
// migrate to not checked
|
|
|
|
// migrate to not checked
|
|
|
|
actions.push( |
|
|
|
actions.push( |
|
|
|
await Filter.update( |
|
|
|
Filter.update( |
|
|
|
filter.id, |
|
|
|
filter.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
comparison_op: 'notchecked', |
|
|
|
comparison_op: 'notchecked', |
|
|
@ -162,7 +162,7 @@ const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => { |
|
|
|
} else if (['notempty', 'notnull'].includes(filter.comparison_op)) { |
|
|
|
} else if (['notempty', 'notnull'].includes(filter.comparison_op)) { |
|
|
|
// migrate to checked
|
|
|
|
// migrate to checked
|
|
|
|
actions.push( |
|
|
|
actions.push( |
|
|
|
await Filter.update( |
|
|
|
Filter.update( |
|
|
|
filter.id, |
|
|
|
filter.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
comparison_op: 'checked', |
|
|
|
comparison_op: 'checked', |
|
|
@ -174,7 +174,7 @@ const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => { |
|
|
|
if (['true', 'True', '1', 'T', 'Y'].includes(filter.value)) { |
|
|
|
if (['true', 'True', '1', 'T', 'Y'].includes(filter.value)) { |
|
|
|
// migrate to checked
|
|
|
|
// migrate to checked
|
|
|
|
actions.push( |
|
|
|
actions.push( |
|
|
|
await Filter.update( |
|
|
|
Filter.update( |
|
|
|
filter.id, |
|
|
|
filter.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
comparison_op: 'checked', |
|
|
|
comparison_op: 'checked', |
|
|
@ -186,7 +186,7 @@ const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => { |
|
|
|
} else if (['false', 'False', '0', 'F', 'N'].includes(filter.value)) { |
|
|
|
} else if (['false', 'False', '0', 'F', 'N'].includes(filter.value)) { |
|
|
|
// migrate to notchecked
|
|
|
|
// migrate to notchecked
|
|
|
|
actions.push( |
|
|
|
actions.push( |
|
|
|
await Filter.update( |
|
|
|
Filter.update( |
|
|
|
filter.id, |
|
|
|
filter.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
comparison_op: 'notchecked', |
|
|
|
comparison_op: 'notchecked', |
|
|
@ -197,13 +197,13 @@ const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => { |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// invalid value - good to delete
|
|
|
|
// invalid value - good to delete
|
|
|
|
actions.push(await Filter.delete(filter.id, ncMeta)); |
|
|
|
actions.push(Filter.delete(filter.id, ncMeta)); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (filter.comparison_op === 'neq') { |
|
|
|
} else if (filter.comparison_op === 'neq') { |
|
|
|
if (['false', 'False', '0', 'F', 'N'].includes(filter.value)) { |
|
|
|
if (['false', 'False', '0', 'F', 'N'].includes(filter.value)) { |
|
|
|
// migrate to checked
|
|
|
|
// migrate to checked
|
|
|
|
actions.push( |
|
|
|
actions.push( |
|
|
|
await Filter.update( |
|
|
|
Filter.update( |
|
|
|
filter.id, |
|
|
|
filter.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
comparison_op: 'checked', |
|
|
|
comparison_op: 'checked', |
|
|
@ -215,7 +215,7 @@ const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => { |
|
|
|
} else if (['true', 'True', '1', 'T', 'Y'].includes(filter.value)) { |
|
|
|
} else if (['true', 'True', '1', 'T', 'Y'].includes(filter.value)) { |
|
|
|
// migrate to not checked
|
|
|
|
// migrate to not checked
|
|
|
|
actions.push( |
|
|
|
actions.push( |
|
|
|
await Filter.update( |
|
|
|
Filter.update( |
|
|
|
filter.id, |
|
|
|
filter.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
comparison_op: 'notchecked', |
|
|
|
comparison_op: 'notchecked', |
|
|
@ -226,7 +226,7 @@ const migrateToCheckboxFilter = async (filter, actions: any[], ncMeta) => { |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// invalid value - good to delete
|
|
|
|
// invalid value - good to delete
|
|
|
|
actions.push(await Filter.delete(filter.id, ncMeta)); |
|
|
|
actions.push(Filter.delete(filter.id, ncMeta)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return actions; |
|
|
|
return actions; |
|
|
@ -346,7 +346,7 @@ async function updateProjectMeta(ncMeta: NcMetaIO) { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
actions.push( |
|
|
|
actions.push( |
|
|
|
await Project.update( |
|
|
|
Project.update( |
|
|
|
project.id, |
|
|
|
project.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
meta: JSON.stringify(newProjectMeta), |
|
|
|
meta: JSON.stringify(newProjectMeta), |
|
|
|