Skip to content

Commit

Permalink
linting, only import local date mapper when entity uses local date
Browse files Browse the repository at this point in the history
  • Loading branch information
ruddell committed Oct 5, 2018
1 parent 7ebf03a commit 26054ab
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/entity/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = async function (generator, igniteContext) {
const entityFileName = `${name}.json`
const localEntityFilePath = `.jhipster/${entityFileName}`

let entityContainsLocalDate = false
// load the entity config into memory
let entityConfig = await fs.readJson(localEntityFilePath)
entityConfig.fields.forEach((field) => {
Expand All @@ -36,9 +37,13 @@ module.exports = async function (generator, igniteContext) {
'byte[]',
'ByteBuffer'
].includes(field.fieldType)
if (field.fieldType === 'LocalDate') {
entityContainsLocalDate = true
}
})

props.entityConfig = entityConfig
props.entityContainsLocalDate = entityContainsLocalDate
props.microserviceName = entityConfig.hasOwnProperty('microserviceName') ? (entityConfig.microserviceName + '/') : ''

const apiFilePath = `${process.cwd()}/App/Services/Api.js`
Expand Down
2 changes: 2 additions & 0 deletions templates/entity-detail-screen.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { connect } from 'react-redux'
import <%= props.name %>Actions from '../Redux/<%= props.name %>Redux'
import RoundedButton from '../Components/RoundedButton'
import { Actions as NavigationActions } from 'react-native-router-flux'
<%_ if (props.entityContainsLocalDate) { _%>
import { jsDateToLocalDate } from '../Transforms/DateTransforms'
<%_ } _%>

// Styles
import styles from './Styles/<%= props.name %>EntityDetailScreenStyle'
Expand Down
5 changes: 3 additions & 2 deletions templates/entity-edit-screen.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@ import { connect } from 'react-redux'
import <%= props.name %>Actions from '../Redux/<%= props.name %>Redux'
import { Actions as NavigationActions } from 'react-native-router-flux'
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
<%_ if (props.entityContainsLocalDate) { _%>
import { jsDateToLocalDate } from '../Transforms/DateTransforms'
<%_ } _%>

import t from 'tcomb-form-native'

// Styles
import styles from './Styles/<%= props.name %>EntityEditScreenStyle'

let Form = t.form.Form

<%_ props.entityConfig.fields.forEach((field) => {
if (field.fieldIsEnum) { _%>
const <%= field.fieldType %> = t.enums({
<%_
const enumValues = field.fieldValues.split(',')
enumValues.forEach((enumValue, index) => {
_%>
<%= enumValue %>: '<%= enumValue %>'<%= index !== enumValues.length -1 ? ',' : '' %>
<%= enumValue %>: '<%= enumValue %>'<%= index !== enumValues.length -1 ? ',' : '' %>
<%_ }) //end of value loop _%>
})
<%_ } // end of if statement
Expand Down
3 changes: 3 additions & 0 deletions templates/saga.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { call, put } from 'redux-saga/effects'
import <%= props.name %>Actions from '../Redux/<%= props.name %>Redux'
import { callApi } from './CallApiSaga'
<%_ if (props.entityContainsLocalDate) { _%>
import { localDateToJsDate } from '../Transforms/DateTransforms'
<%_ } _%>

export function * get<%= props.name %> (api, action) {
const { <%= camelCase(props.name) %>Id } = action
// make the call to the api
Expand Down

0 comments on commit 26054ab

Please sign in to comment.