Disclaimer: This is the first open source project that I’ve contributed to, and I have never developed on ruby on rails before this.
I am working on this feature request:
I have added a new macro via the rails console as follows:
Macro.create_if_not_exists(
name: 'Rails rel pend',
perform: {
'ticket.pending_time' => {
operator: 'rel',
value: 7,
range: 'day',
}
},
updated_by_id: 1,
created_by_id: 1,
ux_flow_next_up: 'none',
note: 'MACRO FROM RAILS CONSOLE',
active: true,
)
The intended functionality of this macro is to set the ticket “pending_time” to a relative date, rather than a statically selected one. Unfortunately, the assets will need to be changed to handle such a macro.
In a test environment (docker) I have implemented a change in the following file:
This is the code I have added:
# apply pending_date
if attributes[1] is 'pending_time'
pendtil = new Date
pendtil.setDate(pendtil.getDate()+content.value)
console.log params.ticket[attributes[1]]
params.ticket[attributes[1]] = pendtil.toISOString()
console.log params.ticket[attributes[1]]
This was intended to handle only my specific macro.
In testing my new macro, I noticed that the console will correctly log the old ‘pending_time’ for the ticket and the new time, 7 days from now. However, I’ve encountered some strange results:
I created a new ticket (id: 2). I set it to pending reminder.
# App.Ticket.find(2)['pending_time']
"2019-12-13T21:00:00.000Z"
That’s good - it was saved.
# App.Ticket.macro({macro: App.Macro.find(4).perform, ticket: App.Ticket.find(2)})
Array [ 7 ]
2019-12-13T21:00:00.000Z
2019-12-19T11:11:32.865Z
Seems to have worked? But then afterwards I get this:
# App.Ticket.find(2)['pending_time']
"2019-12-13T21:00:00.000Z"
It didn’t change??? How can I make these changes persist? I have a gut feeling that it has to do with the Ticket.save method in the controllers, but I honestly can’t think of what I need to change.
Could someone please point me in the right direction?