|
@@ -39,37 +39,42 @@ export const useTicketEdit = (
|
|
|
const initialTicketValue = ref<FormValues>()
|
|
|
const mutationUpdate = new MutationHandler(useTicketUpdateMutation({}))
|
|
|
|
|
|
- watch(ticket, (newTicket, oldTicket) => {
|
|
|
- if (!newTicket) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // We need only to reset the form, when really something was changed (updatedAt is not relevant for the form).
|
|
|
- if (
|
|
|
- isEqualWith(newTicket, oldTicket, (value1, value2, key) => {
|
|
|
- if (key === 'updatedAt') return true
|
|
|
+ watch(
|
|
|
+ ticket,
|
|
|
+ (newTicket, oldTicket) => {
|
|
|
+ if (!newTicket) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const ticketId = initialTicketValue.value?.id || newTicket.id
|
|
|
+ const { internalId: ownerInternalId } = newTicket.owner
|
|
|
+
|
|
|
+ initialTicketValue.value = {
|
|
|
+ id: newTicket.id,
|
|
|
+ owner_id: ownerInternalId === 1 ? null : ownerInternalId,
|
|
|
+ }
|
|
|
+
|
|
|
+ // We need only to reset the form, when really something was changed (updatedAt is not relevant for the form).
|
|
|
+ if (
|
|
|
+ !oldTicket ||
|
|
|
+ isEqualWith(newTicket, oldTicket, (value1, value2, key) => {
|
|
|
+ if (key === 'updatedAt') return true
|
|
|
+ })
|
|
|
+ ) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO: check why article type was changed back to initial?!
|
|
|
+ form.value?.resetForm(initialTicketValue.value, newTicket, {
|
|
|
+ // don't reset to new values, if user changes something
|
|
|
+ // if ticket is different, it's probably navigation to another ticket,
|
|
|
+ // so we can safely reset the form
|
|
|
+ // TODO: navigation to another ticket is currently always a re-render of the form, because of the component key(=newTicket.id) or?
|
|
|
+ resetDirty: ticketId !== newTicket.id,
|
|
|
})
|
|
|
- ) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- const ticketId = initialTicketValue.value?.id || newTicket.id
|
|
|
- const { internalId: ownerInternalId } = newTicket.owner
|
|
|
-
|
|
|
- initialTicketValue.value = {
|
|
|
- id: newTicket.id,
|
|
|
- owner_id: ownerInternalId === 1 ? null : ownerInternalId,
|
|
|
- }
|
|
|
-
|
|
|
- // TODO: check why article type was changed back to initial?!
|
|
|
- form.value?.resetForm(initialTicketValue.value, newTicket, {
|
|
|
- // don't reset to new values, if user changes something
|
|
|
- // if ticket is different, it's probably navigation to another ticket,
|
|
|
- // so we can safely reset the form
|
|
|
- // TODO: navigation to another ticket is currently always a re-render of the form, because of the component key(=newTicket.id) or?
|
|
|
- resetDirty: ticketId !== newTicket.id,
|
|
|
- })
|
|
|
- })
|
|
|
+ },
|
|
|
+ { immediate: true },
|
|
|
+ )
|
|
|
|
|
|
const isTicketFormGroupValid = computed(() => {
|
|
|
const ticketGroup = form.value?.formNode?.at('ticket')
|