Skip to content

Commit

Permalink
feat(backoffice-v2): added the ability to add a default for document …
Browse files Browse the repository at this point in the history
…fields (#2592)

Co-authored-by: Alon Peretz <8467965+alonp99@users.noreply.github.com>
  • Loading branch information
Omri-Levy and alonp99 authored Jul 31, 2024
1 parent ae89f57 commit 84028d5
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,32 @@ export const useDocumentBlocks = ({
value,
formatMinimum,
formatMaximum,
default: defaultValue,
},
]) => {
const fieldValue = value || (properties?.[title] ?? '');
const getFieldValue = () => {
if (typeof value !== 'undefined') {
return value;
}

if (
typeof properties?.[title] === 'undefined' &&
typeof defaultValue !== 'undefined'
) {
return defaultValue;
}

if (typeof properties?.[title] === 'undefined' && type === 'boolean') {
return false;
}

if (typeof properties?.[title] === 'undefined') {
return '';
}

return properties?.[title];
};
const fieldValue = getFieldValue();
const isEditableDecision = isDoneWithRevision || !decision?.status;
const isEditableType =
(title === 'type' && !checkIsBusiness(workflow)) || title !== 'type';
Expand Down

0 comments on commit 84028d5

Please sign in to comment.