Commit fe66bb39 by Van

feat(all) : Add checbox "Tous les champs". Add autocomplete on field add search

parent 7c03595b
......@@ -4,10 +4,26 @@
.border-none {
border: none !important;
}
.allCheckbox{
display: flex;
float: left;
margin-right: 6px;
}
.allCheckbox label{
margin-right: 1em;
}
.chooseField {
height: 26px !important;
}
.select span{
width: 20em;
text-align: center;
}
.addContentTypeContainer {
margin-bottom: 30px;
}
......
......@@ -33,6 +33,7 @@ class CustomQueries {
listContentTypeContainer: '.listContentTypeContainer-'+this.name,
removeContentTypeBtn: '#removeContentType-'+this.name,
addFieldBtn: '#addField-'+this.name,
allFields: '#allFields-'+this.name,
validateFieldBtn: '#validateField-'+this.name,
cancelFieldBtn: '#cancelField-'+this.name,
removeFieldBtn: '#removeField-'+this.name,
......@@ -59,10 +60,13 @@ class CustomQueries {
loadOriginalContent() {
let content = this.json;
for(let index in content) {
this.createContentTypeBlock(index);
this.loadOriginalField(index, content[index], content)
if (index != 'all'){
this.createContentTypeBlock(index);
this.loadOriginalField(index, content[index], content)
}
}
}
/**
* INIT JSON content for fields
* @param contentType
......@@ -84,6 +88,7 @@ class CustomQueries {
this.loadOriginalFieldContent(contentType, index, fields[index]);
}
}
/**
* INIT JSON content for fields content
* @param contentType
......@@ -126,6 +131,10 @@ class CustomQueries {
createContentTypeBlock(contentType) {
if(!this.usedContentType[contentType] && contentType) {
this.usedContentType[contentType] = [];
let checked = "";
if (jQuery.inArray(contentType, this.json['all']) !== -1) {
checked = "checked";
}
$(this.selectors.listContentTypeContainer).append(
`<fieldset class="bolt-field-repeater">
<div class="repeater-slot contentType ${contentType}">
......@@ -144,6 +153,10 @@ class CustomQueries {
</div>
</div>
<div class="btn-group">
<div class="allCheckbox">
<label for="allFields">Tous les champs</label>
<input ${checked} type="checkbox" name="allFields" class="${checked}" id="allFields-${this.name}-${contentType}">
</div>
<button type="button" class="btn btn-sm btn-default" id="addField-${this.name}-${contentType}">
<i class="fa fa-plus"></i> Ajouter un champ
</button>
......@@ -173,6 +186,7 @@ class CustomQueries {
</div>
</fieldset>`
);
this.initEventClickAllFields(contentType);
this.initEventClickBtnRemoveContentType(contentType);
this.initEventClickBtnAddField(contentType);
}
......@@ -319,6 +333,16 @@ class CustomQueries {
this.rebuildJson();
});
}
/**
* @param contentType
*/
initEventClickAllFields(contentType){
$(this.selectors.allFields+'-'+contentType).on('click', (e) => {
this.rebuildJson();
});
}
/**
* Field add event
* @param contentType
......@@ -340,7 +364,8 @@ class CustomQueries {
}
}
$(this.selectors.listContentTypeContainer+' .contentType.'+contentType+' .headField').show();
});
});
$('.chooseField').select2();
// Field validate btn
$(this.selectors.validateFieldBtn+'-'+contentType).on('click', (e) => {
......@@ -415,7 +440,9 @@ class CustomQueries {
* Rebuild Json data
*/
rebuildJson() {
let json = {};
let json = {
all: {}
};
$('.tags').each(function () {
let id = $(this).attr('id').split('-');
let value = $(this).select2('val');
......@@ -435,6 +462,12 @@ class CustomQueries {
json[id[1]][id[2]][id[3]] = value;
}
});
$('.allCheckbox input').each(function () {
if($(this).is(':checked')) {
let contentType = $(this).attr('id').replace('allFields-list-', '');
json.all.push(contentType);
}
});
/*console.log(json);*/
this.element.val(JSON.stringify(json));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment