Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Saving update UI #390

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b6e21a5
trigger plugins map
Oct 30, 2023
6aa1c33
conflict experiment
dulguun0225 Oct 30, 2023
419293e
update
hitchikermn Oct 30, 2023
2f813c4
contract type field change
hitchikermn Oct 30, 2023
cacfc0f
ui table odd color
hitchikermn Oct 30, 2023
bfc8a4c
contract type update
hitchikermn Oct 30, 2023
43f53ef
update(payment): Added payment-name to the payments list (#4705)
Daarii Oct 30, 2023
a89efae
fix(inbox): refetch conversation when assign
Anu-Ujin Oct 30, 2023
25038c6
update(automations):add ability date config on trigger
Wlkr123 Oct 30, 2023
47ddfdb
Merge branch 'dev' of github.com:erxes/erxes into dev
Wlkr123 Oct 30, 2023
b76dde7
fix conversation tagger length
Anu-Ujin Oct 30, 2023
82f3d82
fix(automations):check length selectOptions in manageProperties action
Wlkr123 Oct 30, 2023
56bb40e
Merge branch 'dev' of github.com:erxes/erxes into dev
Wlkr123 Oct 30, 2023
75c087b
fix(internalnote): Internal note check disappear after conversation s…
Anu-Ujin Oct 30, 2023
9544464
Merge branch 'dev' of github.com:erxes/erxes into dev
Anu-Ujin Oct 30, 2023
b94f983
fix(automations):can't update complex field properties
Wlkr123 Oct 30, 2023
e8b8f6d
fix(automations):wait 10 second when work if branch action type
Wlkr123 Oct 30, 2023
3bfef5b
update(automations):add set option in number type operator
Wlkr123 Oct 30, 2023
cb6d9c0
Merge branch 'dev' of github.com:erxes/erxes into dev
Wlkr123 Oct 30, 2023
f692004
update
Oct 31, 2023
5d68e56
git pull upstream devMerge branch 'dev' of github.com:erxes/erxes-com…
munkhsaikhan Oct 31, 2023
b6858d3
Merge branch 'dev' of github.com:erxes/erxes into saving_update_ui
munkhsaikhan Oct 31, 2023
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
2 changes: 0 additions & 2 deletions exm-web/modules/chat/hooks/useChatMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ export const useChatMessages = (): IUseChats => {

newData.list = [chatMessageAdd, ...newData.list]

console.log(chatMessageAdd)

return { chatMessages: newData }
})
} catch (e) {
Expand Down
3 changes: 3 additions & 0 deletions packages/api-plugin-template.erxes/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,3 +704,6 @@ async function startServer() {
}

startServer();


// conflict test
33 changes: 21 additions & 12 deletions packages/api-utils/src/automations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,25 +350,34 @@ export const setProperty = async ({
if (rule.field.includes(complexFieldKey)) {
const fieldId = rule.field.replace(`${complexFieldKey}.`, '');

const complexFieldData = await sendCommonMessage({
subdomain,
serviceName: 'forms',
action: 'fields.generateTypedItem',
data: {
field: fieldId,
value
},
isRPC: true
});

if (
(relatedItem[complexFieldKey] || []).find(
obj => obj.field === fieldId
)
) {
selectorDoc[`${complexFieldKey}.field`] = fieldId;
setDoc[`${complexFieldKey}.$.value`] = value;
setDoc[`${complexFieldKey}.$.stringValue`] = value;

const complexFieldDataKeys = Object.keys(complexFieldData).filter(
key => key !== 'field'
);

for (const complexFieldDataKey of complexFieldDataKeys) {
setDoc[`${complexFieldKey}.$.${complexFieldDataKey}`] =
complexFieldData[complexFieldDataKey];
}
} else {
pushDoc[complexFieldKey] = await sendCommonMessage({
subdomain,
serviceName: 'forms',
action: 'fields.generateTypedItem',
data: {
field: fieldId,
value
},
isRPC: true
});
pushDoc[complexFieldKey] = complexFieldData;
}
}
}
Expand Down
105 changes: 83 additions & 22 deletions packages/plugin-automations-api/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,31 +97,33 @@ export const executeActions = async (
}

if (action.type === ACTIONS.IF) {
let ifActionId;
setTimeout(async () => {
let ifActionId;

const isIn = await isInSegment(
subdomain,
action.config.contentId,
execution.targetId
);
if (isIn) {
ifActionId = action.config.yes;
} else {
ifActionId = action.config.no;
}
const isIn = await isInSegment(
subdomain,
action.config.contentId,
execution.targetId
);
if (isIn) {
ifActionId = action.config.yes;
} else {
ifActionId = action.config.no;
}

execAction.nextActionId = ifActionId;
execAction.result = { condition: isIn };
execution.actions = [...(execution.actions || []), execAction];
execution = await execution.save();
execAction.nextActionId = ifActionId;
execAction.result = { condition: isIn };
execution.actions = [...(execution.actions || []), execAction];
execution = await execution.save();

return executeActions(
subdomain,
triggerType,
execution,
actionsMap,
ifActionId
);
return executeActions(
subdomain,
triggerType,
execution,
actionsMap,
ifActionId
);
}, 10000);
}

if (action.type === ACTIONS.SET_PROPERTY) {
Expand Down Expand Up @@ -319,6 +321,61 @@ export const calculateExecution = async ({
});
};

const isWaitingDateConfig = dateConfig => {
if (dateConfig) {
const NOW = new Date();

if (dateConfig.type === 'range') {
const { startDate, endDate } = dateConfig;
if (startDate < NOW && endDate > NOW) {
return true;
}
}

if (dateConfig?.type === 'cycle') {
const { frequencyType } = dateConfig;

const generateDate = (inputDate, isMonth?) => {
const date = new Date(inputDate);

return new Date(
NOW.getFullYear(),
isMonth ? NOW.getMonth() : date.getMonth(),
date.getDay()
);
};

if (frequencyType === 'everyYear') {
const startDate = generateDate(dateConfig.startDate);
if (dateConfig?.endDate) {
const endDate = generateDate(dateConfig.endDate);

if (NOW < startDate && NOW > endDate) {
return true;
}
}
if (NOW < startDate) {
return true;
}
}
if (frequencyType === 'everyMonth') {
const startDate = generateDate(dateConfig.startDate, true);
if (dateConfig?.endDate) {
const endDate = generateDate(dateConfig.endDate, true);

if (NOW < startDate && NOW > endDate) {
return true;
}
}
if (NOW < startDate) {
return true;
}
}
}
}
return false;
};

/*
* target is one of the TriggerType objects
*/
Expand Down Expand Up @@ -349,6 +406,10 @@ export const receiveTrigger = async ({
continue;
}

if (isWaitingDateConfig(trigger?.config?.dateConfig)) {
continue;
}

const execution = await calculateExecution({
models,
subdomain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export const PROPERTY_OPERATOR = {
{
value: 'divide',
label: 'Divide'
},
{
value: 'set',
label: 'Set'
}
],
Default: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class SetProperty extends React.Component<Props, State> {
};

getFieldType = (chosenField: FieldsCombinedByType) => {
if (chosenField.selectOptions) {
if (chosenField.selectOptions && chosenField.selectOptions?.length > 0) {
return 'select';
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React from 'react';
import { ITrigger } from '../../../types';
import SegmentsForm from '@erxes/ui-segments/src/containers/form/SegmentsForm';
import { Description, TriggerTabs } from '../../../styles';
import { Description, FlexContainer, TriggerTabs } from '../../../styles';
import { ScrolledContent } from '@erxes/ui-automations/src/styles';
import { __ } from 'coreui/utils';
import { __ } from '@erxes/ui/src';
import { Tabs, TabTitle } from '@erxes/ui/src/components/tabs';
import ReEnrollmentContainer from '../../../containers/forms/triggers/ReEnrollment';
import { Button, ModalTrigger } from '@erxes/ui/src';
import DateSettings from './subForms/Date';
import { ModalFooter } from '@erxes/ui/src/styles/main';

type Props = {
closeModal: () => void;
Expand Down Expand Up @@ -64,15 +67,60 @@ class TriggerDetailForm extends React.Component<
);
}

renderSettings() {
const { activeTrigger, addConfig } = this.props;
const config = activeTrigger.config || {};

const onChange = config => {
activeTrigger.config = config;
addConfig(activeTrigger, activeTrigger.id, config);
};

const onClear = () => {
const { contentId, reEnrollment, reEnrollmentRules } =
activeTrigger?.config || {};

activeTrigger.config = { contentId, reEnrollment, reEnrollmentRules };
addConfig(activeTrigger, activeTrigger.id);
};

const trigger = <Button icon="settings" btnStyle="link" />;

const content = () => {
return (
<>
<DateSettings onChange={onChange} config={config} />
<ModalFooter>
<Button btnStyle="simple" onClick={onClear}>
{__('Clear')}
</Button>
</ModalFooter>
</>
);
};

return (
<ModalTrigger
title="Trigger Settings"
trigger={trigger}
content={content}
hideHeader={true}
/>
);
}

render() {
const { currentTab, activeTrigger } = this.state;

return (
<>
<Description>
<h4>
{activeTrigger.label} {__('based')}
</h4>
<FlexContainer>
<h4>
{activeTrigger.label} {__('based')}
</h4>
{this.renderSettings()}
</FlexContainer>
<p>{activeTrigger.description}</p>
</Description>
<TriggerTabs>
Expand Down
Loading
Loading