import AddBikePresenter from 'PedalPatrol/src/components/presenters/addbike-presenter.js'
AddBikePresenter
Extends:
Class for the AddBike presenter and view
Constructor Summary
Public Constructor | ||
public |
constructor(view: Object) Creates an instance of AddBikePresenter |
Member Summary
Public Members | ||
public |
changeText(colours: List, renderer: Function): * Converts a list of colour objects to a list of objects with a component using the renderer function. |
|
public |
checkEditingState(editingState: Boolean, success: Function, failure: Function): * Checks the editing state of the view and calls one of its passed in functions. |
|
public |
checkInputs(inputData: List, inputRequirementFailure: Function): Boolean: * Checks the input data for required inputs and calls an alert function if inputs are missing. |
|
public |
clearPhotos: * Resets the current photos to the default photos. |
|
public |
|
|
public |
deleteBike(id: string, callback: Function): * Delete a bike from the database |
|
public |
getCurrentPhotos: List: * Returns a deep copy of the current photos. |
|
public |
Gets the data from the model and returns it to the caller. |
|
public |
getTextInputData(data: Object, isEditPage: Boolean): List: * Return the data for the text inputs. |
|
public |
onDestroy: * If the view or presenter is destroyed, unsubscribe the presenter from the model. |
|
public |
Called when the model is updated with new data. |
|
public |
toggleColours(sectionedMultiSelect: Object, data: Object, onColoursFound: Function, UNIQUE_KEY: string): * Toggles the colours from the data if the data is present. |
|
public |
Updates the bike model with new data. |
|
public |
view: * |
Private Members | ||
private |
_buildDataFromView(newData: Object): Object: * Build the data obtained from the view and insert it into a new data object. |
|
private |
_deepCopy: List: * Returns a deep copy of the array by reassigning the values. |
|
private |
_getRequiredInputs(inputs: List): List: * Returns the required inputs based on the required property |
|
private |
_getString(val: Number/string): string: * Checks if the value is valid and if so, convert it to a string. |
|
private |
_translateDataToInput(data: Object): List: * Translates data input (Bike data) to the text inputs. |
|
private |
check: * |
|
private |
filterItems: * |
|
private |
getProp: * |
Method Summary
Public Methods | ||
public |
selectPhotoTapped(imagePicker: Object, setEditing: Function, id: Number, photos: List) Open the image picker. |
Public Constructors
Public Members
public changeText(colours: List, renderer: Function): * source
Converts a list of colour objects to a list of objects with a component using the renderer function.
public checkEditingState(editingState: Boolean, success: Function, failure: Function): * source
Checks the editing state of the view and calls one of its passed in functions.
public checkInputs(inputData: List, inputRequirementFailure: Function): Boolean: * source
Checks the input data for required inputs and calls an alert function if inputs are missing.
public currentPhotos: * source
public getCurrentPhotos: List: * source
Returns a deep copy of the current photos.
Return:
List | A list of the current photos |
public getTextInputData(data: Object, isEditPage: Boolean): List: * source
Return the data for the text inputs. Object: name: the name/label of the text input disabled: true: if the field is disabled; false: otherwise multiline: true: if the input is allowed to span multiple lines; false: otherwise text: initial text of the input
Return:
List | A list of data objects (name, multiline, text) |
public onDestroy: * source
If the view or presenter is destroyed, unsubscribe the presenter from the model.
public onUpdated(newData: Object): * source
Called when the model is updated with new data. Refreshes the state of the view. Method is supplied with the data to add. Better way to refresh the state?
public toggleColours(sectionedMultiSelect: Object, data: Object, onColoursFound: Function, UNIQUE_KEY: string): * source
Toggles the colours from the data if the data is present.
public view: * source
Private Members
private _buildDataFromView(newData: Object): Object: * source
Build the data obtained from the view and insert it into a new data object. Current attributes of newData object: {Object} inputTextData: [{name, multiline, disabled, text}] {List} selectedColours {Object} picture: uri
private _deepCopy: List: * source
Returns a deep copy of the array by reassigning the values. This is to make sure we can clear the data.
Return:
List | A list to copy |
private _getRequiredInputs(inputs: List): List: * source
Returns the required inputs based on the required property
Return:
List | A list of required text inputs |
private _getString(val: Number/string): string: * source
Checks if the value is valid and if so, convert it to a string.
private _translateDataToInput(data: Object): List: * source
Translates data input (Bike data) to the text inputs. Could be refactored to be made easier for adaptations.
Return:
List | A copy of the data that is now in the form of the text input |