Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions src/cloud/components/ContentManager/ContentManagerToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,18 +292,10 @@ const ContentManagerToolbar = ({

const docProp = props[key] as FilledSerializedPropData
switch (docProp.type) {
case 'json':
if (docProp.data.dataType === 'timeperiod') {
values[key] = {
type: docProp.type,
subType: 'timeperiod',
value: docProp.data.data,
}
}
break
case 'user':
values[key] = {
type: docProp.type,
subType: docProp.subType,
value:
docProp.data == null
? []
Expand All @@ -315,6 +307,7 @@ const ContentManagerToolbar = ({
case 'status':
values[key] = {
type: docProp.type,
subType: docProp.subType,
value:
docProp.data == null
? undefined
Expand All @@ -328,6 +321,7 @@ const ContentManagerToolbar = ({
case 'string':
values[key] = {
type: docProp.type,
subType: docProp.subType,
value: docProp.data,
}
break
Expand Down Expand Up @@ -366,14 +360,6 @@ const ContentManagerToolbar = ({

const docProp = props[key] as FilledSerializedPropData
switch (docProp.type) {
case 'json':
if (
docProp.data.dataType !== 'timeperiod' ||
docProp.data.data !== values[key]['value']
) {
delete values[key]
}
break
case 'user':
{
let newUserArray = values[key].value.slice() as string[]
Expand All @@ -391,11 +377,9 @@ const ContentManagerToolbar = ({
case 'status':
{
const docPropStatus: SerializedStatus | undefined =
props[key] == null
? undefined
: Array.isArray(props[key].data)
? props[key].data[0]
: props[key].data
docProp[key] == Array.isArray(docProp[key].data)
? docProp[key].data[0]
: docProp[key].data
if (
docPropStatus == null ||
docPropStatus.id !== values[key].value.id
Expand Down Expand Up @@ -595,8 +579,9 @@ const ContentManagerToolbar = ({
updateProp([
propColumn.name,
{
type: 'json',
data: { dataType: 'timeperiod', data: val },
type: 'number',
subType: 'timeperiod',
data: val,
},
])
}}
Expand Down
2 changes: 2 additions & 0 deletions src/cloud/components/DocPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ColoredBlock from '../../../design/components/atoms/ColoredBlock'
import Editor from '../Editor'
import ApplicationPage from '../ApplicationPage'
import { freePlanDocLimit, freePlanMembersLimit } from '../../lib/subscription'
import { useCloudDocPreview } from '../../lib/hooks/useCloudDocPreview'

interface DocPageProps {
doc: SerializedDocWithSupplemental
Expand Down Expand Up @@ -74,6 +75,7 @@ const DocPage = ({
}, [currentDoc, team])

useTitle(pageTitle)
useCloudDocPreview(team)

useEffect(() => {
if (currentDoc == null) {
Expand Down
10 changes: 4 additions & 6 deletions src/cloud/components/DocProperties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,9 @@ const DocProperties = ({
</div>
{docProperties.map((prop, i) => {
const iconPath = getIconPathOfPropType(
prop[1].data.type === 'json' &&
prop[1].data.data != null &&
prop[1].data.data.dataType != null
? prop[1].data.data.dataType
: prop[1].data.type
prop[1].data.subType || prop[1].data.type
)

return (
<div className='doc-props__property' key={`prop-${i}`}>
<Button
Expand All @@ -108,7 +105,8 @@ const DocProperties = ({
onUpdate={(prop, updated) => {
if (
prop.name !== updated.name ||
prop.data.type !== updated.data.type
prop.data.type !== updated.data.type ||
prop.data.subType !== updated.data.subType
) {
modifyProp(prop.name, updated.name, updated.data)
}
Expand Down
26 changes: 14 additions & 12 deletions src/cloud/components/Modal/contents/SmartView/ConditionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ const ConditionItem = ({
onChange: (selectedOption: { label: any; value: string }) => {
update(
getDefaultConditionByType(
selectedOption.value,
condition.rule
selectedOption.value.split('/')[0],
condition.rule,
selectedOption.value.split('/')[1] || undefined
)
)
},
Expand Down Expand Up @@ -152,8 +153,8 @@ function inferConditionPrimaryType(t: TFunction, condition: EditableCondition) {
value: supportedCustomPropertyTypes['status'].value,
}
break
case 'json':
switch (condition.value.value.type) {
case 'number':
switch (condition.value.subType) {
case 'timeperiod':
return {
label: (
Expand All @@ -167,7 +168,6 @@ function inferConditionPrimaryType(t: TFunction, condition: EditableCondition) {
default:
break
}

//unsupported
case 'number':
default:
Expand All @@ -180,7 +180,8 @@ function inferConditionPrimaryType(t: TFunction, condition: EditableCondition) {

function getDefaultConditionByType(
type: string,
rule: 'and' | 'or'
rule: 'and' | 'or',
subType?: string
): EditableCondition {
switch (type) {
case 'date': {
Expand All @@ -193,6 +194,7 @@ function getDefaultConditionByType(
type: 'relative',
period: 0,
},
subType,
type: 'date',
},
}
Expand All @@ -205,19 +207,18 @@ function getDefaultConditionByType(
name: '',
value: [],
type: 'user',
subType,
},
}
case 'json':
case 'number':
return {
rule,
type: 'prop',
value: {
name: '',
value: {
type: 'timeperiod',
value: 0,
},
type: 'json',
value: 0,
type: 'number',
subType,
},
}
case 'status':
Expand All @@ -228,6 +229,7 @@ function getDefaultConditionByType(
name: '',
value: -1,
type: 'status',
subType,
},
}
case 'label':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const PropConditionValueControl = ({
}
/>
)}
{condition.type === 'number' && (
{condition.type === 'number' && condition.subType == null && (
<FormInput
type='number'
value={condition.value.toString()}
Expand All @@ -227,17 +227,15 @@ const PropConditionValueControl = ({
}
/>
)}
{condition.type === 'json' && condition.value.type === 'timeperiod' && (
{condition.type === 'number' && condition.subType === 'timeperiod' && (
<TimePeriodForm
disabled={
condition.name.trim() === '' ||
sendingMap.get('properties') === 'suggestions'
}
period={condition.value.value}
period={condition.value}
updatePeriod={(period) => {
updateValue({
value: { type: 'timeperiod', value: period },
})
updateValue({ value: period })
}}
/>
)}
Expand Down
Loading