terrier-engine 4.34.0 → 4.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- import TerrierFormPart from "./parts/terrier-form-part"
2
1
  import {PartTag} from "tuff-core/parts"
3
2
  import * as inflection from "inflection"
4
3
  import Messages from "tuff-core/messages"
5
4
  import {Logger} from "tuff-core/logging"
6
5
  import dayjs from "dayjs"
6
+ import {TerrierFormFields} from "./forms"
7
7
 
8
8
  const log = new Logger("Schedules")
9
9
 
@@ -81,65 +81,59 @@ export type CombinedRegularSchedule = {
81
81
  // Form
82
82
  ////////////////////////////////////////////////////////////////////////////////
83
83
 
84
- export class RegularScheduleForm extends TerrierFormPart<CombinedRegularSchedule> {
84
+ export class RegularScheduleFields extends TerrierFormFields<CombinedRegularSchedule> {
85
85
 
86
86
  scheduleTypeChangeKey = Messages.typedKey<{schedule_type: ScheduleType}>()
87
87
 
88
- async init() {
89
- this.onChange(this.scheduleTypeChangeKey, m => {
90
- log.info(`Schedule type changed to ${m.data.schedule_type}`)
91
- this.dirty()
92
- })
93
- }
94
-
95
88
  get parentClasses(): Array<string> {
96
89
  return ['tt-flex', 'column', 'gap', 'regular-schedule-form', 'tt-form']
97
90
  }
98
91
 
99
-
100
92
  render(parent: PartTag): any {
101
- parent.label('.caption-size', label => {
102
- this.radio(label, 'schedule_type', 'none')
103
- .emitChange(this.scheduleTypeChangeKey, {schedule_type: 'none'})
104
- label.span().text("Do Not Deliver")
105
- })
106
-
107
- parent.label('.caption-size', label => {
108
- this.radio(label, 'schedule_type', 'daily')
109
- .emitChange(this.scheduleTypeChangeKey, {schedule_type: 'daily'})
110
- label.span().text("Deliver Daily")
111
- })
112
- if (this.state.schedule_type == 'daily') {
113
- parent.div('.schedule-type-fields.daily.tt-flex.gap', row => {
114
- this.select(row, 'hour_of_day', HourOfDayOptions)
93
+ parent.div('.tt-flex.column.gap.regular-schedule-form.tt-form', col => {
94
+ col.label('.caption-size', label => {
95
+ this.radio(label, 'schedule_type', 'none')
96
+ .emitChange(this.scheduleTypeChangeKey, {schedule_type: 'none'})
97
+ label.span().text("Do Not Deliver")
115
98
  })
116
- }
117
99
 
118
- parent.label('.caption-size', label => {
119
- this.radio(label, 'schedule_type', 'weekly')
120
- .emitChange(this.scheduleTypeChangeKey, {schedule_type: 'weekly'})
121
- label.span().text("Deliver Weekly")
122
- })
123
- if (this.state.schedule_type == 'weekly') {
124
- parent.div('.schedule-type-fields.weekly.tt-flex.gap', row => {
125
- this.select(row, 'day_of_week', DayOfWeekOptions)
126
- .data({tooltip: "Day of the week"})
127
- this.select(row, 'hour_of_day', HourOfDayOptions)
100
+ col.label('.caption-size', label => {
101
+ this.radio(label, 'schedule_type', 'daily')
102
+ .emitChange(this.scheduleTypeChangeKey, {schedule_type: 'daily'})
103
+ label.span().text("Deliver Daily")
128
104
  })
129
- }
130
-
131
- parent.label('.caption-size', label => {
132
- this.radio(label, 'schedule_type', 'monthly')
133
- .emitChange(this.scheduleTypeChangeKey, {schedule_type: 'monthly'})
134
- label.span().text("Deliver Monthly")
135
- })
136
- if (this.state.schedule_type == 'monthly') {
137
- parent.div('.schedule-type-fields.monthly.tt-flex.gap', row => {
138
- this.select(row, 'day_of_month', DayOfMonthOptions)
139
- .data({tooltip: "Day of the month"})
140
- this.select(row, 'hour_of_day', HourOfDayOptions)
105
+ if (this.data.schedule_type == 'daily') {
106
+ col.div('.schedule-type-fields.daily.tt-flex.gap', row => {
107
+ this.select(row, 'hour_of_day', HourOfDayOptions)
108
+ })
109
+ }
110
+
111
+ col.label('.caption-size', label => {
112
+ this.radio(label, 'schedule_type', 'weekly')
113
+ .emitChange(this.scheduleTypeChangeKey, {schedule_type: 'weekly'})
114
+ label.span().text("Deliver Weekly")
141
115
  })
142
- }
116
+ if (this.data.schedule_type == 'weekly') {
117
+ col.div('.schedule-type-fields.weekly.tt-flex.gap', row => {
118
+ this.select(row, 'day_of_week', DayOfWeekOptions)
119
+ .data({tooltip: "Day of the week"})
120
+ this.select(row, 'hour_of_day', HourOfDayOptions)
121
+ })
122
+ }
123
+
124
+ col.label('.caption-size', label => {
125
+ this.radio(label, 'schedule_type', 'monthly')
126
+ .emitChange(this.scheduleTypeChangeKey, {schedule_type: 'monthly'})
127
+ label.span().text("Deliver Monthly")
128
+ })
129
+ if (this.data.schedule_type == 'monthly') {
130
+ col.div('.schedule-type-fields.monthly.tt-flex.gap', row => {
131
+ this.select(row, 'day_of_month', DayOfMonthOptions)
132
+ .data({tooltip: "Day of the month"})
133
+ this.select(row, 'hour_of_day', HourOfDayOptions)
134
+ })
135
+ }
136
+ })
143
137
  }
144
138
 
145
139
 
@@ -150,6 +144,7 @@ export class RegularScheduleForm extends TerrierFormPart<CombinedRegularSchedule
150
144
  const raw = await this.serialize()
151
145
  const schedule_type = raw.schedule_type
152
146
  const hour_of_day = raw.hour_of_day || '0'
147
+ log.info(`Serializing schedule type ${schedule_type}`, raw)
153
148
  switch (schedule_type) {
154
149
  case 'none':
155
150
  return {schedule_type}