Skip to content

Commit

Permalink
enhancement: precontribution 33
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Nov 17, 2016
1 parent e58be0e commit a87f839
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/cli/cms/editor/handlebars/printBlock.js
@@ -1,14 +1,19 @@
import printInput from './printInput'
import abeEngine from './abeEngine'

export default function printBlock (ctx) {
export default function printBlock (ctx, obj) {
var res = ''
var precontrib = false
if (obj.data.root.precontrib != null && obj.data.root.precontrib === 'true') {
precontrib = true
}

if(ctx[0].block != null && ctx[0].block !== '') {
res += `<div class="form-group">
<label class="title">${ctx[0].block}</label>
<div class='single-block well well-sm'>`
Array.prototype.forEach.call(ctx, (item) => {
if (precontrib) item.value = ""
res += printInput(item)
})
res += '</div></div>'
Expand Down Expand Up @@ -50,6 +55,7 @@ export default function printBlock (ctx) {
<div id="${key}${i}" class="collapse" >
`
Array.prototype.forEach.call(arrItem[i], (item) => {
if (precontrib) item.value = ""
res += printInput(item)
})
res += '</div></div>'
Expand All @@ -59,6 +65,7 @@ export default function printBlock (ctx) {
</div>
</div>`
}else {
if (precontrib) ctx[0].value = ""
res += printInput(ctx[0])
}
return res
Expand Down
7 changes: 7 additions & 0 deletions src/cli/cms/templates/handlebars/setVariable.js
@@ -0,0 +1,7 @@

/**
* Handlebars helper, to add variable inside template file
*/
export default function setVariable(varName, varValue, options){
options.data.root[varName] = varValue;
};
3 changes: 3 additions & 0 deletions src/cli/cms/templates/index.js
Expand Up @@ -18,6 +18,7 @@ import times from './handlebars/times'
import truncate from './handlebars/truncate'
import lowercase from './handlebars/lowercase'
import uppercase from './handlebars/uppercase'
import setVariable from './handlebars/setVariable'

import * as template from './template'
import * as assets from './assets'
Expand All @@ -41,6 +42,7 @@ Handlebars.registerHelper('times', times)
Handlebars.registerHelper('truncate', truncate)
Handlebars.registerHelper('lowercase', lowercase)
Handlebars.registerHelper('uppercase', uppercase)
Handlebars.registerHelper('setVariable', setVariable)

HandlebarsIntl.registerWith(Handlebars)

Expand All @@ -58,6 +60,7 @@ export {
truncate,
lowercase,
uppercase,
setVariable,
math,
moduloIf,
notEmpty,
Expand Down
1 change: 0 additions & 1 deletion src/server/views/partials/create-form-folder.html

This file was deleted.

8 changes: 6 additions & 2 deletions src/server/views/partials/create-form-template.html
Expand Up @@ -2,9 +2,13 @@
<label for="selectTemplate" class="control-label">{{@root.text.template}} *</label>
<select class="form-control" id="selectTemplate" data-id="selectTemplate" data-required="true" name="selectTemplate" data-type-template-abe="true">
<option></option>
{{#each manager.list.templates}}
{{#each @root.manager.list.templates}}
{{#ifCond @root.json.abe_meta.template name}}
<option value="{{name}}" clean-value="{{website}}" selected="selected">{{name}}</option>
{{#ifCond @root.precontrib "true"}}
<option value="{{name}}" clean-value="{{website}}">{{name}}</option>
{{else}}
<option value="{{name}}" clean-value="{{website}}" selected="selected">{{name}}</option>
{{/ifCond}}
{{else}}
<option value="{{name}}" clean-value="{{website}}">{{name}}</option>
{{/ifCond}}
Expand Down
3 changes: 1 addition & 2 deletions src/server/views/partials/engine.html
Expand Up @@ -47,10 +47,9 @@
<div class="form-create" data-form-abe-create="true">
<div data-post-path-preview="true" class="breadcrumb"></div>

{{abeImport 'create-form-folder' @root.manager.config @root}}
{{&folders @root.manager.list.structure 1 @root.json.abe_meta.link}}
{{abeImport 'create-form-template' @root.manager.config @root}}
{{abeImport 'create-form-tplname' @root.manager.config @root}}
{{abeImport 'create-form-addons' @root.manager.config @root}}

<input class="form-control" type="hidden" name="oldFilePath" data-id="oldFilePath" id="oldFilePath" value="{{@root.json.abe_meta.link}}" />
<div class="">
Expand Down

0 comments on commit a87f839

Please sign in to comment.