Skip to content

Commit

Permalink
prefill
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Aug 4, 2016
1 parent 47c9519 commit b3b19c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli/helpers/abe-template.js
Expand Up @@ -71,7 +71,7 @@ function translate(text) {
var currentMatch = `{{abe ${splitedMatch}`
if(/({{abe.*type=[\'|\"]translate.*}})/.test(currentMatch)) {
var locale = getAttr(currentMatch, 'locale')
var source = getAttr(currentMatch, 'source')
var source = getAttr(currentMatch, 'source')

if (locale.indexOf('{{') === -1) {
locale = `'${locale}'`
Expand Down
15 changes: 14 additions & 1 deletion src/cli/helpers/abe-utils.js
Expand Up @@ -314,7 +314,17 @@ export default class Utils {
var data = Sql.getDataRequest(tplPath, match[0], jsonPage)
jsonPage[sourceAttr][obj.key] = data
if (!obj.editable) {
jsonPage[obj.key] = data
if (obj.maxLength) {
jsonPage[obj.key] = data.slice(0, obj.maxLength)
}else {
jsonPage[obj.key] = data
}
}else if (obj.prefill && (typeof jsonPage[obj.key] === 'undefined' || jsonPage[obj.key] === null || jsonPage[obj.key] === '')) {
if (obj.maxLength) {
jsonPage[obj.key] = data.slice(0, obj.maxLength)
}else {
jsonPage[obj.key] = data
}
}

if(typeof obj.paginate !== 'undefined' && obj.paginate !== null && obj.paginate !== '') {
Expand Down Expand Up @@ -506,6 +516,7 @@ export default class Utils {

var defaultValues = {
type: 'text'
,prefill: false
,key: ''
,desc: ''
,maxLength: null
Expand All @@ -528,6 +539,7 @@ export default class Utils {
var obj = {
type: getAttr(str, 'type')
,key: key
,prefill: getAttr(str, 'prefill')
,desc: getAttr(str, 'desc')
,autocomplete: getAttr(str, 'autocomplete')
,maxLength: getAttr(str, 'max-length')
Expand All @@ -548,6 +560,7 @@ export default class Utils {
obj = extend(true, defaultValues, obj)

obj.editable = (typeof obj.editable === 'undefined' || obj.editable === null || obj.editable === '' || obj.editable === 'false') ? false : true
obj.prefill = (typeof obj.prefill !== 'undefined' && obj.prefill !== null && obj.prefill === 'true') ? true : false

obj = Hooks.instance.trigger('afterAbeAttributes', obj, str, json)

Expand Down

0 comments on commit b3b19c7

Please sign in to comment.