@@ -5,6 +5,7 @@ import { action } from '@ember/object';
55import { task } from 'ember-concurrency' ;
66import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback' ;
77import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments' ;
8+ import Point from '@fleetbase/fleetops-data/utils/geojson/point' ;
89
910export default class FuelReportFormPanelComponent extends Component {
1011 @service store ;
@@ -39,6 +40,13 @@ export default class FuelReportFormPanelComponent extends Component {
3940 */
4041 @tracked controller ;
4142
43+ /**
44+ * The coordinates input component context instance.
45+ *
46+ * @memberof FuelReportFormPanelComponent
47+ */
48+ @tracked coordinatesInputComponent ;
49+
4250 /**
4351 * Constructs the component and applies initial state.
4452 */
@@ -104,8 +112,56 @@ export default class FuelReportFormPanelComponent extends Component {
104112 return contextComponentCallback ( this , 'onPressCancel' , this . fuelReport ) ;
105113 }
106114
115+ /**
116+ * Set the ruel report reporter
117+ *
118+ * @param {UserModel } user
119+ * @memberof FuelReportFormPanelComponent
120+ */
107121 @action setReporter ( user ) {
108- this . issue . set ( 'reporter' , user ) ;
109- this . issue . set ( 'reported_by_uuid' , user . id ) ;
122+ this . fuelReport . set ( 'reporter' , user ) ;
123+ this . fuelReport . set ( 'reported_by_uuid' , user . id ) ;
124+ }
125+
126+ /**
127+ * Sets the coordinates input component.
128+ *
129+ * @action
130+ * @param {Object } coordinatesInputComponent - The coordinates input component to be set.
131+ * @memberof PlaceFormPanelComponent
132+ */
133+ @action setCoordinatesInput ( coordinatesInputComponent ) {
134+ this . coordinatesInputComponent = coordinatesInputComponent ;
135+ }
136+
137+ /**
138+ * Handle autocomplete callback
139+ *
140+ * @param {AutocompleteEvent } { location }
141+ * @memberof VehicleFormPanelComponent
142+ */
143+ @action onAutocomplete ( { location } ) {
144+ if ( location ) {
145+ this . fuelReport . setProperties ( { location } ) ;
146+
147+ if ( this . coordinatesInputComponent ) {
148+ this . coordinatesInputComponent . updateCoordinates ( location ) ;
149+ }
150+ }
151+ }
152+
153+ /**
154+ * Updates the Vehicle coordinates with the given latitude and longitude.
155+ *
156+ * @action
157+ * @param {Object } coordinates - The latitude and longitude coordinates.
158+ * @param {number } coordinates.latitude - Latitude value.
159+ * @param {number } coordinates.longitude - Longitude value.
160+ * @memberof PlaceFormPanelComponent
161+ */
162+ @action onCoordinatesChanged ( { latitude, longitude } ) {
163+ const location = new Point ( longitude , latitude ) ;
164+
165+ this . fuelReport . setProperties ( { location } ) ;
110166 }
111167}
0 commit comments