refactor: manage every nullable option
gitea/salix-front/pipeline/pr-master This commit is unstable Details

This commit is contained in:
Jon Elias 2025-03-26 12:32:22 +01:00
parent 3783cdeed4
commit ae9cc49add
1 changed files with 11 additions and 1 deletions

View File

@ -93,10 +93,20 @@ const updateAddressTicket = async () => {
};
const updateObservations = async (payload) => {
if (isPayloadEmpty(payload)) return;
await axios.post('AddressObservations/crud', payload);
notes.value = [];
deletes.value = [];
};
function isPayloadEmpty(payload) {
return ['creates', 'deletes', 'updates'].every(
(prop) =>
!payload[prop] ||
payload[prop].length === 0 ||
payload[prop].every((item) => item === undefined || item === null),
);
}
async function updateAll({ data, payload }) {
await updateObservations(payload);
await updateAddress(data);
@ -180,7 +190,7 @@ function handleLocation(data, location) {
<FetchData @on-fetch="getData" auto-load url="ObservationTypes" />
<FormModel
observe-form-changes
:observe-form-changes="false"
:url-update="urlUpdate"
:url="`Addresses/${route.params.addressId}`"
:save-fn="handleDialog"