Skip to content

Commit

Permalink
fix: precontrib (same tag in diffrentes templates)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonknu committed Nov 15, 2016
1 parent 8538893 commit 5bf7e41
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cli/cms/operations/create.js
Expand Up @@ -25,7 +25,7 @@ var create = function(template, pathCreate, name, req, forceJson = {}, duplicate
var templateText = cmsTemplates.template.getTemplate(template)
json = cmsData.values.removeDuplicate(templateText, json)
}
var resHook = abeExtend.hooks.instance.trigger('beforeFirstSave', postUrl, req.query, json)
var resHook = abeExtend.hooks.instance.trigger('beforeFirstSave', postUrl, req.body, json)
postUrl = resHook.postUrl
json = resHook.json

Expand Down
23 changes: 19 additions & 4 deletions src/server/public/scripts/modules/FormCreate.js
Expand Up @@ -73,12 +73,12 @@ export default class FormCreate {
}

_btnSelectTemplate(e) {
var selectedTemplate = e.currentTarget.value
this._selectedTemplate = e.currentTarget.value
Array.prototype.forEach.call(this._precontribTemplate, (input) => {
var linkedTpl = input.getAttribute('data-precontrib-templates').split(',')
var found = false
Array.prototype.forEach.call(linkedTpl, (tpl) => {
if (tpl === selectedTemplate) {
if (tpl === this._selectedTemplate) {
found = true
}
})
Expand All @@ -97,6 +97,21 @@ export default class FormCreate {
var postPath = ""
var isValid = true
Array.prototype.forEach.call(this._formInputs, (input) => {
var isPrecontribForTpl = true;
var found = false;
var linkedTpl = input.parentNode.getAttribute('data-precontrib-templates')
if(linkedTpl){
linkedTpl = linkedTpl.split(',')
Array.prototype.forEach.call(linkedTpl, (tpl) => {
if (tpl === this._selectedTemplate) {
found = true
}
})
}
else{
found = true;
}
if(!found) isPrecontribForTpl = false;
input.parentNode.classList.remove('error')
var autocomplete = input.getAttribute('data-autocomplete') == "true" ? true : false
var slug = input.getAttribute('data-slug')
Expand Down Expand Up @@ -153,7 +168,7 @@ export default class FormCreate {
values[input.getAttribute('data-id')] = value
}

if (value !== "") {
if (value !== "" && isPrecontribForTpl) {
switch(slugType) {
case "path":
postPath += value + "/"
Expand All @@ -164,7 +179,7 @@ export default class FormCreate {
default:
break
}
}else if(required) {
}else if(required && isPrecontribForTpl) {
input.parentNode.classList.add('has-error')
isValid = false
}
Expand Down

0 comments on commit 5bf7e41

Please sign in to comment.