Skip to content

Commit

Permalink
fix publication with options
Browse files Browse the repository at this point in the history
  • Loading branch information
lexoyo committed Dec 22, 2023
1 parent 6a9e602 commit 2d1cfe8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"lit-html": "3.0.2"
},
"dependencies": {
"@silexlabs/grapesjs-data-source": "^0.0.47",
"@silexlabs/grapesjs-data-source": "^0.0.49",
"dedent": "^1.5.1",
"deepmerge": "^4.3.1"
},
Expand Down
2 changes: 2 additions & 0 deletions src/liquid.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const expressionWithFirst = {
'type': 'filter',
'id': 'first',
'label': 'first',
'quotedOptions': [],
'options': {}
},
{
Expand Down Expand Up @@ -172,6 +173,7 @@ export const expressionListWithWhere = {
'type': 'filter',
'id': 'where',
'label': 'where',
'quotedOptions': [],
'options': {
'key': 'lang',
'value': 'FR'
Expand Down
30 changes: 1 addition & 29 deletions src/liquid.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Expression, FIXED_TOKEN_ID, Filter, Property, State, StateId, Token, getPersistantId, getStateVariableName, DataTree, BinariOperator, UnariOperator } from '@silexlabs/grapesjs-data-source'
import { Expression, FIXED_TOKEN_ID, Filter, Property, State, StateId, Token, getPersistantId, getStateVariableName, DataTree, BinariOperator, UnariOperator, isExpression } from '@silexlabs/grapesjs-data-source'
import { Component } from 'grapesjs'

export interface BinaryCondition {
Expand Down Expand Up @@ -245,34 +245,6 @@ function quote(value: string): string {
return `"${value.replace(/"/g, '\\"')}"`
}

function isExpression(json: unknown): boolean {
if(!Array.isArray(json)) return false
return json.every(token => {
if(typeof token !== 'object') return false
if(!token.type) return false
switch(token.type) {
case 'property': {
if(!token.fieldId) return false
if(token.fieldId === FIXED_TOKEN_ID) {
if(!token.options?.value) return false
}
break
}
case 'state': {
if(!token.componentId) return false
if(!token.storedStateId) return false
break
}
case 'filter': {
if(!token.id) return false
break
}
}
return true
})

}

function handleFilterOption(filter: Filter, key: string, value: string): string {
try {
const json = JSON.parse(value)
Expand Down

0 comments on commit 2d1cfe8

Please sign in to comment.