Skip to content

Commit

Permalink
Merge pull request #173 from wonknu/enhancement_139
Browse files Browse the repository at this point in the history
Enhancement 139
  • Loading branch information
gregorybesson committed Mar 23, 2017
2 parents 015464c + 32e22d8 commit 4558627
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
14 changes: 13 additions & 1 deletion docs/abe-attributes.md
Expand Up @@ -48,6 +48,7 @@ are always required for all content type
- [locale](#locale)
- [prefill](#prefill)
- [prefill-quantity](#prefill-quantity)
- [value](#value)

## <a name="tab"></a>tab (String)

Expand Down Expand Up @@ -423,4 +424,15 @@ Default: null
prefill-quantity="3"
```

How many default values to prefill
How many default values to prefill


## <a name="value"></a>value (String)

Default: none

```html
value="default text value"
```

Add a default value inside input, if the input value changes the default value won't be used anymore unless the value of the input become an empty string
2 changes: 1 addition & 1 deletion src/cli/cms/data/attributes.js
Expand Up @@ -29,7 +29,7 @@ export function getAll(str, json) {
source: null,
tab: 'default',
type: 'text',
value: '',
value: null,
file: '',
visible: true
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cms/editor/form.js
Expand Up @@ -54,7 +54,7 @@ export default class Form {
source: null,
tab: 'default',
type: 'text',
value: '',
value: null,
visible: true,
precontribTemplate: ''
}
Expand Down
8 changes: 4 additions & 4 deletions src/cli/cms/editor/handlebars/compileAbe.js
Expand Up @@ -33,7 +33,7 @@ export default function compileAbe(){
value = ''
}
if(typeof value === 'function' || value == null) {
value = ''
value = (hash.value != null) ? hash.value : ''
}
if(hash.type != null && hash.type === 'rich'){
testXSS = xss(value.replace(/&quot;/g, '"'), {
Expand All @@ -57,11 +57,11 @@ export default function compileAbe(){
}else {
value = hash.key
}
// value = ((content) ? content[hash.key.replace('.', '-')] : hash.key)

if(typeof value === 'function' || value == null) {
value = ''
value = (hash.value != null) ? hash.value : ''
}

if(hash.type != null && hash.type === 'rich'){
testXSS = xss(value.replace(/&quot;/g, '"'), {
'whiteList': config.htmlWhiteList,
Expand Down
1 change: 1 addition & 0 deletions src/cli/cms/editor/handlebars/printInput.js
Expand Up @@ -316,6 +316,7 @@ export function printInput (params, root) {
var inputClass = 'form-control form-abe'
res += getLabel(params)

if(params.value === null && params.defaultvalue != null) params.value = params.defaultvalue
params.placeholder = params.placeholder || ''
params.value = params.value || ''

Expand Down
3 changes: 2 additions & 1 deletion src/server/controllers/editor.js
Expand Up @@ -93,7 +93,8 @@ function matchAttrAbe(text, json, util, arrayBlock) {
match
// While regexp match HandlebarsJS template item => keepgoing
while (match = patt.exec(text)) {
addToForm(match[0], text, json, util, arrayBlock, null, null)
var matchText = match[0].replace(/value=([\'\"].*?[\'\"])/g, 'defaultvalue=$1')
addToForm(matchText, text, json, util, arrayBlock, null, null)
}
}

Expand Down

0 comments on commit 4558627

Please sign in to comment.