Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix-and-core #582

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 199
versionName "1.0.62"
versionName "1.0.63"


buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@miblanchard/react-native-slider": "^2.3.1",
"@openforis/arena-core": "0.0.205",
"@openforis/arena-core": "0.0.208",
"@react-native-async-storage/async-storage": "^1.23.1",
"@react-native-clipboard/clipboard": "^1.12.1",
"@react-native-community/datetimepicker": "7.6.2",
Expand Down
3 changes: 3 additions & 0 deletions src/form/Attributes/Code/Preview/hooks/useCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Objects} from 'infra/objectUtils';
import {selectors as formSelectors} from 'state/form';
import {selectors as nodesSelectors} from 'state/nodes';
import surveySelectors from 'state/survey/selectors';
import {selectors as userSelectors} from 'state/user';

const getCategoryItemLabel = (nodeDef, cycle, language) => categoryItem => {
const {codeShown: hasToShowCode = true} =
Expand All @@ -27,6 +28,7 @@ export const useCode = (nodeDef, node = false) => {
const cycle = useSelector(surveySelectors.getSurveyCycle);
const survey = useSelector(surveySelectors.getSurvey);
const record = useSelector(formSelectors.getRecord);
const user = useSelector(userSelectors.getUser);

const nodes = useSelector(state =>
formSelectors.getNodeDefNodesInHierarchy(state, nodeDef),
Expand Down Expand Up @@ -60,6 +62,7 @@ export const useCode = (nodeDef, node = false) => {
.filter(item => {
try {
return expressionEvaluator.evalExpression({
user,
survey,
record,
node: parentNode,
Expand Down
2 changes: 1 addition & 1 deletion src/state/form/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const isNodeDefApplicable = createCachedSelector(
getParentEntityNode,
_getNodeDefUuid,
(parentEntityNode, nodeDefUuid) =>
Nodes.isApplicable(parentEntityNode, nodeDefUuid),
Nodes.isChildApplicable(parentEntityNode, nodeDefUuid),
)({
keySelector: keySelectors.stringKey,
cacheObject: new FifoObjectCache({cacheSize: 4000}),
Expand Down
6 changes: 5 additions & 1 deletion src/state/nodes/sagas/createNodeAndDescendants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@ import formActions from 'state/form/actionCreators';
import formSelectors from 'state/form/selectors';
import recordsActions from 'state/records/actionCreators';
import surveySelectors from 'state/survey/selectors';
import userSelectors from 'state/user/selectors';

function* handleCreateNodeAndDescendants({payload} = {}) {
const {nodeDef, parentNode, isCreating, selectNode} = payload;

const [record, survey] = yield all([
const [record, survey, user] = yield all([
select(formSelectors.getRecord),
select(surveySelectors.getSurvey),
select(userSelectors.getUser),
]);

let updateResult = false;

if (Objects.isEmpty(parentNode)) {
updateResult = yield call(RecordUpdater.createRootEntity, {
user,
survey,
record,
});
} else {
updateResult = yield call(RecordUpdater.createNodeAndDescendants, {
user,
survey,
record,
parentNode,
Expand Down
5 changes: 4 additions & 1 deletion src/state/nodes/sagas/removeNode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import {handleDeleteNodesFiles, handleSetNodesFiles} from 'state/files/sagas';
import formSelectors from 'state/form/selectors';
import recordsActions from 'state/records/actionCreators';
import surveySelectors from 'state/survey/selectors';
import userSelectors from 'state/user/selectors';

function* handleRemoveNode({payload}) {
const {node} = payload;

const [fullRecord, survey] = yield all([
const [fullRecord, survey, user] = yield all([
select(formSelectors.getRecord),
select(surveySelectors.getSurvey),
select(userSelectors.getUser),
]);

const updatedResult = yield call(RecordUpdater.deleteNodes, {
user,
nodeUuids: [node.uuid],
record: fullRecord,
survey,
Expand Down
5 changes: 4 additions & 1 deletion src/state/nodes/sagas/updateNode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import nodesSelectors from 'state/nodes/selectors';
import recordsActions from 'state/records/actionCreators';
import recordsSelectors from 'state/records/selectors';
import surveySelectors from 'state/survey/selectors';
import userSelectors from 'state/user/selectors';

import {updateNodeAndDependants, callbackAndJump} from './methods';

Expand All @@ -27,12 +28,13 @@ function* handleUpdateNode({payload}) {
}),
);

const [survey, node, record] = yield all([
const [survey, node, record, user] = yield all([
select(surveySelectors.getSurvey),
select(state => nodesSelectors.getNodeByUuid(state, updatedNode.uuid)),
select(state =>
recordsSelectors.getRecordByUuid(state, updatedNode.recordUuid),
),
select(userSelectors.getUser),
]);

try {
Expand All @@ -46,6 +48,7 @@ function* handleUpdateNode({payload}) {
const {nodes: updatedNodes, record: updatedRecord} = yield call(
updateNodeAndDependants,
{
user,
node: updatedNode,
record,
survey,
Expand Down
3 changes: 2 additions & 1 deletion src/state/nodes/sagas/updateNode/methods/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import {RecordUpdater} from '@openforis/arena-core';
export {default as callbackAndJump} from './callbackAndJump';
export {default as getNextNode} from './getNextNode';

export const updateNodeAndDependants = async ({survey, record, node}) => {
export const updateNodeAndDependants = async ({user, survey, record, node}) => {
const updateResult = await RecordUpdater.updateAttributeValue({
user,
survey,
record,
attributeUuid: node.uuid,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2634,10 +2634,10 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@openforis/[email protected].205":
version "0.0.205"
resolved "https://npm.pkg.github.com/download/@openforis/arena-core/0.0.205/7a4a1074ac76b00880789904fc5fd5dc7d1d6382#7a4a1074ac76b00880789904fc5fd5dc7d1d6382"
integrity sha512-JISauhuzUbN/UReULxRRe50P7IhCcowkayt6pXAy8gF4m8VypKU1AfJgXLXZ3eSGnvXwyuk2TXzwrxIJ7epw/Q==
"@openforis/[email protected].208":
version "0.0.208"
resolved "https://npm.pkg.github.com/download/@openforis/arena-core/0.0.208/f3003635bd5c24f2d055369e2a28988ad886b3be#f3003635bd5c24f2d055369e2a28988ad886b3be"
integrity sha512-RpPhSGjUqn5IMhmc0Wa0qdb7nyyOseylGqdHgP9ud5o3PdshKZdtEm0/pr71KXU3HNOcU0ffrguR8qdXPI/nbA==
dependencies:
"@jsep-plugin/regex" "^1.0.3"
bignumber.js "^9.1.2"
Expand Down
Loading